-
Notifications
You must be signed in to change notification settings - Fork 93
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
Consider constraints with empty linexpr correctly #237
Conversation
Hi @sebheger, thank you for your contribution. We're now only waiting for you to agree with the Contributor License Agreement (CLA) to merge your pull request. |
@tuliotoffolo Resigned CLA. |
I recognized that the CI is not including gurobi - and my test cases fail on gurobi. I hadn't installed gurobi on the system where i did the fix. It says that my infeasible case is unbounded after being solved with gurobi. |
Ok, after debugged the gurobi part: if status == 4: # INF_OR_UNBD
return OptimizationStatus.UNBOUNDED This is an additional thing to fix. See
|
Indeed... I'll talk to @h-g-s to discuss how we will approach this issue. We may need a "INF_OR_UNBD" status in Python-MIP. |
I would suggest following gurobis suggested approach. To reset the model, set presolves dual_reductions to 0 and "optimize" again. Checking infeasibility for MIP is in most cases done comparably quickly (as long as you don't to know hints about WHY it is infeasible). I guess this gurobi INF_OR_UNBD thing is originated by weak duality. So just knowing that the dual is infeasible, could be both possible status for the primal. |
@tuliotoffolo Take a look. Did some beautifications is cbc & tests and introduced a fix for the gurobi status. |
Thanks, @sebheger. Looks very nice! :) |
@tuliotoffolo I introduced new OptimizationStatus as suggested. I put the code for automatic re-optimization into a comment for the moment. There would be some clarfications needed where to place a method to reoptimize, as the status of an optimization run is only persisted in the Model, but not in GurobiSolver. |
After I had a look at #184 I am not sure if my fixes solve the overall problem. This should be reported to CBC. It should be ideally supported on CBC side to correctly add empty rows (in the same way as supporting empty colums), which could be later modified by the columns parameter of the variable. |
@sebheger Thank you for your work on this. As far as I understand, you indicate that this is not a full solution to the problem and something would need to change on the side of cbc. Has this be reported to them somewhere? That being said, I assume that this PR already deals with some issues - hopefully also mine :-) So is there any chance of getting this PR merged and pushed to PyPi? cc @tuliotoffolo |
Revisiting this pull request: @sebheger, is there any reason for not merging it? |
@tuliotoffolo Feel free to merge it, it solves #237 by a hack. I was hoping it also solves #184, but the segfault still exstists, because both issues arise from an problematic behaviour of the C-api to cbc. |
Constraint without any decision variable like following causes segmentation fault in CBC solver with Python-MIP 1.15. https://github.com/Jij-Inc/ommx/actions/runs/9698846012/job/26766373894 ```python x = DecisionVariable.continuous(0) instance = Instance.from_components( decision_variables=[x], objective=x, constraints=[ # 1 >= 0 is always true Linear(terms={}, constant=1) >= 0, x <= 1, ], sense=Instance.MAXIMIZE, ) ``` This has been reported in coin-or/python-mip#213 and some linked issues, and fixed in coin-or/python-mip#237. We use latest commit of Python-MIP coin-or/python-mip@0ccb811 until the next version is released coin-or/python-mip#384
Fixes #213