-
Notifications
You must be signed in to change notification settings - Fork 51
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
Add MIP check in gurobi interface and update shadow_prices and reduced_cost to throw proper error if MIP #259
Conversation
…dow_prices and reduced_costs to check for MIP before accessing non-existant variables.
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.
Nice, looks pretty good. Is there are reason for the new is_mip
instead of just overwriting is_integer
? They seem to be doing the same thing (check whether it is an integer problem).
I thought of that, but decided that it is a semantic problem. I can see that this may be nitpicky from my side, so I will just leave the choice up to you after reading this and implement it according to your instruction. |
Oh yeah, what I meant is that is_integer is a misnomer since it actually just checks whether there is at least one integer variable (so whether it is a MIP). I agree it's not well named and we could rename it in another PR to maybe has_integers or is_mip like you propose. Or are you saying that there is a difference between a linear problem with one or more integer variables (but not all of them) and a MIP? Either way not a big deal here. If we add your is_mip I would probably want to replace is_integer with it in all other interfaces in a later PR, so the end result would be the same. So go ahead with whatever you prefer for now. |
Merging for now. Will need a follow up to rename is_integer -> is_mip and a new major release. |
Sorry for not informing you about my absence, I am now back to business and I'm thankful to you that my PR was merged. We actually have three kinds of problems here. The first problem is the standard linear programming problem which doesn't have any constraints regarding the integrality of its variables, this case is actually considered by cobrapy right now. The second problem is the integer problem which requires all of its variables to be integers. The last is a mixed integer problem which only requires some of its variables to be integers. The difficulty here is that the assumption of If I add a general constraint, like a piecewise linear constraint in Gurobi, the convexity of the model is endangered and for that case, binary auxiliary variables as well as so called SOS-variables are introduced. At least the auxiliary variables are integer variables in nature, but somehow they don't classify as integer variables, because they are part of a general constraint. How do we fix that now in Optlang and CobraPy? The next step for me would be to look into Cobrapy and see if it actually draws the changes from this PR into optlang now. Sorry for all the text, working with you is a pleasure and I hope your move went well! |
Because MIPs lose convexity, shadow prices and reduced costs aren't available for them until the model was relaxed (variables transformed and general constraints removed) or fixed (fixes integer values to the best solution found). That means that it is necessary for the functions
_get_reduced_costs
and_get_shadow_prices
to not only check if the problem is a pure integer problem but also if the model is a mixed integer problem. For that, another propertyis_mip
was introduced.