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

Update Gurobi license checks in tests #3011

Merged
merged 6 commits into from
Oct 4, 2023

Conversation

jsiirola
Copy link
Member

@jsiirola jsiirola commented Oct 3, 2023

Fixes # .

Summary/Motivation:

This resolves test failures that occur when Gurobi is installed, but not properly licensed.

Changes proposed in this PR:

  • Update Gurobi license guards in tests
  • Add a custom ASL solver interface for Gurobi that implements a license_is_valid() method to enable license checks for the Gurobi NL interface.

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.

@jsiirola jsiirola requested review from mrmundt and emma58 October 3, 2023 19:30
Copy link
Contributor

@emma58 emma58 left a comment

Choose a reason for hiding this comment

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

A couple questions, but otherwise this looks good!

try:
with capture_output():
self.solve(m)
return m.x.value == 0
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there any risk this does the wrong thing if x isn't exactly 0?

Copy link
Member Author

Choose a reason for hiding this comment

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

There is a risk, but this is such a simple problem that Gurobi should solve it exactly in presolve.

@@ -22,6 +22,7 @@
except ImportError:
gurobipy_available = False

gurobi_available = GurobiDirect().available(exception_flag=False)
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this one check the license when you ask about availability? Because if not the changes in this file don't make sense to me.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes. gurobipy_available only checks that the gurobipy python module is importable. The gurobi_available test checks the license.

@codecov
Copy link

codecov bot commented Oct 4, 2023

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (394e082) 88.08% compared to head (c6354a2) 88.07%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3011      +/-   ##
==========================================
- Coverage   88.08%   88.07%   -0.02%     
==========================================
  Files         768      768              
  Lines       89410    89425      +15     
==========================================
+ Hits        78759    78760       +1     
- Misses      10651    10665      +14     
Flag Coverage Δ
linux 85.18% <43.75%> (-0.02%) ⬇️
osx 74.98% <43.75%> (-0.01%) ⬇️
other 85.36% <43.75%> (-0.01%) ⬇️
win 82.42% <43.75%> (-0.03%) ⬇️

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

Files Coverage Δ
pyomo/solvers/plugins/solvers/GUROBI.py 89.06% <93.75%> (+0.53%) ⬆️

... and 4 files with indirect coverage changes

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

@jsiirola jsiirola merged commit eb2628e into Pyomo:main Oct 4, 2023
@jsiirola jsiirola deleted the gurobi-license-checks branch October 4, 2023 02:27
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.

2 participants