← All projects

math-spec

Optimization models as YAML files — checked and typeset as math without data or a solver.

  • python
  • optimization
  • yaml
  • latex
  • energy
2026
energy-models/math-spec Optimization models as YAML files — checked and typeset as math without data or a solver.

math-spec is a small language for writing linear and mixed-integer optimization models as YAML. A file declares the dimensions a model runs over, the data it expects, the variables, and the constraints — something like sum(dispatch, over=generator) == load.

It builds nothing and solves nothing itself. It reads the file, checks everything that can be checked without data, and hands a checked syntax tree to whatever comes next: an engine that builds and solves the model, or a typesetter that prints it as LaTeX, Typst, or Markdown. Because every tool reads the same tree, the equations you publish are the ones you solve.

Misspelled names, mismatched dimensions, or a where filter on an undeclared parameter all fail when the file loads, with an error that names the fix. That means a whole repository of models can be checked in CI with no data at all.

It started as the language layer inside lpspec. I moved it into its own package under the energy-models organization so that other energy modeling tools can share it without depending on my engine. It’s early alpha. I’m the main author.