All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
roboptim::FunctionPool< F, FLIST > Class Template Reference

A pool of functions that will be processed together. More...

#include <roboptim/core/function-pool.hh>

Inheritance diagram for roboptim::FunctionPool< F, FLIST >:

Public Types

typedef F pool_t
 Function type of the pool. More...
 
typedef detail::list_converter
< FLIST >::type 
functionTypeList_t
 
typedef
detail::shared_ptr_variant
< functionTypeList_t >::type 
function_t
 Type of the functions in the pool. More...
 
typedef std::vector< function_tfunctionList_t
 List of functions that will populate the pool. More...
 
typedef F callback_t
 Type of the callback function (where the computation happens). More...
 
typedef boost::shared_ptr
< callback_t
callback_ptr
 

Public Member Functions

 ROBOPTIM_DIFFERENTIABLE_FUNCTION_FWD_TYPEDEFS_ (pool_t)
 
 FunctionPool (const callback_ptr callback, const functionList_t &functions, const std::string &name="")
 FunctionPool constructor. More...
 
virtual ~FunctionPool ()
 Virtual destructor. More...
 
virtual void impl_compute (result_ref result, const_argument_ref x) const
 
virtual void impl_gradient (gradient_ref gradient, const_argument_ref argument, size_type functionId=0) const
 
virtual void impl_jacobian (jacobian_ref jacobian, const_argument_ref arg) const
 
virtual std::ostream & print (std::ostream &) const
 Overriden print function for pools. More...
 

Static Public Member Functions

static size_type listInputSize (const functionList_t &functions)
 Get the input size from the function list. More...
 
static size_type listOutputSize (const functionList_t &functions)
 Get the output size from the function list. More...
 

Detailed Description

template<typename F, typename FLIST>
class roboptim::FunctionPool< F, FLIST >

A pool of functions that will be processed together.

This class provides a way to regroup functions that depend on the same "computation engine", for instance a simulator that generates some data, then each function of the pool can simply read the computed data (which could be done in parallel).

TODO: the actual type of the FunctionPool should depend on the list of constraints that are supported. We could imagine using a metaprogramming version of LCA (lowest common ancestor) to find the Function type that will best match the list. In hybrid scenarios where we have both differentiable and non-differentiable functions, two pools sharing the same callback should probably be used. For now, we will rely on a user-provided function type.

Template Parameters
Ftype of the pool.
FLISTlist of valid function types.

Member Typedef Documentation

template<typename F, typename FLIST>
typedef boost::shared_ptr<callback_t> roboptim::FunctionPool< F, FLIST >::callback_ptr
template<typename F, typename FLIST>
typedef F roboptim::FunctionPool< F, FLIST >::callback_t

Type of the callback function (where the computation happens).

template<typename F, typename FLIST>
typedef detail::shared_ptr_variant<functionTypeList_t>::type roboptim::FunctionPool< F, FLIST >::function_t

Type of the functions in the pool.

template<typename F, typename FLIST>
typedef std::vector<function_t> roboptim::FunctionPool< F, FLIST >::functionList_t

List of functions that will populate the pool.

template<typename F, typename FLIST>
typedef detail::list_converter<FLIST>::type roboptim::FunctionPool< F, FLIST >::functionTypeList_t
template<typename F, typename FLIST>
typedef F roboptim::FunctionPool< F, FLIST >::pool_t

Function type of the pool.

Note: this will be set by LCA called on the function type list.

Constructor & Destructor Documentation

template<typename F , typename FLIST >
roboptim::FunctionPool< F, FLIST >::FunctionPool ( const callback_ptr  callback,
const functionList_t functions,
const std::string &  name = "" 
)
explicit

FunctionPool constructor.

Parameters
callbackcallback function for the engine.
functionsfunctions of the pool.
namename of the pool.
template<typename F , typename FLIST >
roboptim::FunctionPool< F, FLIST >::~FunctionPool ( )
virtual

Virtual destructor.

Member Function Documentation

template<typename F , typename FLIST >
void roboptim::FunctionPool< F, FLIST >::impl_compute ( result_ref  result,
const_argument_ref  x 
) const
virtual
template<typename F , typename FLIST >
void roboptim::FunctionPool< F, FLIST >::impl_gradient ( gradient_ref  gradient,
const_argument_ref  argument,
size_type  functionId = 0 
) const
virtual
template<typename F , typename FLIST >
void roboptim::FunctionPool< F, FLIST >::impl_jacobian ( jacobian_ref  jacobian,
const_argument_ref  arg 
) const
virtual
template<typename F, typename FLIST>
FunctionPool< F, FLIST >::size_type roboptim::FunctionPool< F, FLIST >::listInputSize ( const functionList_t functions)
static

Get the input size from the function list.

template<typename F, typename FLIST>
FunctionPool< F, FLIST >::size_type roboptim::FunctionPool< F, FLIST >::listOutputSize ( const functionList_t functions)
static

Get the output size from the function list.

template<typename F , typename FLIST >
std::ostream & roboptim::FunctionPool< F, FLIST >::print ( std::ostream &  o) const
virtual

Overriden print function for pools.

References roboptim::decindent(), and roboptim::incindent().

template<typename F, typename FLIST>
roboptim::FunctionPool< F, FLIST >::ROBOPTIM_DIFFERENTIABLE_FUNCTION_FWD_TYPEDEFS_ ( pool_t  )