math_spec.piecewise
Expand piecewise: blocks into plain variables and constraints.
A block becomes ordinary affine declarations before anything reads the model,
under names prefixed with the block's own; what each method emits is tabled in
docs/reference/language/piecewise.md. Every rule a block is held to is
decided at load, before this runs: the names it references in
:class:~math_spec.model.Spec, its links where every expression is typed, and
its frame in :func:curve_frame.
Emitted(name, lam, convexity, set, chord, domain_lo, domain_hi, links, assumptions)
dataclass
#
Every name one block's expansion may write, spelled once for the emitter and the collision check.
The set a block states writes names of its own, and they are reserved whichever method the block declares: which of the two write them is the method's business, and a collision is the file's either way.
assumptions
instance-attribute
#
by_kind
property
#
Each name by the kind of declaration it would collide with.
chord
instance-attribute
#
convexity
instance-attribute
#
domain_hi
instance-attribute
#
domain_lo
instance-attribute
#
lam
instance-attribute
#
links
instance-attribute
#
name
instance-attribute
#
set
instance-attribute
#
of(name, pw)
classmethod
#
The names block name writes.
Source code in src/math_spec/piecewise.py
assumptions_of(block, pw)
#
What block assumes of its numbers, by the name the document prints and a refusal quotes.
Every curve assumes its breakpoints are there: a missing parameter row is
not absence, it is a zero, so an undeclared breakpoint sits the curve on
the origin rather than shortening it. A curve has an x-axis only where two
links tie it, so the increasing condition — and the shape it is checked
with — exist only there; lp alone needs a segment to state a line for;
a mask must be one run.
Read off the block rather than off an expansion, so a model states what it
assumes whether or not its curves have been written out. Each condition is
an assumptions: entry over the parameters the file declared, its
description naming the method and the rewrite that takes a curve of any
shape: the expansion writes them into the model, and a model that still
declares the block resolves the same entries at load.
Source code in src/math_spec/piecewise.py
curve_frame(schema, name, pw, links)
#
The dimensions block name builds one curve per coordinate of: every one its links and its gate carry.
In declaration order, because iterating a set would vary the emitted
dims — and every column index behind it — per process. links are the
block's link expressions typed, as
:attr:~math_spec.resolution.Resolved.piecewise holds them.
| RAISES | DESCRIPTION |
|---|---|
DimensionError
|
A link or the gate carries the breakpoint dimension, or
a values or |
Source code in src/math_spec/piecewise.py
declaration_of(pw)
#
The curve of one expanded block, as a program carries it.
Source code in src/math_spec/piecewise.py
expand_piecewise(schema)
#
schema with every piecewise: block written out — schema itself where it declares none.
A method: adjacency block states its restriction as the set
method: sos2 states, and then that set is written out here too: the
binaries are what the method is, so the model that comes back carries no
set of its own (:func:math_spec.sos.emit is where they are spelled).