Skip to content

Commit 101cb4a

Browse files
committed
Add test for variable iis
1 parent 8638210 commit 101cb4a

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

tests/test_iis.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,31 @@ def test_constraint_iis(model_interface):
2323

2424
assert con1_iis
2525
assert con2_iis
26+
27+
28+
def test_variable_iis(model_interface):
29+
model = model_interface
30+
31+
if not hasattr(model, "computeIIS"):
32+
pytest.skip("Model interface does not support IIS computation")
33+
34+
x = model.add_variable(lb=0.0, ub=2.0, name="x")
35+
y = model.add_variable(lb=0.0, ub=3.0, name="y")
36+
37+
con1 = model.add_linear_constraint(x + y, poi.Geq, 6.0)
38+
39+
model.set_objective(x)
40+
41+
model.computeIIS()
42+
43+
con1_iis = model.get_constraint_attribute(con1, poi.ConstraintAttribute.IIS)
44+
x_lb_iis = model.get_variable_attribute(x, poi.VariableAttribute.IISLowerBound)
45+
x_ub_iis = model.get_variable_attribute(x, poi.VariableAttribute.IISUpperBound)
46+
y_lb_iis = model.get_variable_attribute(y, poi.VariableAttribute.IISLowerBound)
47+
y_ub_iis = model.get_variable_attribute(y, poi.VariableAttribute.IISUpperBound)
48+
49+
assert con1_iis
50+
assert not x_lb_iis
51+
assert x_ub_iis
52+
assert not y_lb_iis
53+
assert y_ub_iis

0 commit comments

Comments
 (0)