If the solution that Gurobi returns is not what you expected, the first step is to identify in which sense the solution is wrong. Common situations are:
- Gurobi returns a solution with unexpected variable values.
- Gurobi returns the wrong objective value.
- Gurobi reports the model is infeasible when it has a feasible solution.
- Gurobi returns two different solutions for the same problem.
Gurobi returns a solution with unexpected variable values.
The most common reasons for this are:
- Do you expect variables in your model to take negative values? If so, please ensure that you have defined the lower bounds of such variables to appropriate negative values. The default lower bound for variables in Gurobi is zero.
- Do integer or binary variables take floating values in a solution? First, please check that you declared integer and binary variables as GRB.INTEGER and GRB.BINARY in your model. Also, it is expected that solution values of integer/binary variables can deviate from an integer by a value less than defined by the IntFeasTol parameter (default value 1e-5). For more details, refer to the article Why does Gurobi sometimes return non-integral values for integer variables?
- Can your model have multiple optimal solutions? There may be multiple optimal solutions for the problem, where two solutions have the same optimal objective value but different values for decision variables.
Numerical issues are also a common source of this type of discrepancy.
- Are you working with tight tolerances such as IntFeasTol = 1e-09 and FeasibilityTol = 1e-09? Working with very tight tolerances can sometimes lead to numerical precision issues. For example, a binary variable's "almost 1" value is treated as 0 if it does not fulfil a tight tolerances value. This then results in a wrong variable fixing and an unexpected result.
- Do you have large Big-M values in your model? Large values of Big-Ms in a Big-M constraint can lead to the "Trickle Flows" issue. For example, if you have a constraint y <= 1000000 * x, where x is binary and y >= 0. With the default value of IntFeasTol (1e-5), x = 0.0000099999, y = 9.9999 is integer feasible, implying that y can be positive even when x is zero. Such behaviour can lead to unexpected results. Try to use the smallest possible values of Big-M. See Dealing with big-M constraints.
- Are you using nonlinear functions? Adjust the granularity of piecewise linear approximations of your function constraints with parameters FuncPieces, FuncPieceLength, and FuncPieceError. Also, be sure to use the tightest bounds possible on the variables.
Note: If you are using an older version of Gurobi, please update to the latest Gurobi release. In every release, numerous improvements are made, including bug fixes from previous versions.
Comments
0 comments
Article is closed for comments.