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 support for MOI.TimeLimitSec #440

Merged
merged 3 commits into from
Dec 3, 2023
Merged
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
14 changes: 11 additions & 3 deletions src/MOI/MOI_wrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -527,13 +527,21 @@ function MOI.get(model::Optimizer, param::MOI.RawOptimizerAttribute)
return
end

function MOI.set(model::Optimizer, ::MOI.TimeLimitSec, limit::Real)
MOI.set(model, MOI.RawOptimizerAttribute("CPXPARAM_TimeLimit"), limit)
const _TIME_LIMIT_DEFAULT = 1.0e75

function MOI.set(
model::Optimizer,
::MOI.TimeLimitSec,
limit::Union{Nothing,Real},
)
new_limit = something(limit, _TIME_LIMIT_DEFAULT)
MOI.set(model, MOI.RawOptimizerAttribute("CPXPARAM_TimeLimit"), new_limit)
return
end

function MOI.get(model::Optimizer, ::MOI.TimeLimitSec)
return MOI.get(model, MOI.RawOptimizerAttribute("CPXPARAM_TimeLimit"))
limit = MOI.get(model, MOI.RawOptimizerAttribute("CPXPARAM_TimeLimit"))
return limit === _TIME_LIMIT_DEFAULT ? nothing : limit
end

MOI.supports_incremental_interface(::Optimizer) = true
Expand Down
Loading