Skip to content

Background and history#

The specification of an optimisation model (a spec) takes its shape from development efforts in the Calliope energy system framework. The language of a spec has evolved considerably since porting to the framework-agnostic mathspec project. This evolution has moved the math further out of code and into a file that any piece of software (a tool) can read.

From Calliope to mathspec A timeline in four rows, one per project: Calliope, specsolve, mathspec and fluxopt. The time axis shows one step per year from 2020 to 2025, then one step per month in 2026. In the Calliope row: in August 2020, discussions on YAML math begin; in May 2021, the goal is set to state every constraint in YAML; in February 2023, the parser lands; in 2023, users can replace the math with their own file, the math documentation is generated and a schema validates the math files; in January 2024, 0.7.0.dev2 ships with all of its math in YAML; from 2024 to 2026, Calliope adds piecewise constraints, solver engines, dispatch and MGA math, and post-solve expressions; in September 2026, Calliope 0.7.0 is released. In March 2026, specsolve starts as lpspec, with a language that keeps Calliope's shape. In August 2026, the language and the typesetter are extracted from specsolve into mathspec, and the PyPSA math is written as a spec. In September 2026, mathspec 0.1.0 is on PyPI, specsolve depends on it, the Calliope math is ported to a spec, and fluxopt math is written as a spec. Calliope specsolve mathspec fluxopt First YAML math prototypes goal: all math in YAML First math parser user math, generated docs, schema 0.7.0.dev2 v0.7.0 released depends on mathspec 0.1.0 PyPSA math as a spec v0.1.0 released Calliope math as a spec math written as a spec ported math extracted math extracted 2020 2021 2022 2023 2024 2025 Jan Feb Mar Apr May Jun Jul Aug Sep Oct 2026

The problem#

In many open-source energy system modelling frameworks, the math lives in the source code as calls to a library such as Pyomo or linopy. A reader who wants the equations has to read that code or hand-written duplications of that math. A user cannot add a constraint without writing code and the documentation and the code can easily drift apart. A constraint can also only be validated by building a model with data.

Calliope set out to solve all four problems by moving the math into a human-readable YAML file. mathspec has continued that mission and has gone beyond what was achieved in Calliope, introducing even more features to make it easier to write and validate your math.

Note

Some modelling frameworks use algebraic modelling languages instead, which are programming languages built especially for writing out the math of an optimisation problem (e.g. AMPL or GAMS). While their syntax is close to the math, they don't offer the flexibility of more popular programming languages such as Python or Julia. Those which have widespread usage are also proprietary; few viable open-source alternatives exist.

Initial development record#

When What Source
2020-08 Calliope maintainers begin discussions on YAML math formulations. #100
2021-05 @sjpfenninger sets the goal: every constraint in YAML, and the math documentation generated from it. #360, #361
2023-02 @brynpickering's parser lands, with foreach and the equation grammar. where is a string parsed with the parsing library pyparsing, and constraints are built from constraints.yaml on the labelled-array library xarray. PR #397, #408, #411
2023 A user can replace the built-in math with their own file. The documentation of the math is generated from a built model. A schema validates the math files. PR #414, #442, #454
2024-01 The syntax is documented, and 0.7.0.dev2 is the first published release with all of its math in YAML. PR #456, 0.7.0.dev2
2024 - 2026 Calliope adds piecewise constraints, direct Gurobi and HiGHS solver engines, dispatch and MGA math, and post-solve expressions. PR #551, #569, #716, #839
2026-03 @FBumann creates lpspec (later specsolve): declarative linear and mixed-integer linear programs (LP and MILP) on a streaming relational query library. Its math language develops from a port of Calliope's. specsolve, PR #336
2026-08 The language and the typesetter are extracted from specsolve into a repository of their own. specsolve becomes one engine among many. PR #17
2026-08 The PyPSA math is written as a spec to prove its viability. PR #134 to #143
2026-09 Calliope 0.7.0 is released, its first stable release with YAML math; the Calliope math is rewritten as a spec to prove its viability. 0.7.0, PR #770
2026-09 The first post-alpha release of mathspec is published on the Python Package Index; specsolve depends on mathspec 0.1.0 and fluxopt math is written as a spec. 0.1.0, specsolve #1754, fluxopt #358

People and organisations#

Calliope is developed in the calliope-project organisation by those listed in its AUTHORS file. specsolve is developed by @FBumann in the fluxopt organisation. mathspec is developed in the framework-agnostic energy-models organisation (contributors).

Bryn Pickering
Bryn Pickering

💻 📖 🤔 📆 🚧 👀 🚇
Felix Bumann
Felix Bumann

💻 📖 ⚠️ 🚇 🚧 🤔 👀
Fabian Hofmann
Fabian Hofmann

💻 📖 🐛 🤔 👀 🚧
Jonas Hörsch
Jonas Hörsch

💻 🤔 👀
Stefan Pfenninger-Lee
Stefan Pfenninger-Lee

🤔 👀
Ivan Ruiz Manuel
Ivan Ruiz Manuel

🤔 👀
Tim Tröndle
Tim Tröndle

🤔
Jann Launer
Jann Launer

🤔 🐛
Francesco Lombardi
Francesco Lombardi

🐛
James Morris
James Morris

🐛
Stefan Strömer
Stefan Strömer

🐛
Alexander de Tomás Pascual
Alexander de Tomás Pascual

🐛

See also

  • versions, for how the package version and the language version relate
  • how mathspec works, for what mathspec does with a spec today