6. Sample applications

The following sample applications give hands-on impressions on how to use casiopeia in practice. They all (and some more) are contained within the examples directory of the casiopeia sources.

6.1. Parameter estimation for a Lotka-Volterra predator-prey-model

The aim of the application lotka_volterra_pe.py is to estimate the unknown parameters of a Lotka-Volterra predator-prey-model for experimentally received measurement data and given standard deviations for the measurements [1]. The predator-prey-model is an ODE of the form \(\dot{x} = f(x,p)\), given by

\[\begin{split}\begin{aligned} \dot{x}_1 &= - \alpha x_1 + \beta x_1 x_2 \\ \dot{x}_2 &= \gamma x_2 - \delta x_1 x_2 \\ \end{aligned}\end{split}\]

where \(\alpha = 1.0\) and \(\gamma = 1.0\), the states \(x\) and parameters \(p\) are defined as

\[\begin{split}x = \begin{pmatrix} {x_1} \\ {x_2} \end{pmatrix}, ~ p = \begin{pmatrix} {\beta} \\ {\delta} \end{pmatrix},\end{split}\]

and we can measure the full state, i. e.

\[\phi = x.\]

The values resulting from the parameter estimation are

\[\begin{split}\hat{p} = \begin{pmatrix} {\hat{\beta}} \\ {\hat{\delta}} \end{pmatrix} = \begin{pmatrix} {0.693379029} \\ {0.341128482} \end{pmatrix}.\end{split}\]

The results for the system simulation using the estimated parameters in comparison to the measurement data are shown in the figure below.

_images/lv_results.png

Figure: Simulation results for the Lotka-Volterra predator-prey-model using the estimated parameters, compared to the given measurement data

6.2. Parameter estimation for a pendulum model

The aim of the application pendulum_pe.py is to estimate the spring constant \(k\) of a pendulum model for experimentally received measurement data [2]. The pendulum model is an ODE of the form \(\dot{x} = f(x,u,p)\), given by

\[\begin{split}\begin{aligned} \dot{\nu} &= \omega \\ \dot{\omega} &= \frac{k}{m L^2} (\psi - \nu) - \frac{g}{L} * \sin(\nu) \\ \end{aligned}\end{split}\]

where \(m = 1.0\), \(L = 3.0\) and \(g = 9.81\), the states \(x\), controls \(u\) and parameters \(p\) are defined as

\[\begin{split}x = \begin{pmatrix} {\nu} \\ {\omega} \end{pmatrix}, ~ u = \begin{pmatrix} {\psi} \end{pmatrix}, ~ p = \begin{pmatrix} {k} \end{pmatrix},\end{split}\]

while the only control \(\psi\) is the initial actuation angle of the pendulum, and therefor stays constant over time. Also, we can measure the full state, i. e.

\[\phi = x.\]

The value resulting from the parameter estimation is

\[\hat{p} = \begin{pmatrix} {\hat{k}}\end{pmatrix} = \begin{pmatrix} {2.99763513} \end{pmatrix}.\]

The results for the system simulation using the estimated parameter in comparison to the measurement data are shown in the figures below.

_images/pendulum_results.png

Figure: Simulation results for the pedulum model using the estimated parameters, compared to the given measurement data

6.3. Parameter estimation for a model race car

The aim of the application 2d_vehicle_pe.py is to estimate the unknown parameters of a 2D race car model for experimentally received measurement data [3]. The race car and the interpretation of the model states are shown in the figure below [4].

_images/rc.png

Figure: Depiction of the race car showing the models states

The 2D model of the race car is an ODE of the form \(\dot{x} = f(x,u,p)\), given by

\[\begin{split}\begin{aligned} \dot{X} &= v \, \text{cos}(\psi + C_{1} \delta)\\ \dot{Y} &= v \, \text{sin}(\psi + C_{1} \delta) \\ \dot{\psi} &= v \, \delta \, C_{2} \\ \dot{v} &= C_{\text{m}_{1}} \, D - C_{\text{m}_{2}} \, D \, v - C_{\text{r}_{2}} \, v^{2} - C_{\text{r}_{0}} - (v \, \delta)^{2} \, C_{2} \, C_{1}, \end{aligned}\end{split}\]

where the states \(x\), controls \(u\) and parameters \(p\) are defined as

\[\begin{split}x = \begin{pmatrix} {X} \\ {Y} \\ {\psi} \\ {v} \end{pmatrix}, ~ u = \begin{pmatrix} {\delta} \\ D \end{pmatrix}, ~ p = \begin{pmatrix} {C_{1}} \\ {C_{2}} \\ {C_{\text{m}_{1}}} \\ {C_{\text{m}_{2}}} \\ {C_{\text{r}_{2}}} \\ {C_{\text{r}_{0}}} \end{pmatrix},\end{split}\]

and we can measure the full state, i. e.

\[\phi = x.\]

The values resulting from the parameter estimation are

\[\begin{split}\hat{p} = \begin{pmatrix} {\hat{C_{1}}} \\ {\hat{C_{2}}} \\ {\hat{C_{\text{m}_{1}}}} \\ {\hat{C_{\text{m}_{2}}}} \\ {\hat{C_{\text{r}_{2}}}} \\ {\hat{C_{\text{r}_{0}}}} \end{pmatrix} = \begin{pmatrix} { 0.273408} \\ { 11.5602} \\ {2.45652} \\ {7.90959} \\ {-0.44353} \\ {-0.249098} \end{pmatrix}.\end{split}\]

The results for the system simulation using the estimated parameter in comparison to the measurement data are shown in the figures below.

_images/rc_results.png

Figure: Simulation results for the race car model using the estimated parameters, compared to the given measurement data

An evaluation of the covariance matrix for the estimated parameters shows that the standard deviations of \(\hat{C_{1}}\) and \(\hat{C_{2}}\) are relatively small in comparison to their own values, while the standard deviations of the other parameters are relatively big.

\[\begin{split}\hat{p} = \begin{pmatrix} {\hat{C_{1}}} \\ {\hat{C_{2}}} \\ {\hat{C_{\text{m}_{1}}}} \\ {\hat{C_{\text{m}_{2}}}} \\ {\hat{C_{\text{r}_{2}}}} \\ {\hat{C_{\text{r}_{0}}}} \end{pmatrix} = \begin{pmatrix} { 0.273408} \\ { 11.5602} \\ {2.45652} \\ {7.90959} \\ {-0.44353} \\ {-0.249098} \end{pmatrix} \pm \begin{pmatrix} {0.034497452} \\ {0.058569592} \\ {2.72097859} \\ {5.448817078} \\ {1.478999406} \\ {0.37343932} \end{pmatrix}\end{split}\]

This intends that the estimation results for the parameters \(\hat{C_{\text{m}_{1}}}\), \(\hat{C_{\text{m}_{2}}}\), \(\hat{C_{\text{r}_{2}}}\) and \(\hat{C_{\text{r}_{0}}}\) are probably not accurate, and might change substantially for other measurement and control data. Optimum experimental design can be an option to encounter this problem.

6.4. Optimum experimental design for a model race car

The aim of the application 2d_vehicle_doe_scaled.py is to solve an optimum experimental design problem for the 2D race car model from Parameter estimation for a model race car to obtain control values that allow for a better estimation of the unknown parameters of the model.

6.4.1. Initial setup

For this application, we assume that we are not bound to the previous race track to obtain measurements for the race car, but can drive the car on a rectangular mat of the racetrack’s material. The controls are bounded by the maximum and minimum values of the controls measurements from Parameter estimation for a model race car, as well as the states are bounded by their corresponding maximum and minimum values of the states measurements. The bounds are introduced to prevent the optimizer from creating unrealistic scenarios that could e. g. cause the race car to fall over when taking too sharp turns, which is not explicitly considered within the model.

The previous parameter estimation results \(\hat{p}\) from Parameter estimation for a model race car are used as a “guess” for the parameter values for the experimental design, and with this, to scale all parameter values within the optimization to 1.0 to prevent influences of the numerical values of the parameters on the optimization result.

A subset of the control values from the previous estimation is used as initial guesses for the optimized controls. The quality of the initial experimental setup in terms of estimated standard deviations of the unknown parameters is evaluated as follows

\[\begin{split}p_\text{I} = \begin{pmatrix} {C_{1, \text{I}}} \\ {C_{2, \text{I}}} \\ {C_{\text{m}_{1},\text{I}}} \\ {C_{\text{m}_{2},\text{I}}} \\ {C_{\text{r}_{2},\text{I}}} \\ {C_{\text{r}_{0},\text{I}}} \end{pmatrix} = \begin{pmatrix} {1.0} \\ {1.0} \\ {1.0} \\ {1.0} \\ {1.0} \\ {1.0} \end{pmatrix} \pm \begin{pmatrix} {6.1591763006} \\ {0.318683714861} \\ {92.0037213296} \\ {62.6460661875} \\ {286.556042737} \\ {108.733245939} \end{pmatrix}\end{split}\]

which indicates that the experimental setup is rather inappropriate for a sufficient estimation.

6.4.2. Optimized setup

Note

Running this optimization takes about 10 min on an Intel(R) Core(TM) i5-4570 3.20GHz CPU.

We use the A-criterion as objective for the experimental design (see Optimum experimental design). The results of the optimization can be analyzed and visualized with the script 2d_vehicle_doe_scaled_validation.py. The figure below shows the optimized control values in comparison to the initially used control values, while the suffix coll indicates that the values were obtained using collocation discretization.

_images/rc_doe_controls.png

Figure: Optimized control values in comparison to the initially used control values

The figure below shows a comparison of the simulated states values for both initially used and optimized control values, and with this, the effect of the optimization on the route of the race car and it’s velocity during the measurements.

_images/rc_doe_states.png

Figure: Comparison of the simulated states values for initial and optimized controls

The quality of the optimized experimental setup in terms of estimated standard deviations of the unknown parameters is evaluated as follows

\[\begin{split}p_\text{O} = \begin{pmatrix} {C_{1, \text{O}}} \\ {C_{2, \text{O}}} \\ {C_{\text{m}_{1},\text{O}}} \\ {C_{\text{m}_{2},\text{O}}} \\ {C_{\text{r}_{2},\text{O}}} \\ {C_{\text{r}_{0},\text{O}}} \end{pmatrix} = \begin{pmatrix} {1.0} \\ {1.0} \\ {1.0} \\ {1.0} \\ {1.0} \\ {1.0} \end{pmatrix} \pm \begin{pmatrix} {1.93054150676} \\ {0.278656552587} \\ {1.96689422255} \\ {1.51815346784} \\ {3.42713773836} \\ {1.88475684297} \end{pmatrix}\end{split}\]

which indicates that the optimized setup is more appropriate for parameter estimation compared to the initial experimental design. Though, the estimated standard deviations are still relatively big in comparison to the scaled parameter values, so it would probably make sense to further refine the experimental design.

6.4.3. Further steps

Possible strategies for further refinement of the experimental design could be to increase the duration of the experiment so that more measurements can be taken, or to loosen control and state bounds to allow for greater system excitation.

In case these strategies are not applicable (physical limitations, safety concerns or alike), designing multiple experiments within one optimization problem can be a useful approach, so that several independent experiments can focus on different aspects of the system, which allows for a structured gathering of additional information about the system that can later be used within one parameter estimation.

Both planning of such experiments and using independent measurements data sets within one parameter estimation can be realized with casiopeia as well, see Optimum experimental design of multiple experiments and Parameter estimation from multiple experiments.

References

[1]Bock, Sager et al.: Übungen zur Numerischen Mathematik II, sheet 9, IWR, Heidelberg university, 2006.
[2]Diehl, Moritz: Course on System Identification, exercise 7, SYSCOP, IMTEK, University of Freiburg, 2014/2015.
[3]Verschueren, Robin: Design and implementation of a time-optimal controller for model race cars, Master’s thesis, KU Leuven, 2014.
[4]Spengler, Patrick and Gammeter, Christoph: Modeling of 1:43 scale race cars, Master’s thesis, ETH Zürich, 2010.