Skip to content

Commit

Permalink
Add support for RelativeGap attribute (#111)
Browse files Browse the repository at this point in the history
  • Loading branch information
odow committed Apr 25, 2022
1 parent 4e1266c commit 8f1b532
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/MOI_wrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1763,6 +1763,13 @@ function MOI.get(model::Optimizer, ::MOI.SolveTimeSec)
return Highs_getRunTime(model)
end

function MOI.get(model::Optimizer, ::MOI.RelativeGap)
p = Ref{Cdouble}(0)
ret = Highs_getDoubleInfoValue(model, "mip_gap", p)
_check_ret(ret)
return p[]
end

function MOI.get(model::Optimizer, ::MOI.SimplexIterations)
p = Ref{HighsInt}(0)
ret = Highs_getIntInfoValue(model, "simplex_iteration_count", p)
Expand Down
7 changes: 7 additions & 0 deletions test/MOI_wrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,13 @@ function _knapsack_model(; mip::Bool, solver::String)
return model
end

function test_RelativeGap()
model = _knapsack_model(mip = true, solver = "choose")
MOI.optimize!(model)
@test MOI.get(model, MOI.RelativeGap()) 0.0
return
end

function test_SimplexIterations_BarrierIterations()
model = _knapsack_model(mip = false, solver = "simplex")
@test MOI.get(model, MOI.SimplexIterations()) == 0
Expand Down

2 comments on commit 8f1b532

@odow
Copy link
Member Author

@odow odow commented on 8f1b532 Apr 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/59069

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.1.3 -m "<description of version>" 8f1b532553c4e645569cf5383e9d27321c50cc6b
git push origin v1.1.3

Please sign in to comment.