Small values is automatically considered as 0, how to solve it?
AnsweredHi, I am using Gurobi 9.1.2 build v9.1.2rc0 (win64) to solve my MILP problem. I have some variables with very small values ([1e8,1e7], manually calculated), it seems that Gurobi automatically considers these values as 0. For example:
The values are: 4.12e6 * 0.15 + 9.70E09 = 0.6277e6 and 4.12e6 * 0.3 + 9.70E09 = 1.24576e6
output of program: (0, 0): <gurobi.Var pdt[0,0] (value 0.0)>
(0, 1): <gurobi.Var pdt[0,1] (value 1.2457000000000002e06)>
I tried to set the tolerance using model.Params.IntFeasTol = 1e09, unfortunately, it does not work. If there is any method to improve this? Thank you.

Hi Jinping,
You should definitely scale your variables and constraints before formulating the model. It is bad practice to use such small coefficients and a frequent cause for errors.
The above constraint can for instance be scaled by 1e+6 to improve the numerics. Please refer to our Guidelines for Numerical Issues for further information.
Cheers,
Matthias0 
Hi Matthias,
Thank you very much for answering my question. The small values are obtained before optimization. I checked the link you shared and the reference manual about how to scale variables. However, the approach for addressing this problem in the manual is not very clear to me (maybe because I am new with Gurobi and not very good at coding).
A small part of my constraints is:
P == slop * (X  x_ini) + p_ini
where slop, x_ini and p_ini are predetermined values (very small, e.g., 4.12e6, 0.0, and 9.70E09 in the abovementioned example). X is the variable from the upper level, and P is the output. I wonder if I multiply a term, e.g., 1e2 to the slop and p_ini, and the output is divided by this term, does this still can guarantee the accuracy?
For instance: Pnew == slop*1e2 * (X  x_ini) + p_ini*1e2, whether Pnew / 1e2 = P?
I feel it is worth mentioning that this small value problem appears in calculating P only, and in other constraints, I have nonlinear terms such as A*B (A and B are variables) to determine X. I have set: model.params.NonConvex = 2
Thanks a lot.
0
Please sign in to leave a comment.
Comments
2 comments