Gurobi Effect of Abs/Max
AnsweredHello,
I am working on a project with some max/absolute value constraints using gurobipy. One option is to use the gurobi formulations in the background (e.g. my_var == gp.abs_(other_var)). Likewise for the max expression. However, I know in my case that the `my_var` is part of the objective function in a way where binary formulations are not needed. Will Gurobi pick this up during problem generation, or is it better to just write out the formulation in my case manually? This has been a general question of mine for a while.
In a related way, is there documentation anywhere as to the behavior/backend formulation types gurobi is using when I use these special constraints? I don't need the specifics necessarily, but just having a sense of “it's using dynamic branch and bound for your sinusoidal equation” would be helpful.
-
Hi Matthew,
One advantage of simple general constraints like Abs/Max is that Gurobi will recognize most well-known cases for which a simpler formulation (e.g., continuous without introducing binary variables) exists and applies it instead. If you want to be absolutely sure, you can run your example and check in the log that there are still only continuous variables after presolve.
It is recommended to use simple constraints instead of doing your own reformulations because this increases code/model readability and maintenance. For instance, you don't get any inconsistencies if you change your model and your case-specific reformulation no longer works.
I'm unsure if this provides sufficient information for your second question, but the documentation on general constraints might be a good starting point. The documentation on nonlinear constraints could be interesting if you are interested in how Gurobi handles nonlinear functions like sinusoidal equations.
Hope this helped answer your questions.
Best regards,
Martin
0 -
Hi Martin!
Thanks for your help! It's helpful that Gurobi offers this automatic recognition. I will give it a try.
0
Please sign in to leave a comment.
Comments
2 comments