Skip to content

Commit 8a64563

Browse files
committed
add intervals tests
1 parent 8e55904 commit 8a64563

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed

test/infeasibility.jl

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,69 @@ function test_range()
177177
return
178178
end
179179

180+
function test_range_neg()
181+
model = Model()
182+
@variable(model, 10 <= x <= 11)
183+
@variable(model, -11 <= y <= -1)
184+
@constraint(model, c, x - y <= 1)
185+
@objective(model, Max, x + y)
186+
data = ModelAnalyzer.analyze(ModelAnalyzer.Infeasibility.Analyzer(), model)
187+
list = ModelAnalyzer.list_of_issue_types(data)
188+
@test length(list) == 1
189+
ret = ModelAnalyzer.list_of_issues(data, list[1])
190+
@test length(ret) == 1
191+
@test ret[] ==
192+
ModelAnalyzer.Infeasibility.InfeasibleConstraintRange{Float64}(
193+
c,
194+
11.0,
195+
22.0,
196+
MOI.LessThan{Float64}(1.0),
197+
)
198+
return
199+
end
200+
201+
function test_range_equalto()
202+
model = Model()
203+
@variable(model, x == 1)
204+
@variable(model, y == 2)
205+
@constraint(model, c, x + y == 1)
206+
@objective(model, Max, x + y)
207+
data = ModelAnalyzer.analyze(ModelAnalyzer.Infeasibility.Analyzer(), model)
208+
list = ModelAnalyzer.list_of_issue_types(data)
209+
@test length(list) == 1
210+
ret = ModelAnalyzer.list_of_issues(data, list[1])
211+
@test length(ret) == 1
212+
@test ret[] ==
213+
ModelAnalyzer.Infeasibility.InfeasibleConstraintRange{Float64}(
214+
c,
215+
3.0,
216+
3.0,
217+
MOI.EqualTo{Float64}(1.0),
218+
)
219+
return
220+
end
221+
222+
function test_range_equalto()
223+
model = Model()
224+
@variable(model, x == 1)
225+
@variable(model, y == 2)
226+
@constraint(model, c, 3x + 2y == 1)
227+
@objective(model, Max, x + y)
228+
data = ModelAnalyzer.analyze(ModelAnalyzer.Infeasibility.Analyzer(), model)
229+
list = ModelAnalyzer.list_of_issue_types(data)
230+
@test length(list) == 1
231+
ret = ModelAnalyzer.list_of_issues(data, list[1])
232+
@test length(ret) == 1
233+
@test ret[] ==
234+
ModelAnalyzer.Infeasibility.InfeasibleConstraintRange{Float64}(
235+
c,
236+
7.0,
237+
7.0,
238+
MOI.EqualTo{Float64}(1.0),
239+
)
240+
return
241+
end
242+
180243
function test_range_greaterthan()
181244
model = Model()
182245
@variable(model, 10 <= x <= 11)

0 commit comments

Comments
 (0)