#include <Prg_SFunctionEst.h>


The estimation problem is formulated at the discrete time points
with
a number of experiments. The data of all experiments is concatenated into combined vectors of time points, model inputs, and reference outputs, i.e.
. In order to distinguish multiple experiments, it is assumed that
; for instance each experiment could start with
. Parameter values are constrained to be the same for all experiments, whereas initial states are individual for each experiment. Note that this is not a restriction as generally states can be initialized with parameters and as parameters can be modeled as constant states.
In the following all vector operations are defined element wise. The treated estimation problem reads
subject to the model given with the S-function methods mdlDerivatives
and mdlOutputs
with piecewise constant or linear interpolation of the inputs
and subject to the constraints
The problem is treated as multistage problem with
stages and one sample period per stage per default (multistage=1 or multistage=2). Discrete-time state variables with unknown initial value are introduced for the estimated parameters p, in order to preserve a sparse structure. Additional
junction conditions (equality constraints) are introduced for the estimated parameters and
junction conditions are introduced for the state variables x. Alternatively the problem can be treated without stages hiding model states from the optimizer (multistage=0).
The states of all stages are either initialized with the initial states
or with individually given initial guesses
All but the initial states of the experiments may be initialized with the results of an initial-value simulation for given initial states and inputs (multistage=0 or multistage=1). With multistage=2, individual initial states are used for each stage, resulting in the multiple shooting method. This might be useful if no sensible initial guesses can be given for unknown parameters, so that a simulation fails.
states and inputs. If the problem is treated as multistage problem, then not performing the simulation results in the multiple shooting method. This might be useful if no sensible initial guesses can be given for unknown parameters, so that a simulation fails.
Model inputs, states and outputs can be accessed through
In addition to the estimated parameters and initial states, the measurement matrix M is calculated in each optimization iteration. It is defined as
with the sub-matrices
Note that the sub-matrices for estimated initial states of all experiments are stored in compressed form in one column, even though individual initial states are being estimated for each experiment.
Some simple quality measures are directly calculated in order to support a first interpretation of estimation results. These are the precision matrix
and the covariance matrix
assuming that the residual variance
is equal to the measurement variance. Last but not least confidence intervals for estimated parameters and initial states
are obtained applying the t-Test:
Public Member Functions | |
| Prg_SFunctionEst () | |
| constructor | |
| ~Prg_SFunctionEst () | |
| destructor | |
| char * | name () |
| name SFunctionEst | |
Access methods for program specific members (If prefix: prg_) | |
| int | nex () const |
| number of experiments used for estimation | |
| void | set_nex (int val) |
| set number of experiments | |
| int | multistage () const |
| indicate if problem is treated with one stage per time interval | |
| void | set_multistage (int val) |
| set multistage flag | |
| const MATP | ys_ref () const |
| reference values for active model outputs (size: KK+1 . ny) | |
| void | set_ys_ref (const MATP val) |
| set reference outputs | |
| const MATP | M () const |
| measurement matrix M=dy/d(p,x0) (size: (KK+1)*ny . np+nx0) | |
| const MATP | P () const |
| precision matrix P=(M^TM)^(-1) (size: np+nx0 . np+nx0) | |
| const MATP | COV () const |
| covariance matrix (size: np+nx0 . np+nx0) | |
Read methods for model specific members (no If prefix). | |
Note that the prefix mdl_ is omitted in the detailed mathematical problem description. | |
| const VECP | mdl_p () const |
| model parameters | |
| const VECP | mdl_p_min () const |
| lower bounds for model parameters (note: default is 0) | |
| const VECP | mdl_p_max () const |
| upper bounds for model parameters | |
| const IVECP | mdl_p_active () const |
| indicate estimated parameters | |
| const VECP | mdl_p_confidence () const |
| confidence intervals of estimated parameters | |
| const VECP | mdl_p_nominal () const |
| nominal parameter values (for scaling) | |
| const VECP | mdl_x0 () const |
| model initial states (read only, note: write initial states of experiments via mdl_x0s) | |
| const VECP | mdl_x0_min () const |
| lower bounds for initial states | |
| const VECP | mdl_x0_max () const |
| upper bounds for initial states | |
| const IVECP | mdl_x0_active () const |
| indicate estimated initial states | |
| const VECP | mdl_x0_confidence () const |
| confidence intervals of estimated initial states, averaged over multiple experiments | |
| const VECP | mdl_der_x0_min () const |
| minimum for time derivative of x0 | |
| const VECP | mdl_der_x0_max () const |
| maximum for time derivative of x0 | |
| const VECP | mdl_x_nominal () const |
| nominal state values (for scaling) | |
| const IVECP | mdl_u_order () const |
| const VECP | mdl_x_min () const |
| lower bounds on states at stage boundaries (default: -Inf) | |
| const VECP | mdl_x_max () const |
| upper bounds on states at stage boundaries (default: Inf) | |
| const IVECP | mdl_y_active () const |
| indicate measured outputs | |
| const VECP | mdl_y_nominal () const |
| nominal output values (for scaling) | |
| const MATP | mdl_x0s () const |
| initial states for each experiment (size: nex . mdl_nx) | |
| const MATP | mdl_us () const |
| model inputs (size: KK+1 . mdl_nu) | |
| const MATP | mdl_xs () const |
| model states (size: KK+1 . mdl_nx) | |
| const MATP | mdl_ys () const |
| model outputs (read only, size: KK+1 . mdl_ny) | |
Write methods for model specific members (no If prefix). | |
| void | set_mdl_p (const VECP v) |
| set values of model parameter | |
| void | set_mdl_p_min (const VECP v) |
| set lower bounds for model parameters | |
| void | set_mdl_p_max (const VECP v) |
| set upper bounds for model parameters | |
| void | set_mdl_p_active (const IVECP v) |
| set estimated parameters | |
| void | set_mdl_p_nominal (const VECP v) |
| set nominal parameters | |
| void | set_mdl_x0_min (const VECP v) |
| set lower bounds for initial states | |
| void | set_mdl_x0_max (const VECP v) |
| set upper bounds for initial states | |
| void | set_mdl_x0_active (const IVECP v) |
| set estimated initial states | |
| void | set_mdl_der_x0_min (const VECP v) |
| set minimum for dx0dt | |
| void | set_mdl_der_x0_max (const VECP v) |
| set maximum for dx0dt | |
| void | set_mdl_x_nominal (const VECP v) |
| set nominal states | |
| void | set_mdl_u_order (const IVECP v) |
| set interpolation order for inputs | |
| void | set_mdl_x_min (const VECP v) |
| set lower bounds on states | |
| void | set_mdl_x_max (const VECP v) |
| set upper bounds on states | |
| void | set_mdl_y_active (const IVECP v) |
| set measured outputs | |
| void | set_mdl_y_nominal (const VECP v) |
| set nominal outputs | |
| void | set_mdl_x0s (const MATP v) |
| set initial states | |
| void | set_mdl_us (const MATP v) |
| set model inputs | |
| void | set_mdl_xs (const MATP v) |
| set model states | |
Protected Member Functions | |
| void | write_active_mx_args (VECP p) |
| write active parameters that are packed in p to _mx_args | |
Implementation of predefined methods. | |
| void | setup_model () |
| load S-function | |
| void | setup_stages (IVECP ks, VECP ts) |
| Setup stages and time sampling. | |
| void | setup (int k, Omu_VariableVec &x, Omu_VariableVec &u, Omu_VariableVec &c) |
| Allocate states x, control parameters u, and constraints c for stage k. | |
| void | setup_struct (int k, const Omu_VariableVec &x, const Omu_VariableVec &u, Omu_DependentVec &xt, Omu_DependentVec &F, Omu_DependentVec &f, Omu_Dependent &f0, Omu_DependentVec &c) |
| void | init_simulation (int k, Omu_VariableVec &x, Omu_VariableVec &u) |
| Initialize problem variables using simulation. | |
| void | update (int kk, const Omu_StateVec &x, const Omu_Vec &u, const Omu_StateVec &xf, Omu_DependentVec &f, Omu_Dependent &f0, Omu_DependentVec &c) |
| void | consistic (int kk, double t, const Omu_StateVec &x, const Omu_Vec &u, Omu_DependentVec &xt) |
| void | continuous (int kk, double t, const Omu_StateVec &x, const Omu_Vec &u, const Omu_StateVec &dx, Omu_DependentVec &F) |
Protected Attributes | |
| Omu_VariableVec | _mdl_p |
| model parameters (note: default min is 0) | |
| Omu_VariableVec | _mdl_x0 |
| initial states | |
| Omu_VariableVec | _mdl_x |
| state bounds | |
| IVECP | _mdl_p_active |
| indicate estimated parameters | |
| VECP | _mdl_p_confidence |
| confidence intervals for est parameters | |
| IVECP | _mdl_x0_active |
| indicate estimated states | |
| VECP | _mdl_x0_confidence |
| confidence intervals for est x0 | |
| VECP | _mdl_der_x0_min |
| minimum for time derivative of x0 | |
| VECP | _mdl_der_x0_max |
| maximum for time derivative of x0 | |
| IVECP | _mdl_u_order |
| interpolation order (default: 1 (linear)) | |
| IVECP | _mdl_y_active |
| indicate measured outputs | |
| VECP | _mdl_p_nominal |
| nominal parameter values (for scaling) | |
| VECP | _mdl_x_nominal |
| nominal state values (for scaling) | |
| VECP | _mdl_y_nominal |
| nominal output values (for scaling) | |
| int | _nx |
| number of states for optimizer | |
| int | _np |
| number of estimated parameters | |
| int | _nx0 |
| number of estimated initial states | |
| int | _ny |
| number of reference outputs for estimation | |
| int | _multistage |
| treat as multistage problem | |
| int | _nex |
| number of experiments used for estimation | |
| MATP | _mdl_x0s |
| initial states for each experiment | |
| IVECP | _exs |
| index identifying experiment in estimation data | |
| MATP | _mdl_us |
| given model inputs | |
| MATP | _mdl_xs |
| calculated model states | |
| MATP | _mdl_ys |
| calculated model outputs | |
| MATP | _ys_ref |
| reference values for active outputs | |
| double | _ssr |
| sum of squared output residuals | |
| MATP | _M2 |
| measurement matrix M=dy/d(p,x0) | |
| MATP | _P2 |
| precision matrix P=(M^TM)^(-1) | |
| MATP | _COV |
| covariance matrix COV= | |
| MATP | _dydx |
| help variable dy/dx | |
| MATP | _dxdpx0 |
| help variable dx/d(p,x0) | |
| MATP | _dydpx0 |
| help variable dy/d(p,x0) | |
| MATP | _dxfdx |
| help variable dxf/dx | |
| MATP | _dxfdpx0 |
| help variable dxf/d(p,x0) | |
Setup stages and time sampling.
The default implementation sets up an optimization problem without stages.
Reimplemented from Omu_Program.
| void Prg_SFunctionEst::setup | ( | int | k, | |
| Omu_VariableVec & | x, | |||
| Omu_VariableVec & | u, | |||
| Omu_VariableVec & | c | |||
| ) | [protected, virtual] |
Allocate states x, control parameters u, and constraints c for stage k.
Additionally setup bounds and initial values.
Implements Omu_Program.
| void Prg_SFunctionEst::init_simulation | ( | int | k, | |
| Omu_VariableVec & | x, | |||
| Omu_VariableVec & | u | |||
| ) | [protected, virtual] |
Initialize problem variables using simulation.
A problem specification may set state variables x and/or control parameters u prior to the evaluation of stage k. The default version causes an initial value simulation based on initial values given in setup.
Reimplemented from Omu_Program.
| const VECP Prg_SFunctionEst::mdl_x_nominal | ( | ) | const [inline] |
nominal state values (for scaling)
interpolation order (0 (constant) or 1 (linear), default: 1)
References _mdl_x_nominal.
.