Binary Variables were assigned a continous value
AnsweredI have a model with only binary or integer variables, but after solving my model, some variables are assigned a continous value. I cannot figure out why...
I implemented the variables as follows. After that, I stated my conditions followed my the optimizecommand.
heu_dyn=gp.Model('model')
y=heu_dyn.addVars(SetK,vtype=GRB.BINARY, name='y')
u=heu_dyn.addVars(SetI, SetK, vtype=GRB.INTEGER, name='u')

Mathematical optimization solvers work with integrality tolerances. In Gurobi this tolerance is controled by the parameter IntFeasTol. This means that a binary variable with value \(\texttt{0.999999}\) is handled as \(\texttt{1}\). Usually, this is not an issue as you (the user) can round the noninteger values to their correct true integer values after an optimization run has been completed. However, there are cases where these tolerances can have significant impact on the solution and the behavior of the model. These cases are most often caused by socalled "trickleflows", which occur when (badly scaled) bigM values are used in the model. Gurobi provides the parameter IntegralityFocus to tackle this issue. Altogether, you should try rounding binaries and integers after a successful optimization run and see whether all constraints are still satisfied (within tolerances FeasibilityTol). If this is not the case, then you should try reducing the IntFeasTol tolerance and experiment with the IntegralityFocus parameter. You could additionally try to improve the scaling of your model, cf. Guidelines for Numerical Issues.
You can find additional information in the Knowledge Base article Why does Gurobi sometimes return nonintegral values for integer variables?
Best regards,
Jaromił0
Please sign in to leave a comment.
Comments
1 comment