Skip to content

Commit 282b455

Browse files
committed
num cuts as attribute
1 parent bd3f78f commit 282b455

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

src/MOI_wrapper.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,3 +136,15 @@ end
136136
function MOI.get(opt::Optimizer, ::MOI.NodeCount)
137137
return MOI.get(opt.oa_model, MOI.NodeCount())
138138
end
139+
140+
"""
141+
NumberOfCuts
142+
143+
Number of cuts added to the outer approximation model.
144+
"""
145+
struct NumberOfCuts <: MOI.AbstractOptimizerAttribute
146+
end
147+
148+
function MOI.get(opt::Optimizer, ::NumberOfCuts)
149+
return opt.num_cuts
150+
end

test/JuMP_tests.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,18 @@ function run_jump_tests(
6969
println(inst)
7070
inst(opt)
7171
end
72+
run_cut_test(_soc1, opt)
73+
run_cut_test(_expdesign, opt)
7274
return
7375
end
7476

77+
function run_cut_test(test_function, opt)
78+
MOI.empty!(opt)
79+
@test MOI.get(opt, Pajarito.NumberOfCuts()) == 0
80+
test_function(opt)
81+
@test MOI.get(opt, Pajarito.NumberOfCuts()) > 0
82+
end
83+
7584
function _soc1(opt)
7685
TOL = 1e-4
7786
m = JuMP.Model(opt)

0 commit comments

Comments
 (0)