From a1ab5ea4589752fe32251cfcbf2c9fc39d2546d9 Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Fri, 8 Sep 2023 10:39:53 +1200 Subject: [PATCH] Update MOI_wrapper.jl --- src/MOI_wrapper/MOI_wrapper.jl | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/src/MOI_wrapper/MOI_wrapper.jl b/src/MOI_wrapper/MOI_wrapper.jl index d296bc9..39f7cc7 100644 --- a/src/MOI_wrapper/MOI_wrapper.jl +++ b/src/MOI_wrapper/MOI_wrapper.jl @@ -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)