This is MOO: Modelica / Model Optimizer v.0.1.0, a flexible and extensible framework for solving optimization problems. MOO provides a generic Nonlinear Programming (NLP) layer with built-in scaling support and a generic NLP solver interface. While primarily designed for dynamic optimization in the Modelica ecosystem (General Dynamic Optimization Problems, training of Physics-enhanced Neural ODEs), it is equally applicable to other domains, e.g. model predictive control (MPC).
Clone with submodules:
git clone --recurse-submodules git@github.com:AMIT-HSBI/MOO.gitMOO uses CMake to compile.
Install with your favorite package manager
-
C Compiler
-
C++ Compiler
-
Fortran Compiler
-
LAPACK
- Debian / Ubuntu:
apt install liblapack-dev - Latest OpenBLAS build from source: add
-DUSE_SYSTEM_LAPACK=OFF -DDOWNLOAD_LAPACK=ONto the CMake configure command
- Debian / Ubuntu:
-
- Set environment variable
SIMPLE_DAE_FMUpointing tofmi-ls-dae-sandbox/Dymola/SimpleDAE.fmu.
- Set environment variable
-
METIS
- Debian / Ubuntu
apt install libmetis-dev - if METIS is not available: add
-DMUMPS_HAS_METIS=OFFto the CMake configure command
- Debian / Ubuntu
-
HSL
- add
-DIPOPT_HAS_HSLto the CMake configure command (package should be found via PkgConfig)
- add
cmake -S . -B build -DCMAKE_INSTALL_PREFIX=installPossible configuration arguments:
MOO_WITH_RADAU: Build with RADAU fortran code to perform simulations (default:ON)MOO_WITH_GDOPT: Build with GDOPT interface (default:ON, WIP)MOO_WITH_C_INTERFACE: Build MOO with the generic C interface (default:ON, WIP)
cmake --build build --parallel <Nr. of cores> --target allAdd -DMOO_TESTS=ON to the CMake configure command.
After building run the tests:
cmake --build build --target testUse act to test the GitHub workflows locally:
act -P ubuntu-latest=catthehacker/ubuntu:full-latest --artifact-server-path $PWD/.artifactsThe most generic problem directly implemented in MOO is a General Dynamic Optimization Problem (GDOP) with free control variables
If the problem is given on a fixed time horizon
In this version, the user is also allowed to use the provided time variable
GDOPs are transcribed to a finite-dimensional NLP by direct collocation. MOO uses flipped Legendre-Gauss-Radau collocation, where the continuous state and control trajectories are represented at each collocation node, while static parameters and optional free times are represented once globally. The resulting NLP contains the collocated dynamics, path constraints, boundary constraints, variable bounds and the discretized Mayer/Lagrange objective.
The user-facing problem is implemented as a GDOP::Problem class. It provides
the dimensions, bounds, initial guesses and callback functions for objective
terms, dynamics, path constraints, boundary constraints and their derivatives.
MOO then assembles the sparse NLP structure, applies scaling, maps solver
variables back to trajectories and exposes the final primal-dual trajectory,
i.e. primal optimal solution / states, controls and parameters as well as
continuous duals / costate estimations after optimization.
One central capability of the GDOP is the pluggable strategy concept. Users can use the
default strategies or provide custom ones, for example for
initialization or adaptive mesh refinement; see src/nlp/instances/gdop/strategies.h and
src/nlp/instances/gdop/strategies.cpp. These strategies are coordinated by
the GDOP orchestrator in src/nlp/instances/gdop/orchestrator.cpp, allowing
solver workflows to be extended without changing the continuous problem
definition. Adaptive mesh refinement for this collocation-based workflow is
discussed in "Enhancing Collocation-Based Dynamic Optimization through Adaptive
Mesh Refinement", Linus Langenkamp and Bernhard Bachmann, 16th International
Modelica & FMI Conference, 2025, DOI: 10.3384/ecp218127.
More detailed API documentation for implementing GDOPs is in
reference/gdop.md.
MOO also provides an Init NLP instance for consistent initialization of
differential-algebraic equation systems. The problem starts from an initial
state and parameter guess (y, p0) and solves for state values y and
parameter corrections, with callbacks evaluated at the corrected parameters
defined below:
The objective can be user-defined, zero for pure feasibility, or the built-in least-squares parameter correction
This makes initialization usable both as a standard feasibility problem and as a parameter-correction problem when the original DAE initialization is inconsistent.
The implementation lives in src/nlp/instances/init/. Small objective and
Hessian checks are in test/init/, and test/init/init_benchmark.cpp contains
a scalable synthetic chemical-equilibrium initialization benchmark.
More detailed API documentation for implementing Init is in
reference/init.md.
The Modelica/Model Optimizer (MOO) is distributed under the GNU Lesser General Public License (LGPL) Version 3. See the full license text for detailed terms and conditions: LGPL-3.0