Skip to content

Commit

Permalink
Add support for MOI.NumberOfThreads
Browse files Browse the repository at this point in the history
  • Loading branch information
hannes-uppman committed Sep 7, 2023
1 parent 537445c commit 9a78043
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/MOI_wrapper/MOI_wrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,23 @@ function MOI.get(model::Optimizer, ::MOI.TimeLimitSec)
return value === nothing ? value : parse(Float64, value)
end

MOI.supports(::Optimizer, ::MOI.NumberOfThreads) = true

function MOI.set(model::Optimizer, ::MOI.NumberOfThreads, value::Integer)
MOI.set(model, MOI.RawOptimizerAttribute("threads"), value)
return
end
function MOI.set(model::Optimizer, ::MOI.NumberOfThreads, ::Nothing)
delete!(model.params, "threads")
Cbc_setParameter(model, "threads", "InvalidIntValue")
return
end

function MOI.get(model::Optimizer, ::MOI.NumberOfThreads)
value = get(model.params, "threads", nothing)
return value === nothing ? value : parse(Int, value)
end

MOI.get(::Optimizer, ::MOI.SolverName) = "COIN Branch-and-Cut (Cbc)"

MOI.get(::Optimizer, ::MOI.SolverVersion) = unsafe_string(Cbc_getVersion())
Expand Down

0 comments on commit 9a78043

Please sign in to comment.