ComponentUID

(class from pyomo.core.base.componentuid)

class pyomo.core.base.componentuid.ComponentUID(component, cuid_buffer=None, context=None)[source]

Bases: object

A Component unique identifier

This class provides a system to generate “component unique identifiers”. Any component in a model can be described by a CUID, and from a CUID you can find the component. An important feature of CUIDs is that they are relative to a model, so you can use a CUID generated on one model to find the equivalent component on another model. This is especially useful when you clone a model and want to, for example, copy a variable value from the cloned model back to the original model.

The CUID has a string representation that can specify a specific component or a group of related components through the use of index wildcards (* for a single element in the index, and ** for all indexes)

__init__(component, cuid_buffer=None, context=None)[source]

Methods

__init__(component[, cuid_buffer, context])

find_component(block)

DEPRECATED.

find_component_on(block)

Return the (unique) component in the block.

generate_cuid_string_map(block[, ctype, ...])

get_repr([version])

list_components(block)

Generator returning all components matching this ComponentUID

matches(component[, context])

Return True if this ComponentUID matches specified component

Member Documentation

find_component(block)[source]

DEPRECATED.

Deprecated since version 5.7.2: ComponentUID.find_component() is deprecated. Use ComponentUID.find_component_on()

find_component_on(block)[source]

Return the (unique) component in the block. If the CUID contains a wildcard in the last component, then returns that component. If there are wildcards elsewhere (or the last component was a partial slice), then returns a reference. See also list_components below.

list_components(block)[source]

Generator returning all components matching this ComponentUID

matches(component, context=None)[source]

Return True if this ComponentUID matches specified component

This is equivalent to:

component in ComponentSet(self.list_components())