Model became infeasible after adding "difference to mean" variables and constraints
AnsweredThe model I'm building includes variables to indicate utilization rates at different facilities. I want to compute the mean utilization rate and add several "difference to mean" variables. I did it as follows:
mean_utilization = m.addVar(name='mean_utilization')
m.addConstr(14 * mean_utilization ==
quicksum(utilization_rate[i] for i in facility_list))
diff_to_mean = m.addVars(facility_list, name='diff_to_mean')
m.addConstrs(
(diff_to_mean[i] == utilization_rate[i] - mean_utilization)
for i in facility_list
)
The problem is, when the two constraints are used simultaneously, the model would immediately return infeasible. I couldn't understand why, since mean_utilization and diff_to_mean don't seem to affect any other parts of the model, and the constraints look perfectly fine and linear. I didn't even add any of these parts into the objective function. They're simply extra variables that don't really do stuff and the model became infeasible.
I would appreciate any help! Thank you very much!
0
-
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?. -
Variables added with Model.addVar() or Model.addVars() are nonnegative by default. Thus, the \( \texttt{diff_to_mean} \) variables are all nonnegative. There almost certainly exists \( \texttt{i} \) for which \( \texttt{utilization_rate[i] - mean_utilization} \) is negative, which would result in an infeasible model. To resolve this, you can try setting the \( \texttt{lb} \) keyword argument when defining the \( \texttt{diff_to_mean} \) variables:
diff_to_mean = m.addVars(facility_list, lb=-gp.GRB.INFINITY, name='diff_to_mean')
0
Post is closed for comments.
Comments
2 comments