Public Member Functions | Protected Attributes | Friends | List of all members

Allows to setup and evaluate a general function based on SymbolicExpressions. More...

#include <function_.hpp>

Inheritance diagram for Function:
Inheritance graph
[legend]

Public Member Functions

returnValue AD_backward (const DVector &seed, EvaluationPoint &df, const int &number=0)
 
returnValue AD_backward (int number, double *seed, double *df)
 
returnValue AD_backward2 (int number, double *seed1, double *seed2, double *df, double *ddf)
 
DVector AD_forward (const EvaluationPoint &x, const int &number=0)
 
returnValue AD_forward (int number, double *seed, double *df)
 
returnValue AD_forward2 (int number, double *seed1, double *seed2, double *df, double *ddf)
 
BooleanType ADisSupported () const
 
returnValue clearBuffer ()
 
DVector evaluate (const EvaluationPoint &x, const int &number=0)
 
template<typename T >
Tmatrix< Tevaluate (const TevaluationPoint< T > &x)
 
returnValue evaluate (int number, double *x, double *_result)
 
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
 
returnValue exportForwardDeclarations (std::ostream &stream, const char *fcnName="ACADOfcn", const char *realString="double") const
 
 Function ()
 
 Function (const Function &rhs)
 
int getDim () const
 
returnValue getExpression (Expression &expression) const
 
OperatorgetExpression (uint componentIdx) const
 
std::string getGlobalExportVariableName () const
 
unsigned getGlobalExportVariableSize () const
 
int getN () const
 
int getN (VariableType &variableType_) const
 
int getNDX () const
 
int getNOD () const
 
int getNP () const
 
int getNPI () const
 
int getNT () const
 
int getNU () const
 
int getNUI () const
 
int getNumberOfVariables () const
 
int getNW () const
 
int getNX () const
 
int getNXA () const
 
int index (VariableType variableType_, int index_) const
 
BooleanType isAffine ()
 
BooleanType isConcave ()
 
BooleanType isConstant ()
 
BooleanType isConvex ()
 
BooleanType isDependingOn (const Expression &variable)
 
BooleanType isLinearIn (const Expression &variable)
 
BooleanType isNondecreasing ()
 
BooleanType isNonincreasing ()
 
NeutralElement isOneOrZero ()
 
BooleanType isPolynomialIn (const Expression &variable)
 
BooleanType isRationalIn (const Expression &variable)
 
BooleanType isSymbolic () const
 
returnValue jacobian (DMatrix &x)
 calculate the jacobian of an evaluated function More...
 
Function operator() (uint idx) const
 
DVector operator() (const EvaluationPoint &x, const int &number=0)
 
Functionoperator<< (const Expression &arg)
 
Functionoperator<< (const double &arg)
 
Functionoperator<< (const DVector &arg)
 
Functionoperator<< (const DMatrix &arg)
 
Functionoperator= (const Function &rhs)
 
returnValue print (std::ostream &stream, const char *fcnName="ACADOfcn", const char *realString="double") const
 
returnValue reset ()
 
double scale (VariableType variableType_, int index_) const
 
returnValue setGlobalExportVariableName (const std::string &var)
 
returnValue setMemoryOffset (int memoryOffset_)
 
returnValue setScale (double *scale_)
 
returnValue substitute (VariableType variableType_, int index_, double sub_)
 
virtual ~Function ()
 

Protected Attributes

FunctionEvaluationTree evaluationTree
 
int memoryOffset
 
double * result
 

Friends

std::ostream & operator<< (std::ostream &stream, const Function &arg)
 

Detailed Description

Allows to setup and evaluate a general function based on SymbolicExpressions.

The class Function allows to setup and evaluate general functions based on SymbolicExpressions.

Author
Boris Houska, Hans Joachim Ferreau

Definition at line 59 of file function_.hpp.

Constructor & Destructor Documentation

BEGIN_NAMESPACE_ACADO Function::Function ( )

Default constructor.

Definition at line 49 of file function.cpp.

Function::Function ( const Function rhs)

Copy constructor (deep copy).

Definition at line 56 of file function.cpp.

Function::~Function ( )
virtual

Destructor.

Definition at line 72 of file function.cpp.

Member Function Documentation

returnValue Function::AD_backward ( const DVector seed,
EvaluationPoint df,
const int &  number = 0 
)

Automatic Differentiation in backward mode.

Parameters
seedthe backward seed
dfthe directional derivative (output)
numberthe storage position

Returns
the result for the derivative.

Definition at line 546 of file function.cpp.

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

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 435 of file function.cpp.

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

Automatic Differentiation in backward mode for 2nd order
derivatives based on buffered values.
IMPORTANT REMARK: run AD_forward first to define
the point x and to compute f and df.

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 448 of file function.cpp.

DVector Function::AD_forward ( const EvaluationPoint x,
const int &  number = 0 
)

Automatic Differentiation in forward mode.

Parameters
xthe evaluation point
numberthe storage position

Returns
The result of the evaluation.

Definition at line 533 of file function.cpp.

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

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 429 of file function.cpp.

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

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 441 of file function.cpp.

BooleanType Function::ADisSupported ( ) const
inline
returnValue Function::clearBuffer ( )

Clears the buffer and resets the buffer size
to 1.

Returns
SUCCESFUL_RETURN

Definition at line 507 of file function.cpp.

DVector Function::evaluate ( const EvaluationPoint x,
const int &  number = 0 
)

Evaluates the function.

Parameters
xthe evaluation point
numberthe storage position

Returns
The result of the evaluation.

Definition at line 520 of file function.cpp.

template<typename T >
Tmatrix< T > Function::evaluate ( const TevaluationPoint< T > &  x)

Evaluates the function at a templated
evaluation point.

Parameters
xthe evaluation point

Returns
The result of the evaluation.

Definition at line 526 of file function_.hpp.

returnValue Function::evaluate ( int  number,
double *  x,
double *  _result 
)

Evaluates the function 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 277 of file function.cpp.

returnValue Function::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 at line 486 of file function.cpp.

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

Definition at line 474 of file function.cpp.

int Function::getDim ( ) const
inline

Returns the dimension of the function

Returns
The requested dimension.
returnValue Function::getExpression ( Expression expression) const

Definition at line 139 of file function.cpp.

Operator * Function::getExpression ( uint  componentIdx) const

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

Returns
The symbolic expression

Definition at line 271 of file function.cpp.

std::string Function::getGlobalExportVariableName ( ) const

Get name of the variable that holds intermediate values.

Definition at line 590 of file function.cpp.

unsigned Function::getGlobalExportVariableSize ( ) const

Get size of the variable that holds intermediate values.

Definition at line 600 of file function.cpp.

int Function::getN ( ) const
inline

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

Returns
The requested number of intermediate states.
int Function::getN ( VariableType variableType_) const

Returns the number of differential states

Returns
The requested number of differential states.

Definition at line 187 of file function.cpp.

int Function::getNDX ( ) const

Returns the number of differential states derivatives

Returns
The requested number of differential state
derivatives.

Definition at line 217 of file function.cpp.

int Function::getNOD ( ) const

Return number of "online data" objects.

Definition at line 257 of file function.cpp.

int Function::getNP ( ) const

Returns the number of parameters

Returns
The requested number of parameters.

Definition at line 233 of file function.cpp.

int Function::getNPI ( ) const

Returns the number of integer parameters

Returns
The requested number of integer parameters.

Definition at line 239 of file function.cpp.

int Function::getNT ( ) const

Returns the number of time variables

Returns
The requested number of time variables.

Definition at line 251 of file function.cpp.

int Function::getNU ( ) const

Returns the number of controls

Returns
The requested number of controls.

Definition at line 222 of file function.cpp.

int Function::getNUI ( ) const

Returns the number of integer controls

Returns
The requested number of integer controls.

Definition at line 227 of file function.cpp.

int Function::getNumberOfVariables ( ) const

Returns the variable counter.

Returns
The number of variables

Definition at line 264 of file function.cpp.

int Function::getNW ( ) const

Returns the number of disturbances

Returns
The requested number of disturbances.

Definition at line 245 of file function.cpp.

int Function::getNX ( ) const

Returns the number of differential states

Returns
The requested number of differential states.

Definition at line 207 of file function.cpp.

int Function::getNXA ( ) const

Returns the number of algebraic states

Returns
The requested number of algebraic states.

Definition at line 212 of file function.cpp.

int Function::index ( VariableType  variableType_,
int  index_ 
) const

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

Returns
The index of the requested variable.

Definition at line 176 of file function.cpp.

BooleanType Function::isAffine ( )

Checks whether the function is affine.

Returns
BT_FALSE if the expression is not affine
BT_TRUE otherwise

Definition at line 368 of file function.cpp.

BooleanType Function::isConcave ( )

Checks whether the function is concave.

Returns
BT_FALSE if the expression is not (DCP-) concave
BT_TRUE otherwise

Definition at line 391 of file function.cpp.

BooleanType Function::isConstant ( )

Checks whether function is a constant.

Definition at line 360 of file function.cpp.

BooleanType Function::isConvex ( )

Checks whether the function is convex.

Returns
BT_FALSE if the expression is not (DCP-) convex
BT_TRUE otherwise

Definition at line 378 of file function.cpp.

BooleanType Function::isDependingOn ( const Expression variable)

Checks whether the function is depending on
var(index)

Returns
BT_FALSE if no dependence is detected
BT_TRUE otherwise

Definition at line 314 of file function.cpp.

BooleanType Function::isLinearIn ( const Expression variable)

Checks whether the function is linear in
(or not depending on) var(index)

Returns
BT_FALSE if no linearity is
detected
BT_TRUE otherwise

Definition at line 319 of file function.cpp.

BooleanType Function::isNondecreasing ( )

Checks whether the function is nondecreasing.

Returns
BT_FALSE if the expression is not nondecreasing
BT_TRUE otherwise

Definition at line 337 of file function.cpp.

BooleanType Function::isNonincreasing ( )

Checks whether the function is nonincreasing.

Returns
BT_FALSE if the expression is not nonincreasing
BT_TRUE otherwise

Definition at line 349 of file function.cpp.

NeutralElement Function::isOneOrZero ( )

Checks whether the function is zero or one

Returns
NE_ZERO
NE_ONE
NE_NEITHER_ONE_NOR_ZERO

Definition at line 307 of file function.cpp.

BooleanType Function::isPolynomialIn ( const Expression variable)

Checks whether the function is polynomial in
the variable var(index)

Returns
BT_FALSE if the expression is not polynomial
BT_TRUE otherwise

Definition at line 325 of file function.cpp.

BooleanType Function::isRationalIn ( const Expression variable)

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

Returns
BT_FALSE if the expression is not rational
BT_TRUE otherwise

Definition at line 331 of file function.cpp.

BooleanType Function::isSymbolic ( ) const
inline

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

returnValue Function::jacobian ( DMatrix x)

calculate the jacobian of an evaluated function

Calculates the matrix diff(fun(x,u,v,p,q,w),x)

Parameters
xwill be assigned jacobian(fun,differential states)

Definition at line 403 of file function.cpp.

Function Function::operator() ( uint  idx) const

Definition at line 145 of file function.cpp.

DVector Function::operator() ( const EvaluationPoint x,
const int &  number = 0 
)
inline

Redundant evaluation routine which is equivalent to
to the evaluate routine above.

Parameters
xthe evaluation point
numberthe storage position

Returns
The result of the evaluation.
Function & Function::operator<< ( const Expression arg)

Loading Expressions (deep copy).

Definition at line 102 of file function.cpp.

Function & Function::operator<< ( const double &  arg)

Loading Expressions (deep copy).

Definition at line 112 of file function.cpp.

Function & Function::operator<< ( const DVector arg)

Loading Symbolic DVector (deep copy).

Definition at line 121 of file function.cpp.

Function & Function::operator<< ( const DMatrix arg)

Loading Symbolic DMatrix (deep copy).

Definition at line 130 of file function.cpp.

Function & Function::operator= ( const Function rhs)

Assignment operator (deep copy).

Definition at line 78 of file function.cpp.

returnValue Function::print ( std::ostream &  stream,
const char *  fcnName = "ACADOfcn",
const char *  realString = "double" 
) const

Prints the function in form of plain C-code into a file. The integer
"precision" must be in [1,16] and defines the number of internal decimal places
which occur in "double" - valued parts of the expression tree.

Parameters
fileThe file to which the expression should be printed.
fcnNameThe name of the generated function (default: "ACADOfcn").
precisionThe number of internal dec. places to be printed (default: 16).

Returns
SUCCESFUL_RETURN

Definition at line 463 of file function.cpp.

returnValue Function::reset ( )

Definition at line 163 of file function.cpp.

double Function::scale ( VariableType  variableType_,
int  index_ 
) const

Returns the scale of a given variable.

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

Definition at line 182 of file function.cpp.

returnValue Function::setGlobalExportVariableName ( const std::string &  var)

Set name of the variable that holds intermediate values.

Definition at line 595 of file function.cpp.

returnValue Function::setMemoryOffset ( int  memoryOffset_)
inline
returnValue Function::setScale ( double *  scale_)

Defines a scale for the case that a C-function is used

Returns
SUCCESSFUL_RETURN

Definition at line 514 of file function.cpp.

returnValue Function::substitute ( VariableType  variableType_,
int  index_,
double  sub_ 
)

Substitutes var(index) with the double sub.

Returns
The substituted expression.
Parameters
index_subst. index
sub_the substitution

Definition at line 290 of file function.cpp.

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  stream,
const Function arg 
)
friend

Prints the function into a stream.

Definition at line 456 of file function.cpp.

Member Data Documentation

FunctionEvaluationTree Function::evaluationTree
protected

Definition at line 519 of file function_.hpp.

int Function::memoryOffset
protected

Definition at line 520 of file function_.hpp.

double* Function::result
protected

Definition at line 522 of file function_.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