MOSOX: a fast model-to-matrix compiler for linear and mixed-integer optimisation

12 July 2026, Version 1

Abstract

Linear and mixed-integer optimisation models are widely used across economics and engineering to study resource allocation, infrastructure planning, and energy-system transitions. Algebraic modelling languages such as GNU MathProg (GMPL), AMPL, and GAMS let researchers write these models close to their mathematical form, keeping them transparent and reviewable even without extensive coding experience. However, as models grow in scale, translating algebraic formulations into solver-ready sparse matrices becomes a major computational bottleneck. This paper introduces MOSOX, a Rust-based command-line tool and library that compiles a targeted subset of GMPL model and data files into sparse matrices, covering the constructs required by the OSeMOSYS energy-system model family. It expands sets, parameters, variables, objectives, and constraints into matrices, exports them in standard MPS format, and can solve models directly via the HiGHS solver. On OSeMOSYS benchmarks, MOSOX compiles matrices up to 6.5 times faster than GLPK's glpsol while also reducing peak memory use on the largest tested model. By combining fast, low-memory compilation with the readability of GMPL and solver-independent output, MOSOX - developed within the Climate Compatible Growth Program - supports reproducible, auditable, and automatable optimisation workflows for large-scale energy-system modelling.

Keywords

optimisation
linear programming
mixed-integer programming
GNU MathProg
GMPL
OSeMOSYS
energy systems modelling
Rust
open-source software
reproducibility

Supplementary weblinks

Comments

Comments are not moderated before they are posted, but they can be removed by the site moderators if they are found to be in contravention of our Commenting and Discussion Policy [opens in a new tab] - please read this policy before you post. Comments should be used for scholarly discussion of the content in question. You can find more information about how to use the commenting feature here [opens in a new tab] .
This site is protected by reCAPTCHA and the Google Privacy Policy [opens in a new tab] and Terms of Service [opens in a new tab] apply.