integrator.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_HPP
35 #define ACADO_TOOLKIT_INTEGRATOR_HPP
36 
37 
44 
46 
47 
49 
50 
62 {
63 
65  friend class ShootingMethod;
66 
67  //
68  // PUBLIC MEMBER FUNCTIONS:
69  //
70  public:
71 
72 
75  Integrator( );
76 
78  Integrator( const Integrator &arg );
79 
81  virtual ~Integrator( );
82 
84  virtual Integrator* clone() const = 0;
85 
86 
87  // ================================================================================
88 
89 
98  virtual returnValue init( const DifferentialEquation &rhs ) = 0;
99 
100 
101 
114  const Transition &trs
115  );
116 
117 
119  );
120 
121 
122 
123  // ================================================================================
124 
134  virtual returnValue freezeMesh() = 0;
135 
136 
145  virtual returnValue freezeAll() = 0;
146 
147 
155  virtual returnValue unfreeze() = 0;
156 
157 
158 
159  // ================================================================================
160 
170  returnValue integrate( double t0 ,
171  double tend ,
172  double *x0 ,
173  double *xa = 0 ,
174  double *p = 0 ,
175  double *u = 0 ,
176  double *w = 0 );
177 
178 
179 
193  returnValue integrate( const Grid &t ,
194  double *x0 ,
195  double *xa = 0 ,
196  double *p = 0 ,
197  double *u = 0 ,
198  double *w = 0 );
199 
200 
201 
211  returnValue integrate( double t0 ,
212  double tend ,
213  const DVector &x0 ,
214  const DVector &xa = emptyVector ,
215  const DVector &p = emptyVector ,
216  const DVector &u = emptyVector ,
217  const DVector &w = emptyVector );
218 
219 
220 
234  returnValue integrate( const Grid &t ,
235  const DVector &x0 ,
236  const DVector &xa = emptyVector ,
237  const DVector &p = emptyVector ,
238  const DVector &u = emptyVector ,
239  const DVector &w = emptyVector );
240 
241 
242 
243  // ================================================================================
244 
245 
250  returnValue setForwardSeed( const int &order ,
251  const DVector &xSeed ,
252  const DVector &pSeed = emptyVector ,
253  const DVector &uSeed = emptyVector ,
254  const DVector &wSeed = emptyVector );
255 
256 
257 
258  // ================================================================================
259 
260 
265  returnValue setBackwardSeed( const int &order ,
266  const DVector &seed );
267 
268 
269 
270  // ================================================================================
271 
277  virtual returnValue deleteAllSeeds();
278 
279 
280  // ================================================================================
281 
282 
289 
290 
291 
296  virtual returnValue setDxInitialization( double *dx0 ) = 0;
300 
301 
302  // ================================================================================
303 
304 
312  inline returnValue getX( DVector &xEnd ) const;
313 
314 
322  inline returnValue getXA( DVector &xaEnd ) const;
323 
324 
325 
335  inline returnValue getX( VariablesGrid &X ) const;
336 
337 
347  inline returnValue getXA( VariablesGrid &XA ) const;
348 
349 
359  inline returnValue getI( VariablesGrid &I ) const;
360 
361 
362 
372  int order ) const;
373 
374 
384  int order ) const;
385 
386 
398  DVector &Dx_p ,
399  DVector &Dx_u ,
400  DVector &Dx_w ,
401  int order ) const;
402 
403  // ================================================================================
404 
405 
406 
407 
411  virtual int getNumberOfSteps() const = 0;
412 
413 
417  virtual int getNumberOfRejectedSteps() const = 0;
418 
419 
420 
425  virtual BooleanType canHandleImplicitSwitches( ) const;
426 
427 
432  virtual BooleanType isDifferentialEquationDefined( ) const;
433 
434 
439  virtual BooleanType isDifferentialEquationAffine( ) const;
440 
442  virtual double getDifferentialEquationSampleTime() const;
443 
444 
446  virtual double getStepSize() const = 0;
447 
448 
453  virtual returnValue printRunTimeProfile() const;
454 
455 
461  virtual returnValue evaluateSensitivities() = 0;
462 
463 
464  //
465  // PROTECTED MEMBER FUNCTIONS:
466  //
467  protected:
468 
469  virtual returnValue setupOptions( );
470 
471 
472  // ================================================================================
473 
474 
478  virtual returnValue evaluate( const DVector &x0 ,
479  const DVector &xa ,
480  const DVector &p ,
481  const DVector &u ,
482  const DVector &w ,
483  const Grid &t_ ) = 0;
484 
487  virtual returnValue evaluateTransition( const double time ,
488  DVector &xd ,
489  const DVector &xa ,
490  const DVector &p ,
491  const DVector &u ,
492  const DVector &w );
493 
494 
496  const DVector &DP,
497  const DVector &DU,
498  const DVector &DW,
499  const int &order );
500 
501 
503  DVector &DP,
504  DVector &DU,
505  DVector &DW,
506  int &order );
507 
508 
509  // ================================================================================
510 
511 
518  const DVector &pSeed ,
520  const DVector &uSeed ,
522  const DVector &wSeed ,
524  const int &order ) = 0;
526 
527  // ================================================================================
528 
529 
534  virtual returnValue setProtectedBackwardSeed( const DVector &seed ,
536  const int &order ) = 0;
538 
539 
540  // ================================================================================
541 
542 
543 
547  virtual returnValue getProtectedX( DVector *xEnd ) const = 0;
550 
551 
559  int order ) const = 0;
560 
561 
574  DVector &Dx_p ,
575  DVector &Dx_u ,
576  DVector &Dx_w ,
577  int order ) const = 0;
578 
579 
580  // ================================================================================
581 
582 
583 
585  virtual int getDim() const = 0;
586 
587 
589  virtual int getDimX() const;
590 
591 
592 
605  void initializeOptions();
606 
607 
608  virtual returnValue setupLogging( );
609 
610 
611  //
612  // DATA MEMBERS:
613  //
614  protected:
615 
616 
617  // DIFFERENTIAL ALGEBRAIC RHS:
618  // ---------------------------
620  short int m ;
621  short int ma ;
622  short int mdx ;
623  short int mn ;
624  short int mu ;
625  short int mui ;
626  short int mp ;
627  short int mpi ;
628  short int mw ;
629  short int md ;
632  // TRANSITION:
633  // ---------------------------
638  // SETTINGS:
639  // ---------
640  double *h ;
641  double hini ;
642  double hmin ;
643  double hmax ;
644  double tune ;
645  double TOL ;
646  int las ;
651  // INTERNAL INDEX LISTS:
652  // ---------------------
653  int *diff_index ;
654  int *ddiff_index ;
655  int *alg_index ;
661  int time_index ;
664  // OTHERS:
665  // -------------------------
667  int count ;
668  int count2 ;
669  int count3 ;
673  // PRINT-LEVEL:
674  // -------------------------
675  int PrintLevel ;
678  // SEED DIMENSIONS:
679  // -------------------------
680  int nFDirs ;
681  int nBDirs ;
682  int nFDirs2 ;
683  int nBDirs2 ;
686  // THE STATE OF AGGREGATION:
687  // -------------------------
692  // STATISTICS:
693  // --------------------------
697 
698 
700 
705 
710 
715 
716 
717 };
718 
719 
721 
722 
723 #include <acado/integrator/integrator.ipp>
724 
725 
726 // collect all remaining headers of integrator directory
736 
737 
738 #endif // ACADO_TOOLKIT_INTEGRATOR_HPP
739 
740 // end of file.
returnValue getX(DVector &xEnd) const
double TOL
Definition: integrator.hpp:645
virtual int getDimX() const
Definition: integrator.cpp:618
virtual returnValue freezeAll()=0
virtual returnValue getProtectedX(DVector *xEnd) const =0
virtual double getStepSize() const =0
double tune
Definition: integrator.hpp:644
virtual returnValue evaluateSensitivities()=0
Allows real time measurements based on the system&#39;s clock.
Definition: real_clock.hpp:53
int * int_parameter_index
Definition: integrator.hpp:659
int maxNumberOfSteps
Definition: integrator.hpp:666
VariablesGrid dxStore
Definition: integrator.hpp:712
virtual int getNumberOfSteps() const =0
DVector dXb
Definition: integrator.hpp:706
short int m
Definition: integrator.hpp:620
void initializeOptions()
Definition: integrator.cpp:587
virtual returnValue deleteAllSeeds()
Definition: integrator.cpp:488
int * diff_index
Definition: integrator.hpp:653
Discretizes a DifferentialEquation by means of single or multiple shooting.
DVector dU
Definition: integrator.hpp:703
virtual int getNumberOfRejectedSteps() const =0
Provides a time grid consisting of vector-valued optimization variables at each grid point...
Allows to pass back messages to the calling function.
double hmin
Definition: integrator.hpp:642
DVector dPb
Definition: integrator.hpp:707
short int mdx
Definition: integrator.hpp:622
Base class for all algorithmic modules within the ACADO Toolkit providing some basic functionality...
StateOfAggregation
virtual int getDim() const =0
Allows to conveniently handle (one-dimensional) grids consisting of time points.
Definition: grid.hpp:58
RealClock functionEvaluation
Definition: integrator.hpp:695
virtual double getDifferentialEquationSampleTime() const
Definition: integrator.cpp:478
short int md
Definition: integrator.hpp:629
Grid timeInterval
Definition: integrator.hpp:648
#define CLOSE_NAMESPACE_ACADO
int * int_control_index
Definition: integrator.hpp:658
virtual returnValue getProtectedBackwardSensitivities(DVector &Dx_x0, DVector &Dx_p, DVector &Dx_u, DVector &Dx_w, int order) const =0
virtual returnValue freezeMesh()=0
VariablesGrid ddxStore
Definition: integrator.hpp:713
Abstract base class for all kinds of algorithms for integrating differential equations (ODEs or DAEs)...
Definition: integrator.hpp:61
VariablesGrid xStore
Definition: integrator.hpp:711
virtual BooleanType canHandleImplicitSwitches() const
Definition: integrator.cpp:459
virtual returnValue setupOptions()
Definition: integrator.cpp:566
int * alg_index
Definition: integrator.hpp:655
StateOfAggregation soa
Definition: integrator.hpp:688
virtual returnValue unfreeze()=0
int nFcnEvaluations
Definition: integrator.hpp:696
short int mu
Definition: integrator.hpp:624
returnValue setForwardSeed(const int &order, const DVector &xSeed, const DVector &pSeed=emptyVector, const DVector &uSeed=emptyVector, const DVector &wSeed=emptyVector)
Definition: integrator.cpp:308
virtual returnValue setDxInitialization(double *dx0)=0
friend class SimulationByIntegration
Definition: integrator.hpp:64
returnValue getI(VariablesGrid &I) const
short int mw
Definition: integrator.hpp:628
double * h
Definition: integrator.hpp:640
RealClock totalTime
Definition: integrator.hpp:694
Transition * transition
Definition: integrator.hpp:634
short int mui
Definition: integrator.hpp:625
returnValue setTransition(const Transition &trs)
Definition: integrator.cpp:198
int * control_index
Definition: integrator.hpp:656
int * disturbance_index
Definition: integrator.hpp:660
virtual returnValue setupLogging()
Definition: integrator.cpp:599
short int mp
Definition: integrator.hpp:626
DVector dX
Definition: integrator.hpp:701
virtual returnValue getProtectedForwardSensitivities(DMatrix *Dx, int order) const =0
DVector xE
Definition: integrator.hpp:699
VariablesGrid iStore
Definition: integrator.hpp:714
returnValue getBackwardSensitivities(DVector &Dx_x0, DVector &Dx_p, DVector &Dx_u, DVector &Dx_w, int order) const
Definition: integrator.cpp:424
returnValue getXA(DVector &xaEnd) const
DVector dUb
Definition: integrator.hpp:708
short int mn
Definition: integrator.hpp:623
virtual returnValue setProtectedForwardSeed(const DVector &xSeed, const DVector &pSeed, const DVector &uSeed, const DVector &wSeed, const int &order)=0
int * parameter_index
Definition: integrator.hpp:657
Allows to setup and evaluate transition functions based on SymbolicExpressions.
Definition: transition.hpp:53
virtual BooleanType isDifferentialEquationAffine() const
Definition: integrator.cpp:471
virtual returnValue diffTransitionForward(DVector &DX, const DVector &DP, const DVector &DU, const DVector &DW, const int &order)
Definition: integrator.cpp:521
int * ddiff_index
Definition: integrator.hpp:654
DVector dW
Definition: integrator.hpp:704
virtual ~Integrator()
Definition: integrator.cpp:139
virtual returnValue init(const DifferentialEquation &rhs)=0
DVector dWb
Definition: integrator.hpp:709
virtual returnValue diffTransitionBackward(DVector &DX, DVector &DP, DVector &DU, DVector &DW, int &order)
Definition: integrator.cpp:542
static DVector emptyVector
Definition: vector.hpp:335
#define BEGIN_NAMESPACE_ACADO
returnValue integrateSensitivities()
Definition: integrator.cpp:357
DVector diff_scale
Definition: integrator.hpp:670
returnValue getForwardSensitivities(DVector &Dx, int order) const
Definition: integrator.cpp:406
short int ma
Definition: integrator.hpp:621
DVector dP
Definition: integrator.hpp:702
short int mpi
Definition: integrator.hpp:627
virtual returnValue evaluate(const DVector &x0, const DVector &xa, const DVector &p, const DVector &u, const DVector &w, const Grid &t_)=0
virtual returnValue evaluateTransition(const double time, DVector &xd, const DVector &xa, const DVector &p, const DVector &u, const DVector &w)
Definition: integrator.cpp:505
double hmax
Definition: integrator.hpp:643
returnValue setBackwardSeed(const int &order, const DVector &seed)
Definition: integrator.cpp:338
virtual returnValue printRunTimeProfile() const
Definition: integrator.cpp:624
double hini
Definition: integrator.hpp:641
virtual Integrator * clone() const =0
virtual returnValue setProtectedBackwardSeed(const DVector &seed, const int &order)=0
returnValue integrate(double t0, double tend, double *x0, double *xa=0, double *p=0, double *u=0, double *w=0)
Definition: integrator.cpp:207
virtual BooleanType isDifferentialEquationDefined() const
Definition: integrator.cpp:465
Allows to setup and evaluate differential equations (ODEs and DAEs) based on SymbolicExpressions.
DifferentialEquation * rhs
Definition: integrator.hpp:619


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