Prevent crash when solver returns suffixes but not values for variables#596
Prevent crash when solver returns suffixes but not values for variables#596ghackebeil merged 7 commits intoPyomo:masterfrom
Conversation
Codecov Report
@@ Coverage Diff @@
## master #596 +/- ##
=========================================
+ Coverage 66.02% 67.23% +1.2%
=========================================
Files 374 393 +19
Lines 60314 62233 +1919
=========================================
+ Hits 39825 41845 +2020
+ Misses 20489 20388 -101
Continue to review full report at Codecov.
|
|
@mfripp Thanks for the nice contribution. I remember running across problems figuring out how to use IIS when I was first getting started. I hope that someone on the team familiar with the ASL interface is able to review this soon. |
|
@jsiirola: Sure, happy to add a test. I took a quick look at the testing framework before I submitted this and another look just now, but couldn't figure out where to add a new test. Any advice? |
|
@mfripp: It might be easier to just upload an example .sol file that exercises this code. I can quickly put together a test using that. |
|
@ghackebeil , were you able to get a test working? Would you like me to look at it? |
|
I have a test put together. I think the easiest thing to do, since this is on a fork, is to merge and I’ll add the test after.
However, there is one controversial piece of this PR that may or may not need to change. Variable values are being set to None in the solution rather than just leaving them alone (i.e., by just initializing the solution entry to an empty dict).
|
|
@ghackebeil You should be able to push directly to the fork. Most people leave "allow edits from maintainers" checked. |
|
@qtothec: Good point |
|
Turns out I do not have push access. @mfripp: Can you change these settings, at least temporarily? |
|
Sorry, I didn't see the July 24 response until just now. Let me know if I can help with anything. |
|
@mfripp: No problem. I have some local commits made to your fork that I'd like to push before we merge this PR. Would you mind enabling push access for me (at least temporarily) on your pyomo fork. I assume that can be done somewhere in the repository settings. |
|
OK, I added you as a collaborator on https://github.com/mfripp/pyomo. I think that should give you push access. Let me know if I can help with anything else.
Matthias
|
|
I believe this is ready to merge, pending someone else's approval. |
Fixes #597.
Summary/Motivation:
When the user requests an irreducibly infeasible set of constraints (IIS) for an infeasible mixed-integer program, cplexamp sometimes returns the IIS but not values for the variables. This currently causes pyomo to crash. Specifically,
pyomo.opt.plugins.solonly creates entries insoln_variablefor variables whose values have been returned by the solver, but then it tries to attach the IIS suffix value to a non-existent item insoln_variable, causing an uncaughtKeyError().There is already code in
pyomo.opt.plugins.solto prevent this problem with constraints. This pull request applies similar code to avoid this problem with variables.The code below currently crashes Pyomo, but this error is fixed by the proposed changes:
Changes proposed in this PR:
{'Value': None}) tosoln_variableif needed before applying the suffix. Note that this entry must include a'Value'key in order to prevent other errors later.Legal Acknowledgement
By contributing to this software project, I agree to the following terms and conditions for my contribution: