JuMP, GLPK integer decision variable value tolerance

Hi,

I was using GLPK within JuMP to solve an integer linear program. The value of the decision variables are close to integer values. I can just round them if they are within an accepted tolerance.

However, GLPK optimizer has parameters for integer tolerance.

julia> opt = GLPK.Optimizer()
A GLPK model

julia> opt.intopt_param.tol_int
1.0e-5
ERROR: InexactError: Int64(-101.99999999999999)
Stacktrace:
  [1] Int64
    @ ./float.jl:812 [inlined]
  [2] convert
    @ ./number.jl:7 [inlined]
  [3] _broadcast_getindex_evalf
    @ ./broadcast.jl:670 [inlined]
  [4] _broadcast_getindex
    @ ./broadcast.jl:653 [inlined]
  [5] getindex
    @ ./broadcast.jl:597 [inlined]
  [6] macro expansion
    @ ./broadcast.jl:961 [inlined]
  [7] macro expansion
    @ ./simdloop.jl:77 [inlined]
  [8] copyto!
    @ ./broadcast.jl:960 [inlined]
  [9] copyto!
    @ ./broadcast.jl:913 [inlined]
 [10] copy
    @ ./broadcast.jl:885 [inlined]
 [11] materialize
    @ ./broadcast.jl:860 [inlined]
 [12] ideal(problem::MOIntegerLinearProblem)

Is it possible to get JuMP to return integer values for these variables or rounding is necessary? Is this solver parameter merely used for integrality check?

Thanks

Rounding is necessary.

Is this solver parameter merely used for integrality check?

The solver parameter is used to define which solutions are feasible. A tolerance of 1e-5 means that GLPK thinks a value is “integer” if it is within +/- 1e-5 of a true integer. (Tolerances are needed because solvers do not use exact arithmetic.)

1 Like

Thanks!

1 Like