Skip to content

Commit

Permalink
Merge branch 'master' into threads
Browse files Browse the repository at this point in the history
  • Loading branch information
odow authored Sep 7, 2023
2 parents 9a78043 + f495d97 commit 17f952e
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"

[compat]
Cbc_jll = "=2.10.5, =200.1000.501, =200.1000.800"
MathOptInterface = "1"
MathOptInterface = "1.7"
julia = "1.6"

[extras]
Expand Down
37 changes: 37 additions & 0 deletions src/MOI_wrapper/MOI_wrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ 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")
Expand All @@ -198,6 +199,42 @@ function MOI.get(model::Optimizer, ::MOI.NumberOfThreads)
return value === nothing ? value : parse(Int, value)
end

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

function MOI.set(model::Optimizer, ::MOI.AbsoluteGapTolerance, value::Real)
MOI.set(model, MOI.RawOptimizerAttribute("allowableGap"), value)
return
end

function MOI.set(model::Optimizer, ::MOI.AbsoluteGapTolerance, ::Nothing)
delete!(model.params, "allowableGap")
Cbc_setParameter(model, "allowableGap", "InvalidDoubleValue")
return
end

function MOI.get(model::Optimizer, ::MOI.AbsoluteGapTolerance)
value = get(model.params, "allowableGap", nothing)
return value === nothing ? value : parse(Float64, value)
end

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

function MOI.set(model::Optimizer, ::MOI.RelativeGapTolerance, value::Real)
MOI.set(model, MOI.RawOptimizerAttribute("ratioGap"), value)
return
end

function MOI.set(model::Optimizer, ::MOI.RelativeGapTolerance, ::Nothing)
delete!(model.params, "ratioGap")
Cbc_setParameter(model, "ratioGap", "InvalidDoubleValue")
return
end

function MOI.get(model::Optimizer, ::MOI.RelativeGapTolerance)
value = get(model.params, "ratioGap", nothing)
return value === nothing ? value : parse(Float64, 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 17f952e

Please sign in to comment.