Skip to content

Commit ad37c02

Browse files
committed
add tests
1 parent e9035d7 commit ad37c02

File tree

1 file changed

+35
-2
lines changed

1 file changed

+35
-2
lines changed

test/numerical.jl

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,22 @@ function test_constraint_bounds_quad()
192192
return
193193
end
194194

195+
function test_constraint_bounds_quad()
196+
model = Model()
197+
@variable(model, x)
198+
@constraint(model, c, [-x^2 - 3] in MOI.Nonpositives(1))
199+
data = ModelAnalyzer.analyze(ModelAnalyzer.Numerical.Analyzer(), model)
200+
list = ModelAnalyzer.list_of_issue_types(data)
201+
@test length(list) == 1
202+
ret = ModelAnalyzer.list_of_issues(
203+
data,
204+
ModelAnalyzer.Numerical.NonconvexQuadraticConstraint,
205+
)
206+
@test length(ret) == 1
207+
@test ModelAnalyzer.constraint(ret[]) == JuMP.index(c)
208+
return
209+
end
210+
195211
function test_no_names()
196212
model = Model()
197213
set_string_names_on_creation(model, false)
@@ -1044,10 +1060,27 @@ function test_vi_in_nonstandard_set()
10441060
model = Model()
10451061
@variable(model, x[1:1])
10461062
@constraint(model, c, x[1] in MOI.ZeroOne())
1047-
@constraint(model, c2, 2x[1] == 0)
1063+
@constraint(model, c1, 3x[1] + 1e-9 in MOI.ZeroOne())
1064+
@constraint(model, c2, 4x[1] - 1e+9 in MOI.ZeroOne())
1065+
@constraint(model, c3, 2x[1] == 0)
10481066
data = ModelAnalyzer.analyze(ModelAnalyzer.Numerical.Analyzer(), model)
10491067
list = ModelAnalyzer.list_of_issue_types(data)
1050-
@test length(list) == 0
1068+
@test length(list) == 2
1069+
ret = ModelAnalyzer.list_of_issues(
1070+
data,
1071+
ModelAnalyzer.Numerical.SmallRHSCoefficient,
1072+
)
1073+
@test length(ret) == 1
1074+
@test ModelAnalyzer.constraint(ret[], model) == c1
1075+
@test ModelAnalyzer.value(ret[]) == 1e-9
1076+
#
1077+
ret = ModelAnalyzer.list_of_issues(
1078+
data,
1079+
ModelAnalyzer.Numerical.LargeRHSCoefficient,
1080+
)
1081+
@test length(ret) == 1
1082+
@test ModelAnalyzer.constraint(ret[], model) == c2
1083+
@test ModelAnalyzer.value(ret[]) == -1e+9
10511084
return
10521085
end
10531086

0 commit comments

Comments
 (0)