5. Optimum experimental design

The module casiopeia.doe contains the classes used for optimum experimental design.

5.1. Optimum experimental design of single experiments

class casiopeia.doe.DoE(system, time_points, uinit=None, umin=None, umax=None, qinit=None, qmin=None, qmax=None, pdata=None, x0=None, xmin=None, xmax=None, wv=None, weps_u=None, discretization_method='collocation', optimality_criterion='A', **kwargs)[source]

The class casiopeia.doe.DoE is used to set up Design-of-Experiments-problems for systems defined with the casiopeia.system.System class.

The aim of the experimental design optimization is to identify a set of controls that can be used for the generation of measurement data which allows for a better estimation of the unknown parameters of a system.

To achieve this, an information function on the covariance matrix of the estimated parameters is minimized. The values of the estimated parameters, though they are mostly an initial guess for their values, are not changed during the optimization.

Optimum experimental design and parameter estimation methods can be used interchangeably until a desired accuracy of the parameters has been achieved.

Raises:

AttributeError, NotImplementedError

Parameters:
  • system (casiopeia.system.System) – system considered for parameter estimation, specified using the casiopeia.system.System class
  • time_points (numpy.ndarray, casadi.DMatrix, list) – time points \(t_\text{N} \in \mathbb{R}^\text{N}\) used to discretize the continuous time problem. Controls will be applied at the first \(N-1\) time points, while measurements take place at all \(N\) time points.
  • umin (numpy.ndarray, casadi.DMatrix) – optional, lower bounds of the time-varying controls \(u_\text{min} \in \mathbb{R}^{\text{n}_\text{u}}\); if not values are given, \(-\infty\) will be used
  • umax (numpy.ndarray, casadi.DMatrix) – optional, upper bounds of the time-vaying controls \(u_\text{max} \in \mathbb{R}^{\text{n}_\text{u}}\); if not values are given, \(\infty\) will be used
  • uinit (numpy.ndarray, casadi.DMatrix) – optional, initial guess for the values of the time-varying controls \(u_\text{N} \in \mathbb{R}^{\text{n}_\text{u} \times \text{N}-1}\) that (might) change at the switching time points; if no values are given, 0 will be used; note that a poorly or wrongly chosen initial guess can cause the optimization to fail, and note that the the second dimension of \(u_N\) is \(N-1\) and not \(N\), since there is no control value applied at the last time point
  • qmin (numpy.ndarray, casadi.DMatrix) – optional, lower bounds of the time-constant controls \(q_\text{min} \in \mathbb{R}^{\text{n}_\text{q}}\); if not values are given, \(-\infty\) will be used
  • qmax (numpy.ndarray, casadi.DMatrix) – optional, upper bounds of the time-constant controls \(q_\text{max} \in \mathbb{R}^{\text{n}_\text{q}}\); if not values are given, \(\infty\) will be used
  • qinit (numpy.ndarray, casadi.DMatrix) – optional, initial guess for the optimal values of the time-constant controls \(q_\text{init} \in \mathbb{R}^{\text{n}_\text{q}}\); if not values are given, 0 will be used; note that a poorly or wrongly chosen initial guess can cause the optimization to fail
  • pdata (numpy.ndarray, casadi.DMatrix) – values of the time-constant parameters \(p \in \mathbb{R}^{\text{n}_\text{p}}\)
  • x0 (numpy.ndarray, casadi.DMatrix, list) – state values \(x_0 \in \mathbb{R}^{\text{n}_\text{x}}\) at the first time point \(t_0\)
  • xmin (numpy.ndarray, casadi.DMatrix) – optional, lower bounds of the states \(x_\text{min} \in \mathbb{R}^{\text{n}_\text{x}}\); if no value is given, \(-\infty\) will be used
  • xmax (numpy.ndarray, casadi.DMatrix) – optional, lower bounds of the states \(x_\text{max} \in \mathbb{R}^{\text{n}_\text{x}}\); if no value is given, \(\infty\) will be used
  • wv (numpy.ndarray, casadi.DMatrix) – weightings for the measurements \(w_\text{v} \in \mathbb{R}^{\text{n}_\text{y} \times \text{N}}\)
  • weps_u (numpy.ndarray, casadi.DMatrix) – weightings for the input errors \(w_{\epsilon_\text{u}} \in \mathbb{R}^{\text{n}_{\epsilon_\text{u}}}\) (only necessary if input errors are used within system)
  • discretization_method (str) – optional, the method that shall be used for discretization of the continuous time problem w. r. t. the time points given in \(t_\text{N}\); possible values are “collocation” (default) and “multiple_shooting”
  • optimality_criterion (str) –

    optional, the information function \(I_\text{X}(\cdot)\) to be used on the covariance matrix, possible values are A (default) and D, while

    \[\begin{split}\begin{aligned} I_\text{A}(\Sigma_\text{p}) & = \frac{1}{n_\text{p}} \text{Tr}(\Sigma_\text{p}),\\ I_\text{D}(\Sigma_\text{p}) & = \begin{vmatrix} \Sigma_\text{p} \end{vmatrix} ^{\frac{1}{n_\text{p}}}, \end{aligned}\end{split}\]

    for further information see e. g. [1]

Depending on the discretization method specified in discretization_method, the following parameters can be used for further specification:

Parameters:
  • collocation_scheme (str) – optional, scheme used for setting up the collocation polynomials, possible values are radau (default) and legendre
  • number_of_collocation_points (int) – optional, order of collocation polynomials \(d \in \mathbb{Z}\) (default values is 3)
  • integrator (str) – optional, integrator to be used with multiple shooting. See the CasADi documentation for a list of all available integrators. As a default, cvodes is used.
  • integrator_options (dict) – optional, options to be passed to the CasADi integrator used with multiple shooting (see the CasADi documentation for a list of all possible options)

You do not need to specify initial guesses for the estimated states, since these are obtained with a system simulation using the initial states and the provided initial guesses for the controls.

The resulting optimization problem has the following form:

\[\begin{split}\begin{aligned} \text{arg}\,\underset{u, q, x}{\text{min}} & & I(\Sigma_{\text{p}}(x, u, q; p)) &\\ \text{subject to:} & & g(x, u, q; p) & = 0\\ & & u_\text{min} \leq u_\text{k} & \leq u_\text{max} \hspace{1cm} k = 1, \dots, N-1\\ & & x_\text{min} \leq x_\text{k} & \leq x_\text{max} \hspace{1cm} k = 1, \dots, N\\ & & x_1 \leq x(t_1) & \leq x_1 \end{aligned}\end{split}\]

where \(\Sigma_p = \text{Cov}(p)\) and \(g(\cdot)\) contains the discretized system dynamics according to the specified discretization method. If the system is non-dynamic, it only contains the user-provided equality constraints.

References

[1]Körkel, Stefan: Numerische Methoden für Optimale Versuchsplanungsprobleme bei nichtlinearen DAE-Modellen, PhD Thesis, Heidelberg university, 2002, pages 74/75.
plot_confidence_ellipsoids(properties='initial')[source]
Parameters:properties (str) – Set whether the experimental properties for the initial setup (“initial”, default), the optimized setup (“optimized”) or for both setups (“all”) shall be plotted. In the later case, both ellipsoids for one pair of parameters will be displayed within one plot.

Plot confidence ellipsoids for all parameter pairs. Since the number of plots is possibly big, all plots will be saved within a folder confidence_ellipsoids_scriptname in you current working directory rather than being displayed directly.

5.2. Optimum experimental design of multiple experiments

class casiopeia.doe.MultiDoE(doe_setups=[], optimality_criterion='A')[source]

The class casiopeia.doe.MultiDoE is used to construct a single experimental design problem from multiple experimental design problems defined via two or more objects of type casiopeia.doe.DoE.

This provides the possibility to design multiple experiments within one single optimization, so that the several experiments can focus on different aspects of the system which in combination then yields more information about the complete system.

Also, this functionality is in particular useful in case an experiment is limited to only small variable bounds, small time horizons, highly depends on the initialization of the system, or any other case when a single experiment might not be enough to capture enough information about a system.

Note

It is assumed that the system description used for setting up the several experimental design problems is the same!

Parameters:doe_setups (list) – list of two or more objects of type casiopeia.doe.DoE