diff --git a/pyomo/contrib/fme/fourier_motzkin_elimination.py b/pyomo/contrib/fme/fourier_motzkin_elimination.py index 021650e8f9a..ad3a6b5aeb2 100644 --- a/pyomo/contrib/fme/fourier_motzkin_elimination.py +++ b/pyomo/contrib/fme/fourier_motzkin_elimination.py @@ -730,12 +730,9 @@ def post_process_fme_constraints( continue # deactivate the constraint projected_constraints[i].deactivate() - m.del_component(obj) - # make objective to maximize its infeasibility - obj = Objective( - expr=projected_constraints[i].body - projected_constraints[i].lower - ) - m.add_component(obj_name, obj) + # Our constraint looks like: 0 <= a^Tx - b, so make objective to + # maximize its infeasibility + obj.expr = projected_constraints[i].body - projected_constraints[i].lower results = solver_factory.solve(m) if results.solver.termination_condition == TerminationCondition.unbounded: obj_val = -float('inf') @@ -753,13 +750,13 @@ def post_process_fme_constraints( obj_val = value(obj) # if we couldn't make it infeasible, it's useless if obj_val >= tolerance: - m.del_component(projected_constraints[i]) del projected_constraints[i] else: projected_constraints[i].activate() # clean up m.del_component(obj) + del obj for obj in active_objs: obj.activate() # undo relax integrality