AttachedConstraint

AttachedConstraint#

class AttachedConstraint#

Attached constraint — a write-through handle bound to a host (Instance or ParametricInstance).

AttachedConstraint is returned by Instance.add_constraint / ParametricInstance.add_constraint and by their constraints[id] getters. Unlike Constraint, which is a snapshot, reads pull live data from the parent host and context setters write through to its SoA context store. Two AttachedConstraint instances pointing at the same id on the same host observe the same state.

The handle keeps the parent host alive through a refcount; drop the wrapper to release the back-reference.

__copy__() AttachedConstraint#
__deepcopy__(_memo: Any) AttachedConstraint#
__repr__() str#
add_parameter(key: str, value: str) None#

Add a single parameter entry. Writes through to the parent host’s context store.

add_parameters(parameters: Mapping[str, str]) None#

Add parameter entries. Writes through to the parent host’s context store.

Existing keys are overwritten, and keys not mentioned in parameters are preserved. Use set_parameters to replace the whole map.

add_subscripts(subscripts: Sequence[int]) None#

Append subscripts. Writes through to the parent host’s context store.

detach() Constraint#

Return a Constraint snapshot of the current state. Mutations on the returned object do not propagate back.

evaluate(state: ToState, atol: Optional[float] = None) EvaluatedConstraint#

Evaluate the constraint with the given state. Only valid on Instance-hosted handles, since ParametricInstance constraints may still reference unsubstituted parameters.

set_description(description: str) None#

Set the description. Writes through to the parent host’s context store.

set_name(name: str) None#

Set the name. Writes through to the parent host’s context store.

set_parameters(parameters: Mapping[str, str]) None#

Replace all parameters. Writes through to the parent host’s context store.

set_subscripts(subscripts: Sequence[int]) None#

Set the subscripts. Writes through to the parent host’s context store.

property constraint_id: int#

Read-only property.

The id this handle points at.

property description: Optional[str]#

Read-only property.

property equality: Equality#

Read-only property.

property function: Function#

Read-only property.

property instance: Any#

Read-only property.

The parent host this constraint lives in (Instance or ParametricInstance).

property name: Optional[str]#

Read-only property.

property parameters: dict[str, str]#

Read-only property.

property provenance: list[Provenance]#

Read-only property.

property subscripts: list[int]#

Read-only property.