-
Notifications
You must be signed in to change notification settings - Fork 81
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
GurobiSolver ignores constant term in objective #111
Comments
Alternatively, add a fixed variable, and add a constraint using JuMP, Gurobi
model = Model(solver=GurobiSolver(OutputFlag=1))
@variable model x
@variable model y
@constraint model y == -1
@objective model Min x^2 + y
solve(model) |
Oh, well, that's a pretty good reason for GurobiSolver to ignore them, then 😄 Yeah, I definitely could, but was hoping I wouldn't have to. I like the fixed variable idea a lot, too. Thanks! |
FWIW it looks like Gurobi supports constant offsets through their new multiobjective interface ( |
Let's reopen this so it can be implemented in the future. |
Ok, thanks! |
I was wrong. See http://www.gurobi.com/documentation/7.0/refman/objcon.html#attr:ObjCon |
It appears that
GurobiSolver
ignores any constant terms in the JuMP model's cost function. For example:The gurobi output shows:
but the optimal objective value is actually
-1
, as confirmed by JuMP:Of course, for most optimization problems this is fine. Any constant term in the objective doesn't affect the minimizer, and JuMP still reports the correct final objective with
getvalue()
.However, there is one case in which this absolutely does matter: mixed-integer programming. When solving an MIP, Gurobi checks optimality by measuring (among other things), the relative gap between the best incumbent and the best bound. Since this gap is relative to the actual cost value, adding an arbitrary constant offset (or failing to add one) will affect whether the MIP gap is considered small enough.
This is causing some trouble for me, since I see very different solve times depending on how the particular initial state of my system affects the (eliminated) constant term in the cost.
Is there any way to turn this on in Gurobi.jl? I'd be happy to do the work myself, but I'd appreciate some pointers on where to look, since I haven't used the internal Gurobi interface at all.
The text was updated successfully, but these errors were encountered: