# JuMP, GLPK integer decision variable value tolerance

**URL:** <https://discourse.julialang.org/t/jump-glpk-integer-decision-variable-value-tolerance/91218>\
**Category:** Optimization (Mathematical)\
**Tags:** jump, optimization\
**Created:** [December 4, 2022, 3:06pm UTC](https://discourse.julialang.org/t/jump-glpk-integer-decision-variable-value-tolerance/91218 "2022-12-04T15:06:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gokhan\_Kof](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gokhan_kof/32/43267_2.png) [@Gokhan\_Kof](https://discourse.julialang.org/u/Gokhan_Kof)\
**Post date:** [December 4, 2022, 3:06pm UTC](https://discourse.julialang.org/t/jump-glpk-integer-decision-variable-value-tolerance/91218/1 "2022-12-04T15:06:51Z")

</div>

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
julia> opt = GLPK.Optimizer()
A GLPK model

julia> opt.intopt_param.tol_int
1.0e-5

```

```julia
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

---

<div class="post-metadata">

**Author:** ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)\
**Post date:** [December 4, 2022, 7:25pm UTC](https://discourse.julialang.org/t/jump-glpk-integer-decision-variable-value-tolerance/91218/2 "2022-12-04T19:25:10Z")

</div>

> [@Gokhan\_Kof](#):
>
> Is it possible to get JuMP to return integer values for these variables or rounding is necessary?

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.)

---

<div class="post-metadata">

**Author:** ![Gokhan\_Kof](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gokhan_kof/32/43267_2.png) [@Gokhan\_Kof](https://discourse.julialang.org/u/Gokhan_Kof)\
**Post date:** [December 4, 2022, 7:32pm UTC](https://discourse.julialang.org/t/jump-glpk-integer-decision-variable-value-tolerance/91218/3 "2022-12-04T19:32:56Z")

</div>

Thanks!
