-
Notifications
You must be signed in to change notification settings - Fork 514
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
Remove deprecated gurobipy addConstr call #3350
Remove deprecated gurobipy addConstr call #3350
Conversation
Hi, I am currently testing this PR by running: python examples/pyomo/columngeneration/cutting_stock.py gurobi_persistent File "d:\dev\pyomo\pyomo\solvers\plugins\solvers\GUROBI.py", line 38, in |
con.canonical_form(), self._max_constraint_degree | ||
) | ||
# elif isinstance(con, LinearCanonicalRepn): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this commented block something that should be kept ? Happy to leave it as is to minimize the diff
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that is completely removable (looking back, I think LinearCanonicalRepn
disappeared from Pyomo more than 7 years ago).
Yes - the problem is your definition of the class GurobiModel(gurobipy.Model): Parsing / compiling this definition (during module import) accesses the The simplest "workaround" might be something like: class GurobiModel(gurobipy.Model if gurobipy_available else object): However, that will run afoul of another test in the Pyomo unittest system: this solution still triggers the gurobipy import - when you implicitly cast The better solution is probably to define an |
Thank you so much for your help @jsiirola, I have implemented your suggestion, and it works great! |
@quantresearch1 I removed the [WIP] marking from the title to check the test status on this PR. Is this ready for review or still work in progress? |
@blnicho thanks, let me fix the unit tests first before asking for a review |
…antresearch1/pyomo into gurobipy_addconstr_deprecated
@blnicho I think I have fixed it. The issue was that for NumericConstant expression, the degree is 0. I would incorrectly raise a DegreeError as I was expecting _get_expr_from_pyomo_repn to only give me degrees 1 or 2 |
@jsiirola The win/3.9 build failed with a segmentation in conda, should I just give the CI another run ? Sorry I am not sure how to debug this issue. Platform: win-64 |
@quantresearch1: the windows failure is an issue with conda that crops up with surprising regularity (the error is happening while trying to set up the conda environment and has nothing to do with Pyomo). Usually waiting a couple hours and re-running that job will clear it. |
Great to see all checks are now passing. May I merge it ? |
Summary/Motivation:
With both the previous and latest major gurobi versions, we get a deprecation warning when calling model.addConstr.
Python 3.10.11 (tags/v3.10.11:7d4cc5a, Apr 5 2023, 00:38:17) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
Changes proposed in this PR:
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: