Skip to content

Commit 8f1b532

Browse files
authored
Add support for RelativeGap attribute (#111)
1 parent 4e1266c commit 8f1b532

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/MOI_wrapper.jl

+7
Original file line numberDiff line numberDiff line change
@@ -1763,6 +1763,13 @@ function MOI.get(model::Optimizer, ::MOI.SolveTimeSec)
17631763
return Highs_getRunTime(model)
17641764
end
17651765

1766+
function MOI.get(model::Optimizer, ::MOI.RelativeGap)
1767+
p = Ref{Cdouble}(0)
1768+
ret = Highs_getDoubleInfoValue(model, "mip_gap", p)
1769+
_check_ret(ret)
1770+
return p[]
1771+
end
1772+
17661773
function MOI.get(model::Optimizer, ::MOI.SimplexIterations)
17671774
p = Ref{HighsInt}(0)
17681775
ret = Highs_getIntInfoValue(model, "simplex_iteration_count", p)

test/MOI_wrapper.jl

+7
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,13 @@ function _knapsack_model(; mip::Bool, solver::String)
253253
return model
254254
end
255255

256+
function test_RelativeGap()
257+
model = _knapsack_model(mip = true, solver = "choose")
258+
MOI.optimize!(model)
259+
@test MOI.get(model, MOI.RelativeGap()) 0.0
260+
return
261+
end
262+
256263
function test_SimplexIterations_BarrierIterations()
257264
model = _knapsack_model(mip = false, solver = "simplex")
258265
@test MOI.get(model, MOI.SimplexIterations()) == 0

0 commit comments

Comments
 (0)