Skip to content

Commit db40624

Browse files
committed
add failing test
1 parent 56a8380 commit db40624

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

pyomo/contrib/appsi/solvers/tests/test_persistent_solvers.py

+21
Original file line numberDiff line numberDiff line change
@@ -918,6 +918,27 @@ def test_bounds_with_params(
918918
res = opt.solve(m)
919919
self.assertAlmostEqual(m.y.value, 3)
920920

921+
@parameterized.expand(input=_load_tests(all_solvers, only_child_vars_options))
922+
def test_bounds_with_immutable_params(
923+
self, name: str, opt_class: Type[PersistentSolver], only_child_vars
924+
):
925+
# this test is for issue #2574
926+
opt: PersistentSolver = opt_class(only_child_vars=only_child_vars)
927+
if not opt.available():
928+
raise unittest.SkipTest
929+
m = pe.ConcreteModel()
930+
m.p = pe.Param(mutable=False, initialize=1)
931+
m.q = pe.Param([1, 2], mutable=False, initialize=10)
932+
m.y = pe.Var()
933+
m.y.setlb(m.p)
934+
m.y.setub(m.q[1])
935+
m.obj = pe.Objective(expr=m.y)
936+
res = opt.solve(m)
937+
self.assertAlmostEqual(m.y.value, 1)
938+
m.y.setlb(m.q[2])
939+
res = opt.solve(m)
940+
self.assertAlmostEqual(m.y.value, 10)
941+
921942
@parameterized.expand(input=_load_tests(all_solvers, only_child_vars_options))
922943
def test_solution_loader(
923944
self, name: str, opt_class: Type[PersistentSolver], only_child_vars

0 commit comments

Comments
 (0)