Cplex AdvInd (Advanced Start Switch) equivalent in Gurobi
AnsweredHello,
In CPLEX there is an AdvInd flag that can:
"For MIP models, setting 1 (one) will cause CPLEX to continue with a partially explored MIP tree if one is available. If tree exploration has not yet begun, setting 1 (one) specifies that CPLEX should use a loaded MIP start, if available. Setting 2 retains the current incumbent (if there is one), re-applies presolve, and starts a new search from a new root."
https://www.ibm.com/support/knowledgecenter/SSSA5P_20.1.0/ilog.odms.cplex.help/CPLEX/Parameters/topics/AdvInd.html
By default that parameter is set to one. However, I am not able to find a Gurobi equivalent for the same. I have a Gurobi model in which I solve two very similar optimization problems, per iteration, with some change in bounds and objective function. Gurobi seems to start afresh while solving the second optimization problem; the C++ + Cplex implementation is 5-10x faster than Python + Gurobi. Is this because of the inherent speed bottleneck of Python?
The task is to solve a multiobjective optimization problem. The model is defined as follows:
def _initialize_base_model(self):
self.m = gp.Model('moo_knapsack')
self.v_items = self.m.addVars(self.n_variables, vtype=GRB.BINARY, name='item')
self.v_objs = self.m.addVars(self.n_objectives,
lb=-GRB.INFINITY,
vtype=GRB.CONTINUOUS,
name="obj")
self.c_capacity = self.m.addConstr(gp.quicksum(self.weight[i] * self.v_items[i]
for i in range(self.n_variables))
<= self.capacity,
name='capacity')
for j in range(self.n_objectives):
self.m.addConstr(
self.v_objs[j] == gp.quicksum(self.objectives[j, i] * self.v_items[i]
for i in range(self.n_variables)))
self.m.setParam(GRB.Param.TimeLimit, self.cfg['time_limit'])
self.m.update()
And the two related optimization problems we solve are as follows:
def get_solution(self, epsilon=None):
"""Get a (efficient, nondominated) solution tuple for a
given epsilon"""
x, z = None, None
# Solve P
self.m.setObjective(self.v_objs[self.K])
j = 0
for i in range(self.n_objectives):
self.v_objs[i].ub = epsilon[j] - self.delta if i != self.K else self.ub[self.K]
j = j + 1 if i != self.K else j
self.m.optimize()
if self.m.getAttr('Status') == OPTIMAL:
z_p = np.floor(self.m.ObjVal + 0.5)
# Solve Q
self.m.setObjective(gp.quicksum(self.v_objs))
self.v_objs[self.K].ub = z_p
self.m.optimize()
if self.m.getAttr('Status') == OPTIMAL:
x = [np.floor(self.v_items[i].x + 0.5) for i in range(self.n_variables)]
z = np.matmul(self.objectives, x)
return x, z
Any help will be much appreciated.
Thank you.
-
Hi Rahul,
A feature similar to the CPLEX AdvInd setting is on our future roadmap and will be added in an upcoming release.
For now, could you share a Gurobi LOG file of the two subsequent runs performed one after each other, where you think that no information is being re-used? Maybe, we can find a different workaround.
Best regards,
Jaromił0 -
Hi Jaromił,
Have you added this feature yet?
Thanks
Masoud
0 -
Hi Masoud,
Yes, with version 9.5, we introduced the parameter LPWarmStart to control this feature.
Best regards,
Jaromił0 -
Great, thanks for the reply!
Masoud
0
Please sign in to leave a comment.
Comments
4 comments