function_.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__HPP
35 #define ACADO_TOOLKIT_FUNCTION__HPP
36 
37 
39 
40 
42 
43 
44 class EvaluationPoint;
45 template <typename T> class TevaluationPoint;
46 
47 
59 class Function{
60 
61 //
62 // PUBLIC MEMBER FUNCTIONS:
63 //
64 
65 public:
66 
68  Function();
69 
71  Function( const Function& rhs );
72 
74  virtual ~Function( );
75 
77  Function& operator=( const Function& rhs );
78 
79 
81  Function& operator<<( const Expression& arg );
82 
84  Function& operator<<( const double &arg );
85 
87  Function& operator<<( const DVector& arg );
88 
90  Function& operator<<( const DMatrix& arg );
91 
93  ) const;
94 
95 
96  returnValue getExpression( Expression& expression ) const;
97 
98 
99  returnValue reset( );
100 
101 
105  inline int getDim () const;
106 
107 
112  inline int getN () const;
113 
117  int getN (VariableType &variableType_) const;
118 
122  int getNX () const;
123 
127  int getNXA () const;
128 
133  int getNDX () const;
134 
138  int getNU () const;
139 
143  int getNUI () const;
144 
148  int getNP () const;
149 
153  int getNPI () const;
154 
158  int getNW () const;
159 
163  int getNT () const;
164 
166  int getNOD() const;
167 
168 
173  int index( VariableType variableType_, int index_ ) const;
174 
175 
180  double scale( VariableType variableType_, int index_ ) const;
181 
182 
186  int getNumberOfVariables() const;
187 
191  Operator* getExpression( uint componentIdx
192  ) const;
193 
194 
202  DVector evaluate( const EvaluationPoint &x ,
203  const int &number = 0 );
204 
205 
214  inline DVector operator()( const EvaluationPoint &x ,
215  const int &number = 0 );
216 
217 
218 
226  template <typename T> Tmatrix<T> evaluate( const TevaluationPoint<T> &x );
227 
228 
229 
236  returnValue evaluate( int number ,
237  double *x ,
238  double *_result );
239 
240 
241 
246  returnValue substitute( VariableType variableType_,
247  int index_ ,
248  double sub_ );
249 
250 
251 
259 
260 
261 
268  BooleanType isDependingOn( const Expression &variable );
269 
270 
271 
279  BooleanType isLinearIn( const Expression &variable );
280 
281 
282 
289  BooleanType isPolynomialIn( const Expression &variable );
290 
291 
292 
293 
300  BooleanType isRationalIn( const Expression &variable );
301 
302 
303 
310 
311 
318 
321 
328 
329 
336 
337 
344 
345 
346 
355  const int &number = 0 );
356 
357 
358 
365  returnValue AD_forward( int number ,
366  double *seed ,
367  double *df );
369 
370 
371 
380  returnValue AD_backward( const DVector &seed ,
381  EvaluationPoint &df ,
382  const int &number = 0 );
383 
384 
390  returnValue AD_backward( int number ,
392  double *seed ,
393  double *df );
395 
396 
397 
405  returnValue AD_forward2( int number ,
407  double *seed1 ,
408  double *seed2 ,
410  double *df ,
412  double *ddf );
414 
415 
416 
424  returnValue AD_backward2( int number ,
426  double *seed1 ,
427  double *seed2 ,
428  double *df ,
430  double *ddf );
432 
433 
441  //returnValue jacobian(DMatrix &x,DMatrix &p=emptyMatrix,DMatrix &u=emptyMatrix,DMatrix &w=emptyMatrix);
442 
444  friend std::ostream& operator<<( std::ostream& stream, const Function &arg);
445 
456  returnValue print( std::ostream& stream,
457  const char *fcnName = "ACADOfcn",
458  const char *realString = "double"
459  ) const;
460 
461  returnValue exportForwardDeclarations( std::ostream& stream,
462  const char *fcnName = "ACADOfcn",
463  const char *realString = "double"
464  ) const;
465 
466  returnValue exportCode( std::ostream& stream,
467  const char *fcnName = "ACADOfcn",
468  const char *realString = "double",
469  uint _numX = 0,
470  uint _numXA = 0,
471  uint _numU = 0,
472  uint _numP = 0,
473  uint _numDX = 0,
474  uint _numOD = 0,
475  bool allocateMemory = true,
476  bool staticMemory = false
477  ) const;
478 
484 
485 
486 
490  returnValue setScale( double *scale_ );
491 
492 
497  inline BooleanType isSymbolic() const;
498 
499 
500  inline BooleanType ADisSupported() const;
501 
502 
503  inline returnValue setMemoryOffset( int memoryOffset_ );
504 
506  returnValue setGlobalExportVariableName(const std::string& var);
507 
509  std::string getGlobalExportVariableName( ) const;
510 
512  unsigned getGlobalExportVariableSize( ) const;
513 
514 // PROTECTED MEMBERS:
515 // ------------------
516 
517 protected:
518 
521 
522  double* result;
523 };
524 
525 
526 template <typename T> Tmatrix<T> Function::evaluate( const TevaluationPoint<T> &x ){
527 
528  Tmatrix<T> Tresult(getDim());
530  return Tresult;
531 }
532 
533 
535 
536 
537 
538 #include <acado/function/function.ipp>
539 
540 
541 #endif // ACADO_TOOLKIT_FUNCTION__HPP
542 
543 /*
544  * end of file
545  */
BooleanType isRationalIn(const Expression &variable)
Definition: function.cpp:331
std::string getGlobalExportVariableName() const
Definition: function.cpp:590
Allows to setup and evaluate a general function based on SymbolicExpressions.
Definition: function_.hpp:59
Implements a templated dense matrix class.
Definition: t_matrix.hpp:53
int getNOD() const
Definition: function.cpp:257
int getNPI() const
Definition: function.cpp:239
Abstract base class for all scalar-valued symbolic operators.
Definition: operator.hpp:60
returnValue setMemoryOffset(int memoryOffset_)
int getNDX() const
Definition: function.cpp:217
double * result
Definition: function_.hpp:522
BooleanType isSymbolic() const
Allows to pass back messages to the calling function.
DVector evaluate(const EvaluationPoint &x, const int &number=0)
Definition: function.cpp:520
int getNUI() const
Definition: function.cpp:227
Allows to setup function evaluation points.
int getNU() const
Definition: function.cpp:222
BEGIN_NAMESPACE_ACADO typedef unsigned int uint
Definition: acado_types.hpp:42
Tmatrix< T > * getEvaluationPointer() const
BooleanType isConcave()
Definition: function.cpp:391
returnValue AD_backward2(int number, double *seed1, double *seed2, double *df, double *ddf)
Definition: function.cpp:448
#define CLOSE_NAMESPACE_ACADO
returnValue substitute(VariableType variableType_, int index_, double sub_)
Definition: function.cpp:290
int getNXA() const
Definition: function.cpp:212
returnValue setGlobalExportVariableName(const std::string &var)
Definition: function.cpp:595
returnValue getExpression(Expression &expression) const
Definition: function.cpp:139
VariableType
Definition: acado_types.hpp:95
returnValue print(std::ostream &stream, const char *fcnName="ACADOfcn", const char *realString="double") const
Definition: function.cpp:463
BooleanType isNonincreasing()
Definition: function.cpp:349
Base class for all variables within the symbolic expressions family.
Definition: expression.hpp:56
returnValue jacobian(DMatrix &x)
calculate the jacobian of an evaluated function
Definition: function.cpp:403
int getNW() const
Definition: function.cpp:245
virtual returnValue evaluate(double *x, double *result)
BooleanType isLinearIn(const Expression &variable)
Definition: function.cpp:319
unsigned getGlobalExportVariableSize() const
Definition: function.cpp:600
int getNP() const
Definition: function.cpp:233
returnValue setScale(double *scale_)
Definition: function.cpp:514
int getDim() const
returnValue exportCode(std::ostream &stream, 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
Definition: function.cpp:486
double scale(VariableType variableType_, int index_) const
Definition: function.cpp:182
FunctionEvaluationTree evaluationTree
Definition: function_.hpp:519
Function & operator=(const Function &rhs)
Definition: function.cpp:78
int getN() const
BooleanType isAffine()
Definition: function.cpp:368
BooleanType isDependingOn(const Expression &variable)
Definition: function.cpp:314
returnValue reset()
Definition: function.cpp:163
returnValue clearBuffer()
Definition: function.cpp:507
int index(VariableType variableType_, int index_) const
Definition: function.cpp:176
BooleanType ADisSupported() const
void rhs(const real_t *x, real_t *f)
BooleanType isConvex()
Definition: function.cpp:378
int getNT() const
Definition: function.cpp:251
returnValue AD_backward(const DVector &seed, EvaluationPoint &df, const int &number=0)
Definition: function.cpp:546
NeutralElement
Definition: acado_types.hpp:64
Organizes the evaluation of the function tree.
DVector AD_forward(const EvaluationPoint &x, const int &number=0)
Definition: function.cpp:533
returnValue exportForwardDeclarations(std::ostream &stream, const char *fcnName="ACADOfcn", const char *realString="double") const
Definition: function.cpp:474
int getNX() const
Definition: function.cpp:207
#define BEGIN_NAMESPACE_ACADO
virtual ~Function()
Definition: function.cpp:72
Function()
Definition: function.cpp:49
returnValue AD_forward2(int number, double *seed1, double *seed2, double *df, double *ddf)
Definition: function.cpp:441
Function & operator<<(const Expression &arg)
Definition: function.cpp:102
NeutralElement isOneOrZero()
Definition: function.cpp:307
BooleanType isConstant()
Definition: function.cpp:360
BooleanType isNondecreasing()
Definition: function.cpp:337
int memoryOffset
Definition: function_.hpp:520
Function operator()(uint idx) const
Definition: function.cpp:145
int getNumberOfVariables() const
Definition: function.cpp:264
Allows to setup function evaluation points.
Definition: function_.hpp:45
BooleanType isPolynomialIn(const Expression &variable)
Definition: function.cpp:325


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