From 808f15774ab297987b6970bdf69dc048abde98b2 Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Thu, 7 Mar 2024 16:04:08 +1300 Subject: [PATCH] Add support for MOI.RelativeGapTolerance and MOI.AbsoluteGapTolerance (#224) --- src/MOI/MOI_wrapper.jl | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/MOI/MOI_wrapper.jl b/src/MOI/MOI_wrapper.jl index 7a079325..a4387f8e 100644 --- a/src/MOI/MOI_wrapper.jl +++ b/src/MOI/MOI_wrapper.jl @@ -4424,3 +4424,33 @@ function MOI.get( column = _info(model, vi).column return model.cached_solution.variable_dual[column] end + +#= + RelativeGapTolerance +=# + +MOI.supports(::Optimizer, ::MOI.RelativeGapTolerance) = true + +function MOI.get(model::Optimizer, ::MOI.RelativeGapTolerance) + return Xpress.getcontrol(model.inner, Lib.XPRS_MIPRELSTOP) +end + +function MOI.set(model::Optimizer, ::MOI.RelativeGapTolerance, value::Float64) + Xpress.setcontrol!(model.inner, Lib.XPRS_MIPRELSTOP, value) + return +end + +#= + AbsoluteGapTolerance +=# + +MOI.supports(::Optimizer, ::MOI.AbsoluteGapTolerance) = true + +function MOI.get(model::Optimizer, ::MOI.AbsoluteGapTolerance) + return Xpress.getcontrol(model.inner, Lib.XPRS_MIPABSSTOP) +end + +function MOI.set(model::Optimizer, ::MOI.AbsoluteGapTolerance, value::Float64) + Xpress.setcontrol!(model.inner, Lib.XPRS_MIPABSSTOP, value) + return +end