Skip to content

Commit

Permalink
Black
Browse files Browse the repository at this point in the history
  • Loading branch information
emma58 committed Sep 9, 2024
1 parent e97eed6 commit f2545d4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
12 changes: 7 additions & 5 deletions pyomo/gdp/plugins/hull.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ def _transform_disjunctionData(
disjunct=obj,
bigmConstraint=disaggregated_var_bounds,
var_free_indicator=var_free,
var_idx=idx
var_idx=idx,
)
original_var_info = var.parent_block().private_data()
disaggregated_var_map = original_var_info.disaggregated_var_map
Expand Down Expand Up @@ -622,15 +622,17 @@ def _declare_disaggregated_var_bounds(
if var_idx is not None:
lb_idx = (var_idx, 'lb')
bigmConstraint.add(lb_idx, var_free_indicator * lb <= disaggregatedVar)
disaggregated_var_info.bigm_constraint_map[
disaggregatedVar][disjunct]['lb'] = bigmConstraint[lb_idx]
disaggregated_var_info.bigm_constraint_map[disaggregatedVar][disjunct][
'lb'
] = bigmConstraint[lb_idx]
if ub:
ub_idx = 'ub'
if var_idx is not None:
ub_idx = (var_idx, 'ub')
bigmConstraint.add(ub_idx, disaggregatedVar <= ub * var_free_indicator)
disaggregated_var_info.bigm_constraint_map[
disaggregatedVar][disjunct]['ub'] = bigmConstraint[ub_idx]
disaggregated_var_info.bigm_constraint_map[disaggregatedVar][disjunct][
'ub'
] = bigmConstraint[ub_idx]

# store the mappings from variables to their disaggregated selves on
# the transformation block
Expand Down
10 changes: 6 additions & 4 deletions pyomo/gdp/tests/test_hull.py
Original file line number Diff line number Diff line change
Expand Up @@ -531,14 +531,16 @@ def test_bigMConstraint_mappings(self):
if i == 1: # this disjunct has x, w, and no y
mappings[disjBlock[i].disaggregatedVars.w] = disjBlock[i].w_bounds
mappings[transBlock._disaggregatedVars[0]] = {
key: val for key, val in transBlock._boundsConstraints.items() if
key[0] == 0
key: val
for key, val in transBlock._boundsConstraints.items()
if key[0] == 0
}
elif i == 0: # this disjunct has x, y, and no w
mappings[disjBlock[i].disaggregatedVars.y] = disjBlock[i].y_bounds
mappings[transBlock._disaggregatedVars[1]] = {
key: val for key, val in transBlock._boundsConstraints.items() if
key[0] == 1
key: val
for key, val in transBlock._boundsConstraints.items()
if key[0] == 1
}
for var, cons in mappings.items():
returned_cons = hull.get_var_bounds_constraint(var)
Expand Down

0 comments on commit f2545d4

Please sign in to comment.