Skip to content

Commit ce9f57a

Browse files
Return MOI.TIME_LIMIT when the solver times out (#46)
1 parent 085d2ad commit ce9f57a

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/optimize.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,10 @@ function MOI.get(model::Optimizer, ::MOI.TerminationStatus)
236236
else
237237
return MOI.OPTIMAL
238238
end
239+
elseif model.solver_status == "UNKNOWN" &&
240+
model.time_limit_sec !== nothing &&
241+
model.solve_time_sec >= model.time_limit_sec
242+
return MOI.TIME_LIMIT # The solver timed out
239243
else
240244
return MOI.OTHER_ERROR
241245
end

test/runtests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1432,7 +1432,7 @@ function test_highs_optimization_time_limit()
14321432
MOI.set(solver, MOI.TimeLimitSec(), 9e-4) # Very small limit
14331433
index_map, _ = MOI.optimize!(solver, model)
14341434
@test !isnan(MOI.get(solver, MOI.SolveTimeSec()))
1435-
@test MOI.get(solver, MOI.TerminationStatus()) === MOI.OTHER_ERROR
1435+
@test MOI.get(solver, MOI.TerminationStatus()) === MOI.TIME_LIMIT
14361436
solver = MiniZinc.Optimizer{Float64}("highs")
14371437
MOI.set(solver, MOI.TimeLimitSec(), 100)
14381438
index_map, _ = MOI.optimize!(solver, model)

0 commit comments

Comments
 (0)