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

The class COperator is an auxiliary class to use C-Functions within a function evaluation tree. More...

#include <c_operator.hpp>

Inheritance diagram for COperator:
Inheritance graph
[legend]

Public Member Functions

virtual returnValue AD_backward (int dim, VariableType *varType, int *component, Operator *seed, Operator **df, int &nNewIS, TreeProjection ***newIS)
 
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 OperatorAD_forward (int dim, VariableType *varType, int *component, Operator **seed, int &nNewIS, TreeProjection ***newIS)
 
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)
 
virtual returnValue AD_symmetric (int dim, VariableType *varType, int *component, Operator *l, Operator **S, int dimS, Operator **dfS, Operator **ldf, Operator **H, int &nNewLIS, TreeProjection ***newLIS, int &nNewSIS, TreeProjection ***newSIS, int &nNewHIS, TreeProjection ***newHIS)
 
virtual returnValue clearBuffer ()
 
virtual Operatorclone () const
 
 COperator ()
 
 COperator (const CFunction &fcn, const Expression &arg, int component_)
 
 COperator (const COperator &arg)
 
virtual Operatordifferentiate (int index)
 
virtual returnValue enumerateVariables (SymbolicIndexList *indexList)
 
virtual returnValue evaluate (int number, double *x, double *result)
 
virtual returnValue evaluate (EvaluationBase *x)
 
virtual CurvatureType getCurvature ()
 
virtual MonotonicityType getMonotonicity ()
 
virtual OperatorName getName ()
 
int increaseID ()
 
virtual BooleanType isDependingOn (VariableType var) const
 
virtual BooleanType isDependingOn (int dim, VariableType *varType, int *component, BooleanType *implicit_dep)
 
virtual BooleanType isLinearIn (int dim, VariableType *varType, int *component, BooleanType *implicit_dep)
 
virtual NeutralElement isOneOrZero () const
 
virtual BooleanType isPolynomialIn (int dim, VariableType *varType, int *component, BooleanType *implicit_dep)
 
virtual BooleanType isRationalIn (int dim, VariableType *varType, int *component, BooleanType *implicit_dep)
 
virtual BooleanType isSymbolic () const
 
virtual BooleanType isVariable (VariableType &varType, int &component) const
 
virtual returnValue loadIndices (SymbolicIndexList *indexList)
 
COperatoroperator= (const COperator &arg)
 
virtual std::ostream & print (std::ostream &stream) const
 
virtual returnValue setCurvature (CurvatureType curvature_)
 
virtual returnValue setMonotonicity (MonotonicityType monotonicity_)
 
virtual Operatorsubstitute (int index, const Operator *sub)
 
 ~COperator ()
 
- Public Member Functions inherited from SmoothOperator
virtual TreeProjectioncloneTreeProjection () const
 
virtual int getGlobalIndex () const
 
virtual double getValue () const
 
virtual BooleanType isSmooth () const
 
Expression operator* (const double &arg) const
 
Expression operator* (const DVector &arg) const
 
Expression operator* (const DMatrix &arg) const
 
Expression operator* (const Operator &arg) const
 
Expression operator* (const Expression &arg) const
 
Operatoroperator*= (const double &arg)
 
Operatoroperator*= (const DVector &arg)
 
Operatoroperator*= (const DMatrix &arg)
 
Operatoroperator*= (const Expression &arg)
 
Expression operator+ (const double &arg) const
 
Expression operator+ (const DVector &arg) const
 
Expression operator+ (const DMatrix &arg) const
 
Expression operator+ (const Operator &arg) const
 
Expression operator+ (const Expression &arg) const
 
Operatoroperator+= (const double &arg)
 
Operatoroperator+= (const DVector &arg)
 
Operatoroperator+= (const DMatrix &arg)
 
Operatoroperator+= (const Expression &arg)
 
Expression operator- (const double &arg) const
 
Expression operator- (const DVector &arg) const
 
Expression operator- (const DMatrix &arg) const
 
Expression operator- (const Operator &arg) const
 
Expression operator- (const Expression &arg) const
 
Expression operator- () const
 
Operatoroperator-= (const double &arg)
 
Operatoroperator-= (const DVector &arg)
 
Operatoroperator-= (const DMatrix &arg)
 
Operatoroperator-= (const Expression &arg)
 
Expression operator/ (const double &arg) const
 
Expression operator/ (const Operator &arg) const
 
Expression operator/ (const Expression &arg) const
 
Operatoroperator/= (const double &arg)
 
Operatoroperator/= (const Expression &arg)
 
ConstraintComponent operator<= (const double &ub) const
 
ConstraintComponent operator<= (const DVector &ub) const
 
ConstraintComponent operator<= (const VariablesGrid &ub) const
 
virtual Operatoroperator= (const double &arg)
 
virtual Operatoroperator= (const DVector &arg)
 
virtual Operatoroperator= (const DMatrix &arg)
 
virtual Operatoroperator= (const Expression &arg)
 
virtual Operatoroperator= (const Operator &arg)
 
ConstraintComponent operator== (const double &b) const
 
ConstraintComponent operator== (const DVector &b) const
 
ConstraintComponent operator== (const VariablesGrid &b) const
 
ConstraintComponent operator>= (const double &lb) const
 
ConstraintComponent operator>= (const DVector &lb) const
 
ConstraintComponent operator>= (const VariablesGrid &lb) const
 
virtual OperatorpassArgument () const
 
 SmoothOperator ()
 
virtual ~SmoothOperator ()
 
- Public Member Functions inherited from Operator
virtual returnValue initDerivative ()
 
virtual BooleanType isTrivial () const
 
virtual OperatormyAdd (Operator *a, Operator *b)
 
virtual OperatormyLogarithm (Operator *a)
 
virtual OperatormyPower (Operator *a, Operator *b)
 
virtual OperatormyPowerInt (Operator *a, int b)
 
virtual OperatormyProd (Operator *a, Operator *b)
 
virtual OperatormySubtract (Operator *a, Operator *b)
 
 Operator ()
 
Expression operator* (const double &arg) const
 
Expression operator* (const DVector &arg) const
 
Expression operator* (const DMatrix &arg) const
 
Expression operator* (const Operator &arg) const
 
Expression operator* (const Expression &arg) const
 
Operatoroperator*= (const double &arg)
 
Operatoroperator*= (const DVector &arg)
 
Operatoroperator*= (const DMatrix &arg)
 
Operatoroperator*= (const Expression &arg)
 
Expression operator+ (const double &arg) const
 
Expression operator+ (const DVector &arg) const
 
Expression operator+ (const DMatrix &arg) const
 
Expression operator+ (const Operator &arg) const
 
Expression operator+ (const Expression &arg) const
 
Operatoroperator+= (const double &arg)
 
Operatoroperator+= (const DVector &arg)
 
Operatoroperator+= (const DMatrix &arg)
 
Operatoroperator+= (const Expression &arg)
 
Expression operator- (const double &arg) const
 
Expression operator- (const DVector &arg) const
 
Expression operator- (const DMatrix &arg) const
 
Expression operator- (const Operator &arg) const
 
Expression operator- (const Expression &arg) const
 
Expression operator- () const
 
Operatoroperator-= (const double &arg)
 
Operatoroperator-= (const DVector &arg)
 
Operatoroperator-= (const DMatrix &arg)
 
Operatoroperator-= (const Expression &arg)
 
Expression operator/ (const double &arg) const
 
Expression operator/ (const Operator &arg) const
 
Expression operator/ (const Expression &arg) const
 
Operatoroperator/= (const double &arg)
 
Operatoroperator/= (const Expression &arg)
 
ConstraintComponent operator<= (const double &ub) const
 
ConstraintComponent operator<= (const DVector &ub) const
 
ConstraintComponent operator<= (const VariablesGrid &ub) const
 
ConstraintComponent operator== (const double &b) const
 
ConstraintComponent operator== (const DVector &b) const
 
ConstraintComponent operator== (const VariablesGrid &b) const
 
ConstraintComponent operator>= (const double &lb) const
 
ConstraintComponent operator>= (const DVector &lb) const
 
ConstraintComponent operator>= (const VariablesGrid &lb) const
 
virtual returnValue setVariableExportName (const VariableType &_type, const std::vector< std::string > &_name)
 
virtual ~Operator ()
 

Protected Member Functions

void copy (const COperator &arg)
 
void deleteAll ()
 
- Protected Member Functions inherited from Operator
returnValue ADsymCommon (Operator *a, TreeProjection &da, TreeProjection &dda, int dim, VariableType *varType, int *component, Operator *l, Operator **S, int dimS, Operator **dfS, Operator **ldf, Operator **H, int &nNewLIS, TreeProjection ***newLIS, int &nNewSIS, TreeProjection ***newSIS, int &nNewHIS, TreeProjection ***newHIS)
 
returnValue ADsymCommon2 (Operator *a, Operator *b, TreeProjection &dx, TreeProjection &dy, TreeProjection &dxx, TreeProjection &dxy, TreeProjection &dyy, int dim, VariableType *varType, int *component, Operator *l, Operator **S, int dimS, Operator **dfS, Operator **ldf, Operator **H, int &nNewLIS, TreeProjection ***newLIS, int &nNewSIS, TreeProjection ***newSIS, int &nNewHIS, TreeProjection ***newHIS)
 
virtual TreeProjectionconvert2TreeProjection (Operator *a) const
 

Protected Attributes

Expression argument
 
uint bufferSize
 
CFunction cFunction
 
int component
 
double ** cresult
 
double ** d_cresult
 
double ** d_result
 
BooleanType first
 
int globalTypeID
 
int * idx
 
double ** result
 
- Protected Attributes inherited from Operator
BooleanType initialized
 

Static Protected Attributes

static int counter = 0
 

Additional Inherited Members

- Public Attributes inherited from SmoothOperator
int nCount
 
- Public Attributes inherited from Operator
int nCount
 

Detailed Description

The class COperator is an auxiliary class to use C-Functions within a function evaluation tree.

The class COperator is designed to be an auxiliary class to use C-Functions within a function evaluation tree.

Author
Boris Houska, Hans Joachim Ferreau

Definition at line 58 of file c_operator.hpp.

Constructor & Destructor Documentation

COperator::COperator ( )

Default constructor.

Definition at line 46 of file c_operator.cpp.

COperator::COperator ( const CFunction fcn,
const Expression arg,
int  component_ 
)

Default constructor.

Definition at line 63 of file c_operator.cpp.

COperator::COperator ( const COperator arg)

Copy constructor (deep copy).

Definition at line 100 of file c_operator.cpp.

COperator::~COperator ( )

Default destructor.

Definition at line 102 of file c_operator.cpp.

Member Function Documentation

returnValue COperator::AD_backward ( int  dim,
VariableType varType,
int *  component,
Operator seed,
Operator **  df,
int &  nNewIS,
TreeProjection ***  newIS 
)
virtual

Automatic Differentiation in backward mode on the symbolic
level. This function generates an expression for a
backward derivative

Returns
SUCCESSFUL_RETURN
Parameters
dimnumber of directions
varTypethe variable types
componentand their components
seedthe backward seed
dfthe result
nNewISthe number of new IS
newISthe new IS-pointer

Implements SmoothOperator.

Definition at line 260 of file c_operator.cpp.

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

Implements SmoothOperator.

Definition at line 450 of file c_operator.cpp.

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

Implements SmoothOperator.

Definition at line 497 of file c_operator.cpp.

Operator * COperator::AD_forward ( int  dim,
VariableType varType,
int *  component,
Operator **  seed,
int &  nNewIS,
TreeProjection ***  newIS 
)
virtual

Automatic Differentiation in forward mode on the symbolic
level. This function generates an expression for a
forward derivative

Returns
SUCCESSFUL_RETURN
Parameters
dimdimension of the seed
varTypethe variable types
componentand their components
seedthe forward seed
nNewISthe number of new IS
newISthe new IS-pointer

Implements SmoothOperator.

Definition at line 247 of file c_operator.cpp.

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

Implements SmoothOperator.

Definition at line 429 of file c_operator.cpp.

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

Implements SmoothOperator.

Definition at line 384 of file c_operator.cpp.

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

Implements SmoothOperator.

Definition at line 456 of file c_operator.cpp.

returnValue COperator::AD_symmetric ( int  dim,
VariableType varType,
int *  component,
Operator l,
Operator **  S,
int  dimS,
Operator **  dfS,
Operator **  ldf,
Operator **  H,
int &  nNewLIS,
TreeProjection ***  newLIS,
int &  nNewSIS,
TreeProjection ***  newSIS,
int &  nNewHIS,
TreeProjection ***  newHIS 
)
virtual

Automatic Differentiation in symmetric mode on the symbolic
level. This function generates an expression for a
second order derivative.

Returns
SUCCESSFUL_RETURN
Parameters
dimnumber of directions
varTypethe variable types
componentand their components
lthe backward seed
Sforward seed matrix
dimSdimension of forward seed
dfSfirst order foward result
ldffirst order backward result
Hupper trianglular part of the Hessian
nNewLISthe number of newLIS
newLISthe new LIS-pointer
nNewSISthe number of newSIS
newSISthe new SIS-pointer
nNewHISthe number of newHIS
newHISthe new HIS-pointer

Implements SmoothOperator.

Definition at line 273 of file c_operator.cpp.

returnValue COperator::clearBuffer ( )
virtual

Clears the buffer and resets the buffer size
to 1.

Returns
SUCCESFUL_RETURN

Implements SmoothOperator.

Definition at line 517 of file c_operator.cpp.

Operator * COperator::clone ( ) const
virtual

Provides a deep copy of the expression.

Returns
a clone of the expression.

Implements SmoothOperator.

Definition at line 511 of file c_operator.cpp.

void COperator::copy ( const COperator arg)
protected

Protected copy routine.

Definition at line 119 of file c_operator.cpp.

void COperator::deleteAll ( )
protected

Protected delete routine.

Definition at line 167 of file c_operator.cpp.

Operator * COperator::differentiate ( int  index)
virtual

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

Returns
The expression for the derivative.
Parameters
indexdiff. index

Implements SmoothOperator.

Definition at line 238 of file c_operator.cpp.

returnValue COperator::enumerateVariables ( SymbolicIndexList indexList)
virtual

Enumerates all variables based on a common
IndexList.

Returns
SUCCESFUL_RETURN

Implements SmoothOperator.

Definition at line 530 of file c_operator.cpp.

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

Implements SmoothOperator.

Definition at line 191 of file c_operator.cpp.

returnValue COperator::evaluate ( EvaluationBase x)
virtual

Evaluates the expression (templated version)

Implements SmoothOperator.

Definition at line 230 of file c_operator.cpp.

CurvatureType COperator::getCurvature ( )
virtual

Returns the curvature of the expression

Returns
CT_CONSTANT
CT_AFFINE
CT_CONVEX
CT_CONCAVE

Implements SmoothOperator.

Definition at line 366 of file c_operator.cpp.

MonotonicityType COperator::getMonotonicity ( )
virtual

Returns the monotonicity of the expression.

Returns
MT_NONDECREASING
MT_NONINCREASING
MT_NONMONOTONIC

Implements SmoothOperator.

Definition at line 360 of file c_operator.cpp.

OperatorName COperator::getName ( )
virtual

Asks the expression for its name.

Returns
the name of the expression.

Implements SmoothOperator.

Definition at line 547 of file c_operator.cpp.

int COperator::increaseID ( )

ID Operator.

Definition at line 116 of file c_operator.cpp.

BooleanType COperator::isDependingOn ( VariableType  var) const
virtual

Asks the expression whether it is depending on a certian type of
variable.

Returns
BT_TRUE if a dependency is detected,
BT_FALSE otherwise.

Implements SmoothOperator.

Definition at line 308 of file c_operator.cpp.

BooleanType COperator::isDependingOn ( int  dim,
VariableType varType,
int *  component,
BooleanType implicit_dep 
)
virtual

Checks whether the expression is depending on a variable

Returns
BT_FALSE if no dependence is detected
BT_TRUE otherwise
Parameters
dimnumber of directions
varTypethe variable types
componentand their components
implicit_depimplicit dependencies

Implements SmoothOperator.

Definition at line 319 of file c_operator.cpp.

BooleanType COperator::isLinearIn ( int  dim,
VariableType varType,
int *  component,
BooleanType implicit_dep 
)
virtual

Checks whether the expression is linear in
(or not depending on) a variable

Returns
BT_FALSE if no linearity is
detected
BT_TRUE otherwise
Parameters
dimnumber of directions
varTypethe variable types
componentand their components
implicit_depimplicit dependencies

Implements SmoothOperator.

Definition at line 333 of file c_operator.cpp.

NeutralElement COperator::isOneOrZero ( ) const
virtual

Checks whether the expression is zero or one

Returns
NE_ZERO
NE_ONE
NE_NEITHER_ONE_NOR_ZERO

Implements SmoothOperator.

Definition at line 301 of file c_operator.cpp.

BooleanType COperator::isPolynomialIn ( int  dim,
VariableType varType,
int *  component,
BooleanType implicit_dep 
)
virtual

Checks whether the expression is polynomial in
the specified variables

Returns
BT_FALSE if the expression is not polynomial
BT_TRUE otherwise
Parameters
dimnumber of directions
varTypethe variable types
componentand their components
implicit_depimplicit dependencies

Implements SmoothOperator.

Definition at line 342 of file c_operator.cpp.

BooleanType COperator::isRationalIn ( int  dim,
VariableType varType,
int *  component,
BooleanType implicit_dep 
)
virtual

Checks whether the expression is rational in
the specified variables

Returns
BT_FALSE if the expression is not rational
BT_TRUE otherwise
Parameters
dimnumber of directions
varTypethe variable types
componentand their components
implicit_depimplicit dependencies

Implements SmoothOperator.

Definition at line 351 of file c_operator.cpp.

BooleanType COperator::isSymbolic ( ) const
virtual

Asks whether all elements are purely symbolic.

Returns
BT_TRUE if the complete tree is symbolic.
BT_FALSE otherwise (e.g. if C functions are linked).

Implements SmoothOperator.

Definition at line 573 of file c_operator.cpp.

BooleanType COperator::isVariable ( VariableType varType,
int &  component 
) const
virtual

Asks the expression whether it is a variable.

Returns
The answer.

Implements SmoothOperator.

Definition at line 553 of file c_operator.cpp.

returnValue COperator::loadIndices ( SymbolicIndexList indexList)
virtual

The function loadIndices passes an IndexList through
the whole expression tree. Whenever a variable gets the
IndexList it tries to make an entry. However if a
variable recognices that it has already been added
before it will not be allowed to make a second entry.
Note that all variables, in paticular the intermediate
states, will keep in mind whether they were allowed
to make an entry or not. This guarantees that
intermediate states are never evaluated twice if they
occur at several knots of the tree.

THIS FUNCTION IS FOR INTERNAL USE ONLY.

PLEASE CALL THIS FUNTION AT MOST ONES FOR AN EXPRESSION
AS A KIND OF INIT ROUTINE.

Returns
the name of the expression.
Parameters
indexListThe index list to be filled with entries

Implements SmoothOperator.

Definition at line 559 of file c_operator.cpp.

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

Assignment Operator (deep copy).

Definition at line 105 of file c_operator.cpp.

std::ostream & COperator::print ( std::ostream &  stream) const
virtual

Prints the expression into a stream.

Returns
SUCCESFUL_RETURN

Implements SmoothOperator.

Definition at line 504 of file c_operator.cpp.

returnValue COperator::setCurvature ( CurvatureType  curvature_)
virtual

Overwrites the curvature of the expression.
(For the case that the curvature is explicitly known)

Returns
SUCCESSFUL_RETURN

Implements SmoothOperator.

Definition at line 378 of file c_operator.cpp.

returnValue COperator::setMonotonicity ( MonotonicityType  monotonicity_)
virtual

Overwrites the monotonicity of the expression.
(For the case that the monotonicity is explicitly known)

Returns
SUCCESSFUL_RETURN

Implements SmoothOperator.

Definition at line 372 of file c_operator.cpp.

Operator * COperator::substitute ( int  index,
const Operator sub 
)
virtual

Substitutes var(index) with the expression sub.

Returns
The substituted expression.
Parameters
indexsubst. index
subthe substitution

Implements SmoothOperator.

Definition at line 294 of file c_operator.cpp.

Member Data Documentation

Expression COperator::argument
protected

The argument for the evaluation

Definition at line 460 of file c_operator.hpp.

uint COperator::bufferSize
protected

The size of the buffer.

Definition at line 469 of file c_operator.hpp.

CFunction COperator::cFunction
protected

The C function to be evaluated

Definition at line 459 of file c_operator.hpp.

int COperator::component
protected

The component of the CFunction

Definition at line 468 of file c_operator.hpp.

BEGIN_NAMESPACE_ACADO int COperator::counter = 0
staticprotected

counter of the C-Operators

Definition at line 475 of file c_operator.hpp.

double** COperator::cresult
protected

The results of the evaluation of the Cfunction

Definition at line 465 of file c_operator.hpp.

double** COperator::d_cresult
protected

The results for the derivative of the Cfunction

Definition at line 466 of file c_operator.hpp.

double** COperator::d_result
protected

The results for the derivative of the argument

Definition at line 463 of file c_operator.hpp.

BooleanType COperator::first
protected

Whether this compontent is evaluated first

Definition at line 471 of file c_operator.hpp.

int COperator::globalTypeID
protected

global ID of the C-Operator

Definition at line 474 of file c_operator.hpp.

int* COperator::idx
protected

variable index list

Definition at line 473 of file c_operator.hpp.

double** COperator::result
protected

The results of the evaluation of the argument

Definition at line 462 of file c_operator.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:23