set an initial value for a variable in Gurobi
AnsweredHello everyone, I have encountered a perplexing problem when setting initial values using Gurobi. For example, if I want to set the initial value of a variable "var" to -10000.
And I manually checked that this initial value satisfies the constraints. However, Gurobi also reported during runtime that it successfully used the initial value I provided to solve the model: "User MIP start produced solution with objective 0 (0.02s) Loaded user MIP start with objective 0".
However, when I checked the values of the output variables that Gurobi successfully solved again, I found that the value had changed and was no longer -10000 that I provided, but became 0. However, when I checked the start property of the variable, it was still -10000, which confused me a lot. Can you help me with this?
-
Hej,
By default the lower bound and upper bound for the variables is 0 and + infinity that is set by gurobi unless you specify otherwise. I think its the reason that when you optimize and check again it takes the lowest value which in your case would be 0 same as the lower bound.
If you use this, then it will take values in negative as well
m.addVar(var, lb=-gp.GRB-INFINITY, vtype=___)
or
m.addVar(var, lb=-10000, vtype=___)3 -
Thanks!!! I checked my code and indeed found the issue. Thank you very much for your help!
2
Please sign in to leave a comment.
Comments
2 comments