math_spec.sos
Expand sos: blocks into the binaries and rows that state the same restriction.
A set becomes ordinary declarations under names prefixed with the block's own,
the way a piecewise: block becomes weights and rows; what it emits is
tabled in docs/reference/language/piecewise.md. An unpicked member is held
at zero from both sides, so the rewrite states the same feasible set whatever
sign the member takes — what it needs is a coefficient on each side, which a
model declaring a set without is refused at load for
(:meth:math_spec.model.Spec validates it) rather than here.
Coefficients = tuple[float | str | None, float | str | None]
module-attribute
#
Emitted(seg, pick, link)
dataclass
#
Every name one set's expansion writes, spelled once for the emitter and the collision check.
The linking row is named after what it says, which the two orders do not
share: order 2 admits a member in either half of one segment, and order 1
admits it alone. below is the same row from underneath, written only
where the member may be nonzero below zero.
coefficients(domain, lower, upper)
#
What a member's two linking rows multiply its binary by, None on a side the model leaves open.
The 0 and 1 a binary's domain fixes, which no bounds block carries; otherwise the member's own declared bounds, each a number or the name of a parameter. A parameter is a coefficient like any other: it is what the row multiplies by, and no rewrite needs to know its value. Nothing else is a coefficient: a number below the bound would cap a picked member the set does not cap, and one above it is a looser row than the bound already states.
Source code in src/math_spec/sos.py
emit(raw, name)
#
Write what the set name states as declarations of raw, and drop the block.
| PARAMETER | DESCRIPTION |
|---|---|
raw
|
A model as data, mid-expansion, declaring the set and the variable it runs over. |
name
|
Which set to lower.
TYPE:
|
Source code in src/math_spec/sos.py
expand_sets(schema)
#
schema with every sos: block written out as binaries and the rows that link them.
The curves an expansion wrote out ride along, because a model whose curves are already written out is the one this is usually asked of.
Source code in src/math_spec/sos.py
section(raw, name)
#
The name section of the raw model, created empty where the file declares none.