Skip to content
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

Move away from dependence on gurobi.sh #3384

Merged
merged 27 commits into from
Nov 6, 2024

Conversation

jsiirola
Copy link
Member

@jsiirola jsiirola commented Oct 16, 2024

Fixes #3285 .

Summary/Motivation:

Gurobi has deprecated the use of the gurobi.sh script, which is used by the default Pyomo interface to Gurobi. While we could have just changed the default interface to gurobi_direct, this PR does not go down that path because:

  • gurobi_direct is significantly less performant than the current LP shell interface
  • the gurobi_direct has a slightly different API
  • we want to retire / replace all the solver interfaces in pyomo.solvers "soon"

Instead, this PR adds a new solver that is a relatively thin veneer around the GUROBISHELL interface that avoids the subprocess call and the need to write results to a "soln" file. While this is adding yet another interface, it offers a minimally-disruptive path to avoid the deprecation warnings that will appear in Gurobi 12.

Changes proposed in this PR:

  • Refactor GUROBI_RUN so that the bulk of the functionality can be executed directly (pulling out the soln file writer to a separate function)
  • Add GUROBIFILE as a LP/MPS file-based input, direct interface output solver interface that has maximal overlap with the current GUROBISHELL.
  • Remove GHA pin of Gurobi to 10.0.3
  • Update tests to "not fail" in Gurobi 11

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.

pyomo/solvers/plugins/solvers/GUROBI.py Outdated Show resolved Hide resolved
pyomo/solvers/plugins/solvers/GUROBI.py Outdated Show resolved Hide resolved
Comment on lines 672 to 674
# translate the options into a normal python dictionary, from a
# pyutilib SectionWrapper - the gurobi_run function doesn't know
# about pyomo, so the translation is necessary.
Copy link
Contributor

Choose a reason for hiding this comment

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

This comment also appears to be wrong.

Copy link
Member Author

Choose a reason for hiding this comment

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

No - this is still correct. I updated the comment to clarify it a bit.

pyomo/solvers/plugins/solvers/GUROBI.py Outdated Show resolved Hide resolved
@jsiirola jsiirola requested a review from mrmundt October 28, 2024 22:27
@jsiirola
Copy link
Member Author

The test failures in Jenkins are real; however, I need #3394 to resolve the issue.

Copy link
Member

@blnicho blnicho left a comment

Choose a reason for hiding this comment

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

I have a couple questions but nothing major enough to prevent merging

@@ -127,7 +135,8 @@ class MultipleBigMTransformation(GDP_to_MIP_Transformation, _BigM_MixIn):
CONFIG.declare(
'solver',
ConfigValue(
default=SolverFactory('gurobi'),
Copy link
Member

Choose a reason for hiding this comment

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

Now that #3394 has been merged can the changes in this file be reverted?

Copy link
Member

Choose a reason for hiding this comment

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

Oops, I just noticed the last commit message which seems to already be using the deferred config stuff so ignore my original question. Is the Solver domain implemented here general enough to go into pyomo.common or pyomo.util?

Copy link
Member Author

Choose a reason for hiding this comment

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

It is pretty general, but could use some discussion before promulgating it elsewhere. In particular, what is the "correct" way to know if you were handed a "solver" object? Given that we have 3 different base classes floating around (core, APPSI, and contrib/solver), inheritance is probably not the right answer. This implementation just looks for a solve() method and hopes it quacks.

pyomo/solvers/plugins/solvers/GUROBI.py Show resolved Hide resolved
@blnicho blnicho merged commit c463632 into Pyomo:main Nov 6, 2024
32 checks passed
@jsiirola jsiirola deleted the gurobi-sh-deprecation branch November 6, 2024 21: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.

Gurobi interactive shell scripts are deprecated
3 participants