lifted_erk_export.cpp
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 
36 
37 using namespace std;
38 
40 
41 //
42 // PUBLIC MEMBER FUNCTIONS:
43 //
44 
46  const std::string& _commonHeaderName
47  ) : ExplicitRungeKuttaExport( _userInteraction,_commonHeaderName )
48 {
49  solver = 0;
50 }
51 
52 
54  ) : ExplicitRungeKuttaExport( arg )
55 {
56  solver = arg.solver;
57 }
58 
59 
61 {
62  if ( solver )
63  delete solver;
64  solver = 0;
65 
66  clear( );
67 }
68 
69 
70 
72 {
73  int sensGen;
74  get( DYNAMIC_SENSITIVITY,sensGen );
75 
76  int liftMode = 1;
77  // liftMode == 1 --> EXACT LIFTING
78  // liftMode == 2 --> INEXACT LIFTING
79  if( (ExportSensitivityType)sensGen == INEXACT ) liftMode = 2;
80 
81  OnlineData dummy0;
82  Control dummy1;
83  DifferentialState dummy2;
84  AlgebraicState dummy3;
86  dummy0.clearStaticCounters();
87  dummy1.clearStaticCounters();
88  dummy2.clearStaticCounters();
89  dummy3.clearStaticCounters();
90  dummy4.clearStaticCounters();
91 
92  x = DifferentialState("", NX, 1);
94  z = AlgebraicState("", NXA, 1);
95  u = Control("", NU, 1);
96  od = OnlineData("", NOD, 1);
97 
98  if( NDX > 0 && NDX != NX ) {
100  }
101  if( rhs_.getNumRows() != (NX+NXA) ) {
102  return ACADOERROR( RET_INVALID_OPTION );
103  }
104 
105  // collect the algebraic equations:
106  Expression g_, rhs2_;
107  if( NXA == 0 ) return ACADOERRORTEXT( RET_INVALID_OPTION, "Only DAE systems supported for the lifted ERK integrator!");
108  else {
109  g_ = rhs_.getRows(NX,NX+NXA);
110  rhs2_ = rhs_.getRows(0,NX);
111  }
112 
113  DifferentialEquation f, f_ODE, g;
114  // add usual ODE
115  f_ODE << rhs2_;
116  if( f_ODE.getNDX() > 0 ) {
117  return ACADOERRORTEXT( RET_INVALID_OPTION, "No implicit systems supported when using an explicit integration method!");
118  }
119 
120  if( (ExportSensitivityType)sensGen == FORWARD || (ExportSensitivityType)sensGen == INEXACT ) {
121  DifferentialState Gx("", NX,NX), Gu("", NX,NU);
122  AlgebraicState deltaZ("", NXA,1), Zx("", NXA,NX), Zu("", NXA,NU);
123  // no free parameters yet!
124  // DifferentialState Gp(NX,NP);
125 
126  f << rhs2_ + multipleForwardDerivative( rhs2_, z, deltaZ );
127  /* if ( f.getDim() != f.getNX() )
128  return ACADOERROR( RET_ILLFORMED_ODE );*/
129 
130  // add VDE for differential states
131  f << multipleForwardDerivative( rhs2_, x, Gx ) + multipleForwardDerivative( rhs2_, z, Zx );
132  /* if ( f.getDim() != f.getNX() )
133  return ACADOERROR( RET_ILLFORMED_ODE );*/
134 
135 
136  // add VDE for control inputs
137  f << multipleForwardDerivative( rhs2_, x, Gu ) + multipleForwardDerivative( rhs2_, z, Zu ) + forwardDerivative( rhs2_, u );
138  // if ( f.getDim() != f.getNX() )
139  // return ACADOERROR( RET_ILLFORMED_ODE );
140 
141  // no free parameters yet!
142  // f << forwardDerivative( rhs_, x ) * Gp + forwardDerivative( rhs_, p );
143 
144  g << g_;
145  if( liftMode == 1 ) {
146  g << multipleForwardDerivative( g_, x, Gx );
147  }
148  else {
149  g << multipleForwardDerivative( g_, x, Gx ) + multipleForwardDerivative( g_, z, Zx );
150  }
151  g << forwardDerivative( g_, z );
152  if( liftMode == 1 ) {
153  g << forwardDerivative( g_, u ) + multipleForwardDerivative( g_, x, Gu );
154  }
155  else {
156  g << forwardDerivative( g_, u ) + multipleForwardDerivative( g_, x, Gu ) + multipleForwardDerivative( g_, z, Zu );
157  }
158  }
159  else {
160  return ACADOERRORTEXT( RET_NOT_YET_IMPLEMENTED, "The lifted ERK integrator is currently only implemented with forward sensitivity propagation!" );
161  }
162  if( f.getNT() > 0 ) timeDependant = true;
163 
164  return diffs_rhs.init(f, "acado_rhs_ext", NX * (1 + NX + NU), NXA * (2 + NX + NU), NU, NP, NDX, NOD)
165  & alg_rhs.init(g, "acado_alg_rhs", NX * (1 + NX + NU), NXA * (2 + NX + NU), NU, NP, NDX, NOD);
166 
167  return SUCCESSFUL_RETURN;
168 }
169 
170 
172 {
173  int useOMP;
174  get(CG_USE_OPENMP, useOMP);
175  ExportStruct structWspace;
176  structWspace = useOMP ? ACADO_LOCAL : ACADO_WORKSPACE;
177 
178  int sensGen;
179  get( DYNAMIC_SENSITIVITY,sensGen );
181 
182  int liftMode = 1;
183  // liftMode == 1 --> EXACT LIFTING
184  // liftMode == 2 --> INEXACT LIFTING
185  if( (ExportSensitivityType)sensGen == INEXACT ) liftMode = 2;
186 
187  bool DERIVATIVES = ((ExportSensitivityType)sensGen != NO_SENSITIVITY);
188 
189  LOG( LVL_DEBUG ) << "Preparing to export ExplicitRungeKuttaExport... " << endl;
190 
191  // setup linear solver:
192  int solverType;
194 
195  if ( solver )
196  delete solver;
197  solver = 0;
198 
199  switch( (LinearAlgebraSolver) solverType ) {
200  case GAUSS_LU:
202  solver->init( NXA, NX+NU+1 );
203  solver->setReuse( true ); // IFTR method
204  solver->setup();
206  break;
207  default:
208  return ACADOERROR( RET_INVALID_OPTION );
209  }
210  rk_A = ExportVariable( "rk_A", NXA, NXA, REAL, structWspace );
211  rk_b = ExportVariable( "rk_b", NXA, 1+NX+NU, REAL, structWspace );
212 
213  // export RK scheme
214  uint rhsDim = NX*(NX+NU+1);
215  uint zDim = NXA*(NX+NU+1);
216  inputDim = (NX+NXA)*(NX+NU+1) + NU + NOD;
217  if( !DERIVATIVES ) return ACADOERROR( RET_INVALID_OPTION );
218  const uint rkOrder = getNumStages();
219 
220  double h = (grid.getLastTime() - grid.getFirstTime())/grid.getNumIntervals();
221 
222  ExportVariable Ah ( "A*h", DMatrix( AA )*=h );
223  ExportVariable b4h( "b4*h", DMatrix( bb )*=h );
224 
225  rk_index = ExportVariable( "rk_index", 1, 1, INT, ACADO_LOCAL, true );
226  rk_eta = ExportVariable( "rk_eta", 1, inputDim );
227 
228  rk_ttt.setup( "rk_ttt", 1, 1, REAL, structWspace, true );
229  uint timeDep = 0;
230  if( timeDependant ) timeDep = 1;
231 
232  rk_xxx.setup("rk_xxx", 1, inputDim+NXA+timeDep, REAL, structWspace);
233  rk_kkk.setup("rk_kkk", rkOrder, rhsDim, REAL, structWspace);
234 
235  rk_zzz.setup("rk_zzz", getN()*grid.getNumIntervals()*rkOrder, NXA, REAL, structWspace);
236  rk_zTemp.setup("rk_zTemp", 1, NXA*(1+NX+NXA+NU), REAL, structWspace);
237 // if( liftMode == 1 ) {
238  rk_diffZ.setup("rk_diffZ", getN()*grid.getNumIntervals()*rkOrder*NXA, NX+NU, REAL, structWspace);
239  rk_delta.setup( "rk_delta", 1, NX+NU, REAL, ACADO_WORKSPACE );
240  rk_prev.setup( "rk_prev", getN(), NX+NU, REAL, ACADO_WORKSPACE );
241 // }
242 
243  if ( useOMP )
244  {
245  ExportVariable auxVar;
246 
247  auxVar = getAuxVariable();
248  auxVar.setName( "odeAuxVar" );
249  auxVar.setDataStruct( ACADO_LOCAL );
250  rhs.setGlobalExportVariable( auxVar );
252  }
253 
254  ExportIndex run( "run1" );
255  ExportIndex shoot_index( "shoot_index" );
256  ExportIndex k_index( "k_index" );
257 
258  // setup INTEGRATE function
259  integrate = ExportFunction( "integrate", rk_eta, rk_index ); // you need the rk_index for LIFTING !
261  rk_eta.setDoc( "Working array to pass the input values and return the results." );
262  reset_int.setDoc( "The internal memory of the integrator can be reset." );
263  rk_index.setDoc( "Number of the shooting interval." );
264  error_code.setDoc( "Status code of the integrator." );
265  integrate.doc( "Performs the integration and sensitivity propagation for one shooting interval." );
266  integrate.addIndex( run );
267  integrate.addIndex( shoot_index );
268  integrate.addIndex( k_index );
269 
270  ExportVariable det( "det", 1, 1, REAL, ACADO_LOCAL, true );
271  integrate.addDeclaration( det );
272 
273  integrate << shoot_index.getFullName() << " = " << rk_index.getFullName() << ";\n";
274 
275  ExportVariable numInt( "numInts", 1, 1, INT );
276  if( !equidistantControlGrid() ) {
277  integrate.addStatement( std::string( "int numSteps[" ) + toString( numSteps.getDim() ) + "] = {" + toString( numSteps(0) ) );
278  uint i;
279  for( i = 1; i < numSteps.getDim(); i++ ) {
280  integrate.addStatement( std::string( ", " ) + toString( numSteps(i) ) );
281  }
282  integrate.addStatement( std::string( "};\n" ) );
283  integrate.addStatement( std::string( "int " ) + numInt.getName() + " = numSteps[" + rk_index.getName() + "];\n" );
284  }
285 
287 
288  if( DERIVATIVES ) {
289  // initialize sensitivities:
290  DMatrix idX = eye<double>( NX );
291  DMatrix zeroXU = zeros<double>( NX,NU );
292  integrate.addStatement( rk_eta.getCols( NX+NXA,NXA+NX*(1+NX) ) == idX.makeVector().transpose() );
293  integrate.addStatement( rk_eta.getCols( (NX+NXA)*(1+NX),(NX+NXA)*(1+NX)+NX*NU ) == zeroXU.makeVector().transpose() );
294  }
295 
296  if( inputDim > (rhsDim+zDim) ) {
297  integrate.addStatement( rk_xxx.getCols( NXA+rhsDim+zDim,NXA+inputDim ) == rk_eta.getCols( rhsDim+zDim,inputDim ) );
298  }
299 // if( liftMode == 1 ) {
300  integrate.addStatement( rk_delta.getCols( 0,NX ) == rk_eta.getCols( 0,NX ) - rk_prev.getSubMatrix(shoot_index,shoot_index+1,0,NX) );
301  integrate.addStatement( rk_delta.getCols( NX,NX+NU ) == rk_eta.getCols( rhsDim+zDim,rhsDim+zDim+NU ) - rk_prev.getSubMatrix(shoot_index,shoot_index+1,NX,NX+NU) );
302 
303  integrate.addStatement( rk_prev.getSubMatrix(shoot_index,shoot_index+1,0,NX) == rk_eta.getCols( 0,NX ) );
304  integrate.addStatement( rk_prev.getSubMatrix(shoot_index,shoot_index+1,NX,NX+NU) == rk_eta.getCols( rhsDim+zDim,rhsDim+zDim+NU ) );
305 // }
307 
308  // integrator loop
309  ExportForLoop loop;
310  if( equidistantControlGrid() ) {
311  loop = ExportForLoop( run, 0, grid.getNumIntervals() );
312  }
313  else {
314  loop = ExportForLoop( run, 0, 1 );
315  loop.addStatement( std::string("for(") + run.getName() + " = 0; " + run.getName() + " < " + numInt.getName() + "; " + run.getName() + "++ ) {\n" );
316  }
317  loop.addStatement( k_index == (shoot_index*grid.getNumIntervals()+run) );
318 
319  for( uint run1 = 0; run1 < rkOrder; run1++ )
320  {
321  loop.addStatement( rk_xxx.getCols( 0,NX ) == rk_eta.getCols( 0,NX ) + Ah.getRow(run1)*rk_kkk.getCols( 0,NX ) );
322  loop.addStatement( rk_xxx.getCols( NX,NX*(1+NX) ) == rk_eta.getCols( NX+NXA,NXA+NX*(1+NX) ) + Ah.getRow(run1)*rk_kkk.getCols( NX,NX*(1+NX) ) );
323  loop.addStatement( rk_xxx.getCols( NX*(1+NX),rhsDim ) == rk_eta.getCols( (NX+NXA)*(1+NX),(NX+NXA)*(1+NX)+NX*NU ) + Ah.getRow(run1)*rk_kkk.getCols( NX*(1+NX),rhsDim ) );
324  if( timeDependant ) loop.addStatement( rk_xxx.getCol( NXA+inputDim ) == rk_ttt + ((double)cc(run1))/grid.getNumIntervals() );
325 
326  // update algebraic variables based on previous SQP step:
327 // if( liftMode == 1 ) {
328  loop.addStatement( rk_zzz.getRow(k_index*rkOrder+run1) += rk_delta*rk_diffZ.getRows( k_index*rkOrder*NXA+run1*NXA,k_index*rkOrder*NXA+run1*NXA+NXA ).getTranspose() );
329 // }
330 
331  // evaluate the right algebraic variables and equations:
332  loop.addStatement( rk_xxx.getCols( rhsDim,rhsDim+NXA ) == rk_zzz.getRow(k_index*rkOrder+run1) );
333  if( liftMode == 2 ) {
334  for( uint i = 0; i < NXA; i++ ) {
335  for( uint j = 0; j < NX; j++ ) {
336  loop.addStatement( rk_xxx.getCol( rhsDim+2*NXA+i*NX+j ) == rk_diffZ.getElement( k_index*rkOrder*NXA+run1*NXA+i,j ) );
337  }
338  for( uint j = 0; j < NU; j++ ) {
339  loop.addStatement( rk_xxx.getCol( rhsDim+NXA*(2+NX)+i*NU+j ) == rk_diffZ.getElement( k_index*rkOrder*NXA+run1*NXA+i,NX+j ) );
340  }
341  }
342  }
344 
345  // JACOBIAN FACTORIZATION ALGEBRAIC EQUATIONS
346  if( liftMode == 1 ) { // EXACT
347  for( uint i = 0; i < NXA; i++ ) {
348  for( uint j = 0; j < NXA; j++ ) {
349  loop.addStatement( rk_A.getElement(i,j) == rk_zTemp.getCol(NXA*(1+NX)+i*NXA+j) );
350  }
351  }
352  loop.addStatement( det.getFullName() + " = " + ExportStatement::fcnPrefix + "_" + solver->getNameSolveFunction() + "( " + rk_A.getFullName() + ", " + rk_auxSolver.getFullName() + " );\n" );
353  }
354  else { // INEXACT
355  if( run1 == 0 ) {
356  loop.addStatement( std::string("if(") + run.getName() + " == 0) {\n" );
357  for( uint i = 0; i < NXA; i++ ) {
358  for( uint j = 0; j < NXA; j++ ) {
359  loop.addStatement( rk_A.getElement(i,j) == rk_zTemp.getCol(NXA*(1+NX)+i*NXA+j) );
360  }
361  }
362  loop.addStatement( det.getFullName() + " = " + ExportStatement::fcnPrefix + "_" + solver->getNameSolveFunction() + "( " + rk_A.getFullName() + ", " + rk_auxSolver.getFullName() + " );\n" );
363  loop.addStatement( std::string("}\n") );
364  }
365  }
366  for( uint i = 0; i < NXA; i++ ) {
367  loop.addStatement( rk_b.getElement(i,0) == 0.0 - rk_zTemp.getCol(i) );
368  for( uint j = 0; j < NX; j++ ) {
369  loop.addStatement( rk_b.getElement(i,1+j) == 0.0 - rk_zTemp.getCol(NXA+i*NX+j) );
370  }
371  for( uint j = 0; j < NU; j++ ) {
372  loop.addStatement( rk_b.getElement(i,1+NX+j) == 0.0 - rk_zTemp.getCol(NXA*(1+NX+NXA)+i*NU+j) );
373  }
374  }
375 
376  // NEWTON STEP ON THE ALGEBRAIC EQUATIONS
378  loop.addStatement( rk_zzz.getRow(k_index*rkOrder+run1) += rk_b.getCol( 0 ).getTranspose() );
379  loop.addStatement( rk_xxx.getCols( rhsDim+NXA,rhsDim+2*NXA ) == rk_b.getCol( 0 ).getTranspose() );
380  for( uint i = 0; i < NXA; i++ ) {
381  for( uint j = 0; j < NX; j++ ) {
382  if( liftMode == 1 ) loop.addStatement( rk_diffZ.getElement( k_index*rkOrder*NXA+run1*NXA+i,j ) == rk_b.getElement(i,1+j) );
383  else loop.addStatement( rk_diffZ.getElement( k_index*rkOrder*NXA+run1*NXA+i,j ) += rk_b.getElement(i,1+j) );
384  loop.addStatement( rk_xxx.getCol( rhsDim+2*NXA+i*NX+j ) == rk_diffZ.getElement( k_index*rkOrder*NXA+run1*NXA+i,j ) );
385  }
386  for( uint j = 0; j < NU; j++ ) {
387  if( liftMode == 1 ) loop.addStatement( rk_diffZ.getElement( k_index*rkOrder*NXA+run1*NXA+i,NX+j ) == rk_b.getElement(i,1+NX+j) );
388  else loop.addStatement( rk_diffZ.getElement( k_index*rkOrder*NXA+run1*NXA+i,NX+j ) += rk_b.getElement(i,1+NX+j) );
389  loop.addStatement( rk_xxx.getCol( rhsDim+NXA*(2+NX)+i*NU+j ) == rk_diffZ.getElement( k_index*rkOrder*NXA+run1*NXA+i,NX+j ) );
390  }
391  }
392 
394  }
395  loop.addStatement( rk_eta.getCols( 0,NX ) += b4h^rk_kkk.getCols(0,NX) );
396  loop.addStatement( rk_eta.getCols( NX+NXA,NXA+NX*(1+NX) ) += b4h^rk_kkk.getCols(NX,NX*(1+NX)) );
397  loop.addStatement( rk_eta.getCols( (NX+NXA)*(1+NX),(NX+NXA)*(1+NX)+NX*NU ) += b4h^rk_kkk.getCols(NX*(1+NX),rhsDim) );
398  loop.addStatement( rk_ttt += DMatrix(1.0/grid.getNumIntervals()) );
399  // end of integrator loop
400 
401  if( !equidistantControlGrid() ) {
402  loop.addStatement( "}\n" );
403  // loop.unrollLoop();
404  }
405  integrate.addStatement( loop );
406 
408 
409  LOG( LVL_DEBUG ) << "done" << endl;
410 
411  return SUCCESSFUL_RETURN;
412 }
413 
414 
416  ExportStruct dataStruct
417  ) const
418 {
419  ExplicitRungeKuttaExport::getDataDeclarations( declarations, dataStruct );
420 
421  solver->getDataDeclarations( declarations,dataStruct );
422 
423  declarations.addDeclaration( rk_A,dataStruct );
424  declarations.addDeclaration( rk_b,dataStruct );
425  declarations.addDeclaration( rk_auxSolver,dataStruct );
426 
427  declarations.addDeclaration( rk_zzz,dataStruct );
428  declarations.addDeclaration( rk_zTemp,dataStruct );
429 
430  declarations.addDeclaration( rk_diffZ,dataStruct );
431  declarations.addDeclaration( rk_delta,dataStruct );
432  declarations.addDeclaration( rk_prev,dataStruct );
433 
434  return SUCCESSFUL_RETURN;
435 }
436 
437 
439  )
440 {
441  // int printLevel;
442  // get( PRINTLEVEL,printLevel );
443  //
444  // if ( (PrintLevel)printLevel >= HIGH )
445  // acadoPrintf( "--> Exporting %s... ",fileName.getName() );
446 
447  int useOMP;
448  get(CG_USE_OPENMP, useOMP);
449  if ( useOMP )
450  {
452 
453  code << "#pragma omp threadprivate( "
454  << getAuxVariable().getFullName() << ", "
455  << rk_xxx.getFullName() << ", "
456  << rk_ttt.getFullName() << ", "
457  << rk_kkk.getFullName()
458  << " )\n\n";
459  }
460 
461  int sensGen;
462  get( DYNAMIC_SENSITIVITY,sensGen );
463  if( exportRhs ) {
464  code.addFunction( rhs );
465  code.addFunction( diffs_rhs );
466  code.addFunction( alg_rhs );
467  solver->getCode( code ); // solver for the algebraic equations
468  }
469  else {
470  return ACADOERRORTEXT( RET_NOT_YET_IMPLEMENTED, "Externally defined dynamics not yet supported for the lifted ERK integrator!");
471  }
472 
473  double h = (grid.getLastTime() - grid.getFirstTime())/grid.getNumIntervals();
474  code.addComment(std::string("Fixed step size:") + toString(h));
475  code.addFunction( integrate );
476 
477 
478  // if ( (PrintLevel)printLevel >= HIGH )
479  // acadoPrintf( "done.\n" );
480 
481  return SUCCESSFUL_RETURN;
482 }
483 
484 
486 {
487  ExportVariable max;
489  if( diffs_rhs.getGlobalExportVariable().getDim() > max.getDim() ) {
491  }
492  if( alg_rhs.getGlobalExportVariable().getDim() > max.getDim() ) {
494  }
495  return max;
496 }
497 
498 
499 // PROTECTED:
500 
501 
502 
504 
505 // end of file.
#define LOG(level)
Just define a handy macro for getting the logger.
Lowest level, the debug level.
ExportVariable getAuxVariable() const
ExportVariable getRow(const ExportIndex &idx) const
uint getN() const
Allows to export a tailored explicit Runge-Kutta integrator for fast model predictive control...
Definition: erk_export.hpp:54
ExportVariable getGlobalExportVariable() const
double getFirstTime() const
Allows to export a tailored explicit Runge-Kutta integrator with a lifted Newton method to efficientl...
LinearAlgebraSolver
ExportVariable getTranspose() const
ExportVariable rk_A
LiftedERKExport(UserInteraction *_userInteraction=0, const std::string &_commonHeaderName="")
ExportVariable & setup(const std::string &_name, uint _nRows=1, uint _nCols=1, ExportType _type=REAL, ExportStruct _dataStruct=ACADO_LOCAL, bool _callItByValue=false, const std::string &_prefix=std::string())
ExportVariable rk_prev
UserInteraction * userInteraction
ExportAcadoFunction diffs_rhs
int getNDX() const
Definition: function.cpp:217
returnValue get(OptionsName name, int &value) const
Definition: options.cpp:69
ExportVariable rk_index
virtual ExportVariable getGlobalExportVariable(const uint factor) const
Allows to pass back messages to the calling function.
ExportVariable rk_kkk
Definition: rk_export.hpp:189
GenericMatrix & makeVector()
Definition: matrix.cpp:124
DifferentialState x
Expression forwardDerivative(const Expression &arg1, const Expression &arg2)
uint getNumRows() const
returnValue addComment(const std::string &_comment)
BEGIN_NAMESPACE_ACADO typedef unsigned int uint
Definition: acado_types.hpp:42
Allows to export code of a for-loop.
string toString(T const &value)
returnValue setName(const std::string &_name)
Definition: export_data.cpp:61
ExportVariable getElement(const ExportIndex &rowIdx, const ExportIndex &colIdx) const
ExportVariable rk_auxSolver
#define CLOSE_NAMESPACE_ACADO
ExportVariable rk_zTemp
ExportLinearSolver * solver
ExportVariable getSubMatrix(const ExportIndex &rowIdx1, const ExportIndex &rowIdx2, const ExportIndex &colIdx1, const ExportIndex &colIdx2) const
ExportVariable rk_delta
GenericMatrix< double > DMatrix
Definition: matrix.hpp:457
const std::string getNameDiffsRHS() const
Defines a scalar-valued index variable to be used for exporting code.
Base class for all variables within the symbolic expressions family.
Definition: expression.hpp:56
virtual returnValue setDoc(const std::string &_doc)
std::string commonHeaderName
ExportVariable rk_eta
ExportStruct
virtual ExportFunction & doc(const std::string &_doc)
static std::string fcnPrefix
ExportVariable getCols(const ExportIndex &idx1, const ExportIndex &idx2) const
Expression multipleForwardDerivative(const Expression &arg1, const Expression &arg2, const Expression &seed)
Allows to export Gaussian elimination for solving linear systems of specific dimensions.
unsigned getDim() const
Definition: vector.hpp:172
const std::string getNameSolveReuseFunction()
ExportVariable reset_int
Encapsulates all user interaction for setting options, logging data and plotting results.
Allows to export code of an arbitrary function.
ExportAcadoFunction alg_rhs
virtual uint getDim() const
returnValue setDataStruct(ExportStruct _dataStruct)
Definition: export_data.cpp:80
returnValue addStatement(const ExportStatement &_statement)
int getNT() const
Definition: function.cpp:251
ExportFunction integrate
returnValue setReuse(const bool &reuse)
std::string getFullName() const
virtual returnValue getDataDeclarations(ExportStatementBlock &declarations, ExportStruct dataStruct=ACADO_ANY) const
Definition: erk_export.cpp:290
ExportVariable rk_b
returnValue addLinebreak(uint num=1)
ExportFunction & setReturnValue(const ExportVariable &_functionReturnValue, bool _returnAsPointer=false)
virtual returnValue setDifferentialEquation(const Expression &rhs)
uint getNumIntervals() const
virtual returnValue setup()=0
returnValue setGlobalExportVariable(const ExportVariable &var)
ExportVariable rk_xxx
DifferentialStateDerivative dx
std::string getName() const
ExportVariable getRows(const ExportIndex &idx1, const ExportIndex &idx2) const
returnValue addDeclaration(const ExportVariable &_data, ExportStruct _dataStruct=ACADO_ANY)
ExportVariable rk_diffZ
double getLastTime() const
ExportVariable rk_ttt
const std::string getNameSolveFunction()
#define BEGIN_NAMESPACE_ACADO
ExportVariable error_code
returnValue clearStaticCounters()
Definition: expression.hpp:398
ExportVariable rk_zzz
returnValue addFunction(const ExportFunction &_function)
virtual returnValue getDataDeclarations(ExportStatementBlock &declarations, ExportStruct dataStruct=ACADO_ANY) const =0
virtual returnValue clear()
virtual returnValue getCode(ExportStatementBlock &code)=0
Allows to export code for a block of statements.
virtual ~LiftedERKExport()
Expression getRows(const uint &rowIdx1, const uint &rowIdx2) const
Definition: expression.cpp:548
ExportArgument getAddress(const ExportIndex &_rowIdx, const ExportIndex &_colIdx=emptyConstExportIndex) const
virtual returnValue getCode(ExportStatementBlock &code)
returnValue init(const uint newDim, const bool &reuse=true, const bool &unrolling=false)
ExportVariable getCol(const ExportIndex &idx) const
virtual returnValue getDataDeclarations(ExportStatementBlock &declarations, ExportStruct dataStruct=ACADO_ANY) const
returnValue init(const Function &_f, const std::string &_name="acadoFcn", const uint _numX=0, const uint _numXA=0, const uint _numU=0, const uint _numP=0, const uint _numDX=0, const uint _numOD=0)
ExportFunction & addIndex(const ExportIndex &_index)
#define ACADOERROR(retval)
virtual bool equidistantControlGrid() const
Defines a matrix-valued variable to be used for exporting code.
ExportAcadoFunction rhs
virtual returnValue setup()
#define ACADOERRORTEXT(retval, text)
returnValue addFunctionCall(const std::string &_fName, const ExportArgument &_argument1=emptyConstExportArgument, const ExportArgument &_argument2=emptyConstExportArgument, const ExportArgument &_argument3=emptyConstExportArgument, const ExportArgument &_argument4=emptyConstExportArgument, const ExportArgument &_argument5=emptyConstExportArgument, const ExportArgument &_argument6=emptyConstExportArgument, const ExportArgument &_argument7=emptyConstExportArgument, const ExportArgument &_argument8=emptyConstExportArgument, const ExportArgument &_argument9=emptyConstExportArgument)
Allows to setup and evaluate differential equations (ODEs and DAEs) based on SymbolicExpressions.
std::string getName() const
Definition: export_data.cpp:86


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