Skip to content

Commit a49fcb6

Browse files
committed
separate test at the end
1 parent 49df057 commit a49fcb6

File tree

1 file changed

+55
-9
lines changed

1 file changed

+55
-9
lines changed

test/JuMP_tests.jl

Lines changed: 55 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,23 +64,15 @@ function run_jump_tests(
6464
_psd2,
6565
_expdesign,
6666
_specialorderedset,
67+
_soc1_ncuts,
6768
]
6869
@testset "$inst" for inst in insts
6970
println(inst)
7071
inst(opt)
7172
end
72-
run_cut_test(_soc1, opt)
73-
run_cut_test(_expdesign, opt)
7473
return
7574
end
7675

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-
8476
function _soc1(opt)
8577
TOL = 1e-4
8678
m = JuMP.Model(opt)
@@ -492,4 +484,58 @@ function _specialorderedset(opt)
492484
return
493485
end
494486

487+
function _soc1_ncuts(opt)
488+
TOL = 1e-4
489+
m = JuMP.Model(opt)
490+
491+
JuMP.@variable(m, x)
492+
JuMP.@objective(m, Min, -x)
493+
xlb1 = JuMP.@constraint(m, x >= 4)
494+
soc1 = JuMP.@constraint(m, [3.5, x] in JuMP.SecondOrderCone())
495+
@test MOI.get(m, Pajarito.NumberOfCuts()) == 0
496+
JuMP.optimize!(m)
497+
@test JuMP.termination_status(m) == MOI.INFEASIBLE
498+
@test JuMP.primal_status(m) == MOI.NO_SOLUTION
499+
500+
JuMP.delete(m, xlb1)
501+
JuMP.optimize!(m)
502+
@test MOI.get(m, Pajarito.NumberOfCuts()) > 0
503+
@test JuMP.termination_status(m) == MOI.OPTIMAL
504+
@test JuMP.primal_status(m) == MOI.FEASIBLE_POINT
505+
@test isapprox(JuMP.objective_value(m), -3.5, atol = TOL)
506+
@test isapprox(JuMP.objective_bound(m), -3.5, atol = TOL)
507+
@test isapprox(JuMP.value(x), 3.5, atol = TOL)
508+
509+
xlb2 = JuMP.@constraint(m, x >= 3.1)
510+
JuMP.set_integer(x)
511+
JuMP.optimize!(m)
512+
@test JuMP.termination_status(m) == MOI.INFEASIBLE
513+
514+
JuMP.delete(m, xlb2)
515+
JuMP.@constraint(m, x >= 0.5)
516+
JuMP.optimize!(m)
517+
@test JuMP.termination_status(m) == MOI.OPTIMAL
518+
@test MOI.get(m, Pajarito.NumberOfCuts()) > 0
519+
@test isapprox(JuMP.objective_value(m), -3, atol = TOL)
520+
@test isapprox(JuMP.objective_bound(m), -3, atol = TOL)
521+
@test isapprox(JuMP.value(x), 3, atol = TOL)
522+
523+
JuMP.@objective(m, Max, -3x)
524+
JuMP.optimize!(m)
525+
@test MOI.get(m, Pajarito.NumberOfCuts()) > 0
526+
@test JuMP.termination_status(m) == MOI.OPTIMAL
527+
@test isapprox(JuMP.objective_value(m), -3, atol = TOL)
528+
@test isapprox(JuMP.objective_bound(m), -3, atol = TOL)
529+
@test isapprox(JuMP.value(x), 1, atol = TOL)
530+
531+
JuMP.set_start_value(x, 1)
532+
JuMP.optimize!(m)
533+
@test JuMP.termination_status(m) == MOI.OPTIMAL
534+
@test MOI.get(m, Pajarito.NumberOfCuts()) > 0
535+
@test isapprox(JuMP.objective_value(m), -3, atol = TOL)
536+
@test isapprox(JuMP.objective_bound(m), -3, atol = TOL)
537+
@test isapprox(JuMP.value(x), 1, atol = TOL)
538+
return
539+
end
540+
495541
end

0 commit comments

Comments
 (0)