integrator_runge_kutta.hpp
Go to the documentation of this file.
00001 /*
00002  *    This file is part of ACADO Toolkit.
00003  *
00004  *    ACADO Toolkit -- A Toolkit for Automatic Control and Dynamic Optimization.
00005  *    Copyright (C) 2008-2014 by Boris Houska, Hans Joachim Ferreau,
00006  *    Milan Vukov, Rien Quirynen, KU Leuven.
00007  *    Developed within the Optimization in Engineering Center (OPTEC)
00008  *    under supervision of Moritz Diehl. All rights reserved.
00009  *
00010  *    ACADO Toolkit is free software; you can redistribute it and/or
00011  *    modify it under the terms of the GNU Lesser General Public
00012  *    License as published by the Free Software Foundation; either
00013  *    version 3 of the License, or (at your option) any later version.
00014  *
00015  *    ACADO Toolkit is distributed in the hope that it will be useful,
00016  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018  *    Lesser General Public License for more details.
00019  *
00020  *    You should have received a copy of the GNU Lesser General Public
00021  *    License along with ACADO Toolkit; if not, write to the Free Software
00022  *    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
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 // PUBLIC MEMBER FUNCTIONS:
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 // PROTECTED MEMBER FUNCTIONS:
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 // DATA MEMBERS:
00428 //
00429 protected:
00430 
00431 
00432     // BUTCHER-
00433     // TABLEAU:
00434     // ----------
00435     int      dim               ;  
00436     double **A                 ;  
00437     double  *b4                ;  
00438     double  *b5                ;  
00439     double  *c                 ;  
00442     // RK-ALGORITHM:
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     // SENSITIVITIES:
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     // STORAGE:
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 // end of file.


acado
Author(s): Milan Vukov, Rien Quirynen
autogenerated on Thu Aug 27 2015 11:58:37