RelationRecord¶
- class flexops.core.registration.RelationRecord(constraint: Any, name: str, target: Any, target_name: str, fitted: Any = None, components: list = <factory>, swap_count: int = 0, surrogate_block: Any = None, surrogate_blocks: list = <factory>, surrogate_instances: list = <factory>, surrogate_instance: Any = None)¶
A non-conservation relationship a unit has declared swappable.
Registered via
register_relation()— an unregistered constraint (a mass balance, a conservation law) can never be swapped, so this list is whatswap_relation()may act on and whatiter_swapped_relations()reports over.- constraint¶
The live, originally-built Constraint.
- Type:
Any
- target¶
The live Var/Reference the relationship determines.
- Type:
Any
- fitted¶
The Constraint a swap attached, replacing
constraint;Noneuntil a swap has happened.- Type:
Any
- components¶
Any Vars/Constraints a builder attached while fitting
fitted(e.g. an auxiliary variable a state-space or big-M form needs); deactivated on the next swap, alongsidefitteditself.- Type:
- swap_count¶
How many times this relation has been swapped; used to keep each successive
fittedConstraint’s name unique (flex-pse never deletes a component, so a second swap cannot reuse the first fitted Constraint’s name).- Type:
- surrogate_block¶
The currently active surrogate sub-block (a Pyomo Block carrying coefficient Vars and the fitted constraint), or
Nonewhen no surrogate has been swapped for this relation.- Type:
Any
- surrogate_blocks¶
Every surrogate block ever built for this relation, oldest first. The list is append-only; deactivated blocks remain here so
switch_surrogate_blockcan reactivate them.- Type:
- surrogate_instances¶
The
Surrogatethat built each entry ofsurrogate_blocks, index-aligned with it, soswitch_surrogate_blockcan restore the matchingsurrogate_instance.- Type:
- surrogate_instance¶
The
Surrogateinstance currently active for this relation, orNonewhensurrogate_blockisNone(no swap yet, or the active surrogate built no block). Used byget_surrogate_spec()to read its spec back (read_spec) without depending on block attributes; it is the one source of the relation’s spec.- Type:
Any