ocra-recipes
Doxygen documentation for the ocra-recipes repository
Public Member Functions | List of all members
ocra::Constraint< T > Class Template Reference

Constraint class. More...

#include <Constraint.h>

Inheritance diagram for ocra::Constraint< T >:
[legend]
Collaboration diagram for ocra::Constraint< T >:
[legend]

Public Member Functions

 Constraint (T *function, bool equality, const VectorXd &v=VectorXd())
 
 Constraint (T *function, const VectorXd &l=VectorXd(), const VectorXd &u=VectorXd())
 
 operator const T & ()
 
virtual T & getFunction (void)
 
virtual const T & getFunction (void) const
 

Detailed Description

template<class T>
class ocra::Constraint< T >

Constraint class.

Warning
None

Given a function $ f $ over $ x \in R^n $ and possibly over the time $ t $, we can write a constraint whose most generic expression is $ l \le f(x,t) \le u $, with $ l $ and $ u $ two vectors of size $ m $ having their value in $ \left(R\cup\left\{-\infty,+\infty\right\}\right)^m $ and verifying $ l \le u $. This class is a C++ translation of this mathematical writing, but distinguishes some specific cases, for the ease of use, that are enumerated by eConstraintType :

The Constraint class is templated by the type of the function on which the constraint is built. Provided the class definition of this function provides the good typedef functionType_t, the hierarchy of the Function classes is mimicked by Constraint: if B is a class deriving of A and B::functionType_t is A, then Constraint will automatically derived from Constraint. As a concrete example, if DiagonalLinearFunction derives from LinearFunction that derives from Function, then Constraint<DiagonalLinearFunction> will derive from Constraint<LinearFunction> that will itself derive from Constraint<Function>. Thus a Constraint<DiagonalLinearFunction> is also a Constraint<LinearFunction> for example.

A Constraint class inherits from FunctionInterfaceMapping of the interface of Function, an instance of Constraint can be treated as a Function, to directly call methods of function on it. Constraint<T> is however not deriving from Function.

See also
FunctionInterfaceMapping

Definition at line 100 of file Constraint.h.

Constructor & Destructor Documentation

template<class T >
ocra::Constraint< T >::Constraint ( T *  function,
bool  equality,
const VectorXd &  v = VectorXd() 
)
inline

Constraint constructor to build simple equality/inequality constraints

Parameters
[in]functionA pointer to the function on which the constraint is imposed.
[in]equalityTrue if the constraint is an equality, false if it is an inequality.
[in]vAn optional vector to shift the constraint

The following cases arise:

  • Constraint(f, true): the constraint describes $ f(x,t) = 0 $ (type CSTR_EQUAL_ZERO)
  • Constraint(f, false): the constraint describes $ f(x,t) \le 0 $ (type CSTR_LOWER_ZERO)
  • Constraint(f, true, b): the constraint describes $ f(x,t) = b $ (type CSTR_EQUAL_B)
  • Constraint(f, false, u): the constraint describes $ f(x,t) \le u $ (type CSTR_LOWER_U)
Precondition
If v is given (and non null), v.size() must be equal to function->getDimension()

Definition at line 576 of file Constraint.h.

template<class T >
ocra::Constraint< T >::Constraint ( T *  function,
const VectorXd &  l = VectorXd(),
const VectorXd &  u = VectorXd() 
)
inline

Constraint constructor to build inequality constraints with possibly lower and upper bounds

Parameters
[in]functionA pointer to the function on which the constraint is imposed.
[in]lLower bound vector.
[in]uLower bound vector.

The following cases arise:

  • Constraint(f): the constraint describes $ f(x,t) \ge 0 $ (type CSTR_GREATER_ZERO)
  • Constraint(f, l): the constraint describes $ f(x,t) \ge l $ (type CSTR_GREATER_L)
  • Constraint(f, l, u): the constraint describes $ l \le f(x,t) \le u $ (type CSTR_LOWER_AND_GREATER)
  • Constraint(f, l, u) with l==VectorXd(): the constraint describes $ f(x,t) \le u $ (type CSTR_LOWER_U)
  • Constraint(f, l, u) with l==u: the constraint describes $ f(x,t) = u $ (type CSTR_EQUAL_B)
Precondition
l<=u
If l or u is given (and non null), their size must be equal to function->getDimension()

Definition at line 585 of file Constraint.h.

Member Function Documentation

template<class T>
virtual T& ocra::Constraint< T >::getFunction ( void  )
inlinevirtual

getter on the function on which the constraint is built

Definition at line 156 of file Constraint.h.

template<class T>
virtual const T& ocra::Constraint< T >::getFunction ( void  ) const
inlinevirtual

Definition at line 157 of file Constraint.h.

template<class T>
ocra::Constraint< T >::operator const T & ( )
inline

Conversion operator

Definition at line 152 of file Constraint.h.


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