API reference

pyomo.dae.flatten.slice_component_along_sets(...)

This function generates all possible slices of the provided component along the provided sets.

pyomo.dae.flatten.flatten_components_along_sets(m, ...)

This function iterates over components (recursively) contained in a block and partitions their data objects into components indexed only by the specified sets.

pyomo.dae.flatten.flatten_dae_components(...)

Partitions components into ComponentData and Components indexed only by the provided set.

pyomo.dae.flatten.slice_component_along_sets(component, sets, context_slice=None, normalize=None)[source]

This function generates all possible slices of the provided component along the provided sets. That is, it will iterate over the component’s other indexing sets and, for each index, yield a slice along the sets specified in the call signature.

Parameters:
  • component (Component) – The component whose slices will be yielded

  • sets (ComponentSet) – ComponentSet of Pyomo sets that will be sliced along

  • context_slice (IndexedComponent_slice) – If provided, instead of creating a new slice, we will extend this one with appropriate getattr and getitem calls.

  • normalize (Bool) – If False, the returned index (from the product of “other sets”) is not normalized, regardless of the value of normalize_index.flatten. This is necessary to use this index with _fill_indices.

Yields:

tuple – The first entry is the index in the product of “other sets” corresponding to the slice, and the second entry is the slice at that index.

pyomo.dae.flatten.flatten_components_along_sets(m, sets, ctype, indices=None, active=None)[source]

This function iterates over components (recursively) contained in a block and partitions their data objects into components indexed only by the specified sets.

Parameters:
  • m (BlockData) – Block whose components (and their sub-components) will be partitioned

  • sets (Tuple of Pyomo Sets) – Sets to be sliced. Returned components will be indexed by some combination of these sets, if at all.

  • ctype (Subclass of Component) – Type of component to identify and partition

  • indices (Iterable or ComponentMap) – Indices of sets to use when descending into subblocks. If an iterable is provided, the order corresponds to the order in sets. If a ComponentMap is provided, the keys must be in sets.

  • active (Bool or None) – If not None, this is a boolean flag used to filter component objects by their active status. A reference-to-slice is returned if any data object defined by the slice matches this flag.

Returns:

The first entry is a list of tuples of Pyomo Sets. The second is a list of lists of Components, indexed by the corresponding sets in the first list. If the components are unindexed, ComponentData are returned and the tuple of sets contains only UnindexedComponent_set. If the components are indexed, they are references-to-slices.

Return type:

List of tuples of Sets, list of lists of Components

pyomo.dae.flatten.flatten_dae_components(model, time, ctype, indices=None, active=None)[source]

Partitions components into ComponentData and Components indexed only by the provided set.

Parameters:
  • model (BlockData) – Block whose components are partitioned

  • time (Set) – Indexing by this set (and only this set) will be preserved in the returned components.

  • ctype (Subclass of Component) – Type of component to identify, partition, and return

  • indices (Tuple or ComponentMap) – Contains the index of the specified set to be used when descending into blocks

  • active (Bool or None) – If provided, used as a filter to only return components with the specified active flag. A reference-to-slice is returned if any data object defined by the slice matches this flag.

Returns:

The first list contains ComponentData for all components not indexed by the provided set. The second contains references-to -slices for all components indexed by the provided set.

Return type:

List of ComponentData, list of Component