Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00034 #ifndef ACADO_TOOLKIT_INTEGRATOR_RUNGE_KUTTA_HPP
00035 #define ACADO_TOOLKIT_INTEGRATOR_RUNGE_KUTTA_HPP
00036
00037
00038 #include <acado/integrator/integrator_fwd.hpp>
00039
00040
00041 BEGIN_NAMESPACE_ACADO
00042
00043
00054 class IntegratorRK : public Integrator{
00055
00056
00057
00058
00059
00060 public:
00061
00063 IntegratorRK();
00064
00066 IntegratorRK( int dim_, double power_ );
00067
00069 IntegratorRK( const DifferentialEquation &rhs_, int dim_, double power_ );
00070
00072 IntegratorRK( const IntegratorRK& arg );
00073
00075 virtual ~IntegratorRK( );
00076
00078 virtual IntegratorRK& operator=( const IntegratorRK& arg );
00079
00081 virtual Integrator* clone() const = 0;
00082
00083
00084
00085
00086
00087
00096 virtual returnValue init( const DifferentialEquation &rhs_ );
00097
00098
00110 inline returnValue init( const DifferentialEquation &rhs_,
00111 const Transition &trs_ );
00112
00113
00114
00115
00125 virtual returnValue freezeMesh();
00126
00127
00136 virtual returnValue freezeAll();
00137
00138
00146 virtual returnValue unfreeze();
00147
00148
00149
00150
00151
00174 virtual returnValue step( int number
00175 );
00176
00177
00186 virtual returnValue stop();
00187
00188
00193 virtual returnValue setDxInitialization( double *dx0 );
00197
00198
00199
00200
00204 virtual int getNumberOfSteps() const;
00205
00206
00210 virtual int getNumberOfRejectedSteps() const;
00211
00212
00214 virtual double getStepSize() const;
00215
00216
00217
00218
00219 protected:
00220
00221
00223 virtual int getDim() const;
00224
00225
00226
00227
00228
00229
00233 virtual returnValue evaluate( const DVector &x0 ,
00234 const DVector &xa ,
00235 const DVector &p ,
00236 const DVector &u ,
00237 const DVector &w ,
00238 const Grid &t_ );
00239
00240
00241
00242
00243
00244
00250 virtual returnValue evaluateSensitivities();
00251
00252
00253
00254
00255
00256
00261 virtual returnValue setProtectedForwardSeed( const DVector &xSeed ,
00263 const DVector &pSeed ,
00265 const DVector &uSeed ,
00267 const DVector &wSeed ,
00269 const int &order );
00271
00272
00273
00274
00279 virtual returnValue setProtectedBackwardSeed( const DVector &seed ,
00281 const int &order );
00283
00284
00285
00286
00287
00291 virtual returnValue getProtectedX( DVector *xEnd ) const;
00294
00295
00300 virtual returnValue getProtectedForwardSensitivities( DMatrix *Dx ,
00303 int order ) const;
00304
00305
00306
00318 virtual returnValue getProtectedBackwardSensitivities( DVector &Dx_x0,
00319 DVector &Dx_p ,
00320 DVector &Dx_u ,
00321 DVector &Dx_w ,
00322 int order ) const;
00323
00324
00325
00326
00327
00328
00331 void deleteAll();
00332
00333
00336 void constructAll( const IntegratorRK& arg );
00337
00338
00339
00346 void allocateMemory( );
00347
00348
00354 void initializeVariables();
00355
00356
00358 virtual void initializeButcherTableau() = 0;
00359
00360
00364 double determineEta45();
00365
00366
00370 double determineEta45( int number );
00371
00372
00375 void determineEtaGForward( int number );
00376
00377
00381 void determineEtaGForward2( int number );
00382
00383
00386 void determineEtaHBackward( int number );
00387
00388
00391 void determineEtaHBackward2( int number );
00392
00393
00397 void printIntermediateResults();
00398
00399
00400
00403 returnValue setForwardSeed2( const DVector &xSeed ,
00405 const DVector &pSeed ,
00407 const DVector &uSeed ,
00409 const DVector &wSeed );
00411
00412
00415 virtual returnValue setBackwardSeed2( const DVector &seed );
00417
00418
00419
00420 void interpolate( int jj, double *e1, double *d1, double *e2, VariablesGrid &poly );
00421
00422
00423 void logCurrentIntegratorStep( const DVector& currentX = emptyConstVector
00424 );
00425
00426
00427
00428
00429 protected:
00430
00431
00432
00433
00434
00435 int dim ;
00436 double **A ;
00437 double *b4 ;
00438 double *b5 ;
00439 double *c ;
00442
00443
00444 double *eta4 ;
00445 double *eta5 ;
00446 double *eta4_ ;
00447 double *eta5_ ;
00448 double **k ;
00449 double **k2 ;
00450 double **l ;
00451 double **l2 ;
00452 double t ;
00453 double *x ;
00454 double err_power ;
00457
00458
00459 DVector fseed ;
00460 DVector bseed ;
00462 DVector fseed2 ;
00463 DVector bseed2 ;
00465 double *G ;
00466 double *etaG ;
00468 double *G2 ;
00469 double *G3 ;
00470 double *etaG2 ;
00471 double *etaG3 ;
00473 double *H ;
00474 double *etaH ;
00476 double *H2 ;
00477 double *H3 ;
00478 double *etaH2 ;
00479 double *etaH3 ;
00482
00483
00484 int maxAlloc ;
00486 };
00487
00488
00489 CLOSE_NAMESPACE_ACADO
00490
00491
00492 #include <acado/integrator/integrator_runge_kutta.ipp>
00493
00494
00495 #endif // ACADO_TOOLKIT_INTEGRATOR_RUNGE_KUTTA_HPP
00496
00497