function_evaluation_tree.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_FUNCTION_EVALUATION_TREE_HPP
35 #define ACADO_TOOLKIT_FUNCTION_EVALUATION_TREE_HPP
36 
40 
42 
54 {
55 
56 //
57 // PUBLIC MEMBER FUNCTIONS:
58 //
59 public:
60 
63 
66 
68  virtual ~FunctionEvaluationTree( );
69 
72 
74  virtual returnValue operator<<( const Expression& arg );
75 
76 
80  virtual int getDim () const;
81 
82 
87  virtual int getN () const;
88 
89 
93  virtual int getNX () const;
94 
98  virtual int getNXA () const;
99 
104  virtual int getNDX () const;
105 
106 
110  virtual int getNU () const;
111 
115  virtual int getNUI () const;
116 
120  virtual int getNP () const;
121 
125  virtual int getNPI () const;
126 
130  virtual int getNW () const;
131 
135  virtual int getNT () const;
136 
138  virtual int getNOD () const;
139 
140 
145  virtual int index( VariableType variableType_, int index_ ) const;
146 
147 
152  virtual double scale( VariableType variableType_, int index_ ) const;
153 
154 
158  virtual int getNumberOfVariables() const;
159 
160 
164  virtual Operator* getExpression( uint componentIdx
165  ) const;
166 
167 
172  virtual returnValue evaluate( double *x ,
173  double *result );
174 
175 
176 
178  template <typename T> returnValue evaluate( Tmatrix<T> *x, Tmatrix<T> *result );
179 
180 
181 
188  virtual returnValue evaluate( double *x ,
189  double *result ,
190  PrintLevel printL );
191 
192 
193 
194 
201  virtual returnValue evaluate( int number ,
202  double *x ,
203  double *result );
204 
205 
206 
213 
214 
215 
220  virtual FunctionEvaluationTree substitute( VariableType variableType_,
221  int index_ ,
222  double sub_ );
223 
224 
231  virtual NeutralElement isOneOrZero();
232 
233 
234 
241  virtual BooleanType isDependingOn( const Expression &variable );
242 
243 
251  virtual BooleanType isLinearIn( const Expression &variable );
252 
253 
260  virtual BooleanType isPolynomialIn( const Expression &variable );
261 
262 
269  virtual BooleanType isRationalIn( const Expression &variable );
270 
271 
279 
280 
281 
289  virtual CurvatureType getCurvature( );
290 
291 
292 
297  virtual returnValue AD_forward( double *x ,
299  double *seed ,
300  double *f ,
302  double *df );
304 
305 
306 
313  virtual returnValue AD_forward( int number ,
314  double *seed ,
315  double *df );
317 
318 
319 
327  virtual returnValue AD_forward( int number ,
328  double *x ,
330  double *seed ,
331  double *f ,
333  double *df );
335 
336 
337  // IMPORTANT REMARK FOR AD_BACKWARD: run evaluate first to define
338  // the point x and to compute f.
339 
344  virtual returnValue AD_backward( double *seed ,
345  double *df );
347 
348 
349 
350  // IMPORTANT REMARK FOR AD_BACKWARD: run evaluate first to define
351  // the point x and to compute f.
352 
358  virtual returnValue AD_backward( int number ,
360  double *seed ,
361  double *df );
363 
364 
365 
366 
374  virtual returnValue AD_forward2( int number ,
376  double *seed1 ,
377  double *seed2 ,
379  double *df ,
381  double *ddf );
383 
384 
385 
386  // IMPORTANT REMARK FOR AD_BACKWARD2: run AD_forward first to define
387  // the point x and to compute f and df.
388 
394  virtual returnValue AD_backward2( int number ,
396  double *seed1 ,
397  double *seed2 ,
398  double *df ,
400  double *ddf );
402 
403 
412  returnValue C_print( std::ostream& stream = std::cout,
413  const char *fcnName = "ACADOfcn",
414  const char *realString = "double"
415  ) const;
416 
417  returnValue exportForwardDeclarations( std::ostream& stream = std::cout,
418  const char *fcnName = "ACADOfcn",
419  const char *realString = "double"
420  ) const;
421 
422  returnValue exportCode( std::ostream& stream = std::cout,
423  const char *fcnName = "ACADOfcn",
424  const char *realString = "double",
425  uint _numX = 0,
426  uint _numXA = 0,
427  uint _numU = 0,
428  uint _numP = 0,
429  uint _numDX = 0,
430  uint _numOD = 0,
431  bool allocateMemory = true,
432  bool staticMemory = false
433  ) const;
434 
439  virtual returnValue clearBuffer();
440 
441 
447  virtual returnValue makeImplicit();
448  virtual returnValue makeImplicit( int dim_ );
449 
450 
455  virtual BooleanType isSymbolic() const;
456 
457 
459  virtual returnValue setScale( double *scale_ );
460 
461  virtual returnValue getExpression( Expression& expression ) const;
462 
463  returnValue setGlobalExportVariableName(const std::string& _name);
464 
465  std::string getGlobalExportVariableName() const;
466 
467  unsigned getGlobalExportVariableSize() const;
468 
469  //
470  // DATA MEMBERS:
471  //
472 protected:
473 
474  Operator **f ;
476  int *lhs_comp ;
478  int dim ;
479  int n ;
482 
485 };
486 
487 
489  Tmatrix<T> *result ){
490 
491  int run1;
492 
494 
495  for( run1 = 0; run1 < n; run1++ ){
496  sub[run1]->evaluate(&y);
497  x->operator()(indexList->index(VT_INTERMEDIATE_STATE,lhs_comp[run1])) = y.res;
498  }
499 
500  for( run1 = 0; run1 < dim; run1++ ){
501  f[run1]->evaluate(&y);
502  result->operator()(run1) = y.res;
503  }
504 
505  return SUCCESSFUL_RETURN;
506 }
507 
508 
509 
511 
512 
513 
514 #include <acado/function/function_evaluation_tree.ipp>
515 
516 
517 #endif // ACADO_TOOLKIT_FUNCTION_HPP
518 
519 // end of file.
Implements a templated dense matrix class.
Definition: t_matrix.hpp:53
virtual returnValue AD_backward2(int number, double *seed1, double *seed2, double *df, double *ddf)
Abstract base class for all scalar-valued symbolic operators.
Definition: operator.hpp:60
virtual int getNumberOfVariables() const
virtual returnValue AD_forward(double *x, double *seed, double *f, double *df)
virtual returnValue AD_forward2(int number, double *seed1, double *seed2, double *df, double *ddf)
FunctionEvaluationTree * differentiate(int index)
Allows to pass back messages to the calling function.
returnValue exportForwardDeclarations(std::ostream &stream=std::cout, const char *fcnName="ACADOfcn", const char *realString="double") const
BEGIN_NAMESPACE_ACADO typedef unsigned int uint
Definition: acado_types.hpp:42
returnValue C_print(std::ostream &stream=std::cout, const char *fcnName="ACADOfcn", const char *realString="double") const
int index(VariableType variableType_, int index_) const
unsigned getGlobalExportVariableSize() const
virtual returnValue AD_backward(double *seed, double *df)
#define CLOSE_NAMESPACE_ACADO
virtual returnValue operator<<(const Expression &arg)
Manages the indices of SymbolicVariables.
VariableType
Definition: acado_types.hpp:95
virtual int getDim() const
virtual int index(VariableType variableType_, int index_) const
Base class for all variables within the symbolic expressions family.
Definition: expression.hpp:56
virtual MonotonicityType getMonotonicity()
virtual Operator * getExpression(uint componentIdx) const
virtual returnValue evaluate(double *x, double *result)
virtual NeutralElement isOneOrZero()
virtual BooleanType isRationalIn(const Expression &variable)
virtual int getN() const
virtual BooleanType isDependingOn(const Expression &variable)
returnValue exportCode(std::ostream &stream=std::cout, const char *fcnName="ACADOfcn", const char *realString="double", uint _numX=0, uint _numXA=0, uint _numU=0, uint _numP=0, uint _numDX=0, uint _numOD=0, bool allocateMemory=true, bool staticMemory=false) const
std::string getGlobalExportVariableName() const
PrintLevel
virtual double scale(VariableType variableType_, int index_) const
virtual BooleanType isSymbolic() const
virtual returnValue evaluate(int number, double *x, double *result)=0
NeutralElement
Definition: acado_types.hpp:64
Organizes the evaluation of the function tree.
MonotonicityType
virtual FunctionEvaluationTree substitute(VariableType variableType_, int index_, double sub_)
CurvatureType
Templated class for operator evaluation.
FunctionEvaluationTree & operator=(const FunctionEvaluationTree &arg)
#define BEGIN_NAMESPACE_ACADO
returnValue setGlobalExportVariableName(const std::string &_name)
virtual returnValue setScale(double *scale_)
virtual CurvatureType getCurvature()
virtual BooleanType isLinearIn(const Expression &variable)
virtual returnValue makeImplicit()
virtual BooleanType isPolynomialIn(const Expression &variable)


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