Skip to content

Commit

Permalink
Black
Browse files Browse the repository at this point in the history
  • Loading branch information
emma58 committed Sep 23, 2024
1 parent 7beea07 commit 5d023cd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# ___________________________________________________________________________

from pyomo.contrib.piecewise.transform.reduced_inner_representation_gdp import (
ReducedInnerRepresentationGDPTransformation
ReducedInnerRepresentationGDPTransformation,
)
from pyomo.core import Constraint
from pyomo.core.base import TransformationFactory
Expand All @@ -31,8 +31,9 @@ class AccidentalReducedInnerRepresentationGDPTransformation(
CONFIG = ReducedInnerRepresentationGDPTransformation.CONFIG()
_transformation_name = 'pw_linear_accidental_reduced_inner_repn'

def _add_disjunctive_constraints(self, disj, transBlock, extreme_pts,
num_extreme_pts):
def _add_disjunctive_constraints(
self, disj, transBlock, extreme_pts, num_extreme_pts
):
disj.lambdas_sum_to_one = Constraint(
expr=sum(transBlock.lambdas[i] for i in extreme_pts) >= 1
)
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ def _transform_pw_linear_expr(self, pw_expr, pw_linear_func, transformation_bloc
# disjunctive constraints
for simplex in pw_linear_func._simplices:
disj = transBlock.disjuncts[len(transBlock.disjuncts)]
self._add_disjunctive_constraints(disj, transBlock,
extreme_pts_by_simplex[simplex],
num_extreme_pts)
self._add_disjunctive_constraints(
disj, transBlock, extreme_pts_by_simplex[simplex], num_extreme_pts
)
# Make the disjunction
transBlock.pick_a_piece = Disjunction(
expr=[d for d in transBlock.disjuncts.values()]
Expand All @@ -133,11 +133,10 @@ def linear_combo(b, i):

return transBlock.substitute_var

def _add_disjunctive_constraints(self, disj, transBlock, extreme_pts,
num_extreme_pts):
cons = disj.lambdas_zero_for_other_simplices = Constraint(
NonNegativeIntegers
)
def _add_disjunctive_constraints(
self, disj, transBlock, extreme_pts, num_extreme_pts
):
cons = disj.lambdas_zero_for_other_simplices = Constraint(NonNegativeIntegers)
for i in range(num_extreme_pts):
if i not in extreme_pts:
cons[len(cons)] = transBlock.lambdas[i] <= 0

0 comments on commit 5d023cd

Please sign in to comment.