integrator.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_HPP
00035 #define ACADO_TOOLKIT_INTEGRATOR_HPP
00036 
00037 
00038 #include <acado/utils/acado_utils.hpp>
00039 #include <acado/user_interaction/algorithmic_base.hpp>
00040 #include <acado/matrix_vector/matrix_vector.hpp>
00041 #include <acado/variables_grid/variables_grid.hpp>
00042 #include <acado/symbolic_expression/symbolic_expression.hpp>
00043 #include <acado/function/function.hpp>
00044 
00045 #include <acado/integrator/integrator_fwd.hpp>
00046 
00047 
00048 BEGIN_NAMESPACE_ACADO
00049 
00050 
00061 class Integrator : public AlgorithmicBase
00062 {
00063 
00064         friend class SimulationByIntegration;
00065         friend class ShootingMethod;
00066 
00067         //
00068         // PUBLIC MEMBER FUNCTIONS:
00069         //
00070         public:
00071 
00072 
00075                 Integrator( );
00076 
00078                 Integrator( const Integrator &arg );
00079 
00081                 virtual ~Integrator( );
00082 
00084                 virtual Integrator* clone() const = 0;
00085 
00086 
00087         // ================================================================================
00088 
00089 
00098                 virtual returnValue init( const DifferentialEquation &rhs ) = 0;
00099 
00100 
00101 
00113                 returnValue init(       const DifferentialEquation &rhs,
00114                                                         const Transition           &trs
00115                                                         );
00116 
00117 
00118                 returnValue setTransition(      const Transition &trs
00119                                                                         );
00120 
00121 
00122 
00123                 // ================================================================================
00124 
00134                 virtual returnValue freezeMesh() = 0;
00135 
00136 
00145                 virtual returnValue freezeAll() = 0;
00146 
00147 
00155                 virtual returnValue unfreeze() = 0;
00156 
00157 
00158 
00159                 // ================================================================================
00160 
00170                 returnValue integrate(  double t0        ,
00171                                                                 double tend      ,
00172                                                                 double *x0       ,
00173                                                                 double *xa  = 0  ,
00174                                                                 double *p   = 0  ,
00175                                                                 double *u   = 0  ,
00176                                                                 double *w   = 0    );
00177 
00178 
00179 
00193                 returnValue integrate(  const Grid   &t          ,
00194                                                                 double      *x0          ,
00195                                                                 double      *xa  = 0     ,
00196                                                                 double      *p   = 0     ,
00197                                                                 double      *u   = 0     ,
00198                                                                 double      *w   = 0       );
00199 
00200 
00201 
00211                 returnValue integrate(  double       t0                  ,
00212                                                                 double       tend                ,
00213                                                                 const DVector &x0                 ,
00214                                                                 const DVector &xa  = emptyVector  ,
00215                                                                 const DVector &p   = emptyVector  ,
00216                                                                 const DVector &u   = emptyVector  ,
00217                                                                 const DVector &w   = emptyVector    );
00218 
00219 
00220 
00234                 returnValue integrate(  const Grid   &t                  ,
00235                                                                 const DVector &x0                 ,
00236                                                                 const DVector &xa  = emptyVector  ,
00237                                                                 const DVector &p   = emptyVector  ,
00238                                                                 const DVector &u   = emptyVector  ,
00239                                                                 const DVector &w   = emptyVector    );
00240 
00241 
00242 
00243                 // ================================================================================
00244 
00245 
00250                 returnValue setForwardSeed(     const int    &order                ,
00251                                                                         const DVector &xSeed                ,
00252                                                                         const DVector &pSeed = emptyVector  ,
00253                                                                         const DVector &uSeed = emptyVector  ,
00254                                                                         const DVector &wSeed = emptyVector    );
00255 
00256 
00257 
00258                 // ================================================================================
00259 
00260 
00265                 returnValue setBackwardSeed(    const int    &order ,
00266                                                                                 const DVector &seed    );
00267 
00268 
00269 
00270                 // ================================================================================
00271 
00277                 virtual returnValue deleteAllSeeds();
00278 
00279 
00280                 // ================================================================================
00281 
00282 
00288                 returnValue integrateSensitivities( );
00289 
00290 
00291 
00296                 virtual returnValue setDxInitialization( double *dx0   ) = 0;
00300 
00301 
00302                 // ================================================================================
00303 
00304 
00312                 inline  returnValue getX( DVector &xEnd ) const;
00313 
00314 
00322                 inline  returnValue getXA( DVector &xaEnd ) const;
00323 
00324 
00325 
00335                 inline  returnValue getX( VariablesGrid &X ) const;
00336 
00337 
00347                 inline  returnValue getXA( VariablesGrid &XA ) const;
00348 
00349 
00359                 inline  returnValue getI( VariablesGrid &I ) const;
00360 
00361 
00362 
00371                  returnValue getForwardSensitivities(   DVector &Dx,
00372                                                                                                 int order ) const;
00373 
00374 
00383                 returnValue getForwardSensitivities(    VariablesGrid &Dx,
00384                                                                                                 int order ) const;
00385 
00386 
00397                 returnValue getBackwardSensitivities(   DVector &Dx_x0,
00398                                                                                                 DVector &Dx_p ,
00399                                                                                                 DVector &Dx_u ,
00400                                                                                                 DVector &Dx_w ,
00401                                                                                                 int order      ) const;
00402 
00403                 // ================================================================================
00404 
00405 
00406 
00407 
00411                 virtual int getNumberOfSteps() const = 0;
00412 
00413 
00417                 virtual int getNumberOfRejectedSteps() const = 0;
00418 
00419 
00420 
00425                 virtual BooleanType canHandleImplicitSwitches( ) const;
00426 
00427 
00432                 virtual BooleanType isDifferentialEquationDefined( ) const;     
00433 
00434 
00439                 virtual BooleanType isDifferentialEquationAffine( ) const;
00440 
00442                 virtual double getDifferentialEquationSampleTime() const;
00443 
00444 
00446                 virtual double getStepSize() const = 0;
00447 
00448 
00453                 virtual returnValue printRunTimeProfile() const;
00454 
00455 
00461                 virtual returnValue evaluateSensitivities() = 0;
00462 
00463 
00464         //
00465         // PROTECTED MEMBER FUNCTIONS:
00466         //
00467         protected:
00468 
00469                 virtual returnValue setupOptions( );
00470 
00471 
00472                 // ================================================================================
00473 
00474 
00478                 virtual returnValue evaluate( const DVector &x0    ,
00479                                                                         const DVector &xa    ,
00480                                                                         const DVector &p     ,
00481                                                                         const DVector &u     ,
00482                                                                         const DVector &w     ,
00483                                                                         const Grid   &t_      ) = 0;
00484 
00487                 virtual returnValue evaluateTransition( const double time   ,
00488                                                                                                         DVector &xd    ,
00489                                                                                                 const DVector &xa    ,
00490                                                                                                 const DVector &p     ,
00491                                                                                                 const DVector &u     ,
00492                                                                                                 const DVector &w       );
00493 
00494 
00495                 virtual returnValue diffTransitionForward(       DVector &DX,
00496                                                                                                 const DVector &DP,
00497                                                                                                 const DVector &DU,
00498                                                                                                 const DVector &DW,
00499                                                                                                 const int    &order );
00500 
00501 
00502                 virtual returnValue diffTransitionBackward( DVector &DX,
00503                                                                                                         DVector &DP,
00504                                                                                                         DVector &DU,
00505                                                                                                         DVector &DW,
00506                                                                                                         int    &order );
00507 
00508 
00509                 // ================================================================================
00510 
00511 
00516                 virtual returnValue setProtectedForwardSeed( const DVector &xSeed     ,
00518                                                                                                         const DVector &pSeed     ,
00520                                                                                                         const DVector &uSeed     ,
00522                                                                                                         const DVector &wSeed     ,
00524                                                                                                         const int    &order      ) = 0;
00526 
00527                 // ================================================================================
00528 
00529 
00534                 virtual returnValue setProtectedBackwardSeed(  const DVector &seed    ,
00536                                                                                                         const int    &order     ) = 0;
00538 
00539 
00540                 // ================================================================================
00541 
00542 
00543 
00547                 virtual returnValue getProtectedX( DVector *xEnd  ) const = 0;
00550 
00551 
00556                 virtual returnValue getProtectedForwardSensitivities( DMatrix *Dx  ,
00559                                                                                                                         int order    ) const = 0;
00560 
00561 
00573                 virtual returnValue getProtectedBackwardSensitivities( DVector &Dx_x0,
00574                                                                                                                         DVector &Dx_p ,
00575                                                                                                                         DVector &Dx_u ,
00576                                                                                                                         DVector &Dx_w ,
00577                                                                                                                         int order      ) const = 0;
00578 
00579 
00580                 // ================================================================================
00581 
00582 
00583 
00585                 virtual int getDim() const = 0;
00586 
00587 
00589                 virtual int getDimX() const;
00590 
00591 
00592 
00605                 void initializeOptions();
00606 
00607 
00608                 virtual returnValue setupLogging( );
00609 
00610 
00611         //
00612         // DATA MEMBERS:
00613         //
00614         protected:
00615 
00616 
00617                 // DIFFERENTIAL ALGEBRAIC RHS:
00618                 // ---------------------------
00619                 DifferentialEquation *rhs    ;  
00620                 short int             m      ;  
00621                 short int             ma     ;  
00622                 short int             mdx    ;  
00623                 short int             mn     ;  
00624                 short int             mu     ;  
00625                 short int             mui    ;  
00626                 short int             mp     ;  
00627                 short int             mpi    ;  
00628                 short int             mw     ;  
00629                 short int             md     ;  
00632                 // TRANSITION:
00633                 // ---------------------------
00634                 Transition        *transition;  
00638                 // SETTINGS:
00639                 // ---------
00640                 double  *h                   ;  
00641                 double   hini                ;  
00642                 double   hmin                ;  
00643                 double   hmax                ;  
00644                 double   tune                ;  
00645                 double   TOL                 ;  
00646                 int      las                 ;  
00648                 Grid     timeInterval        ;  
00651                 // INTERNAL INDEX LISTS:
00652                 // ---------------------
00653                 int    *diff_index         ;  
00654                 int    *ddiff_index        ;  
00655                 int    *alg_index          ;  
00656                 int    *control_index      ;  
00657                 int    *parameter_index    ;  
00658                 int    *int_control_index  ;  
00659                 int    *int_parameter_index;  
00660                 int    *disturbance_index  ;  
00661                 int     time_index         ;  
00664                 // OTHERS:
00665                 // -------------------------
00666                 int     maxNumberOfSteps   ;  
00667                 int     count              ;  
00668                 int     count2             ;  
00669                 int     count3             ;  
00670                 DVector  diff_scale         ;  
00673                 // PRINT-LEVEL:
00674                 // -------------------------
00675                 int PrintLevel             ;  
00678                 // SEED DIMENSIONS:
00679                 // -------------------------
00680                 int        nFDirs          ;  
00681                 int        nBDirs          ;  
00682                 int        nFDirs2         ;  
00683                 int        nBDirs2         ;  
00686                 // THE STATE OF AGGREGATION:
00687                 // -------------------------
00688                 StateOfAggregation soa     ;  
00692                 // STATISTICS:
00693                 // --------------------------
00694                 RealClock totalTime         ;
00695                 RealClock functionEvaluation;
00696                 int       nFcnEvaluations   ;
00697 
00698 
00699                 DVector                    xE;
00700 
00701                 DVector                    dX;
00702                 DVector                    dP;
00703                 DVector                    dU;
00704                 DVector                    dW;
00705 
00706                 DVector                   dXb;
00707                 DVector                   dPb;
00708                 DVector                   dUb;
00709                 DVector                   dWb;
00710 
00711                 VariablesGrid         xStore;
00712                 VariablesGrid        dxStore;
00713                 VariablesGrid       ddxStore;
00714                 VariablesGrid         iStore;
00715 
00716 
00717 };
00718 
00719 
00720 CLOSE_NAMESPACE_ACADO
00721 
00722 
00723 #include <acado/integrator/integrator.ipp>
00724 
00725 
00726 // collect all remaining headers of integrator directory
00727 #include <acado/integrator/integrator_runge_kutta.hpp>
00728 #include <acado/integrator/integrator_runge_kutta12.hpp>
00729 #include <acado/integrator/integrator_runge_kutta23.hpp>
00730 #include <acado/integrator/integrator_runge_kutta45.hpp>
00731 #include <acado/integrator/integrator_runge_kutta78.hpp>
00732 #include <acado/integrator/integrator_discretized_ode.hpp>
00733 #include <acado/integrator/integrator_bdf.hpp>
00734 #include <acado/integrator/integrator_lyapunov.hpp>
00735 #include <acado/integrator/integrator_lyapunov45.hpp>
00736 
00737 
00738 #endif  // ACADO_TOOLKIT_INTEGRATOR_HPP
00739 
00740 // end of file.


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