jump-dev / HiGHS.jl

A Julia interface to the HiGHS solver
https://highs.dev
MIT License
97 stars 13 forks source link

Time limit not working #125

Closed Ranash1375 closed 1 year ago

Ranash1375 commented 1 year ago

Hi,

I wrote a linear MIP. No matter what I set for the time limit parameter, the solver doesn't stop before finding the optimal solution. I was wondering if it is just my problem.

m = Model(HiGHS.Optimizer)
set_optimizer_attribute(m, "presolve", "on")
set_optimizer_attribute(m, "time_limit", stime)

Thanks

odow commented 1 year ago

Potentially the same as https://github.com/ERGO-Code/HiGHS/issues/947.

HiGHS.jl just passes the settings to the solver, so any issue is in the upstream solver, not in HiGHS.jl.

odow commented 1 year ago

I can confirm that HiGHS.jl can set a time limit and terminate appropriately, so if it isn't terminating, that's a bug in the upstream solver, and likely the same one that I linked above:

julia> using JuMP

julia> import HiGHS

julia> function main(N)
           w, c = rand(N), rand(N)
           model = Model(HiGHS.Optimizer)
           @variable(model, x[1:N] >= 0, Int)
           @constraint(model, w' * x <= 10)
           @objective(model, Max, c' * x)
           set_time_limit_sec(model, 0.001)
           optimize!(model)
           solution_summary(model)
       end
main(1main (generic function with 1 method)

julia> main(100)
Presolving model
1 rows, 100 cols, 100 nonzeros
1 rows, 100 cols, 100 nonzeros

Solving report
  Status            Time limit reached
  Primal bound      -inf
  Dual bound        inf
  Gap               0% (tolerance: 0.01%)
  Solution status   -
  Timing            0.01 (total)
                    0.01 (presolve)
                    0.00 (postsolve)
  Nodes             0
  LP iterations     0 (total)
                    0 (strong br.)
                    0 (separation)
                    0 (heuristics)
* Solver : HiGHS

* Status
  Termination status : TIME_LIMIT
  Primal status      : NO_SOLUTION
  Dual status        : NO_SOLUTION
  Message from the solver:
  "kHighsModelStatusTimeLimit"

* Candidate solution
  Objective bound      : Inf
  Relative gap         : NaN

* Work counters
  Solve time (sec)   : 1.18906e-02
  Simplex iterations : -1
  Barrier iterations : -1
  Node count         : 0

Closing because this isn't a bug in HiGHS.jl and it is already reported upstream.