ACADO Toolkit  1.2.0beta
Toolkit for Automatic Control and Dynamic Optimization
Public Member Functions | Protected Attributes | Friends

Allows to setup and evaluate transition functions based on SymbolicExpressions. More...

#include <transition.hpp>

Inheritance diagram for Transition:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 Transition ()
 Default constructor.
 Transition (const Transition &arg)
 Copy constructor (deep copy).
virtual ~Transition ()
 Destructor.
Transitionoperator= (const Transition &arg)
 Assignment operator (deep copy).
Transitionoperator<< (const DifferentialState &arg)
 Loading Expressions (deep copy).
Transitionoperator== (const Expression &arg)
 Loading Expressions (deep copy).
Transitionoperator== (const double &arg)
 Loading Expressions (deep copy).
Transitionoperator== (const Vector &arg)
 Loading Symbolic Vector (deep copy).
Transitionoperator== (const Matrix &arg)
 Loading Symbolic Matrix (deep copy).
Vector getDifferentialStateComponents () const
Functionoperator<< (const Expression &arg)
 Loading Expressions (deep copy).
Functionoperator<< (const double &arg)
 Loading Expressions (deep copy).
Functionoperator<< (const Vector &arg)
 Loading Symbolic Vector (deep copy).
Functionoperator<< (const Matrix &arg)
 Loading Symbolic Matrix (deep copy).
Function operator() (uint idx) const
Vector operator() (const EvaluationPoint &x, const int &number=0)
 Redundant evaluation routine which is equivalent to
to the evaluate routine above.
returnValue getExpression (Expression &expression) const
OperatorgetExpression (uint componentIdx) const
 Returns the symbolic expression of the given component of the function.
returnValue reset ()
int getDim () const
 Returns the dimension of the function
.
int getN () const
 Returns the number of intermediate expressions that have
been detected in the function.
int getN (VariableType &variableType_) const
 Returns the number of differential states
.
int getNX () const
 Returns the number of differential states
.
int getNXA () const
 Returns the number of algebraic states
.
int getNDX () const
 Returns the number of differential states derivatives
.
int getNU () const
 Returns the number of controls
.
int getNUI () const
 Returns the number of integer controls
.
int getNP () const
 Returns the number of parameters
.
int getNPI () const
 Returns the number of integer parameters
.
int getNW () const
 Returns the number of disturbances
.
int getNT () const
 Returns the number of time variables
.
int index (VariableType variableType_, int index_) const
 Returns the index of the variable with specified type and
component.
double scale (VariableType variableType_, int index_) const
 Returns the scale of a given variable.
int getNumberOfVariables () const
 Returns the variable counter.
Vector evaluate (const EvaluationPoint &x, const int &number=0)
 Evaluates the function.
template<typename T >
Tmatrix< T > evaluate (const TevaluationPoint< T > &x)
 Evaluates the function at a templated
evaluation point.
returnValue 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)
.
returnValue substitute (VariableType variableType_, int index_, double sub_)
 Substitutes var(index) with the double sub.
NeutralElement isOneOrZero ()
 Checks whether the function is zero or one
.
BooleanType isDependingOn (const Expression &variable)
 Checks whether the function is depending on
var(index)
.
BooleanType isLinearIn (const Expression &variable)
 Checks whether the function is linear in
(or not depending on) var(index)
.
BooleanType isPolynomialIn (const Expression &variable)
 Checks whether the function is polynomial in
the variable var(index)
.
BooleanType isRationalIn (const Expression &variable)
 Checks whether the function is rational in
the variable var(index)
.
BooleanType isNondecreasing ()
 Checks whether the function is nondecreasing.
BooleanType isNonincreasing ()
 Checks whether the function is nonincreasing.
BooleanType isAffine ()
 Checks whether the function is affine.
BooleanType isConvex ()
 Checks whether the function is convex.
BooleanType isConcave ()
 Checks whether the function is concave.
Vector AD_forward (const EvaluationPoint &x, const int &number=0)
 Automatic Differentiation in forward mode.
returnValue AD_forward (int number, double *seed, double *df)
 Automatic Differentiation in forward mode.
returnValue AD_backward (const Vector &seed, EvaluationPoint &df, const int &number=0)
 Automatic Differentiation in backward mode.
returnValue AD_backward (int number, double *seed, double *df)
 Automatic Differentiation in backward mode based on
buffered values
.
returnValue AD_forward2 (int number, double *seed1, double *seed2, double *df, double *ddf)
 Automatic Differentiation in forward mode for
2nd derivatives.
returnValue 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.
returnValue jacobian (Matrix &x)
 calculate the jacobian of an evaluated function
returnValue print (FILE *file, const char *fcnName="ACADOfcn", const char *realString="double", int precision=16) const
 Prints the function in form of plain C-code into a file.
returnValue exportHeader (FILE *file, const char *fcnName="ACADOfcn", const char *realString="double") const
returnValue exportForwardDeclarations (FILE *file, const char *fcnName="ACADOfcn", const char *realString="double") const
returnValue exportCode (FILE *file, const char *fcnName="ACADOfcn", const char *realString="double", int precision=16, uint _numX=0, uint _numXA=0, uint _numU=0, uint _numP=0, uint _numDX=0) const
returnValue clearBuffer ()
 Clears the buffer and resets the buffer size
to 1.
returnValue setScale (double *scale_)
 Defines a scale for the case that a C-function is used
.
BooleanType isSymbolic () const
 Returns whether the function is symbolic or not.
BooleanType ADisSupported () const
returnValue setMemoryOffset (int memoryOffset_)
returnValue setGlobalExportVariableName (const String &var)
 Set name of the variable that holds intermediate values.
String getGlobalExportVariableName () const
 Get name of the variable that holds intermediate values.
unsigned getGlobalExportVariableSize () const
 Get size of the variable that holds intermediate values.

Protected Attributes

int counter
int * component
FunctionEvaluationTree evaluationTree
int memoryOffset
double * result

Friends

returnValue operator<< (FILE *file, Function &arg)
 Prints the function into a file.

Detailed Description

The class OutputFcn allows to setup and evaluate transition functions based on SymbolicExpressions.

Author:
Boris Houska, Hans Joachim Ferreau

Constructor & Destructor Documentation

References component, and counter.

References component, and counter.

Transition::~Transition ( ) [virtual]

References component.


Member Function Documentation

returnValue Function::AD_backward ( const Vector seed,
EvaluationPoint df,
const int &  number = 0 
) [inherited]
returnValue Function::AD_backward ( int  number,
double *  seed,
double *  df 
) [inherited]
Returns:
SUCCESFUL_RETURN
RET_NAN
Parameters:
numberthe buffer position
seedthe seed
dfthe derivative of the expression

References FunctionEvaluationTree::AD_backward(), Function::evaluationTree, and Function::memoryOffset.

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


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

References FunctionEvaluationTree::AD_backward2(), Function::evaluationTree, and Function::memoryOffset.

Referenced by MayerTerm::evaluateSensitivities().

Vector Function::AD_forward ( const EvaluationPoint x,
const int &  number = 0 
) [inherited]



Parameters:
xthe evaluation point
numberthe storage position

Returns:
The result of the evaluation.

References Function::getDim(), EvaluationPoint::getEvaluationPointer(), and Function::result.

Referenced by Function::AD_backward(), Integrator::diffTransitionForward(), MayerTerm::evaluateSensitivities(), and LSQTerm::evaluateSensitivitiesGN().

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


This function uses the intermediate
results from a buffer

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

References FunctionEvaluationTree::AD_forward(), Function::evaluationTree, and Function::memoryOffset.

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


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

References FunctionEvaluationTree::AD_forward2(), Function::evaluationTree, and Function::memoryOffset.

BooleanType Function::ADisSupported ( ) const [inline, inherited]


Returns:
SUCCESFUL_RETURN

References FunctionEvaluationTree::clearBuffer(), and Function::evaluationTree.

Vector Function::evaluate ( const EvaluationPoint x,
const int &  number = 0 
) [inherited]
template<typename T >
Tmatrix< T > Function::evaluate ( const TevaluationPoint< T > &  x) [inherited]



Parameters:
xthe evaluation point

Returns:
The result of the evaluation.

References FunctionEvaluationTree::evaluate(), Function::evaluationTree, Function::getDim(), and TevaluationPoint< T >::getEvaluationPointer().

returnValue Function::evaluate ( int  number,
double *  x,
double *  _result 
) [inherited]
Returns:
SUCCESFUL_RETURN
RET_NAN
Parameters:
numberstorage position
xthe input variable x
_resultthe result

References FunctionEvaluationTree::evaluate(), Function::evaluationTree, Function::memoryOffset, and SUCCESSFUL_RETURN.

returnValue Function::exportCode ( FILE *  file,
const char *  fcnName = "ACADOfcn",
const char *  realString = "double",
int  precision = 16,
uint  _numX = 0,
uint  _numXA = 0,
uint  _numU = 0,
uint  _numP = 0,
uint  _numDX = 0 
) const [inherited]
returnValue Function::exportForwardDeclarations ( FILE *  file,
const char *  fcnName = "ACADOfcn",
const char *  realString = "double" 
) const [inherited]
returnValue Function::exportHeader ( FILE *  file,
const char *  fcnName = "ACADOfcn",
const char *  realString = "double" 
) const [inherited]

References component, and counter.

BEGIN_NAMESPACE_ACADO int Function::getDim ( ) const [inline, inherited]
Returns:
The requested dimension.

References Function::evaluationTree, and FunctionEvaluationTree::getDim().

Referenced by Function::AD_backward(), Function::AD_forward(), PointConstraint::add(), CoupledPathConstraint::add(), BoundaryConstraint::add(), PathConstraint::add(), Curve::add(), PointConstraint::computeForwardSensitivityBlock(), AlgebraicConsistencyConstraint::computeForwardSensitivityBlock(), ConstraintElement::ConstraintElement(), OutputFcn::evaluate(), PointConstraint::evaluate(), PathConstraint::evaluate(), LSQTerm::evaluate(), LSQEndTerm::evaluate(), Function::evaluate(), PointConstraint::evaluateSensitivities(), LSQTerm::evaluateSensitivities(), PathConstraint::evaluateSensitivities(), AlgebraicConsistencyConstraint::evaluateSensitivities(), LSQTerm::evaluateSensitivitiesGN(), LSQEndTerm::evaluateSensitivitiesGN(), Function::exportCode(), Function::exportForwardDeclarations(), Function::exportHeader(), Function::Function(), ConstraintElement::get(), Integrator::getBackwardSensitivities(), Expression::getDependencyPattern(), PathConstraint::getDim(), BoundaryConstraint::getNC(), PointConstraint::getNC(), CoupledPathConstraint::getNC(), DifferentialEquation::getNumDynamicEquations(), DynamicSystem::getNumOutputs(), Integrator::getX(), Integrator::getXA(), ModelData::hasDifferentialEquation(), ModelContainer::hasDifferentialEquation(), IntegratorBDF::init(), IntegratorRK::init(), IntegratorLYAPUNOV::init(), EllipsoidalIntegrator::init(), Integrator::integrate(), Integrator::integrateSensitivities(), DynamicSystem::isConsistentOutputFcn(), Function::jacobian(), LSQEndTerm::LSQEndTerm(), LSQTerm::LSQTerm(), DifferentialEquation::makeImplicit(), OCP::minimizeLSQ(), OCP::minimizeLSQEndTerm(), Function::operator()(), Function::operator<<(), ConstraintElement::operator=(), Function::operator=(), LSQTerm::operator=(), LSQEndTerm::operator=(), Function::print(), ExportNLPSolver::setConstraints(), LSQTerm::setGrid(), IntegratorExport::setModelData(), and ExportNLPSolver::setObjective().

returnValue Function::getExpression ( Expression expression) const [inherited]
Operator * Function::getExpression ( uint  componentIdx) const [inherited]


Returns:
The symbolic expression

References Function::evaluationTree, and FunctionEvaluationTree::getExpression().

unsigned Function::getGlobalExportVariableSize ( ) const [inherited]
int Function::getN ( ) const [inline, inherited]


Returns:
The requested number of intermediate states.

References Function::evaluationTree, and FunctionEvaluationTree::getN().

Referenced by Function::getN(), IntegratorBDF::init(), IntegratorLYAPUNOV::init(), and IntegratorRK::init().

int Function::getN ( VariableType variableType_) const [inherited]
int Function::getNDX ( ) const [inherited]
int Function::getNP ( ) const [inherited]
int Function::getNPI ( ) const [inherited]
int Function::getNT ( ) const [inherited]
int Function::getNU ( ) const [inherited]
int Function::getNUI ( ) const [inherited]
int Function::getNumberOfVariables ( ) const [inherited]


Returns:
The number of variables

References Function::evaluationTree, and FunctionEvaluationTree::getNumberOfVariables().

Referenced by Function::AD_backward(), IntegratorLYAPUNOV::allocateMemory(), IntegratorRK::allocateMemory(), IntegratorBDF::allocateMemory(), PointConstraint::computeForwardSensitivityBlock(), IntegratorRK::constructAll(), IntegratorLYAPUNOV::constructAll(), IntegratorBDF::constructAll(), IntegratorLYAPUNOV::determineEtaHBackward(), IntegratorRK::determineEtaHBackward(), IntegratorLYAPUNOV::determineEtaHBackward2(), IntegratorRK::determineEtaHBackward2(), MayerTerm::evaluateSensitivities(), LSQTerm::evaluateSensitivities(), PointConstraint::evaluateSensitivities(), BoundaryConstraint::evaluateSensitivities(), PathConstraint::evaluateSensitivities(), CoupledPathConstraint::evaluateSensitivities(), IntegratorLYAPUNOV::evaluateSensitivities(), IntegratorRK::evaluateSensitivities(), LSQTerm::evaluateSensitivitiesGN(), LSQEndTerm::evaluateSensitivitiesGN(), Expression::getDependencyPattern(), TevaluationPoint< T >::init(), EvaluationPoint::init(), Function::jacobian(), IntegratorDiscretizedODE::performADbackwardStep(), IntegratorDiscretizedODE::performADbackwardStep2(), IntegratorLYAPUNOV::setBackwardSeed2(), IntegratorRK::setBackwardSeed2(), IntegratorLYAPUNOV::setForwardSeed2(), IntegratorRK::setForwardSeed2(), IntegratorLYAPUNOV::setProtectedBackwardSeed(), IntegratorRK::setProtectedBackwardSeed(), IntegratorLYAPUNOV::setProtectedForwardSeed(), and IntegratorRK::setProtectedForwardSeed().

int Function::getNW ( ) const [inherited]
int Function::getNX ( ) const [inherited]
int Function::getNXA ( ) const [inherited]
int Function::index ( VariableType  variableType_,
int  index_ 
) const [inherited]


Returns:
BT_FALSE if the expression is not affine
BT_TRUE otherwise

References BT_FALSE, BT_TRUE, Function::isConcave(), and Function::isConvex().

Referenced by Integrator::isDifferentialEquationAffine(), LSQTerm::isQuadratic(), and LSQEndTerm::isQuadratic().


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

References BT_FALSE, BT_TRUE, CT_AFFINE, CT_CONCAVE, CT_CONSTANT, Function::evaluationTree, and FunctionEvaluationTree::getCurvature().

Referenced by Function::isAffine().


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

References BT_FALSE, BT_TRUE, CT_AFFINE, CT_CONSTANT, CT_CONVEX, Function::evaluationTree, and FunctionEvaluationTree::getCurvature().

Referenced by Function::isAffine().

BooleanType Function::isDependingOn ( const Expression variable) [inherited]
Returns:
BT_FALSE if no dependence is detected
BT_TRUE otherwise

References Function::evaluationTree, and FunctionEvaluationTree::isDependingOn().

BooleanType Function::isLinearIn ( const Expression variable) [inherited]
Returns:
BT_FALSE if no linearity is
detected
BT_TRUE otherwise

References Function::evaluationTree, and FunctionEvaluationTree::isLinearIn().


Returns:
BT_FALSE if the expression is not nondecreasing
BT_TRUE otherwise

References BT_FALSE, BT_TRUE, Function::evaluationTree, FunctionEvaluationTree::getMonotonicity(), MT_CONSTANT, and MT_NONDECREASING.


Returns:
BT_FALSE if the expression is not nonincreasing
BT_TRUE otherwise

References BT_FALSE, BT_TRUE, Function::evaluationTree, FunctionEvaluationTree::getMonotonicity(), MT_CONSTANT, and MT_NONINCREASING.

Returns:
NE_ZERO
NE_ONE
NE_NEITHER_ONE_NOR_ZERO

References Function::evaluationTree, and FunctionEvaluationTree::isOneOrZero().

Referenced by ExportNLPSolver::setObjective().

BooleanType Function::isPolynomialIn ( const Expression variable) [inherited]
Returns:
BT_FALSE if the expression is not polynomial
BT_TRUE otherwise

References Function::evaluationTree, and FunctionEvaluationTree::isPolynomialIn().

BooleanType Function::isRationalIn ( const Expression variable) [inherited]
Returns:
BT_FALSE if the expression is not rational
BT_TRUE otherwise

References Function::evaluationTree, and FunctionEvaluationTree::isRationalIn().

BooleanType Function::isSymbolic ( ) const [inline, inherited]

If BT_TRUE
is returned, automatic differentiation will be used by
default.

References Function::evaluationTree, and FunctionEvaluationTree::isSymbolic().

Referenced by Function::ADisSupported(), LSQTerm::isQuadratic(), and Function::substitute().

returnValue Function::jacobian ( Matrix x) [inherited]

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

Parameters:
xwill be assigned jacobian(fun,differential states)

References Function::AD_backward(), Function::getDim(), Function::getNumberOfVariables(), Function::getNX(), Function::index(), VectorspaceElement::setAll(), SUCCESSFUL_RETURN, and VT_DIFFERENTIAL_STATE.

Function Function::operator() ( uint  idx) const [inherited]
Vector Function::operator() ( const EvaluationPoint x,
const int &  number = 0 
) [inline, inherited]



Parameters:
xthe evaluation point
numberthe storage position

Returns:
The result of the evaluation.

References Function::evaluate().

Transition & Transition::operator<< ( const DifferentialState arg)
Function & Function::operator<< ( const Expression arg) [inherited]
Function & Function::operator<< ( const double &  arg) [inherited]
Function & Function::operator<< ( const Vector arg) [inherited]
Function & Function::operator<< ( const Matrix arg) [inherited]
Transition & Transition::operator= ( const Transition arg)

References component, and counter.

Transition & Transition::operator== ( const Expression arg)

References operator<<().

Referenced by operator==().

Transition & Transition::operator== ( const double &  arg)

References operator==().

Transition & Transition::operator== ( const Vector arg)
Transition & Transition::operator== ( const Matrix arg)
returnValue Function::print ( FILE *  file,
const char *  fcnName = "ACADOfcn",
const char *  realString = "double",
int  precision = 16 
) const [inherited]

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

References FunctionEvaluationTree::C_print(), Function::evaluationTree, Function::getDim(), and SUCCESSFUL_RETURN.

Referenced by operator<<().

returnValue Function::reset ( ) [inherited]
double Function::scale ( VariableType  variableType_,
int  index_ 
) const [inherited]
returnValue Function::setMemoryOffset ( int  memoryOffset_) [inline, inherited]
returnValue Function::setScale ( double *  scale_) [inherited]
Returns:
SUCCESSFUL_RETURN

References Function::evaluationTree, and FunctionEvaluationTree::setScale().

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


Returns:
The substituted expression.
Parameters:
index_subst. index
sub_the substitution

References ACADOERROR, BT_TRUE, Function::evaluationTree, Function::isSymbolic(), RET_ONLY_SUPPORTED_FOR_SYMBOLIC_FUNCTIONS, FunctionEvaluationTree::substitute(), and SUCCESSFUL_RETURN.


Friends And Related Function Documentation

returnValue operator<< ( FILE *  file,
Function arg 
) [friend, inherited]


Returns:
SUCCESSFUL_RETURN

Member Data Documentation

int* Transition::component [protected]
int Transition::counter [protected]
int Function::memoryOffset [protected, inherited]
double* Function::result [protected, inherited]

The documentation for this class was generated from the following files:
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines