Skip to content

Commit 4e1266c

Browse files
authored
Add support for NodeCount attribute (#110)
1 parent 3e73b92 commit 4e1266c

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

src/MOI_wrapper.jl

+6-7
Original file line numberDiff line numberDiff line change
@@ -1777,13 +1777,12 @@ function MOI.get(model::Optimizer, ::MOI.BarrierIterations)
17771777
return Int64(p[])
17781778
end
17791779

1780-
# TODO(odow): missing an upstream method for this.
1781-
# function MOI.get(model::Optimizer, ::MOI.NodeCount)
1782-
# p = Ref{Int64}(0)
1783-
# ret = Highs_getLongInfoValue(model, "mip_node_count", p)
1784-
# _check_ret(ret)
1785-
# return p[]
1786-
# end
1780+
function MOI.get(model::Optimizer, ::MOI.NodeCount)
1781+
p = Ref{Int64}(0)
1782+
ret = Highs_getInt64InfoValue(model, "mip_node_count", p)
1783+
_check_ret(ret)
1784+
return p[]
1785+
end
17871786

17881787
function MOI.get(
17891788
model::Optimizer,

test/MOI_wrapper.jl

+8
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,14 @@ function test_SimplexIterations_BarrierIterations()
267267
@test MOI.get(model, MOI.BarrierIterations()) > 0
268268
end
269269

270+
function test_NodeCount()
271+
model = _knapsack_model(mip = true, solver = "choose")
272+
@test MOI.get(model, MOI.NodeCount()) == 0
273+
MOI.optimize!(model)
274+
@test MOI.get(model, MOI.NodeCount()) > 0
275+
return
276+
end
277+
270278
end
271279

272280
TestMOIHighs.runtests()

0 commit comments

Comments
 (0)