rename_components
(function from pyomo.util.components)
- pyomo.util.components.rename_components(model, component_list, prefix)[source]
Rename components in component_list using the prefix AND unique_component_name
- Parameters:
Examples
>>> model = pyo.ConcreteModel() >>> model.x = pyo.Var() >>> model.y = pyo.Var() >>> c_list = list(model.component_objects(ctype=pyo.Var, descend_into=True)) >>> new = rename_components(model, component_list=c_list, prefix='special_') >>> str(new) "ComponentMap({'special_x (key=...)': 'x', 'special_y (key=...)': 'y'})"
- Returns:
ComponentMap – to a string that provides their old fully qualified names
- Return type:
maps the renamed Component objects
Todo
need to add a check to see if someone accidentally passes a generator since this can lead to an infinite loop