HQP  1.9.7
Omu_Integrator Class Referenceabstract

Interface for a solver for differential (algebraic) equations. More...

#include <Omu_Integrator.h>

Inheritance diagram for Omu_Integrator:
[legend]

Public Member Functions

 Omu_Integrator ()
 constructor
 
virtual ~Omu_Integrator ()
 destructor
 
virtual const char * name ()=0
 Name of a specific integrator. More...
 
Low-level interface for Omuses employing an integrator.

The default implementations call the high-level interface.

virtual void setup_stages (const Omu_Program *sys)
 Setup stages for integrator. More...
 
virtual void setup_struct (int k, const Omu_VariableVec &x, const Omu_VariableVec &u, const Omu_DependentVec &Ft)
 Setup struct for one stage k. More...
 
virtual void init_stage (int k, const Omu_VariableVec &x, const Omu_VariableVec &u, const Omu_DependentVec &Ft, bool sa=false)
 Initialize solution of differential equations for stage k. More...
 
virtual void solve (int kk, double tstart, double tend, const Omu_VariableVec &x, const Omu_VariableVec &u, Omu_Program *sys, Omu_DependentVec &Ft, Omu_StateVec &xt)
 Solve differential equations over one sample period. More...
 
High-level interface for derived classes implementing an integrator.

This interface hides details of Omuses, like the classification of variables as discrete-time states, expansion states, and control parameters.

Instead it treats continuous-time DAE states and sensitivity parameters.

virtual void init (int k, const Omu_StateVec &xc, const Omu_Vec &q, const Omu_DependentVec &Fc, bool sa)
 Initialize integrator, like adaptation of array dimensions and test of pre-conditions, like explicit ODE. More...
 
virtual void solve (int kk, double tstart, double tend, Omu_StateVec &xc, Omu_StateVec &dxc, Omu_Vec &q, Omu_DependentVec &Fc)
 Solve differential equations over one sample period. More...
 
virtual void residual (int kk, double t, const Omu_StateVec &xc, const Omu_StateVec &dxc, const Omu_Vec &q, Omu_DependentVec &Fc)
 Callback to evaluate residuals of continuous-time equations. More...
 
Member access methods
int K () const
 get number of stages for which integrator has been set up
 

Protected Member Functions

Depreciated methods.

These methods are called by the default implementations of hte current versions.

virtual void init_stage (int k, const Omu_States &x, const Omu_Vector &u, bool sa=false)
 Initialize solution of differential equations for stage k. More...
 
virtual void solve (int kk, double tstart, double tend, const Omu_States &x, const Omu_Vector &u, Omu_Program *sys, VECP xt, MATP Sx=MNULL, MATP Su=MNULL)
 Solve differential equations over sample period. More...
 

Protected Attributes

Omu_Program_sys
 Pointer to problem definition that is valid during solve.
 
int _K
 number of stages for which integrator was set up
 
int _k
 index of current stage
 
int _kk
 index of current sample period
 
int _nxt
 total number of DAE states
 
int _nd
 number of discrete-time states
 
int _nv
 number of expansion variables
 
int _na
 number of algebraic states (no time derivative)
 
int _nx
 number of states treated by optimizer (nx=nxt-nv)
 
int _nu
 number of control parameters
 
int _nq
 number of sensitivity parameters (nq=nx+nu)
 
bool _sa
 Indicate if sensitivity analysis is required together with solution of differential equations.
 
bool _serr
 Boolean to indicate if sensitivities should be considered for error tolerance (default: false).
 
int _n
 Number of continuous-time states during integration (nxt-nd: total number minus discrete-time states).
 
int _m
 Number of control parameters during integration (nd+nu: discrete-time states and actual control parameters).
 
If_List _ifList
 container for interface elements
 
double _stepsize
 Constant stepsize to be taken by integator. More...
 
double _min_stepsize
 Minimal stepsize to be taken by integator. More...
 
double _rtol
 Relative integration error tolerance (only for variable stepsize).
 
double _atol
 Absolute integration error tolerance (only for variable stepsize).
 
int _res_evals
 number of residual evaluations
 
int _sen_evals
 number of sensitivity evaluations
 
int _jac_evals
 number of Jacobian evaluations
 

Detailed Description

Interface for a solver for differential (algebraic) equations.

The solver is employed internally to numerically integrate continuous-time model equations over sample periods and discrete-time stages.

Member Function Documentation

virtual void Omu_Integrator::init ( int  k,
const Omu_StateVec xc,
const Omu_Vec q,
const Omu_DependentVec Fc,
bool  sa 
)
inlinevirtual

Initialize integrator, like adaptation of array dimensions and test of pre-conditions, like explicit ODE.

An explicit ODE is present if Fc.Jdx.is_scalar() and Fc.Jdx[0][0] != 0.0. An algebraic state j, 0<=j<_n can be identified with Fc.Jdx.is_zero_column[j]. Note that the init method should not find consistent initial conditions of a DAE as parameters may jump between sample periods kk afterwards.

Parameters
kstage
xccontinuous-time states, dim(xc)=_n
qsensitivity parameters, dim(q)=_nq
Fcpre-initialized data structures for evaluating residuals, dim(Fc)=_n, including structurally analyzed Jacobians, dim(Fc.Jx)=_n._n, dim(Fc.Jxp)=_n._n, dim(Fc.Jq)=_n._nq
saindicates if sensitivity analysis is required

Reimplemented in Omu_IntGRK4, Omu_IntDASPK, Omu_IntSDIRK, Omu_IntIMP, and Omu_IntODE.

virtual void Omu_Integrator::init_stage ( int  k,
const Omu_VariableVec x,
const Omu_VariableVec u,
const Omu_DependentVec Ft,
bool  sa = false 
)
virtual

Initialize solution of differential equations for stage k.

Note: The numbers of variables and equation structure (given in F) shall be the same for all sample periods of a stage.

Parameters
kstage
xstate variables for optimization, including bounds etc.
ucontrol parameters for optimization
Ftpre-initialized data structures for resisuals and Jacobians
satrue if sensitivity analysis shall be performed

Reimplemented in Omu_IntOdeTs.

virtual void Omu_Integrator::init_stage ( int  k,
const Omu_States x,
const Omu_Vector u,
bool  sa = false 
)
inlineprotectedvirtual

Initialize solution of differential equations for stage k.

Reimplemented in Omu_IntODE.

virtual const char* Omu_Integrator::name ( )
pure virtual

Name of a specific integrator.

Implemented in Omu_IntGRK4, Omu_IntDASPK, Omu_IntOdeTs, Omu_IntRK4, Omu_IntSDIRK, Omu_IntIMP, Omu_IntEuler, and Omu_IntRKsuite.

virtual void Omu_Integrator::residual ( int  kk,
double  t,
const Omu_StateVec xc,
const Omu_StateVec dxc,
const Omu_Vec q,
Omu_DependentVec Fc 
)
virtual

Callback to evaluate residuals of continuous-time equations.

Parameters
kksample period
ttime for evaluation
xccontinuous-time states, dim(xc)=_n
dxcderivatives of continuous-time states wrt time, dim(dxc)=_n
qsensitivity parameters, dim(q)=_nq
Return values
Fcresiduals for continuous-time equations, dim(Fc)=_n; Jacobians Fc.Jx, Fc.Jdx, Fc.Jq if Fc.is_required_J() is true
virtual void Omu_Integrator::setup_stages ( const Omu_Program sys)
virtual

Setup stages for integrator.

This method is called once after Omu_Program's setup_stages has been performed.

Parameters
syspointer to problem definition
virtual void Omu_Integrator::setup_struct ( int  k,
const Omu_VariableVec x,
const Omu_VariableVec u,
const Omu_DependentVec Ft 
)
virtual

Setup struct for one stage k.

This method is called once during problem setup. Note: The numbers of variables and equation structure (given in Ft) shall be the same for all sample periods of a stage.

Parameters
kstage
xstate variables for optimization, including bounds etc.
ucontrol parameters for optimization
Ftpre-initialized data structures for resisuals and Jacobians
virtual void Omu_Integrator::solve ( int  kk,
double  tstart,
double  tend,
const Omu_VariableVec x,
const Omu_VariableVec u,
Omu_Program sys,
Omu_DependentVec Ft,
Omu_StateVec xt 
)
virtual

Solve differential equations over one sample period.

The differential-algebraic equations can be evaluated by calling Omu_Program::continuous for sys. Note that the first _nd elements of xt are discrete-time states that need to be treated like control parameters u by an integrator. Furthermore, the last _nv elements of xt are expansion variables that are not seen by the optimizer and accordingly no sensitivities are required with respect to them. The default implementation of solve calls the high-level version.

Parameters
kksample period
tstartstart time for integration
tendend time for integration
xstate variables for optimization, including bounds etc.
ucontrol parameters for optimization
sysproblem definition for calling Omu_Program::continuous
Ftpre-initialized data structures for resisuals and Jacobians
xtstart values for integration at tstart, dim(xt)=_nxt; initial sensitivity matrices xt.Sx, dim(xt.Sx)=_nxt._nx, and xt.Su, dim(xt.Su)=_nxt._nu, if _sa is true
Return values
xtresult at tend; xt.Sx and xt.Su at tend if _sa is true
Exceptions
E_CONVindicate that the integrator failed to converge; may be caught during optimization step length test

Reimplemented in Omu_IntOdeTs, and Omu_IntODE.

virtual void Omu_Integrator::solve ( int  kk,
double  tstart,
double  tend,
Omu_StateVec xc,
Omu_StateVec dxc,
Omu_Vec q,
Omu_DependentVec Fc 
)
virtual

Solve differential equations over one sample period.

Additionally solve sensitivity equations if _sa is true. The default implementation calls the depreciated solve method.

Parameters
kksample period
tstartstart time for integration
tendend time for integration
xccontinuous-time states at tstart, dim(xc)=_n; sensitivities xc.Sq at tstart, dim(xc.Sq)=_n._nq, if _sa is true
dxcpre-allocated time derivatives of continuous-time states, dim(dxc)=_n
qsensitivity parameters, dim(q)=_nq
Fcpre-allocated argument for residual calls, dim(Fc)=_n, including structurally analyzed Jacobians Fc.Jx, Fc.Jdx, Fc.Jq
Return values
xccontinuous-time states at tend; sensitivities xc.Sq at tend if _sa is true
Exceptions
E_CONVindicate that the integrator failed to converge; may be caught during optimization step length test

Reimplemented in Omu_IntGRK4, Omu_IntDASPK, Omu_IntSDIRK, and Omu_IntIMP.

virtual void Omu_Integrator::solve ( int  kk,
double  tstart,
double  tend,
const Omu_States x,
const Omu_Vector u,
Omu_Program sys,
VECP  xt,
MATP  Sx = MNULL,
MATP  Su = MNULL 
)
inlineprotectedvirtual

Solve differential equations over sample period.

Member Data Documentation

double Omu_Integrator::_min_stepsize
protected

Minimal stepsize to be taken by integator.

Default: 0.0, i.e. no limitation.

double Omu_Integrator::_stepsize
protected

Constant stepsize to be taken by integator.

For stepsize>0, an integrator takes ceil((tend-tstart)/stepsize) equidistant steps in the sampling interval [tstart,tend]. Default: 0.0, i.e. integrator chooses own stepsize.


The documentation for this class was generated from the following file: