Skip to content

Commit

Permalink
Make some coeff matching tests more rigorous
Browse files Browse the repository at this point in the history
  • Loading branch information
shermanjasonaf committed Dec 1, 2024
1 parent 3b4c59d commit ec086dd
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions pyomo/contrib/pyros/tests/test_grcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1664,6 +1664,50 @@ def test_coefficient_matching_robust_infeasible_proof_in_pyros(self):
pyrosTerminationCondition.robust_infeasible,
msg="Robust infeasible problem not identified via coefficient matching.",
)
self.assertEqual(
results.iterations,
0,
msg="Number of PyROS iterations not as expected.",
)

@unittest.skipUnless(ipopt_available, "IPOPT not available")
def test_coefficient_matching_robust_infeasible_param_only_con(self):
"""
Test robust infeasibility reported due to equality
constraint depending only on uncertain params.
"""
m = build_leyffer()
m.robust_infeasible_eq_con = Constraint(expr=m.u == 1)

box_set = BoxSet(bounds=[(0.25, 2)])

ipopt = SolverFactory("ipopt")
pyros_solver = SolverFactory("pyros")

results = pyros_solver.solve(
model=m,
first_stage_variables=[m.x1, m.x2],
second_stage_variables=[],
uncertain_params=[m.u],
uncertainty_set=box_set,
local_solver=ipopt,
global_solver=ipopt,
options={
"objective_focus": ObjectiveType.worst_case,
"solve_master_globally": True,
},
)

self.assertEqual(
results.pyros_termination_condition,
pyrosTerminationCondition.robust_infeasible,
msg="Robust infeasible problem not identified via coefficient matching.",
)
self.assertEqual(
results.iterations,
0,
msg="Number of PyROS iterations not as expected.",
)

@unittest.skipUnless(ipopt_available, "IPOPT not available.")
def test_coefficient_matching_nonlinear_expr(self):
Expand Down

0 comments on commit ec086dd

Please sign in to comment.