jump-dev/GLPK.jl

`set_time_limit_sec` does not work with some Float64 values

henriquebecker91 opened this issue · 2 comments

JuMP has the function set_time_limit_sec which expects seconds (and accept Float64 values). There is no problem using it with Gurobi.jl and CPLEX.jl, but with GLPK.jl if the time is a fractional number sometimes the code errors with:

ERROR: InexactError: trunc(Int32, 3.153599441e10)
Stacktrace:
  [1] trunc
    @ ./float.jl:695 [inlined]
  [2] ceil
    @ ./float.jl:295 [inlined]
  [3] set(model::GLPK.Optimizer, #unused#::MathOptInterface.TimeLimitSec, limit::Float64)
    @ GLPK ~/.julia/packages/GLPK/hDmA0/src/MOI_wrapper/MOI_wrapper.jl:383
  [4] set(m::JuMP.Model, attr::MathOptInterface.TimeLimitSec, value::Float64)
    @ JuMP ~/.julia/packages/JuMP/qhoVb/src/JuMP.jl:893
  [5] set_time_limit_sec
    @ ~/.julia/packages/JuMP/qhoVb/src/JuMP.jl:644 [inlined]
...

Underneath I believe GLPK works with an integer number of milliseconds, and if the Float64 cannot be converted to an integer amount of milliseconds then the code breaks. Probably the API should not be so finicky, and just round up a millisecond.

I am grateful for the fast solution. I see by the solution that I have misdiagnosed the problem. I was using a very large time limit exactly because there is no solve-agnostic way to set an "infinite" time limit, and GLPK has a much slower time limit cap than the other solvers.

odow commented

Oops, I missed an issue with a very fractional time limit: #169.