integrator_runge_kutta.hpp
Go to the documentation of this file.
1 /*
2  * This file is part of ACADO Toolkit.
3  *
4  * ACADO Toolkit -- A Toolkit for Automatic Control and Dynamic Optimization.
5  * Copyright (C) 2008-2014 by Boris Houska, Hans Joachim Ferreau,
6  * Milan Vukov, Rien Quirynen, KU Leuven.
7  * Developed within the Optimization in Engineering Center (OPTEC)
8  * under supervision of Moritz Diehl. All rights reserved.
9  *
10  * ACADO Toolkit is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public
12  * License as published by the Free Software Foundation; either
13  * version 3 of the License, or (at your option) any later version.
14  *
15  * ACADO Toolkit is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  * Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public
21  * License along with ACADO Toolkit; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23  *
24  */
25 
26 
27 
34 #ifndef ACADO_TOOLKIT_INTEGRATOR_RUNGE_KUTTA_HPP
35 #define ACADO_TOOLKIT_INTEGRATOR_RUNGE_KUTTA_HPP
36 
37 
39 
40 
42 
43 
54 class IntegratorRK : public Integrator{
55 
56 //
57 // PUBLIC MEMBER FUNCTIONS:
58 //
59 
60 public:
61 
63  IntegratorRK();
64 
66  IntegratorRK( int dim_, double power_ );
67 
69  IntegratorRK( const DifferentialEquation &rhs_, int dim_, double power_ );
70 
72  IntegratorRK( const IntegratorRK& arg );
73 
75  virtual ~IntegratorRK( );
76 
78  virtual IntegratorRK& operator=( const IntegratorRK& arg );
79 
81  virtual Integrator* clone() const = 0;
82 
83 
84 
85  // ================================================================================
86 
87 
96  virtual returnValue init( const DifferentialEquation &rhs_ );
97 
98 
110  inline returnValue init( const DifferentialEquation &rhs_,
111  const Transition &trs_ );
112 
113 
114  // ================================================================================
115 
125  virtual returnValue freezeMesh();
126 
127 
136  virtual returnValue freezeAll();
137 
138 
146  virtual returnValue unfreeze();
147 
148 
149 
150  // ================================================================================
151 
174  virtual returnValue step( int number
175  );
176 
177 
186  virtual returnValue stop();
187 
188 
193  virtual returnValue setDxInitialization( double *dx0 );
197 
198  // ================================================================================
199 
200 
204  virtual int getNumberOfSteps() const;
205 
206 
210  virtual int getNumberOfRejectedSteps() const;
211 
212 
214  virtual double getStepSize() const;
215 
216 //
217 // PROTECTED MEMBER FUNCTIONS:
218 //
219 protected:
220 
221 
223  virtual int getDim() const;
224 
225 
226 
227  // ================================================================================
228 
229 
233  virtual returnValue evaluate( const DVector &x0 ,
234  const DVector &xa ,
235  const DVector &p ,
236  const DVector &u ,
237  const DVector &w ,
238  const Grid &t_ );
239 
240 
241  // ================================================================================
242 
243 
244 
251 
252 
253 
254  // ================================================================================
255 
256 
261  virtual returnValue setProtectedForwardSeed( const DVector &xSeed ,
263  const DVector &pSeed ,
265  const DVector &uSeed ,
267  const DVector &wSeed ,
269  const int &order );
271 
272  // ================================================================================
273 
274 
279  virtual returnValue setProtectedBackwardSeed( const DVector &seed ,
281  const int &order );
283 
284 
285  // ================================================================================
286 
287 
291  virtual returnValue getProtectedX( DVector *xEnd ) const;
294 
295 
303  int order ) const;
304 
305 
306 
319  DVector &Dx_p ,
320  DVector &Dx_u ,
321  DVector &Dx_w ,
322  int order ) const;
323 
324 
325 
326  // ================================================================================
327 
328 
331  void deleteAll();
332 
333 
336  void constructAll( const IntegratorRK& arg );
337 
338 
339 
346  void allocateMemory( );
347 
348 
354  void initializeVariables();
355 
356 
358  virtual void initializeButcherTableau() = 0;
359 
360 
364  double determineEta45();
365 
366 
370  double determineEta45( int number );
371 
372 
375  void determineEtaGForward( int number );
376 
377 
381  void determineEtaGForward2( int number );
382 
383 
386  void determineEtaHBackward( int number );
387 
388 
391  void determineEtaHBackward2( int number );
392 
393 
398 
399 
400 
403  returnValue setForwardSeed2( const DVector &xSeed ,
405  const DVector &pSeed ,
407  const DVector &uSeed ,
409  const DVector &wSeed );
411 
412 
415  virtual returnValue setBackwardSeed2( const DVector &seed );
417 
418 
419 
420  void interpolate( int jj, double *e1, double *d1, double *e2, VariablesGrid &poly );
421 
422 
423  void logCurrentIntegratorStep( const DVector& currentX = emptyConstVector
424  );
425 
426 
427 // DATA MEMBERS:
428 //
429 protected:
430 
431 
432  // BUTCHER-
433  // TABLEAU:
434  // ----------
435  int dim ;
436  double **A ;
437  double *b4 ;
438  double *b5 ;
439  double *c ;
442  // RK-ALGORITHM:
443  // -------------
444  double *eta4 ;
445  double *eta5 ;
446  double *eta4_ ;
447  double *eta5_ ;
448  double **k ;
449  double **k2 ;
450  double **l ;
451  double **l2 ;
452  double t ;
453  double *x ;
454  double err_power ;
457  // SENSITIVITIES:
458  // --------------
465  double *G ;
466  double *etaG ;
468  double *G2 ;
469  double *G3 ;
470  double *etaG2 ;
471  double *etaG3 ;
473  double *H ;
474  double *etaH ;
476  double *H2 ;
477  double *H3 ;
478  double *etaH2 ;
479  double *etaH3 ;
482  // STORAGE:
483  // --------
484  int maxAlloc ;
486 };
487 
488 
490 
491 
492 #include <acado/integrator/integrator_runge_kutta.ipp>
493 
494 
495 #endif // ACADO_TOOLKIT_INTEGRATOR_RUNGE_KUTTA_HPP
496 
497 // end of file.
virtual int getNumberOfSteps() const
virtual void initializeButcherTableau()=0
void determineEtaHBackward(int number)
void constructAll(const IntegratorRK &arg)
virtual returnValue init(const DifferentialEquation &rhs_)
virtual returnValue getProtectedBackwardSensitivities(DVector &Dx_x0, DVector &Dx_p, DVector &Dx_u, DVector &Dx_w, int order) const
virtual returnValue setProtectedForwardSeed(const DVector &xSeed, const DVector &pSeed, const DVector &uSeed, const DVector &wSeed, const int &order)
Provides a time grid consisting of vector-valued optimization variables at each grid point...
Allows to pass back messages to the calling function.
virtual double getStepSize() const
Allows to conveniently handle (one-dimensional) grids consisting of time points.
Definition: grid.hpp:58
virtual returnValue getProtectedX(DVector *xEnd) const
#define CLOSE_NAMESPACE_ACADO
virtual returnValue stop()
virtual int getDim() const
virtual Integrator * clone() const =0
Abstract base class for all kinds of algorithms for integrating differential equations (ODEs or DAEs)...
Definition: integrator.hpp:61
virtual returnValue getProtectedForwardSensitivities(DMatrix *Dx, int order) const
static const DVector emptyConstVector
Definition: vector.hpp:336
void determineEtaGForward(int number)
virtual returnValue evaluate(const DVector &x0, const DVector &xa, const DVector &p, const DVector &u, const DVector &w, const Grid &t_)
virtual returnValue unfreeze()
void determineEtaGForward2(int number)
virtual returnValue freezeAll()
void interpolate(int jj, double *e1, double *d1, double *e2, VariablesGrid &poly)
void logCurrentIntegratorStep(const DVector &currentX=emptyConstVector)
virtual returnValue freezeMesh()
virtual IntegratorRK & operator=(const IntegratorRK &arg)
virtual returnValue setBackwardSeed2(const DVector &seed)
Allows to setup and evaluate transition functions based on SymbolicExpressions.
Definition: transition.hpp:53
virtual int getNumberOfRejectedSteps() const
#define BEGIN_NAMESPACE_ACADO
virtual returnValue step(int number)
Abstract base class for all kinds of Runge-Kutta schemes for integrating ODEs.
returnValue setForwardSeed2(const DVector &xSeed, const DVector &pSeed, const DVector &uSeed, const DVector &wSeed)
virtual returnValue evaluateSensitivities()
virtual returnValue setProtectedBackwardSeed(const DVector &seed, const int &order)
virtual returnValue setDxInitialization(double *dx0)
Allows to setup and evaluate differential equations (ODEs and DAEs) based on SymbolicExpressions.
void determineEtaHBackward2(int number)


acado
Author(s): Milan Vukov, Rien Quirynen
autogenerated on Mon Jun 10 2019 12:34:42