ocra-recipes
Doxygen documentation for the ocra-recipes repository
|
Function class. More...
#include <Function.h>
Public Member Functions | |
virtual | ~Function () |
int | getDimension () const |
virtual void | updateFdot () const |
virtual void | updateFddot () const |
virtual void | updateJdotXdot () const |
const Variable & | getVariable () const |
Variable & | getVariable () |
template<eFunctionAbility Ability> | |
void | invalidate () |
void | invalidateAll (int timestamp) |
void | invalidateAll () |
template<eFunctionAbility Ability> | |
bool | isValid () const |
template<eFunctionAbility Ability> | |
bool | canCompute () const |
template<eFunctionAbility Ability> | |
const IFunction< Ability >::return_type & | get () const |
template<eFunctionAbility Ability> | |
IFunction< Ability >::return_sub_type | get (int index) const |
const VectorXd & | getValue () const |
double | getValue (int index) const |
const MatrixXd & | getJacobian () const |
MatrixXdRow | getJacobian (int index) const |
Public Member Functions inherited from ocra::ObserverSubject | |
ObserverSubject () | |
virtual | ~ObserverSubject () |
Public Member Functions inherited from ocra::Observer | |
virtual | ~Observer () |
template<int EVT> | |
void | bind (SubjectBase< EVT > &subject) |
Call this method to automatically propagate observed events to observers connected to the subject given in argument. More... | |
template<int EVT> | |
void | stopPropagation () |
Public Member Functions inherited from ocra::ObserverBase< EVT_RESIZE > | |
void | bind (subject_type &subject) |
Call this method to automatically propagate observed events to observers connected to the subject given in argument. More... | |
Public Member Functions inherited from ocra::ObserverBase< EVT_CHANGE_DEPENDENCIES > | |
void | bind (subject_type &subject) |
Call this method to automatically propagate observed events to observers connected to the subject given in argument. More... | |
Public Member Functions inherited from ocra::ObserverBase< EVT_CHANGE_VALUE > | |
void | bind (subject_type &subject) |
Call this method to automatically propagate observed events to observers connected to the subject given in argument. More... | |
Public Member Functions inherited from ocra::Subject | |
virtual | ~Subject () |
template<int EVT, class Derived , class Base > | |
void | connect (Derived &object, void(Base::*newCallback)(int)) const |
Call this method to register a non-static method as a callback. More... | |
template<int EVT> | |
void | connect (void(*newCallback)(int)) const |
Call this method to register a free function as a callback. More... | |
template<int EVT, class Derived , class Base > | |
void | disconnect (Derived &object, void(Base::*callbackToErase)(int)) const |
Disconnect non-static method. More... | |
template<int EVT> | |
void | disconnect (void(*callbackToErase)(int)) const |
Disconnect free function. More... | |
template<int EVT> | |
void | propagate () const |
template<int EVT> | |
void | propagate (int timestamp) const |
Public Member Functions inherited from ocra::SubjectBase< EVT_RESIZE > | |
void | connect (T &object, typename SubjectBaseTraits< EVT, T >::callback_type newCallback) const |
Call this method to register a non-static method as a callback. More... | |
void | connect (typename SubjectBaseTraits< EVT, void >::callback_type newCallback) const |
Call this method to register a free function as a callback. More... | |
void | disconnect (T &object, typename SubjectBaseTraits< EVT, T >::callback_type callback) const |
Disconnect non-static method. More... | |
void | disconnect (typename SubjectBaseTraits< EVT, void >::callback_type callbackToErase) const |
Disconnect free function. More... | |
void | propagate (int timestamp) const |
void | propagate () const |
Public Member Functions inherited from ocra::SubjectBase< EVT_CHANGE_DEPENDENCIES > | |
void | connect (T &object, typename SubjectBaseTraits< EVT, T >::callback_type newCallback) const |
Call this method to register a non-static method as a callback. More... | |
void | connect (typename SubjectBaseTraits< EVT, void >::callback_type newCallback) const |
Call this method to register a free function as a callback. More... | |
void | disconnect (T &object, typename SubjectBaseTraits< EVT, T >::callback_type callback) const |
Disconnect non-static method. More... | |
void | disconnect (typename SubjectBaseTraits< EVT, void >::callback_type callbackToErase) const |
Disconnect free function. More... | |
void | propagate (int timestamp) const |
void | propagate () const |
Public Member Functions inherited from ocra::SubjectBase< EVT_CHANGE_VALUE > | |
void | connect (T &object, typename SubjectBaseTraits< EVT, T >::callback_type newCallback) const |
Call this method to register a non-static method as a callback. More... | |
void | connect (typename SubjectBaseTraits< EVT, void >::callback_type newCallback) const |
Call this method to register a free function as a callback. More... | |
void | disconnect (T &object, typename SubjectBaseTraits< EVT, T >::callback_type callback) const |
Disconnect non-static method. More... | |
void | disconnect (typename SubjectBaseTraits< EVT, void >::callback_type callbackToErase) const |
Disconnect free function. More... | |
void | propagate (int timestamp) const |
void | propagate () const |
Public Member Functions inherited from ocra::IFunctionProperties | |
bool | hasSeparableTimeDependancy (void) const |
eFunctionLinearity | getType (void) const |
eFunctionConvexity | getConvexityProperty (void) const |
int | getContinuityProperty (void) const |
const std::string & | getProperty (int i) const |
int | getNumberOfProperties (void) const |
bool | hasProperty (const std::string &functionProperty) const |
bool | isExplicitlyTimeDependant (void) const |
Public Member Functions inherited from ocra::NamedInstance | |
NamedInstance (const std::string &name) | |
const std::string & | getName () const |
virtual | ~NamedInstance () |
Public Member Functions inherited from ocra::AbilitySet | |
AbilitySet & | add (eFunctionAbility prop) |
AbilitySet & | remove (eFunctionAbility prop) |
Protected Member Functions | |
Function (Variable &x, int dimension, eFunctionLinearity linearity=LINEARITY_UNDEFINED, eFunctionConvexity convexity=CONVEXITY_UNDEFINED, int continuity=CONTINUITY_UNKNOWN, bool explicitlyTimeDependant=false, bool separableTimeDependancy=true) | |
Function Constructor. More... | |
void | disconnectVariable () |
void | changeFunctionDimension (int newDimension) |
void | updateInputSize (int timestamp) |
void | resize () |
virtual int | computeDimensionFromInputSize () const |
virtual void | doUpdateInputSizeBegin () |
virtual void | doUpdateInputSizeEnd () |
virtual void | doUpdateDimensionBegin (int newDimension) |
virtual void | doUpdateDimensionEnd (int oldDimension) |
Protected Member Functions inherited from ocra::ObserverBase< EVT_RESIZE > | |
void | stopPropagation () |
Call this method from your callbacks to avoid propagation to the bound subject (if any). More... | |
ObserverBase () | |
~ObserverBase () | |
Protected Member Functions inherited from ocra::ObserverBase< EVT_CHANGE_DEPENDENCIES > | |
void | stopPropagation () |
Call this method from your callbacks to avoid propagation to the bound subject (if any). More... | |
ObserverBase () | |
~ObserverBase () | |
Protected Member Functions inherited from ocra::ObserverBase< EVT_CHANGE_VALUE > | |
void | stopPropagation () |
Call this method from your callbacks to avoid propagation to the bound subject (if any). More... | |
ObserverBase () | |
~ObserverBase () | |
Protected Member Functions inherited from ocra::SubjectBase< EVT_RESIZE > | |
SubjectBase () | |
~SubjectBase () | |
Protected Member Functions inherited from ocra::SubjectBase< EVT_CHANGE_DEPENDENCIES > | |
SubjectBase () | |
~SubjectBase () | |
Protected Member Functions inherited from ocra::SubjectBase< EVT_CHANGE_VALUE > | |
SubjectBase () | |
~SubjectBase () | |
Protected Member Functions inherited from ocra::IFunctionProperties | |
IFunctionProperties (eFunctionLinearity linearity=LINEARITY_UNDEFINED, eFunctionConvexity convexity=CONVEXITY_UNDEFINED, int continuity=CONTINUITY_UNKNOWN, bool explicitlyTimeDependant=false, bool separableTimeDependancy=true) | |
IFunctionProperties Constructor. More... | |
void | changeType (eFunctionLinearity newType) |
void | changeConvexityProperty (eFunctionConvexity newProperty) |
void | changeContinuityProperty (int newProperty) |
void | addProperty (const std::string &functionProperty) |
void | removeProperty (const std::string &functionProperty) |
void | changeExplicitTimeDependancy (bool b) |
void | changeSeparableTimeDependancy (bool b) |
Protected Member Functions inherited from ocra::AbilitySet | |
AbilitySet (const std::vector< bool > &usageSet) | |
const std::vector< bool > & | getUsageSet () const |
AbilitySet (eFunctionAbility prop0=FUN_VALUE, eFunctionAbility prop1=FUN_VALUE) | |
AbilitySet (eFunctionAbility prop0, eFunctionAbility prop1, eFunctionAbility prop2, eFunctionAbility prop3=FUN_VALUE, eFunctionAbility prop4=FUN_VALUE) | |
AbilitySet (eFunctionAbility prop0, eFunctionAbility prop1, eFunctionAbility prop2, eFunctionAbility prop3, eFunctionAbility prop4, eFunctionAbility prop5, eFunctionAbility prop6=FUN_VALUE, eFunctionAbility prop7=FUN_VALUE, eFunctionAbility prop8=FUN_VALUE, eFunctionAbility prop9=FUN_VALUE) | |
Protected Member Functions inherited from ocra::CoupledInputOutputSize | |
CoupledInputOutputSize (bool coupledInputOutputSize) | |
bool | inputAndOutputSizesAreCoupled () const |
Protected Attributes | |
Variable & | x |
VectorXd & | _value |
MatrixXd & | _jacobian |
const int & | _dim |
Additional Inherited Members | |
Protected Types inherited from ocra::ObserverBase< EVT_RESIZE > | |
typedef SubjectBase< EVT > | subject_type |
typedef InvokerBase< EVT > | invoker_type |
Protected Types inherited from ocra::ObserverBase< EVT_CHANGE_DEPENDENCIES > | |
typedef SubjectBase< EVT > | subject_type |
typedef InvokerBase< EVT > | invoker_type |
Protected Types inherited from ocra::ObserverBase< EVT_CHANGE_VALUE > | |
typedef SubjectBase< EVT > | subject_type |
typedef InvokerBase< EVT > | invoker_type |
Function class.
Base class for a function defined as follows: is time-dependant n-dimensional variable living in , A is a set of (possibly changing) parameters. is a function of with a possible explicit time dependency. Thus we have , with The set of parameters is considered to be constant with respect to the time on a mathematical point of view, yet the user can change it anytime. Although might be explicitly time-dependant, no interfaces are given at this level to specify the value of variable . This responsibility is transfered to the derived classes.
Function inherits from several IFunction, each of which comes with a virtual method that need to be overloaded if the corresponding ability is used. Below is the list of abilities with the corresponding methods and return types. In case of doubt or out-of-date documentation, please see the use of the macro DECLARE_FUNCTION_TRAITS in IFunction.h. For the most usual abilities, some shortcuts are implemented to ease both programming and reading.
Ability return type virtual update method buffer alias getter alias FUN_VALUE VectorXd updateValue _value getValue PARTIAL_X MatrixXd updateJacobian _jacobian getJacobian PARTIAL_T VectorXd updatePartialT FUN_DOT VectorXd updateFdot PARTIAL_X_DOT MatrixXd updateJdot PARTIAL_XX std::vector<MatrixXd*> updateHessian FUN_DDOT VectorXd updateFddot PARTIAL_TT VectorXd updatePartialTT PARTIAL_TX MatrixXd updatePartialTX PARTIAL_XT MatrixXd updatePartialXT PARTIAL_T_DOT VectorXd updatePartialTdot PARTIAL_X_DOT_X_DOT VectorXd updateJdotXdot
[Please UPDATE if you add abilities]
Function also inherits from IFunctionProperties and as such is given an interface of trivial getters and setters which don't appear here.
Definition at line 77 of file Function.h.
|
protected |
Function Constructor.
[in] | x | The time-dependant variable on which f is defined. |
[in] | dimension | The dimension of the output space, m in the description of the class. |
[in] | linearity | Linearity property of the function. |
[in] | convexity | Convexity property of the function. |
[in] | continuity | Continuity property of the function. |
[in] | explicitlyTimeDependant | |
[in] | separableTimeDependancy | |
[in] | use[SomeAbility] | Indicates wether the function must perform memory allocation and computation for the corresponding ability. |
Definition at line 6 of file Function.cpp.
|
virtual |
Definition at line 27 of file Function.cpp.
|
inline |
return true if the corresponding ability is enabled
Definition at line 347 of file Function.h.
|
protected |
Changes the dimension of the function to newDimension. This changes the value of _dimension by performing the following actions:
This method calls doUpdateDimensionBegin
before executing its core and doUpdateDimensionEnd after. These virtual methods might throw exceptions depending on their overloaded implementation. By default, doUpdateSizeBegin throws a runtime_error: the programmer of a new function needs to overloaded it if his/her function supports function resizing.
Definition at line 56 of file Function.cpp.
|
protectedvirtual |
Does what it tells...
Reimplemented in ocra::DiagonalLinearFunction, and ocra::DoubleDiagonalLinearFunction.
Definition at line 103 of file Function.cpp.
|
protected |
Call this method before deleting, if needed, the variable &x in any child classes. Else it's automatically called in ~Function. Error prone design inside(tm)
Definition at line 31 of file Function.cpp.
|
protectedvirtual |
Methods for pre and post update in case the dimension of the function has changed. Default implementation of doUpdateDimensionEnd does nothing, doUpdateDimensionBegin throws an exception. These methods might throw exceptions when overloaded. Furthermore, doUpdateDimensionEnd()
must comply with the post condition of updateDimension()
, i.e. let the values of each ability invalidated.
Reimplemented in ocra::DiagonalLinearFunction, ocra::ContactAvoidanceFunction, ocra::DoubleDiagonalLinearFunction, and ocra::LinearTask.
Definition at line 109 of file Function.cpp.
|
protectedvirtual |
Reimplemented in ocra::ContactAvoidanceFunction, ocra::QuadraticFunction, and ocra::LinearTask.
Definition at line 114 of file Function.cpp.
|
protectedvirtual |
Methods for pre and post update in case the variable size has changed. Default implementation of doUpdateInputSizeEnd does nothing, doUpdateInputSizeBegin throws an exception. These methods might throw exceptions when overloaded. Furthermore, doUpdateInputSizeEnd()
must comply with the post condition of updateInputSize()
, i.e. let the values of each ability invalidated.
Reimplemented in Function3, Function2, ocra::DiagonalLinearFunction, ocra::DoubleDiagonalLinearFunction, ocra::LinearTask, ocra::WeightedSquareDistanceFunction, ocra::SquaredLinearFunction, Function1, ocra::FullDynamicEquationFunction, ocra::DynamicEquationFunction, ocra::IdentityFunction, ocra::SumOfLinearFunctions, ocra::FcQuadraticFunction, and ocra::VariableChiFunction.
Definition at line 93 of file Function.cpp.
|
protectedvirtual |
Reimplemented in Function2, ocra::DiagonalLinearFunction, ocra::LinearFunction, ocra::QuadraticFunction, ocra::DoubleDiagonalLinearFunction, ocra::WeightedSquareDistanceFunction, ocra::FullDynamicEquationFunction, ocra::IdentityFunction, ocra::DynamicEquationFunction, and ocra::VariableChiFunction.
Definition at line 98 of file Function.cpp.
|
inline |
Get the value of the quantity corresponding to the function ability specified by Ability. This value is recomputed if needed in a transparent way for the user.
Ability | The label of the ability |
Throws std::runtime_error if the virtual update method has not been overloaded for this ability.
For performance reasons, no exceptions are thrown when this method is called for an ability which is not used. A high-level usage should make its own check by calling first IFunction<Ability>::canBeComputed
.
For example, get<PARTIAL_TX>() returns computed at the current (x,t).
For some abilities, there exist aliases.
Definition at line 353 of file Function.h.
|
inline |
Get a subpart of the value of the quantity corresponding to the function ability specified by Ability. This value is recomputed if needed in a transparent way for the user.
Ability | The label of the ability. |
[in] | index | The index of the subpart of the value (corresponding to f_index). |
For example, get<PARTIAL_X>(i) returns computed at the current (x,t).
Definition at line 359 of file Function.h.
int ocra::Function::getDimension | ( | ) | const |
get the dimension m of the output space
Definition at line 41 of file Function.cpp.
|
inline |
return the jacobian of the function at the current (x,t). Synonym for get<PARTIAL_X>()
Definition at line 375 of file Function.h.
|
inline |
return the ith component of the jacobian of the function at the current (x,t). Synonym for get<PARTIAL_X>(index)
Definition at line 380 of file Function.h.
|
inline |
aliases return the value of the function at the current (x,t). Synonym for get<FUN_VALUE>()
Definition at line 365 of file Function.h.
|
inline |
return the ith component of the value of the function at the current (x,t). Synonym for get<FUN_VALUE>(index)
Definition at line 370 of file Function.h.
const Variable & ocra::Function::getVariable | ( | ) | const |
get the variable x on which the function is defined
Definition at line 46 of file Function.cpp.
Variable & ocra::Function::getVariable | ( | ) |
Definition at line 51 of file Function.cpp.
|
inline |
invalidate the value of the corresponding ability
Definition at line 325 of file Function.h.
|
inline |
invalidate the value of each ability
Definition at line 335 of file Function.h.
|
inline |
Definition at line 330 of file Function.h.
|
inline |
check the validity of the value of the corresponding ability
Definition at line 341 of file Function.h.
|
protected |
Core of updateInputSize()
and Update the size of the memory buffers according to the size of the input variable and the dimension m of the function. Only the buffers corresponding to used ability are resized. This implies that their values are invalidated.
Definition at line 86 of file Function.cpp.
|
virtual |
Generic implentation of updateFddot.
This is not an optimal implementation in case it is known wether the function depends explicitly on time or not. A test is indeed performed at runtime to decide which computations need to be done.
Definition at line 130 of file Function.cpp.
|
virtual |
Generic implementation of updateFdot.
This is not an optimal implementation in case it is known wether the function depends explicitly on the time or not. A test is indeed performed at runtime to decide which computations need to be done.
Reimplemented in MyFunction.
Definition at line 119 of file Function.cpp.
|
protected |
Update the size of the memory buffers according to the size of the input variable and the current dimension m of the function. Only the buffers corresponding to used abilities are resized. This implies that their values are invalidated. This method is automaticaly invoked when the function variable x
is resized.
This method calls doUpdateSizeBegin
before executing its core and doUpdateSizeEnd after. These virtual methods might throw exceptions depending on their overloaded implementation. By default, doUpdateSizeBegin throws a runtime_error: the programmer of a new function needs to overloaded it if his/her function supports variable resizing.
Definition at line 71 of file Function.cpp.
|
virtual |
Generic implementation of updateJdotXdot.
Definition at line 145 of file Function.cpp.
|
protected |
Definition at line 320 of file Function.h.
|
protected |
Definition at line 313 of file Function.h.
|
protected |
Definition at line 312 of file Function.h.
|
protected |
Definition at line 309 of file Function.h.