Convert ILP variables to strict integer values in JuMP

It has often happened that after solving a MILP, my integer or binary variables are getting a value something like 4.237436454375536e-11 or 1.0000000000008162 or even 4.0. In other words even though a variable is meant to be Integer or Binary it gets real values.

I understand that probably the backend solvers (e.g. CPLEX) are using real numbers to solve the mathematical programming problem.

But since JuMP knows the model description, wouldn’t it be easy to apply a conversion of the solved variables after the backend finished calculations, so that the user directly gets something that would be more reasonable (e.g. 0 instead of 4.237436454375536e-11) ?

Something like that would make it more convenient to do the metaanalysis of the solution.

JuMP forces the user to explicitly deal with the non-integrality of solutions returned by a solver.

It’s important that users understand solvers are not using exact arithmetic, and that numerical issues can arise. As one example, “optimal” integer solutions rounded to exact integers may be infeasible. (You’ll often see this with big-M type constraints, where a binary variable might take 1e-8, but when multiplied by a large M the term becomes significant.)

Gurobi has a good series of documentation on this:

2 Likes