Skip to content

Commit

Permalink
Update MOI_wrapper.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
odow authored Sep 7, 2023
1 parent dd57f37 commit a1ab5ea
Showing 1 changed file with 20 additions and 14 deletions.
34 changes: 20 additions & 14 deletions src/MOI_wrapper/MOI_wrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -182,30 +182,36 @@ function MOI.get(model::Optimizer, ::MOI.TimeLimitSec)
end

MOI.supports(::Optimizer, ::MOI.AbsoluteGapTolerance) = true
function MOI.set(model::Optimizer, ::MOI.AbsoluteGapTolerance, value)
if value === nothing
delete!(model.params, "allowableGap")
Cbc_setParameter(model, "allowableGap", "InvalidDoubleValue")
else
MOI.set(model, MOI.RawOptimizerAttribute("allowableGap"), value)
end

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)
if value === nothing
delete!(model.params, "ratioGap")
Cbc_setParameter(model, "ratioGap", "InvalidDoubleValue")
else
MOI.set(model, MOI.RawOptimizerAttribute("ratioGap"), value)
end

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)
Expand Down

0 comments on commit a1ab5ea

Please sign in to comment.