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 what swap_relation() may act on and what iter_swapped_relations() reports over.

constraint

The live, originally-built Constraint.

Type:

Any

name

Its local name — the string swap_relation is called with.

Type:

str

target

The live Var/Reference the relationship determines.

Type:

Any

target_name

target’s local name.

Type:

str

fitted

The Constraint a swap attached, replacing constraint; None until 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, alongside fitted itself.

Type:

list

swap_count

How many times this relation has been swapped; used to keep each successive fitted Constraint’s name unique (flex-pse never deletes a component, so a second swap cannot reuse the first fitted Constraint’s name).

Type:

int

surrogate_block

The currently active surrogate sub-block (a Pyomo Block carrying coefficient Vars and the fitted constraint), or None when 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_block can reactivate them.

Type:

list

surrogate_instances

The Surrogate that built each entry of surrogate_blocks, index-aligned with it, so switch_surrogate_block can restore the matching surrogate_instance.

Type:

list

surrogate_instance

The Surrogate instance currently active for this relation, or None when surrogate_block is None (no swap yet, or the active surrogate built no block). Used by get_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