Skip to content

Commit

Permalink
use get_vars_from_components in create_subsystem_block
Browse files Browse the repository at this point in the history
  • Loading branch information
Robbybp committed Mar 19, 2024
1 parent 9fd202e commit ae439ad
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions pyomo/util/subsystems.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from pyomo.core.expr.visitor import identify_variables
from pyomo.common.collections import ComponentSet, ComponentMap
from pyomo.common.modeling import unique_component_name

from pyomo.util.vars_from_expressions import get_vars_from_components
from pyomo.core.base.constraint import Constraint
from pyomo.core.base.expression import Expression
from pyomo.core.base.objective import Objective
Expand Down Expand Up @@ -131,12 +131,12 @@ def create_subsystem_block(constraints, variables=None, include_fixed=False):
block.vars = Reference(variables)
block.cons = Reference(constraints)
var_set = ComponentSet(variables)
input_vars = []
for con in constraints:
for var in identify_variables(con.expr, include_fixed=include_fixed):
if var not in var_set:
input_vars.append(var)
var_set.add(var)
input_vars = [
var for var in get_vars_from_components(
block, Constraint, include_fixed=include_fixed
)
if var not in var_set
]
block.input_vars = Reference(input_vars)
add_local_external_functions(block)
return block
Expand Down

0 comments on commit ae439ad

Please sign in to comment.