Public Member Functions | Protected Attributes | List of all members

Organizes the evaluation of the function tree. More...

#include <function_evaluation_tree.hpp>

Public Member Functions

virtual returnValue AD_backward (double *seed, double *df)
 
virtual returnValue AD_backward (int number, double *seed, double *df)
 
virtual returnValue AD_backward2 (int number, double *seed1, double *seed2, double *df, double *ddf)
 
virtual returnValue AD_forward (double *x, double *seed, double *f, double *df)
 
virtual returnValue AD_forward (int number, double *seed, double *df)
 
virtual returnValue AD_forward (int number, double *x, double *seed, double *f, double *df)
 
virtual returnValue AD_forward2 (int number, double *seed1, double *seed2, double *df, double *ddf)
 
returnValue C_print (std::ostream &stream=std::cout, const char *fcnName="ACADOfcn", const char *realString="double") const
 
virtual returnValue clearBuffer ()
 
FunctionEvaluationTreedifferentiate (int index)
 
virtual returnValue evaluate (double *x, double *result)
 
template<typename T >
returnValue evaluate (Tmatrix< T > *x, Tmatrix< T > *result)
 
virtual returnValue evaluate (double *x, double *result, PrintLevel printL)
 
virtual returnValue evaluate (int number, double *x, double *result)
 
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
 
returnValue exportForwardDeclarations (std::ostream &stream=std::cout, const char *fcnName="ACADOfcn", const char *realString="double") const
 
 FunctionEvaluationTree ()
 
 FunctionEvaluationTree (const FunctionEvaluationTree &arg)
 
virtual CurvatureType getCurvature ()
 
virtual int getDim () const
 
virtual OperatorgetExpression (uint componentIdx) const
 
virtual returnValue getExpression (Expression &expression) const
 
std::string getGlobalExportVariableName () const
 
unsigned getGlobalExportVariableSize () const
 
virtual MonotonicityType getMonotonicity ()
 
virtual int getN () const
 
virtual int getNDX () const
 
virtual int getNOD () const
 
virtual int getNP () const
 
virtual int getNPI () const
 
virtual int getNT () const
 
virtual int getNU () const
 
virtual int getNUI () const
 
virtual int getNumberOfVariables () const
 
virtual int getNW () const
 
virtual int getNX () const
 
virtual int getNXA () const
 
virtual int index (VariableType variableType_, int index_) const
 
virtual BooleanType isDependingOn (const Expression &variable)
 
virtual BooleanType isLinearIn (const Expression &variable)
 
virtual NeutralElement isOneOrZero ()
 
virtual BooleanType isPolynomialIn (const Expression &variable)
 
virtual BooleanType isRationalIn (const Expression &variable)
 
virtual BooleanType isSymbolic () const
 
virtual returnValue makeImplicit ()
 
virtual returnValue makeImplicit (int dim_)
 
virtual returnValue operator<< (const Expression &arg)
 
FunctionEvaluationTreeoperator= (const FunctionEvaluationTree &arg)
 
virtual double scale (VariableType variableType_, int index_) const
 
returnValue setGlobalExportVariableName (const std::string &_name)
 
virtual returnValue setScale (double *scale_)
 
virtual FunctionEvaluationTree substitute (VariableType variableType_, int index_, double sub_)
 
virtual ~FunctionEvaluationTree ()
 

Protected Attributes

int dim
 
Operator ** f
 
std::string globalExportVariableName
 
SymbolicIndexListindexList
 
int * lhs_comp
 
int n
 
Expression safeCopy
 
Operator ** sub
 

Detailed Description

Organizes the evaluation of the function tree.

The class FunctionEvaluationTree is designed to organize the evaluation of tree structured expressions.

\author Boris Houska, Hans Joachim Ferreau, Milan Vukov

Definition at line 53 of file function_evaluation_tree.hpp.

Constructor & Destructor Documentation

BEGIN_NAMESPACE_ACADO FunctionEvaluationTree::FunctionEvaluationTree ( )

Default constructor.

Definition at line 48 of file function_evaluation_tree.cpp.

FunctionEvaluationTree::FunctionEvaluationTree ( const FunctionEvaluationTree arg)

Copy constructor (deep copy).

Definition at line 60 of file function_evaluation_tree.cpp.

FunctionEvaluationTree::~FunctionEvaluationTree ( )
virtual

Destructor.

Definition at line 100 of file function_evaluation_tree.cpp.

Member Function Documentation

returnValue FunctionEvaluationTree::AD_backward ( double *  seed,
double *  df 
)
virtual

Automatic Differentiation in backward mode.

Returns
SUCCESFUL_RETURN
RET_NAN
Parameters
seedthe seed
dfthe derivative of the expression

Definition at line 772 of file function_evaluation_tree.cpp.

returnValue FunctionEvaluationTree::AD_backward ( int  number,
double *  seed,
double *  df 
)
virtual

Automatic Differentiation in backward mode based on
buffered values

Returns
SUCCESFUL_RETURN
RET_NAN
Parameters
numberthe buffer position
seedthe seed
dfthe derivative of the expression

Definition at line 793 of file function_evaluation_tree.cpp.

returnValue FunctionEvaluationTree::AD_backward2 ( int  number,
double *  seed1,
double *  seed2,
double *  df,
double *  ddf 
)
virtual

Automatic Differentiation in backward mode for 2nd order
derivatives based on buffered values.

Returns
SUCCESFUL_RETURN
RET_NAN
Parameters
numberthe buffer position
seed1the seed1
seed2the seed2
dfthe 1st derivative of the expression
ddfthe 2nd derivative of the expression

Definition at line 830 of file function_evaluation_tree.cpp.

returnValue FunctionEvaluationTree::AD_forward ( double *  x,
double *  seed,
double *  f,
double *  df 
)
virtual

Automatic Differentiation in forward mode.

Returns
SUCCESFUL_RETURN
RET_NAN
Parameters
xThe evaluation point x
seedthe seed
fthe value of the expression at x
dfthe derivative of the expression

Definition at line 719 of file function_evaluation_tree.cpp.

returnValue FunctionEvaluationTree::AD_forward ( int  number,
double *  seed,
double *  df 
)
virtual

Automatic Differentiation in forward mode.
This function uses the intermediate
results from a buffer

Returns
SUCCESFUL_RETURN
RET_NAN
Parameters
numberstorage position
seedthe seed
dfthe derivative of the expression

Definition at line 756 of file function_evaluation_tree.cpp.

returnValue FunctionEvaluationTree::AD_forward ( int  number,
double *  x,
double *  seed,
double *  f,
double *  df 
)
virtual

Automatic Differentiation in forward mode.
This function stores the intermediate
results in a buffer (needed for 2nd order automatic
differentiation in backward mode)

Returns
SUCCESFUL_RETURN
RET_NAN
Parameters
numberstorage position
xThe evaluation point x
seedthe seed
fthe value of the expression at x
dfthe derivative of the expression

Definition at line 738 of file function_evaluation_tree.cpp.

returnValue FunctionEvaluationTree::AD_forward2 ( int  number,
double *  seed1,
double *  seed2,
double *  df,
double *  ddf 
)
virtual

Automatic Differentiation in forward mode for
2nd derivatives.
This function uses intermediate
results from a buffer.

Returns
SUCCESFUL_RETURN
RET_NAN
Parameters
numberthe buffer position
seed1the seed
seed2the seed for the first derivative
dfthe derivative of the expression
ddfthe 2nd derivative of the expression

Definition at line 811 of file function_evaluation_tree.cpp.

returnValue FunctionEvaluationTree::C_print ( std::ostream &  stream = std::cout,
const char *  fcnName = "ACADOfcn",
const char *  realString = "double" 
) const

Prints the expression as C-code into a file.

Parameters
fileThe file to which the expression should be printed.
fcnNameThe name of the generated function (default: "ACADOfcn").
realString

Returns
SUCCESFUL_RETURN

Definition at line 854 of file function_evaluation_tree.cpp.

returnValue FunctionEvaluationTree::clearBuffer ( )
virtual

Clears the buffer and resets the buffer size
to 1.

Returns
SUCCESFUL_RETURN

Definition at line 1016 of file function_evaluation_tree.cpp.

FunctionEvaluationTree * FunctionEvaluationTree::differentiate ( int  index)

Returns the derivative of the expression with respect
to the variable var(index).

Returns
The symbolic expression for the derivative.
Parameters
indexdiff. index

Definition at line 301 of file function_evaluation_tree.cpp.

returnValue FunctionEvaluationTree::evaluate ( double *  x,
double *  result 
)
virtual

Evaluates the expression

Returns
SUCCESSFUL_RETURN
RET_NAN
Parameters
xthe input variable x
resultthe result

Definition at line 238 of file function_evaluation_tree.cpp.

template<typename T >
returnValue FunctionEvaluationTree::evaluate ( Tmatrix< T > *  x,
Tmatrix< T > *  result 
)

Evaluates the expression

Definition at line 488 of file function_evaluation_tree.hpp.

returnValue FunctionEvaluationTree::evaluate ( double *  x,
double *  result,
PrintLevel  printL 
)
virtual

Evaluates the expression and also prints
the intermediate results with a specified
print level.

Returns
SUCCESFUL_RETURN
RET_NAN
Parameters
xthe input variable x
resultthe result
printLthe print level

Definition at line 255 of file function_evaluation_tree.cpp.

returnValue FunctionEvaluationTree::evaluate ( int  number,
double *  x,
double *  result 
)
virtual

Evaluates the expression and stores the intermediate
results in a buffer (needed for automatic differentiation
in backward mode)

Returns
SUCCESFUL_RETURN
RET_NAN
Parameters
numberstorage position
xthe input variable x
resultthe result

Definition at line 284 of file function_evaluation_tree.cpp.

returnValue FunctionEvaluationTree::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

Definition at line 887 of file function_evaluation_tree.cpp.

returnValue FunctionEvaluationTree::exportForwardDeclarations ( std::ostream &  stream = std::cout,
const char *  fcnName = "ACADOfcn",
const char *  realString = "double" 
) const

Definition at line 868 of file function_evaluation_tree.cpp.

CurvatureType FunctionEvaluationTree::getCurvature ( )
virtual

Returns the curvature of the expression

Returns
CT_CONSTANT
CT_AFFINE
CT_CONVEX
CT_CONCAVE

Definition at line 684 of file function_evaluation_tree.cpp.

virtual int FunctionEvaluationTree::getDim ( ) const
virtual

Returns the dimension of the symbolic expression

Returns
The requested dimension.
Operator * FunctionEvaluationTree::getExpression ( uint  componentIdx) const
virtual

Returns the symbolic expression of the given component of the function.

Returns
The symbolic expression

Definition at line 1133 of file function_evaluation_tree.cpp.

returnValue FunctionEvaluationTree::getExpression ( Expression expression) const
virtual

Definition at line 192 of file function_evaluation_tree.cpp.

std::string FunctionEvaluationTree::getGlobalExportVariableName ( ) const

Definition at line 1171 of file function_evaluation_tree.cpp.

unsigned FunctionEvaluationTree::getGlobalExportVariableSize ( ) const

Definition at line 1176 of file function_evaluation_tree.cpp.

MonotonicityType FunctionEvaluationTree::getMonotonicity ( )
virtual

Returns the monotonicity of the expression.

Returns
MT_NONDECREASING
MT_NONINCREASING
MT_NONMONOTONIC

Definition at line 649 of file function_evaluation_tree.cpp.

virtual int FunctionEvaluationTree::getN ( ) const
virtual

Returns the number of intermediate expressions that have
been detected in the symbolic expression.

Returns
The requested number of intermediate states.
int FunctionEvaluationTree::getNDX ( ) const
virtual

Returns the number of differential states derivatives

Returns
The requested number of differential state
derivatives.

Definition at line 1076 of file function_evaluation_tree.cpp.

int FunctionEvaluationTree::getNOD ( ) const
virtual

Return number of "online data" objects.

Definition at line 1111 of file function_evaluation_tree.cpp.

int FunctionEvaluationTree::getNP ( ) const
virtual

Returns the number of parameters

Returns
The requested number of parameters.

Definition at line 1091 of file function_evaluation_tree.cpp.

int FunctionEvaluationTree::getNPI ( ) const
virtual

Returns the number of integer parameters

Returns
The requested number of integer parameters.

Definition at line 1096 of file function_evaluation_tree.cpp.

int FunctionEvaluationTree::getNT ( ) const
virtual

Returns the number of time variables

Returns
The requested number of time variables.

Definition at line 1106 of file function_evaluation_tree.cpp.

int FunctionEvaluationTree::getNU ( ) const
virtual

Returns the number of controls

Returns
The requested number of controls.

Definition at line 1081 of file function_evaluation_tree.cpp.

int FunctionEvaluationTree::getNUI ( ) const
virtual

Returns the number of integer controls

Returns
The requested number of integer controls.

Definition at line 1086 of file function_evaluation_tree.cpp.

int FunctionEvaluationTree::getNumberOfVariables ( ) const
virtual

Returns the variable counter.

Returns
The number of variables

Definition at line 1127 of file function_evaluation_tree.cpp.

int FunctionEvaluationTree::getNW ( ) const
virtual

Returns the number of disturbances

Returns
The requested number of disturbances.

Definition at line 1101 of file function_evaluation_tree.cpp.

int FunctionEvaluationTree::getNX ( ) const
virtual

Returns the number of differential states

Returns
The requested number of differential states.

Definition at line 1066 of file function_evaluation_tree.cpp.

int FunctionEvaluationTree::getNXA ( ) const
virtual

Returns the number of algebraic states

Returns
The requested number of algebraic states.

Definition at line 1071 of file function_evaluation_tree.cpp.

int FunctionEvaluationTree::index ( VariableType  variableType_,
int  index_ 
) const
virtual

Returns the index of the variable with specified type and
component.

Returns
The index of the requested variable.

Definition at line 1116 of file function_evaluation_tree.cpp.

BooleanType FunctionEvaluationTree::isDependingOn ( const Expression variable)
virtual

Checks whether the symbolic expression is depending on
a specified variable.

Returns
BT_FALSE if no dependence is detected
BT_TRUE otherwise

Definition at line 436 of file function_evaluation_tree.cpp.

BooleanType FunctionEvaluationTree::isLinearIn ( const Expression variable)
virtual

Checks whether the symbolic expression is linear in
a specified variable.

Returns
BT_FALSE if no linearity is
detected
BT_TRUE otherwise

Definition at line 489 of file function_evaluation_tree.cpp.

NeutralElement FunctionEvaluationTree::isOneOrZero ( )
virtual

Checks whether the expression is zero or one

Returns
NE_ZERO
NE_ONE
NE_NEITHER_ONE_NOR_ZERO

Definition at line 398 of file function_evaluation_tree.cpp.

BooleanType FunctionEvaluationTree::isPolynomialIn ( const Expression variable)
virtual

Checks whether the expression is polynomial in
a variable.

Returns
BT_FALSE if the expression is not polynomial
BT_TRUE otherwise

Definition at line 542 of file function_evaluation_tree.cpp.

BooleanType FunctionEvaluationTree::isRationalIn ( const Expression variable)
virtual

Checks whether the expression is rational in
the variable var(index)

Returns
BT_FALSE if the expression is not rational
BT_TRUE otherwise

Definition at line 596 of file function_evaluation_tree.cpp.

BooleanType FunctionEvaluationTree::isSymbolic ( ) const
virtual

Returns whether the function is symbolic or not. If BT_TRUE
is returned, automatic differentiation will be used by
default.

Definition at line 1143 of file function_evaluation_tree.cpp.

returnValue FunctionEvaluationTree::makeImplicit ( )
virtual

Make the symbolic expression implicit. This functionality
makes only sense for Differential Equation and should in
general not be used for anything else. (Although it is
public here.)

Definition at line 1038 of file function_evaluation_tree.cpp.

returnValue FunctionEvaluationTree::makeImplicit ( int  dim_)
virtual

Definition at line 1044 of file function_evaluation_tree.cpp.

returnValue FunctionEvaluationTree::operator<< ( const Expression arg)
virtual

Loading Expressions (deep copy).

Definition at line 199 of file function_evaluation_tree.cpp.

FunctionEvaluationTree & FunctionEvaluationTree::operator= ( const FunctionEvaluationTree arg)

Assignment operator (deep copy).

Definition at line 128 of file function_evaluation_tree.cpp.

double FunctionEvaluationTree::scale ( VariableType  variableType_,
int  index_ 
) const
virtual

Returns the scale of a given variable.

Returns
The requested scale or
1.0 if index is out of range

Definition at line 1121 of file function_evaluation_tree.cpp.

returnValue FunctionEvaluationTree::setGlobalExportVariableName ( const std::string &  _name)

Definition at line 1161 of file function_evaluation_tree.cpp.

returnValue FunctionEvaluationTree::setScale ( double *  scale_)
virtual

Defines scalings for the variables.

Definition at line 1156 of file function_evaluation_tree.cpp.

FunctionEvaluationTree FunctionEvaluationTree::substitute ( VariableType  variableType_,
int  index_,
double  sub_ 
)
virtual

Substitutes var(index) with the double sub.

Returns
The substituted expression.
Parameters
index_subst. index
sub_the substitution

Definition at line 309 of file function_evaluation_tree.cpp.

Member Data Documentation

int FunctionEvaluationTree::dim
protected

The dimension of the function.

Definition at line 478 of file function_evaluation_tree.hpp.

Operator** FunctionEvaluationTree::f
protected

The right-hand side expressions

Definition at line 474 of file function_evaluation_tree.hpp.

std::string FunctionEvaluationTree::globalExportVariableName
protected

Name of the variable that holds intermediate expressions.

Definition at line 484 of file function_evaluation_tree.hpp.

SymbolicIndexList* FunctionEvaluationTree::indexList
protected

an SymbolicIndexList

Definition at line 477 of file function_evaluation_tree.hpp.

int* FunctionEvaluationTree::lhs_comp
protected

The components of the intermediate states

Definition at line 476 of file function_evaluation_tree.hpp.

int FunctionEvaluationTree::n
protected

The number of Intermediate expressions

Definition at line 479 of file function_evaluation_tree.hpp.

Expression FunctionEvaluationTree::safeCopy
protected

Definition at line 481 of file function_evaluation_tree.hpp.

Operator** FunctionEvaluationTree::sub
protected

The intermediate expressions

Definition at line 475 of file function_evaluation_tree.hpp.


The documentation for this class was generated from the following files:


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