2
$\begingroup$

I have a multi-period model in gurobipy with 7 types continuous decision variables and 1 type of binary (Thousands indexed total). The model solves properly and the solution has passed many validation tests so far. However, I noticed that some variables come back with a very small negative value (subscript 1x10-10). I could just round these up to 0 in the post processing but am concerned that this implies that there is an issue in my model. I do have large and small coefficients in my model currently.

Is this something to be concerned about? If so, how can I resolve it?

Thank you!

$\endgroup$

2 Answers 2

5
$\begingroup$

A nonnegative decision variable having an "optimal" value of -1e-10 is not unusual, and should not be a problem, whether the variable is continuous, general integer, or binary (yes, binary variables are not necessarily exactly zero or one). So your procedure to adjust the returned value to exactly zero should be fine.

However, having non-zero input data spanning a wade range of magnitudes, or not being within a small number of orders of magnitude of one, does have the potential to cause numerical difficulties in the solver, or to make the solver's assessment of the problem being (primal) infeasible or unbounded, be unreliable. When using Gurobi, the solver can be instructed to be more numerically robust, at the expense of computation speed, by setting the NumericFocus parameter to a value such as 2, or for the most extreme emphasis on numerical robustness, 3.

When there is very large or small magnitude input data, it is better to try to re-scale the problem (by changing units) if possible, or chopping off "nuisance" coefficients which should be exactly zero, but are not due to the procedure used to generate the input data. But if this is not possible, consider setting the NumericFocus parameter to a high value if your non-zero input data does span a wide range of orders of magnitude.

Gurobi staff member Silke Horn wrote in answer to a support question:

In general, we can say that the higher you set NumericFocus the more careful Gurobi tries to be with numerics in the simplex algorithms, presolve, barrier and crossover. We cannot give you all the details, but here are some of the things that the NumericFocus parameter does: It tightens tolerances such as the Markowitz tolerance, bounds on redundant constraint detection or the step length for barrier. It also makes Gurobi use less aggressive cuts. The higher the setting, the tighter the tolerances. With NumericFocus=3, it also switches to quad precision (Quad=1).

Here is a Gurobi forum answer by a Gurobi staff member to a related question..

The NumericFocus parameter automatically controls the quad precision computation, the Markowitz Tolerance, and a few others. Since NumericFocus automatically decides whether to use quad precision, it is possible that setting the value to 2 or 1 will also enable it, where a higher value favors the enabling more. If you want to explicitly enable Quad Precision, you can set the Quad parameter.

$\endgroup$
0
$\begingroup$

You can refer to this answer from Gurobi support. Small differences depend upon numerical tolerances that can be finetuned using attributes as FeasibilityTol, IntFeasTol, OptimalityTol that control numerical offsets for feasible, integer and optimal values.
more information available from Gurobi's manual

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.