def test_no_scaling_factor(self, model2): model2.scaling_factor = pyo.Suffix(direction=pyo.Suffix.EXPORT) sc.scale_single_constraint(model2.c) assert model2.c.upper.value == pytest.approx(1e3)
def test_scaling_factor_and_expression_replacement(self, model): model.c4 = pyo.Constraint(expr=model.x <= 1e6) model.scaling_factor[model.c4] = 1e-6 sc.scale_single_constraint(model.c4) assert model.c4.upper.value == pytest.approx(1) assert model.c4 not in model.scaling_factor
def test_greater_than_constraint(self, model): sc.scale_single_constraint(model.c3) assert model.c3.lower.value == pytest.approx(1) assert model.c3.body() == pytest.approx(model.x.value / 1e3) assert model.c3.upper is None
def test_equality_constraint(self, model): sc.scale_single_constraint(model.c2) assert model.c2.lower.value == pytest.approx(1) assert model.c2.body() == pytest.approx(model.x.value / 1e3) assert model.c2.upper.value == pytest.approx(1)
def test_less_than_constraint(self, model): sc.scale_single_constraint(model.c1) assert model.c1.lower is None assert model.c1.body() == pytest.approx(model.x.value / 1e3) assert model.c1.upper.value == pytest.approx(1)
def test_not_constraint(self, model): with pytest.raises(TypeError): sc.scale_single_constraint(model.x)