Skip to content

Commit

Permalink
modifying the FME post-processing objective without creating and dele…
Browse files Browse the repository at this point in the history
…ting it every iteration
  • Loading branch information
emma58 committed Dec 2, 2024
1 parent 518b161 commit 45691f7
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions pyomo/contrib/fme/fourier_motzkin_elimination.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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
Expand Down

0 comments on commit 45691f7

Please sign in to comment.