cottax.relational.relational_condition module¶
The condition node written as relations: a Rel marker, a Relation between two places, and RelationalCondition, relations and objectives over places with the unknowns they determine and the parameters they hold fixed, and + the join.
- class Rel[source]¶
Bases:
objectMarker for a relation, asked by identity: a relation holds the class itself. A new one subclasses Rel with a symbol.
- symbol: str¶
How a relation writes it.
- check_op(relation: Relation)[source]¶
The op is a Rel class, not an instance or a string.
- Return type:
Iterator[Violation]
- class Relation[V: Place](lhs: Optional[V], rhs: Optional[V], op: type[Rel])[source]¶
Bases:
Frozen,Generic[V]lhs op rhs between two places; a side of None is zero.
- lhs: Optional[V]¶
- rhs: Optional[V]¶
- checks: PerLevel[tuple[Callable[[Any], object], ...]] = (<function check_sides>, <function check_op>)¶
Callable [self] -> iterable of violations, which are raised at construction unless skipped (see unchecked).
- property terms: tuple[V, ...]¶
The sides that are places, left then right.
- class Sense[source]¶
Bases:
objectMarker for which way an objective is driven, asked by identity: an objective holds the class itself.
- symbol: str¶
How an objective writes it.
- check_sense(objective: Objective)[source]¶
The sense is a Sense class, not an instance or a string.
- Return type:
Iterator[Violation]
- class Objective[V: Place](place: V, sense: type[Sense])[source]¶
Bases:
Frozen,Generic[V]A place and the way it is driven: which way changes the answer, so it is the problem’s, stored with the place it drives.
- place: V¶
- check_relates_something(node: RelationalCondition)[source]¶
It relates something: a condition met by every value is not a condition.
- Return type:
Iterator[Violation]
- check_parameters(node: RelationalCondition)[source]¶
A parameter is held fixed: not moved (an unknown), not minimised (an objective), a term of some relation, and never the only kind of term in one.
- Return type:
Iterator[Violation]
- class RelationalCondition[V: Place](relations: tuple[Relation[V], ...], objectives: tuple[Objective[V], ...], unknowns: tuple[V, ...], parameters: tuple[V, ...])[source]¶
Bases:
ConditionalNode[V],Generic[V]A condition node: relations and objectives over places, the unknowns it determines and the parameters it holds fixed. Every other term is a condition. Supports addition.
- unknowns: tuple[V, ...]¶
What this node determines; () for a requirement.
- parameters: tuple[V, ...]¶
a bound, a limit. Read, not a condition, so a proof asks them off the problem’s cycle.
- Type:
Terms read and held fixed while the unknowns move
- checks: PerLevel[tuple[Callable[[Any], object], ...]] = (<function check_relates_something>, <function check_parameters>)¶
Callable [self] -> iterable of violations, which are raised at construction unless skipped (see unchecked).
- property conditions: tuple[V, ...]¶
The objectives, then every relation’s terms that are neither unknowns nor parameters, in order.
- property reads: tuple[V, ...]¶
The conditions, then the parameters.
- property owns: tuple[V, ...]¶
abstract to ABC until a subclass binds the name, and absent on a class that declares it as a field.
- Type:
What the level binds in place of the annotation
- determined(unknowns: tuple[V, ...])[source]¶
Same ConditionalNode but determined by the unknowns.
- Return type:
- class NoSides[source]¶
Bases:
Violation- template: AbstractClassVar[str] = 'a relation with zero on both sides relates nothing'¶
e.g. ‘output {place!r} is owned by both {other!r} and {node!r}’
- Type:
Wording
- class NotASense(sense: object)[source]¶
Bases:
Violation- sense: object¶
- template: AbstractClassVar[str] = '{sense!r} is not a `Sense` class: an objective holds `Min`, `Max` or another'¶
e.g. ‘output {place!r} is owned by both {other!r} and {node!r}’
- Type:
Wording
- class NotARel(op: object)[source]¶
Bases:
Violation- op: object¶
- template: AbstractClassVar[str] = '{op!r} is not a `Rel` class: a relation holds `Eq`, `Le` or another `Rel` itself'¶
e.g. ‘output {place!r} is owned by both {other!r} and {node!r}’
- Type:
Wording
- class RelatesNothing(node: str)[source]¶
Bases:
Violation- node: str¶
- template: AbstractClassVar[str] = '{node}: relates nothing -- a condition met by every value is not a condition'¶
e.g. ‘output {place!r} is owned by both {other!r} and {node!r}’
- Type:
Wording
- class FixedAndMoved(places: tuple)[source]¶
Bases:
Violation- places: tuple¶
- template: AbstractClassVar[str] = '{places!r} held fixed, but also an unknown or an objective: a parameter is read and never moved'¶
e.g. ‘output {place!r} is owned by both {other!r} and {node!r}’
- Type:
Wording
Bases:
Violatione.g. ‘output {place!r} is owned by both {other!r} and {node!r}’
- Type:
Wording
- class FixedRelation(relations: tuple)[source]¶
Bases:
Violation- relations: tuple¶
- template: AbstractClassVar[str] = '{relations!r}: every term held fixed, so no unknown moves the relation -- relate a parameter to an unknown or a condition'¶
e.g. ‘output {place!r} is owned by both {other!r} and {node!r}’
- Type:
Wording