Event Support for Simulation and Sensitivity Analysis in CasADi for use with Modelica and FMI
DOI:
https://doi.org/10.3384/ecp20799Keywords:
hybrid DAEs, sensitivity analysis, CasADi, Modelica, FMIAbstract
CasADi is an open-source framework that can be used to efficiently solve optimization problems involving user-defined ODE/DAE models. Supported solution methods include so-called shooting methods, where solvers for initial-value problems in ODEs or DAEs are referenced inside nonlinear programming (NLP) formulations. In order to solve such NLP formulations with gradient-based algorithms, CasADi implements a fully automatic sensitivity analysis. This analysis includes forward sensitivity analysis, adjoint sensitivity analysis as well as the calculation of higher-order sensitivities for the ODE/DAE models. Because of the variational (differentiate-then-integrate) approach used, the numerical solution can be performed with variable-step size, variable-order integrators such as those from the SUNDIALS suite.
In this work, we present a generalization of the sensitivity analysis support in CasADi to systems with events, as are common in real-world cyber-physical models. In particular, the event extension enables us to formulate and solve optimization problems with such event systems, without a priori knowledge of the number and ordering of events. Ultimately, we expect the proposed approach to be compatible with general cyber-physical models formulated in Modelica or available as model-exchange FMUs.
We demonstrate the proposed approach for two proof-of-concept examples; the classical bouncing ball written in CasADi directly and a simple hybrid DAE describing a breaking spring formulated in Modelica and imported symbolically into CasADi. In the examples, we show that the forward sensitivities calculated to high precision using the proposed approach are consistent with a cruder finite-difference approximation and provide an example of how they can be embedded into optimization formulations. We discuss how the approach can be extended to handle standard FMUs, adhering to FMI 2 or FMI 3, as well as non-trivial Modelica models imported via a symbolic interface based on the emerging Base Modelica standard.
Downloads
Published
Issue
Section
License
Copyright (c) 2024 Joel Andersson, James Goppert
This work is licensed under a Creative Commons Attribution 4.0 International License.