Output using Indicator Constraint is different from the one created without using Indicator Constraint
Awaiting user inputHi,
I was trying to speed up my model building by using Indicator Constraint but although the build time was reduced to an extent and even the solution time, the output that I am getting is different from the one I got without using it.
Code snippet using indicator constrain:
for j, k, l in item_size_store_list:
prob.addConstr( quantity_allocated[j, k, l] - big_number_M * (1 - beta_2_jkl[j, k, l]) \
<= size_level_requirement[j, k, l], "C2_1_{}_{}_{}".format(j, k, l))
prob.addConstr( quantity_allocated[j, k, l] + big_number_M * beta_2_jkl[j, k, l] \
>= size_level_requirement[j, k, l], "C2_2_{}_{}_{}".format(j, k, l))
prob.addConstr((beta_2_jkl[j, k, l]==1)>>(unfulfill_cost[j, k, l]==\
(size_level_requirement[j, k, l] - quantity_allocated[j, k, l])
* ceil(under_pen[j, k, l])), "C2_3_{}_{}_{}".format(j, k, l))
prob.addConstr((beta_2_jkl[j, k, l]==0)>>(unfulfill_cost[j, k, l]==\
( quantity_allocated[j, k, l] - size_level_requirement[j, k, l])
* ceil(over_pen[j, k, l])), "C2_4_{}_{}_{}".format(j, k, l))
# Code snippet without indicator constraint:
for j, k, l in item_size_store_list:
prob.addConstr(quantity_allocated[j, k, l] - big_number_M * (1 - beta_2_jkl[j, k, l]) \
<= size_level_requirement[j, k, l], "C2_1_{}_{}_{}".format(j, k, l))
prob.addConstr(quantity_allocated[j, k, l] + big_number_M * beta_2_jkl[j, k, l] \
>= size_level_requirement[j, k, l], "C2_2_{}_{}_{}".format(j, k, l))
prob.addConstr((size_level_requirement[j, k, l] - quantity_allocated[j, k, l])
* ceil(under_pen[j, k, l]) - big_number_M * (1 - beta_2_jkl[j, k, l]) \
<= unfulfill_cost[j, k, l], "C2_3_{}_{}_{}".format(j, k, l))
prob.addConstr((size_level_requirement[j, k, l] - quantity_allocated[j, k, l])
* ceil(under_pen[j, k, l]) + big_number_M * (1 - beta_2_jkl[j, k, l]) \
>= unfulfill_cost[j, k, l], "C2_4_{}_{}_{}".format(j, k, l))
prob.addConstr((size_level_requirement[j, k, l] - quantity_allocated[j, k, l])
* ceil(over_pen[j, k, l]) - big_number_M * beta_2_jkl[j, k, l] \
<= unfulfill_cost[j, k, l], "C2_5_{}_{}_{}".format(j, k, l))
prob.addConstr((size_level_requirement[j, k, l] - quantity_allocated[j, k, l]) *
ceil(over_pen[j, k, l]) + big_number_M * beta_2_jkl[j, k, l] \
>= unfulfill_cost[j, k, l], "C2_6_{}_{}_{}".format(j, k, l))
Is there any fundamental difference between creating constraint in the given two ways or am I missing something?
-
Official comment
This post is more than three years old. Some information may not be up to date. For current information, please check the Gurobi Documentation or Knowledge Base. If you need more help, please create a new post in the community forum. Or why not try our AI Gurobot?. -
Hi,
What exactly do you mean by different output? Do you mean that the optimization process behaves differently? This can be explained by the fact that Gurobi treats indicator constraints as special objects and uses a special reformulation technique for these. The difference can also depend on the value of your bigM. As long as the optimization process provides the same solution value (within a given MIPGap), there is no reason to worry about possible optimization path differences.
Best regards,
Jaromił0
Post is closed for comments.
Comments
2 comments