irk_export.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 
35 #ifndef ACADO_TOOLKIT_IRK_EXPORT_HPP
36 #define ACADO_TOOLKIT_IRK_EXPORT_HPP
37 
40 
41 
43 
44 
56 {
57  //
58  // PUBLIC MEMBER FUNCTIONS:
59  //
60 
61  public:
62 
68  ImplicitRungeKuttaExport( UserInteraction* _userInteraction = 0,
69  const std::string& _commonHeaderName = ""
70  );
71 
77  );
78 
81  virtual ~ImplicitRungeKuttaExport( );
82 
83 
89  );
90 
91 
96  virtual returnValue setup( );
97 
98 
100  returnValue setEigenvalues( const DMatrix& _eig );
101 
103  returnValue setSimplifiedTransformations( const DMatrix& _transf1, const DMatrix& _transf2 );
104  returnValue setSimplifiedTransformations( const DMatrix& _transf1, const DMatrix& _transf2, const DMatrix& _transf1_T, const DMatrix& _transf2_T );
105 
107  returnValue setSingleTransformations( const double _tau, const DVector& _low_tria, const DMatrix& _transf1, const DMatrix& _transf2 );
108  returnValue setSingleTransformations( const double _tau, const DVector& _low_tria, const DMatrix& _transf1, const DMatrix& _transf2, const DMatrix& _transf1_T, const DMatrix& _transf2_T );
109 
110 
118 
119 
128  returnValue setModel( const std::string& _rhs, const std::string& _diffs_rhs );
129 
130 
138  virtual returnValue setupOutput( const std::vector<Grid> outputGrids_,
139  const std::vector<Expression> rhs );
140 
141 
151  virtual returnValue setupOutput( const std::vector<Grid> outputGrids_,
152  const std::vector<std::string> _outputNames,
153  const std::vector<std::string> _diffs_outputNames,
154  const std::vector<uint> _dims_output );
155 
156 
167  virtual returnValue setupOutput( const std::vector<Grid> outputGrids_,
168  const std::vector<std::string> _outputNames,
169  const std::vector<std::string> _diffs_outputNames,
170  const std::vector<uint> _dims_output,
171  const std::vector<DMatrix> _outputDependencies );
172 
173 
181  ExportStruct dataStruct = ACADO_ANY
182  ) const;
183 
184 
192  ) const;
193 
194 
195 
203  );
204 
205 
206  protected:
207 
208 
214 
215 
222 
223 
235  DVector computeCombinations( const DVector& cVec, uint index, uint numEls );
236 
237 
244  DVector evaluatePolynomial( double time );
245 
246 
253  DVector evaluateDerivedPolynomial( double time );
254 
255 
266  const ExportVariable& variable,
267  const ExportVariable& grid,
268  const std::string& h );
269 
270 
280  const ExportVariable& variable,
281  const ExportVariable& grid );
282 
283 
291 
292 
300 
301 
309 
310 
318 
319 
327 
328 
336  virtual DMatrix formMatrix( const DMatrix& mass, const DMatrix& jacobian );
337 
338 
349  const ExportIndex& index1,
350  const ExportIndex& index2,
351  const ExportIndex& index3,
352  const ExportIndex& tmp_index,
353  const ExportVariable& Ah );
354 
355 
365  const ExportIndex& index1,
366  const ExportIndex& index2,
367  const ExportIndex& index3,
368  const ExportIndex& tmp_index,
369  const ExportIndex& k_index,
370  const ExportVariable& Ah,
371  const ExportVariable& C,
372  const ExportVariable& det,
373  bool DERIVATIVES = false );
374 
375 
385  const ExportIndex& index1,
386  const ExportIndex& index2,
387  const ExportIndex& index3,
388  const ExportIndex& tmp_index,
389  const ExportVariable& Ah,
390  bool DERIVATIVES = false );
391 
392 
402  const ExportIndex& k_index,
403  const ExportVariable& Ah,
404  const ExportVariable& C,
405  const ExportIndex& stage,
406  const ExportIndex& i,
407  const ExportIndex& tmp_index );
408 
409 
419  const ExportVariable& Ah,
420  const ExportIndex& stage );
421 
422 
431  const ExportIndex& k_index,
432  const ExportIndex& stage );
433 
434 
447  const ExportIndex& index1,
448  const ExportIndex& index2,
449  const ExportIndex& tmp_index,
450  const ExportIndex& k_index,
451  const ExportVariable& _rk_A,
452  const ExportVariable& Ah,
453  const ExportVariable& C,
454  bool evaluateB,
455  bool DERIVATIVES );
456 
457 
465 
466 
477  const ExportIndex& index0,
478  const ExportIndex& index1,
479  const ExportIndex& tmp_index1,
480  const ExportIndex& tmp_index2,
481  const ExportVariable& tmp_meas,
482  const ExportVariable& time_tmp,
483  const uint directions );
484 
485 
492  virtual returnValue copy( const ImplicitRungeKuttaExport& arg
493  );
494 
495 
500  uint getNumIts() const;
501 
502 
507  uint getNumItsInit() const;
508 
509 
514  virtual ExportVariable getAuxVariable() const;
515 
516 
517  protected:
518 
519  bool REUSE;
527 
529 
538 
539 
540  // DEFINITION OF THE EXPORTVARIABLES
549  std::vector<ExportVariable> gridVariables;
550  std::vector<uint> totalMeas;
552  std::vector<ExportVariable> rk_outputs;
553  std::vector<ExportVariable> polynVariables;
554  std::vector<ExportVariable> polynDerVariables;
555  std::vector<ExportVariable> numMeasVariables;
556  std::vector<ExportIndex> numMeas;
560 
570 
573 
579 
580  double tau;
584 
587 
588 };
589 
590 
592 
593 
601 #include <acado/code_generation/integrators/irk_export.ipp>
602 
603 
604 #endif // ACADO_TOOLKIT_IRK_EXPORT_HPP
605 
606 // end of file.
DVector computeCombinations(const DVector &cVec, uint index, uint numEls)
Definition: irk_export.cpp:923
ExportVariable debug_mat
Definition: irk_export.hpp:572
ExportVariable rk_diffK
Definition: irk_export.hpp:571
DVector evaluatePolynomial(double time)
Definition: irk_export.cpp:965
returnValue initializeDDMatrix()
Definition: irk_export.cpp:864
virtual returnValue setupOutput(const std::vector< Grid > outputGrids_, const std::vector< Expression > rhs)
std::vector< ExportVariable > gridVariables
Definition: irk_export.hpp:549
returnValue setSimplifiedTransformations(const DMatrix &_transf1, const DMatrix &_transf2)
Allows to export a tailored Runge-Kutta integrator for fast model predictive control.
Definition: rk_export.hpp:54
std::vector< ExportVariable > polynVariables
Definition: irk_export.hpp:553
Allows to export code of an ACADO function.
virtual returnValue evaluateRhsImplicitSystem(ExportStatementBlock *block, const ExportIndex &k_index, const ExportIndex &stage)
Definition: irk_export.cpp:728
Allows to pass back messages to the calling function.
returnValue initializeCoefficients()
Definition: irk_export.cpp:883
ExportLinearSolver * solver
Definition: irk_export.hpp:530
virtual ~ImplicitRungeKuttaExport()
Definition: irk_export.cpp:91
Block< Derived > block(Index startRow, Index startCol, Index blockRows, Index blockCols)
Definition: BlockMethods.h:56
ImplicitRungeKuttaExport(UserInteraction *_userInteraction=0, const std::string &_commonHeaderName="")
Definition: irk_export.cpp:44
BEGIN_NAMESPACE_ACADO typedef unsigned int uint
Definition: acado_types.hpp:42
virtual returnValue prepareInputSystem(ExportStatementBlock &code)
Definition: irk_export.cpp:521
virtual returnValue evaluateStatesImplicitSystem(ExportStatementBlock *block, const ExportIndex &k_index, const ExportVariable &Ah, const ExportVariable &C, const ExportIndex &stage, const ExportIndex &i, const ExportIndex &tmp_index)
Definition: irk_export.cpp:677
ExportVariable rk_mat1
Definition: irk_export.hpp:558
virtual returnValue solveImplicitSystem(ExportStatementBlock *block, const ExportIndex &index1, const ExportIndex &index2, const ExportIndex &index3, const ExportIndex &tmp_index, const ExportIndex &k_index, const ExportVariable &Ah, const ExportVariable &C, const ExportVariable &det, bool DERIVATIVES=false)
Definition: irk_export.cpp:603
#define CLOSE_NAMESPACE_ACADO
ExportVariable rk_rhsOutputTemp
Definition: irk_export.hpp:541
returnValue setSingleTransformations(const double _tau, const DVector &_low_tria, const DMatrix &_transf1, const DMatrix &_transf2)
Defines a scalar-valued index variable to be used for exporting code.
virtual returnValue copy(const ImplicitRungeKuttaExport &arg)
std::vector< uint > totalMeas
Definition: irk_export.hpp:550
Base class for all variables within the symbolic expressions family.
Definition: expression.hpp:56
Allows to export a tailored implicit Runge-Kutta integrator for fast model predictive control...
Definition: irk_export.hpp:55
Expression jacobian(const Expression &arg1, const Expression &arg2)
virtual returnValue evaluateMatrix(ExportStatementBlock *block, const ExportIndex &index1, const ExportIndex &index2, const ExportIndex &tmp_index, const ExportIndex &k_index, const ExportVariable &_rk_A, const ExportVariable &Ah, const ExportVariable &C, bool evaluateB, bool DERIVATIVES)
Definition: irk_export.cpp:747
ExportStruct
std::vector< ExportVariable > numMeasVariables
Definition: irk_export.hpp:555
DVector evaluateDerivedPolynomial(double time)
returnValue setModel(const std::string &_rhs, const std::string &_diffs_rhs)
Definition: irk_export.cpp:159
uint getNumItsInit() const
ExportVariable rk_auxSolver
Definition: irk_export.hpp:563
virtual returnValue solveOutputSystem(ExportStatementBlock *block, const ExportIndex &index1, const ExportIndex &index2, const ExportIndex &index3, const ExportIndex &tmp_index, const ExportVariable &Ah, bool DERIVATIVES=false)
Definition: irk_export.cpp:653
ExportAcadoFunction lin_output
Definition: irk_export.hpp:566
Encapsulates all user interaction for setting options, logging data and plotting results.
ExportVariable rk_diffsOutputTemp
Definition: irk_export.hpp:542
virtual DMatrix formMatrix(const DMatrix &mass, const DMatrix &jacobian)
Definition: irk_export.cpp:549
virtual returnValue getFunctionDeclarations(ExportStatementBlock &declarations) const
Definition: irk_export.cpp:244
virtual returnValue getDataDeclarations(ExportStatementBlock &declarations, ExportStruct dataStruct=ACADO_ANY) const
Definition: irk_export.cpp:200
returnValue evaluateStatesOutputSystem(ExportStatementBlock *block, const ExportVariable &Ah, const ExportIndex &stage)
Definition: irk_export.cpp:705
std::vector< ExportVariable > polynDerVariables
Definition: irk_export.hpp:554
returnValue generateOutput(ExportStatementBlock *block, const ExportIndex &index0, const ExportIndex &index1, const ExportIndex &tmp_index1, const ExportIndex &tmp_index2, const ExportVariable &tmp_meas, const ExportVariable &time_tmp, const uint directions)
Definition: irk_export.cpp:791
ExportVariable rk_mat3
Definition: irk_export.hpp:567
ImplicitRungeKuttaExport & operator=(const ImplicitRungeKuttaExport &arg)
Definition: irk_export.cpp:101
returnValue prepareOutputEvaluation(ExportStatementBlock &code)
returnValue setEigenvalues(const DMatrix &_eig)
std::vector< ExportVariable > rk_outputs
Definition: irk_export.hpp:552
#define BEGIN_NAMESPACE_ACADO
ExportVariable rk_rhsTemp
Definition: irk_export.hpp:564
virtual returnValue prepareOutputSystem(ExportStatementBlock &code)
Definition: irk_export.cpp:535
virtual ExportVariable getAuxVariable() const
Definition: irk_export.cpp:171
Allows to export automatically generated algorithms for solving linear systems of specific dimensions...
ExportVariable rk_diffsTemp3
Definition: irk_export.hpp:569
std::vector< ExportIndex > numMeas
Definition: irk_export.hpp:556
virtual returnValue setDifferentialEquation(const Expression &rhs)
Definition: irk_export.cpp:112
DVector divideMeasurements(uint index)
ExportVariable polynEvalVar
Definition: irk_export.hpp:545
ExportVariable rk_outH
Definition: irk_export.hpp:543
Allows to export code for a block of statements.
virtual returnValue solveInputSystem(ExportStatementBlock *block, const ExportIndex &index1, const ExportIndex &index2, const ExportIndex &index3, const ExportIndex &tmp_index, const ExportVariable &Ah)
Definition: irk_export.cpp:576
virtual returnValue getCode(ExportStatementBlock &code)
Definition: irk_export.cpp:257
Defines a matrix-valued variable to be used for exporting code.
ExportAcadoFunction rhs
virtual returnValue setup()


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