Allows to setup and evaluate a general function based on SymbolicExpressions. More...
#include <function_.hpp>
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< T > | evaluate (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 |
Operator * | getExpression (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 | |
Function | operator() (uint idx) const |
DVector | operator() (const EvaluationPoint &x, const int &number=0) |
Function & | operator<< (const Expression &arg) |
Function & | operator<< (const double &arg) |
Function & | operator<< (const DVector &arg) |
Function & | operator<< (const DMatrix &arg) |
Function & | operator= (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) |
Allows to setup and evaluate a general function based on SymbolicExpressions.
The class Function allows to setup and evaluate general functions based on SymbolicExpressions.
Definition at line 59 of file function_.hpp.
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.
returnValue Function::AD_backward | ( | const DVector & | seed, |
EvaluationPoint & | df, | ||
const int & | number = 0 |
||
) |
Automatic Differentiation in backward mode.
seed | the backward seed |
df | the directional derivative (output) |
number | the storage position |
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
number | the buffer position |
seed | the seed |
df | the 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.
number | the buffer position |
seed1 | the seed1 |
seed2 | the seed2 |
df | the 1st derivative of the expression |
ddf | the 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.
x | the evaluation point |
number | the storage position |
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
number | storage position |
seed | the seed |
df | the 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.
number | the buffer position |
seed1 | the seed |
seed2 | the seed for the first derivative |
df | the derivative of the expression |
ddf | the 2nd derivative of the expression |
Definition at line 441 of file function.cpp.
BooleanType Function::ADisSupported | ( | ) | const [inline] |
Clears the buffer and resets the buffer size
to 1.
Definition at line 507 of file function.cpp.
DVector Function::evaluate | ( | const EvaluationPoint & | x, |
const int & | number = 0 |
||
) |
Evaluates the function.
x | the evaluation point |
number | the storage position |
Reimplemented in OutputFcn.
Definition at line 520 of file function.cpp.
Tmatrix< T > Function::evaluate | ( | const TevaluationPoint< T > & | x | ) |
Evaluates the function at a templated
evaluation point.
x | the evaluation point |
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)
number | storage position |
x | the input variable x |
_result | the 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
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.
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.
int Function::getN | ( | VariableType & | variableType_ | ) | const |
Returns the number of differential states
Definition at line 187 of file function.cpp.
int Function::getNDX | ( | ) | const |
Returns the number of differential states 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
Definition at line 233 of file function.cpp.
int Function::getNPI | ( | ) | const |
Returns the number of integer parameters
Definition at line 239 of file function.cpp.
int Function::getNT | ( | ) | const |
Returns the number of time variables
Definition at line 251 of file function.cpp.
int Function::getNU | ( | ) | const |
Returns the number of controls
Definition at line 222 of file function.cpp.
int Function::getNUI | ( | ) | const |
Returns the number of integer controls
Definition at line 227 of file function.cpp.
int Function::getNumberOfVariables | ( | ) | const |
Returns the variable counter.
Definition at line 264 of file function.cpp.
int Function::getNW | ( | ) | const |
Returns the number of disturbances
Definition at line 245 of file function.cpp.
int Function::getNX | ( | ) | const |
Returns the number of differential states
Definition at line 207 of file function.cpp.
int Function::getNXA | ( | ) | const |
Returns the 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.
Definition at line 176 of file function.cpp.
Checks whether the function is affine.
Definition at line 368 of file function.cpp.
Checks whether the function is concave.
Definition at line 391 of file function.cpp.
Checks whether function is a constant.
Definition at line 360 of file function.cpp.
Checks whether the function is convex.
Definition at line 378 of file function.cpp.
BooleanType Function::isDependingOn | ( | const Expression & | variable | ) |
Checks whether the function is depending on
var(index)
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)
Definition at line 319 of file function.cpp.
Checks whether the function is nondecreasing.
Definition at line 337 of file function.cpp.
Checks whether the function is nonincreasing.
Definition at line 349 of file function.cpp.
Checks whether the function is zero or one
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)
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)
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)
x | will be assigned jacobian(fun,differential states) |
Definition at line 403 of file function.cpp.
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.
x | the evaluation point |
number | the storage position |
Function & Function::operator<< | ( | const Expression & | arg | ) |
Loading Expressions (deep copy).
Reimplemented in DifferentialEquation.
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.
Loading Symbolic DVector (deep copy).
Definition at line 121 of file function.cpp.
Loading Symbolic DMatrix (deep copy).
Definition at line 130 of file function.cpp.
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.
file | The file to which the expression should be printed. |
fcnName | The name of the generated function (default: "ACADOfcn"). |
precision | The number of internal dec. places to be printed (default: 16). |
Definition at line 463 of file function.cpp.
Definition at line 163 of file function.cpp.
double Function::scale | ( | VariableType | variableType_, |
int | index_ | ||
) | const |
Returns the scale of a given variable.
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
Definition at line 514 of file function.cpp.
returnValue Function::substitute | ( | VariableType | variableType_, |
int | index_, | ||
double | sub_ | ||
) |
Substitutes var(index) with the double sub.
index_ | subst. index |
sub_ | the substitution |
Definition at line 290 of file function.cpp.
std::ostream& operator<< | ( | std::ostream & | stream, |
const Function & | arg | ||
) | [friend] |
Prints the function into a stream.
Definition at line 456 of file function.cpp.
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.