irk_export.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 
00035 #ifndef ACADO_TOOLKIT_IRK_EXPORT_HPP
00036 #define ACADO_TOOLKIT_IRK_EXPORT_HPP
00037 
00038 #include <acado/code_generation/integrators/rk_export.hpp>
00039 #include <acado/code_generation/linear_solvers/linear_solver_generation.hpp>
00040 
00041 
00042 BEGIN_NAMESPACE_ACADO
00043 
00044 
00055 class ImplicitRungeKuttaExport : public RungeKuttaExport
00056 {
00057     //
00058     // PUBLIC MEMBER FUNCTIONS:
00059     //
00060 
00061     public:
00062 
00068         ImplicitRungeKuttaExport(       UserInteraction* _userInteraction = 0,
00069                                                         const std::string& _commonHeaderName = ""
00070                                                         );
00071 
00076         ImplicitRungeKuttaExport(       const ImplicitRungeKuttaExport& arg
00077                                                         );
00078 
00081         virtual ~ImplicitRungeKuttaExport( );
00082 
00083 
00088                 ImplicitRungeKuttaExport& operator=(    const ImplicitRungeKuttaExport& arg
00089                                                                                 );
00090 
00091 
00096                 virtual returnValue setup( );
00097 
00098 
00105                 virtual returnValue setDifferentialEquation( const Expression& rhs );
00106 
00107 
00116                 returnValue setModel( const std::string& _rhs, const std::string& _diffs_rhs );
00117                                                         
00118         
00126                 virtual returnValue setupOutput( const std::vector<Grid> outputGrids_,
00127                                                                           const std::vector<Expression> rhs );
00128 
00129 
00139                 virtual returnValue setupOutput(  const std::vector<Grid> outputGrids_,
00140                                                                                   const std::vector<std::string> _outputNames,
00141                                                                                   const std::vector<std::string> _diffs_outputNames,
00142                                                                                   const std::vector<uint> _dims_output );
00143 
00144 
00155                 virtual returnValue setupOutput(  const std::vector<Grid> outputGrids_,
00156                                                                                   const std::vector<std::string> _outputNames,
00157                                                                                   const std::vector<std::string> _diffs_outputNames,
00158                                                                                   const std::vector<uint> _dims_output,
00159                                                                                   const std::vector<DMatrix> _outputDependencies );
00160         
00161 
00168                 virtual returnValue getDataDeclarations(        ExportStatementBlock& declarations,
00169                                                                                                         ExportStruct dataStruct = ACADO_ANY
00170                                                                                                         ) const;
00171 
00172 
00179                 virtual returnValue getFunctionDeclarations(    ExportStatementBlock& declarations
00180                                                                                                                 ) const;
00181 
00182 
00183 
00190                 virtual returnValue getCode(    ExportStatementBlock& code
00191                                                                                 );
00192 
00193 
00194         protected:
00195                 
00196                 
00205                 returnValue getCRSIndex( uint output, ExportIndex row, ExportIndex col );
00206 
00207 
00212                 returnValue initializeDDMatrix( );
00213                 
00214                 
00220                 returnValue initializeCoefficients( );
00221                 
00222                 
00234                 DVector computeCombinations( const DVector& cVec, uint index, uint numEls );
00235                 
00236                 
00243                 DVector evaluatePolynomial( double time );
00244                 
00245                 
00252                 DVector evaluateDerivedPolynomial( double time );
00253 
00254 
00264                 returnValue evaluatePolynomial( ExportStatementBlock& block, 
00265                                                                                 const ExportVariable& variable, 
00266                                                                                 const ExportVariable& grid, 
00267                                                                                 const std::string& h );
00268 
00269 
00278                 returnValue evaluateDerivedPolynomial( ExportStatementBlock& block,
00279                                                                                 const ExportVariable& variable,
00280                                                                                 const ExportVariable& grid );
00281                 
00282                 
00289                 DMatrix evaluatePolynomial( uint index );
00290 
00291 
00298                 DMatrix evaluateDerivedPolynomial( uint index );
00299 
00300 
00307                 DVector divideMeasurements( uint index );
00308 
00309 
00316                 virtual returnValue prepareInputSystem( ExportStatementBlock& code );
00317 
00318 
00325                 virtual returnValue prepareOutputSystem( ExportStatementBlock& code );
00326 
00327 
00335                 virtual DMatrix formMatrix( const DMatrix& mass, const DMatrix& jacobian );
00336 
00337 
00347                 virtual returnValue solveInputSystem(   ExportStatementBlock* block,
00348                                                                                 const ExportIndex& index1,
00349                                                                                 const ExportIndex& index2,
00350                                                                                 const ExportIndex& index3,
00351                                                                                 const ExportIndex& tmp_index,
00352                                                                                 const ExportVariable& Ah );
00353 
00354 
00363                 virtual returnValue solveImplicitSystem(        ExportStatementBlock* block,
00364                                                                                         const ExportIndex& index1,
00365                                                                                         const ExportIndex& index2,
00366                                                                                         const ExportIndex& index3,
00367                                                                                         const ExportIndex& tmp_index,
00368                                                                                         const ExportVariable& Ah,
00369                                                                                         const ExportVariable& C,
00370                                                                                         const ExportVariable& det,
00371                                                                                         bool DERIVATIVES = false );
00372 
00373 
00382                 virtual returnValue solveOutputSystem(  ExportStatementBlock* block,
00383                                                                                 const ExportIndex& index1,
00384                                                                                 const ExportIndex& index2,
00385                                                                                 const ExportIndex& index3,
00386                                                                                 const ExportIndex& tmp_index,
00387                                                                                 const ExportVariable& Ah,
00388                                                                                 bool DERIVATIVES = false );
00389 
00390 
00399                 virtual returnValue evaluateStatesImplicitSystem(       ExportStatementBlock* block,
00400                                                                                         const ExportVariable& Ah,
00401                                                                                         const ExportVariable& C,
00402                                                                                         const ExportIndex& stage,
00403                                                                                         const ExportIndex& i,
00404                                                                                         const ExportIndex& j );
00405 
00406 
00415                 returnValue evaluateStatesOutputSystem(         ExportStatementBlock* block,
00416                                                                                                         const ExportVariable& Ah,
00417                                                                                                         const ExportIndex& stage );
00418 
00419 
00427                 virtual returnValue evaluateRhsImplicitSystem(  ExportStatementBlock* block,
00428                                                                                                                 const ExportIndex& stage );
00429 
00430 
00442                 virtual returnValue evaluateMatrix(     ExportStatementBlock* block,
00443                                                                                 const ExportIndex& index1,
00444                                                                                 const ExportIndex& index2,
00445                                                                                 const ExportIndex& tmp_index,
00446                                                                                 const ExportVariable& Ah,
00447                                                                                 const ExportVariable& C,
00448                                                                                 bool evaluateB,
00449                                                                                 bool DERIVATIVES );
00450 
00451 
00458                 returnValue prepareOutputEvaluation(    ExportStatementBlock& code );
00459 
00460 
00470                 returnValue generateOutput(     ExportStatementBlock* block,
00471                                                                                 const ExportIndex& index0,
00472                                                                                 const ExportIndex& index1,
00473                                                                                 const ExportIndex& tmp_index1,
00474                                                                                 const ExportIndex& tmp_index2,
00475                                                                                 const ExportVariable& tmp_meas,
00476                                                                                 const ExportVariable& time_tmp,
00477                                                                                 const uint directions );
00478 
00479 
00486                 virtual returnValue copy(       const ImplicitRungeKuttaExport& arg
00487                                                         );
00488                 
00489                 
00494                 uint getNumIts() const;
00495                 
00496                 
00501         uint getNumItsInit() const;
00502 
00503 
00508                 ExportVariable getAuxVariable() const;
00509 
00510 
00511     protected:
00512     
00513                 bool REUSE;                                             
00514                 bool CONTINUOUS_OUTPUT;                 
00516                 uint numIts;                                                    
00517                 uint numItsInit;                                                
00519                 uint NDX2;
00520                 uint NVARS2;
00521 
00522                 uint NVARS3;
00523 
00524                 ExportLinearSolver* solver;                             
00526                 DMatrix DD;                                                             
00527                 DMatrix coeffs;                                                 
00529                 DVector numDX_output;
00530                 DVector numXA_output;
00531                 DVector numVARS_output;
00532 
00533         
00534         // DEFINITION OF THE EXPORTVARIABLES
00535                 ExportVariable  rk_rhsOutputTemp;               
00536                 ExportVariable  rk_diffsOutputTemp;             
00537                 ExportVariable  rk_outH;                                
00538                 ExportVariable  rk_out;                                 
00539                 ExportVariable  polynEvalVar;                   
00541                 ExportVariable stepsH;                                  
00543                 std::vector<ExportVariable> gridVariables;      
00544                 std::vector<uint> totalMeas;                            
00546                 std::vector<ExportVariable> rk_outputs;                 
00547                 std::vector<ExportVariable> polynVariables;             
00548                 std::vector<ExportVariable> polynDerVariables;  
00549                 std::vector<ExportVariable> numMeasVariables;   
00550                 std::vector<ExportIndex> numMeas;                               
00552                 ExportVariable  rk_mat1;
00553                 ExportVariable  rk_dk1;
00554 
00555                 ExportVariable  rk_A;                                   
00556                 ExportVariable  rk_b;                                   
00557                 ExportVariable  rk_auxSolver;                   
00558                 ExportVariable  rk_rhsTemp;                             
00560                 ExportAcadoFunction lin_output;
00561                 ExportVariable  rk_mat3;
00562                 ExportVariable  rk_dk3;
00563                 ExportVariable  rk_diffsTemp3;
00564 
00565                 ExportVariable  rk_diffK;
00566                 ExportVariable  debug_mat;
00567 
00568 };
00569 
00570 
00571 CLOSE_NAMESPACE_ACADO
00572 
00573 
00574 #include <acado/code_generation/integrators/irk_forward_export.hpp>
00575 #include <acado/code_generation/integrators/irk_export.ipp>
00576 
00577 
00578 #endif  // ACADO_TOOLKIT_IRK_EXPORT_HPP
00579 
00580 // end of file.


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