Skip to content

Commit 97cde56

Browse files
committed
add tests
1 parent ceccb9f commit 97cde56

File tree

1 file changed

+46
-1
lines changed

1 file changed

+46
-1
lines changed

test/feasibility.jl

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ function test_only_bounds()
109109
ModelAnalyzer.Feasibility.PrimalDualMismatch,
110110
)
111111
@test ret[] == ModelAnalyzer.Feasibility.PrimalDualMismatch(-1.0, 0.0)
112-
# @test ModelAnalyzer.values(ret[]) == [-1.0, 0.0]
112+
@test ModelAnalyzer.values(ret[]) == [-1.0, 0.0]
113113

114114
data = ModelAnalyzer.analyze(
115115
ModelAnalyzer.Feasibility.Analyzer(),
@@ -718,6 +718,51 @@ function test_analyse_no_opt()
718718
return
719719
end
720720

721+
function test_dual_constrained_variable()
722+
model = Model()
723+
@variable(model, x >= 0)
724+
@objective(model, Min, x)
725+
726+
data = ModelAnalyzer.analyze(
727+
ModelAnalyzer.Feasibility.Analyzer(),
728+
model,
729+
primal_point = Dict(JuMP.index(x) => 1.0),
730+
dual_point = Dict(JuMP.index(LowerBoundRef(x)) => -1.0),
731+
)
732+
list = ModelAnalyzer.list_of_issue_types(data)
733+
@test list == [
734+
ModelAnalyzer.Feasibility.DualConstraintViolation,
735+
ModelAnalyzer.Feasibility.DualConstrainedVariableViolation,
736+
ModelAnalyzer.Feasibility.ComplemetarityViolation,
737+
ModelAnalyzer.Feasibility.PrimalDualMismatch,
738+
]
739+
ret = ModelAnalyzer.list_of_issues(
740+
data,
741+
ModelAnalyzer.Feasibility.DualConstrainedVariableViolation,
742+
)
743+
@test ret[] == ModelAnalyzer.Feasibility.DualConstrainedVariableViolation(
744+
JuMP.index(LowerBoundRef(x)),
745+
1.0,
746+
)
747+
@test ModelAnalyzer.constraint(ret[], model) == LowerBoundRef(x)
748+
@test ModelAnalyzer.value(ret[]) == 1.0
749+
750+
buf = IOBuffer()
751+
ModelAnalyzer.summarize(
752+
buf,
753+
ModelAnalyzer.Feasibility.DualConstrainedVariableViolation,
754+
verbose = true,
755+
)
756+
ModelAnalyzer.summarize(
757+
buf,
758+
ModelAnalyzer.Feasibility.DualConstrainedVariableViolation,
759+
verbose = false,
760+
)
761+
ModelAnalyzer.summarize(buf, ret[], verbose = true)
762+
ModelAnalyzer.summarize(buf, ret[], verbose = false)
763+
return
764+
end
765+
721766
# these tests are harder to permorm with a real solver as they tipically
722767
# return coherent objectives
723768
function test_lowlevel_mismatch()

0 commit comments

Comments
 (0)