Skip to content

Add gurobi_direct implementation to contrib.solver #3225

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 24 commits into from
May 8, 2024

Conversation

jsiirola
Copy link
Member

@jsiirola jsiirola commented Apr 4, 2024

Fixes # .

This PR builds on (and includes) PR #3224

Summary/Motivation:

This provides a implementation of the gurobi_direct solver for the new contrib.solver package. The interface makes use of the standard_form writer to send the entire model to Gurobi as a single matrix. As a result, it is reasonably performant (on one huge test, it almost got within ~2x of COEK).

Like all solvers in contrib.solver, this is still a work in progress. I am opening a PR so that others can begin to poke it.

There are still several missing features, including:

  • support for warmstart
  • support for quadratic objectives / constraints

Changes proposed in this PR:

  • add the pyomo.contrib.solver.gurobi_direct solver
  • Improvements to standard_form_
    • return list of Objectives as well as the objective constant offset
    • gracefully handle models with no objective or no constraints
    • add option to control how the objective sense is mapped (or not)

Legal Acknowledgement

By contributing to this software project, I have read the contribution guide and agree to the following terms and conditions for my contribution:

  1. I agree my contributions are submitted under the BSD license.
  2. I represent I am authorized to make the contributions and grant the license. If my employer has rights to intellectual property that includes these contributions, I represent that I have received permission to make contributions and grant the required license on behalf of that employer.

Copy link

codecov bot commented Apr 4, 2024

Codecov Report

Attention: Patch coverage is 95.23810% with 17 lines in your changes are missing coverage. Please review.

Project coverage is 88.41%. Comparing base (c68ce66) to head (9790e08).

Files Patch % Lines
pyomo/contrib/solver/gurobi_direct.py 93.92% 15 Missing ⚠️
pyomo/solvers/plugins/solvers/CPLEX.py 85.71% 1 Missing ⚠️
pyomo/solvers/plugins/solvers/SCIPAMPL.py 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3225      +/-   ##
==========================================
+ Coverage   88.40%   88.41%   +0.01%     
==========================================
  Files         847      849       +2     
  Lines       95285    95585     +300     
==========================================
+ Hits        84232    84511     +279     
- Misses      11053    11074      +21     
Flag Coverage Δ
linux 86.36% <93.27%> (+0.02%) ⬆️
osx 76.24% <92.15%> (+0.06%) ⬆️
other 86.56% <93.27%> (+0.01%) ⬆️
win 83.86% <92.71%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mrmundt mrmundt self-requested a review April 9, 2024 18:39
if repn.c.shape[0]:
gurobi_model.setAttr('ObjCon', repn.c_offset[0])
gurobi_model.setAttr('ModelSense', int(repn.objectives[0].sense))
# gurobi_model.update()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leftover line?

@blnicho blnicho self-requested a review May 7, 2024 18:46
@blnicho blnicho merged commit 7c49bee into Pyomo:main May 8, 2024
33 checks passed
@jsiirola jsiirola deleted the gurobi_direct_rework branch November 15, 2024 03:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants