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. A link expression is judged before
expansion, so a refusal names the link the file wrote rather than an emitted
constraint.
Assumed
#
Bases: NamedTuple
One condition a method puts on the numbers, as the language writes it.
holds and where are where strings, resolved like any the file
wrote. description is the sentence a refusal quotes, which names the
method and the rewrite that takes a curve of any shape.
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
a where string over the parameters the file declared: the expansion writes
them into assumptions:, and a model that still declares the block
derives the same text at load.
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).
| RAISES | DESCRIPTION |
|---|---|
PiecewiseExpansionError
|
A block naming something that does not exist, or emitting a name the file already declares. |