I am trying to set a MIP start with Gurobi MILP solver. I have a set of binary variables :
tupledict_m = master.addVars(list_m, name="m", vtype=GRB.BINARY)
where master is a Gurobi Model, list_m is an tuple of integers. I run the following to set the starting values :
for i in list_m:
tupledict_m[i].start = bool(m_values[i])
where m_values[i] is either 1.0 or 0.0 with float data type.
Right after that if I print :print([tupledict_m[i].start for i in list_m])
I get 1e+101 everywhere. Any idea on why and how to fix that ?
[...] Recall that the Gurobi optimizer employs a lazy update approach, so changes to attributes don't take effect until the next call to Model.update, Model.optimize, or Model.write on the associated model.
So after you set the mip start for your variables, you need to run master.update()
.
Example:
In [1]: from gurobipy import *
In [2]: m = Model()
Academic license - for non-commercial use only
In [3]: x = m.addVars(3, vtype=GRB.BINARY, name="x")
In [4]: x[2].start = 0
In [5]: print(x[2].start)
1e+101
In [6]: m.update()
In [7]: print(x[2].start)
0.0