Tobias Achterberg
unread,Jan 27, 2016, 6:43:36 AM1/27/16Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to gur...@googlegroups.com
Hi Thomas,
it is very likely that your model features numerical issues (rather than Gurobi
having a bug that leads to a global lower bound that is larger than the
objective value of some feasible solution).
Unfortunately, Gurobi (and also no other MIP solver as far as I know) provides
features to better understand the numerical issues in a model. Something like an
IIS procedure that extracts a small sub-model with numerical issues would
certainly be very handy, but this would be pretty hard to implement.
You should be able to easily find the small and large matrix coefficients in
your model yourself. Just implement a loop that goes through all rows in the
model and check the coefficient values.
For continuous models, Gurobi automatically applies scaling. This means to
multiply the rows and the columns with some values with the goal of bringing all
matrix coefficients closer to 1 in absolute terms. Scaling a row by scaler s > 0
means to multiply all coefficients and the right hand side by s. Scaling a
column by scalar s > 0 means to multiply the matrix coefficients and the
objective coefficient of the variable by s and dividing the bounds by s.
There are different scaling options available in Gurobi, see the parameter
"ScaleFlag" parameter.
Of course, scaling the model implicitly modifies the feasibility tolerances. For
example, if a constraint is scaled by 1e-2, then the default feasibility
tolerance of 1e-6 for this row is implicitly increased to 1e-4, because a
violation of 1e-6 in the scaled model means a violation of 1e-4 in the original
model. This is the reason why solutions with "unscaled infeasibilities" may
occur. In a post-processing step we try to clean those up by doing a few simplex
pivots on the original (unscaled) model, but this may fail. Additionally,
presolving is another source for generating internal solutions that turn out to
be slightly infeasible when the internal solution is transformed back to a
solution of the original user model.
For (mixed) integer models, scaling is not applied. The reason is that scaling
integer variables is incompatible with the integrality requirement: if you scale
an integer variable by 2, then the integrality requirement turns into "the
variable must be a multiple of 0.5", which is something that our solving
algorithm does not support. For this reason, it is particularly important for
MIPs that the user tries to control the matrix coefficients himself. This can be
done by completely changing the model or just by scaling. Scaling the rows
should be trivial. Scaling the columns involves some model knowledge. For
example, it is often not necessary to specify Dollars in Cents as integer
variables if the model talks about millions or billions of Dollars. In this
case, it might be better to model this in terms of millions of Dollars, which
means that the decision variables would become continuous variables (ignoring
the fact that a solution may then not exactly correspond to a valid Dollar and
Cent amount). Going from Cents to millions of Dollars means to scale the column
by a factor of 1e+8.
For example, if you model the costs for cruise ships (just learned that the big
ones with capacity for 5000 passengers cost about 700 millions of Dollars), your
constraint with the "Cent" version would look as follows:
min y
s.t. 7e+10 x - y = 0 // cost of a ship
5000x >= 12000 // need ships for 12000 passengers
x >= 0
0 <= y <= 1e+12 // budget is 10 billion dollars
with x integer being the number of ships to buy and y integer being the Cents to
pay for the cruise ships. Now, going from Cents to millions of Dollars means to
scale y by 1e+8, which yields
min 1e+8y
s.t. 7e+10 x - 1e+8y = 0 // cost of a ship
5000x >= 12000 // need ships for 12000 passengers
x >= 0
0 <= y <= 1e+4 // budget is 10 billion dollars
Finally, you can scale the objective function and the first constraint by 1e-8
and the second constraint by 1e-3 to get
min y
s.t. 700 x - y = 0 // cost of a ship
5x >= 12 // need ships for 12000 passengers
x >= 0
0 <= y <= 1e+4 // budget is 10 billion dollars
This looks like a much more reasonable model in terms of numerics.
Regards,
Tobias