Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix default value for MOI.TimeLimitSec #261

Merged
merged 2 commits into from
Sep 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions src/MOI_wrapper/MOI_wrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,9 @@ end
function MOI.set(
model::Optimizer,
::MOI.TimeLimitSec,
value::Union{Nothing,Float64},
limit::Union{Nothing,Real},
)
if value === nothing
model.options.time_limit = Inf
else
model.options.time_limit = value
end
model.options.time_limit = convert(Float64, something(limit, Inf))
return
end

Expand Down Expand Up @@ -102,7 +98,9 @@ MOI.get(model::Optimizer, ::MOI.ResultCount) = length(model.inner.solutions)

MOI.get(model::Optimizer, ::MOI.NumberOfThreads) = model.options.processors

MOI.get(model::Optimizer, ::MOI.TimeLimitSec) = model.options.time_limit
function MOI.get(model::Optimizer, ::MOI.TimeLimitSec)
return isinf(model.options.time_limit) ? nothing : model.options.time_limit
end

MOI.get(model::Optimizer, ::MOI.Silent) = model.options.silent

Expand Down
2 changes: 1 addition & 1 deletion test/functions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
optimizer,
MOI.RawOptimizerAttribute("mip_gap_1"),
)
@test isinf(MOI.get(optimizer, MOI.TimeLimitSec()))
@test MOI.get(optimizer, MOI.TimeLimitSec()) === nothing
MOI.set(optimizer, MOI.TimeLimitSec(), 12.0)
@test MOI.get(optimizer, MOI.TimeLimitSec()) == 12.0
end
Expand Down