math_spec.typesetting.symbols
Which symbol each declared name prints as, and the sidecar that overrides it.
This module decides which symbol a name gets; a :class:~math_spec.typesetting.format.Format decides how it is written.
SymbolTable(notation, indices=dict(), sets=dict(), names=dict())
dataclass
#
How a reader wants the model to print — notation only, kept out of the model.
Every entry is a spelling, printed verbatim. notation: says which
language they are written in, and a render in the other one refuses::
notation: latex
dimensions:
snapshot: {index: t, set: "\\mathcal{T}"}
plant: {index: n}
names:
marginal_cost: "c^{\\mathrm{marg}}"
An entry naming nothing in the model is an error naming the near miss.
| ATTRIBUTE | DESCRIPTION |
|---|---|
notation |
The language the entries are written in; :meth:
TYPE:
|
indices = field(default_factory=dict)
class-attribute
instance-attribute
#
names = field(default_factory=dict)
class-attribute
instance-attribute
#
notation
instance-attribute
#
sets = field(default_factory=dict)
class-attribute
instance-attribute
#
checked_against(program)
#
Reject entries naming nothing in program or in what its formulations state, with the near miss.
A name a piecewise: or sos: block emits counts as declared, so
one table spells both readings of a model: the blocks as the file states
them, and the rows :meth:~math_spec.model.Spec.expand writes out.
Source code in src/math_spec/typesetting/symbols.py
load(source)
classmethod
#
A table from a YAML path or the mapping it parses to.
| RAISES | DESCRIPTION |
|---|---|
SchemaError
|
An unknown section, a section or a dimension that is
not a mapping, or a |
Source code in src/math_spec/typesetting/symbols.py
Symbols(overridden, name, constraint, index, set)
dataclass
#
How every declared name prints: overrides first, derivation for the rest.
Built by :func:symbols_for. Name symbols settle before dimension
indices, so an index is kept off a single letter a variable owns — a
dimension plant beside a variable p would otherwise render
p_{t,p}. A parameter is upright, so \mathrm{p} beside an index
p is not a collision.
| ATTRIBUTE | DESCRIPTION |
|---|---|
overridden |
Names the table spelled; the convention note quotes only derived symbols. |
name |
Each parameter's, variable's and expression's symbol. |
constraint |
Each constraint's symbol, the subscript |
index |
Each dimension's index letter. |
set |
Each dimension's set symbol. |
chosen_expressions(program)
#
The named expressions the solver decides, rather than is handed.
A when does not move one: a variable there asks whether the variable
exists, which the model settles when it is built. Only a value reaching a
variable does — through another named expression too, since a use of one
stands where the name was written.
A dual moves one for the same reason a variable does: the solve settles
it, and no data hands it over.
Source code in src/math_spec/typesetting/symbols.py
symbols_for(program, fmt, table)
#
The :class:Symbols program prints with in fmt, table overriding the derivation.
| RAISES | DESCRIPTION |
|---|---|
SchemaError
|
If table is written in a notation fmt does not read. |