Store previous function computation. More...
#include <roboptim/core/filter/cached-function.hh>
Public Types | |
typedef T::traits_t | traits_t |
Import traits type. | |
typedef GenericDifferentiableFunction < traits_t >::interval_t | interval_t |
Import interval type. | |
typedef argument_t | cacheKey_t |
Key type for the cache. | |
typedef LRUCache< cacheKey_t, vector_t > | functionCache_t |
typedef LRUCache< cacheKey_t, gradient_t > | gradientCache_t |
typedef LRUCache< cacheKey_t, jacobian_t > | jacobianCache_t |
typedef LRUCache< cacheKey_t, hessian_t > | hessianCache_t |
Public Member Functions | |
ROBOPTIM_TWICE_DIFFERENTIABLE_FUNCTION_FWD_TYPEDEFS_ (GenericTwiceDifferentiableFunction< traits_t >) | |
CachedFunction (boost::shared_ptr< const T > fct, size_t size=10) | |
Cache a RobOptim function. | |
~CachedFunction () | |
void | reset () |
Reset the caches. | |
Protected Member Functions | |
virtual void | impl_compute (result_ref result, const_argument_ref argument) 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 void | impl_hessian (hessian_ref hessian, const_argument_ref argument, size_type functionId=0) const |
virtual void | impl_derivative (gradient_ref derivative, value_type argument, size_type order=1) const |
template<> | |
void | impl_gradient (gradient_ref, const_argument_ref, size_type) const |
template<> | |
void | impl_gradient (gradient_ref, const_argument_ref, size_type) const |
template<> | |
void | impl_jacobian (jacobian_ref, const_argument_ref) const |
template<> | |
void | impl_jacobian (jacobian_ref, const_argument_ref) const |
template<> | |
void | impl_hessian (hessian_ref, const_argument_ref, size_type) const |
template<> | |
void | impl_hessian (hessian_ref, const_argument_ref, size_type) const |
template<> | |
void | impl_hessian (hessian_ref, const_argument_ref, size_type) const |
template<> | |
void | impl_hessian (hessian_ref, const_argument_ref, size_type) const |
template<> | |
void | impl_derivative (gradient_ref, value_type, size_type) const |
template<> | |
void | impl_derivative (gradient_ref, value_type, size_type) const |
template<> | |
void | impl_derivative (gradient_ref, value_type, size_type) const |
template<> | |
void | impl_derivative (gradient_ref, value_type, size_type) const |
template<> | |
void | impl_derivative (gradient_ref, value_type, size_type) const |
template<> | |
void | impl_derivative (gradient_ref, value_type, size_type) const |
Protected Attributes | |
boost::shared_ptr< const T > | function_ |
std::vector< functionCache_t > | cache_ |
std::vector< gradientCache_t > | gradientCache_ |
jacobianCache_t | jacobianCache_ |
std::vector< hessianCache_t > | hessianCache_ |
Store previous function computation.
When an expensive function is called several times at the same point (exactly!), the cached function prevents useless computation by caching the function result.
This filter is experimental in this release.
T | input function type. |
typedef argument_t roboptim::CachedFunction< T >::cacheKey_t |
Key type for the cache.
typedef LRUCache<cacheKey_t, vector_t> roboptim::CachedFunction< T >::functionCache_t |
typedef LRUCache<cacheKey_t, gradient_t> roboptim::CachedFunction< T >::gradientCache_t |
typedef LRUCache<cacheKey_t, hessian_t> roboptim::CachedFunction< T >::hessianCache_t |
typedef GenericDifferentiableFunction<traits_t>:: interval_t roboptim::CachedFunction< T >::interval_t |
Import interval type.
typedef LRUCache<cacheKey_t, jacobian_t> roboptim::CachedFunction< T >::jacobianCache_t |
typedef T::traits_t roboptim::CachedFunction< T >::traits_t |
Import traits type.
roboptim::CachedFunction< T >::CachedFunction | ( | boost::shared_ptr< const T > | fct, |
size_t | size = 10 |
||
) | [explicit] |
Cache a RobOptim function.
fct | function to cache. |
size | size of the LRU cache. |
roboptim::CachedFunction< T >::~CachedFunction | ( | ) |
void roboptim::CachedFunction< T >::impl_compute | ( | result_ref | result, |
const_argument_ref | argument | ||
) | const [protected, virtual] |
References roboptim::LRUCache< K, V >::find().
void roboptim::CachedFunction< T >::impl_derivative | ( | gradient_ref | derivative, |
value_type | argument, | ||
size_type | order = 1 |
||
) | const [protected, virtual] |
References roboptim::derivative(), and roboptim::LRUCache< K, V >::find().
void roboptim::CachedFunction< Function >::impl_derivative | ( | gradient_ref | , |
value_type | , | ||
size_type | |||
) | const [inline, protected] |
void roboptim::CachedFunction< SparseFunction >::impl_derivative | ( | gradient_ref | , |
value_type | , | ||
size_type | |||
) | const [inline, protected] |
void roboptim::CachedFunction< DifferentiableFunction >::impl_derivative | ( | gradient_ref | , |
value_type | , | ||
size_type | |||
) | const [inline, protected] |
void roboptim::CachedFunction< DifferentiableSparseFunction >::impl_derivative | ( | gradient_ref | , |
value_type | , | ||
size_type | |||
) | const [inline, protected] |
void roboptim::CachedFunction< TwiceDifferentiableFunction >::impl_derivative | ( | gradient_ref | , |
value_type | , | ||
size_type | |||
) | const [inline, protected] |
void roboptim::CachedFunction< TwiceDifferentiableSparseFunction >::impl_derivative | ( | gradient_ref | , |
value_type | , | ||
size_type | |||
) | const [inline, protected] |
void roboptim::CachedFunction< T >::impl_gradient | ( | gradient_ref | gradient, |
const_argument_ref | argument, | ||
size_type | functionId = 0 |
||
) | const [protected, virtual] |
void roboptim::CachedFunction< Function >::impl_gradient | ( | gradient_ref | , |
const_argument_ref | , | ||
size_type | |||
) | const [inline, protected] |
void roboptim::CachedFunction< SparseFunction >::impl_gradient | ( | gradient_ref | , |
const_argument_ref | , | ||
size_type | |||
) | const [inline, protected] |
void roboptim::CachedFunction< T >::impl_hessian | ( | hessian_ref | hessian, |
const_argument_ref | argument, | ||
size_type | functionId = 0 |
||
) | const [protected, virtual] |
void roboptim::CachedFunction< Function >::impl_hessian | ( | hessian_ref | , |
const_argument_ref | , | ||
size_type | |||
) | const [inline, protected] |
void roboptim::CachedFunction< SparseFunction >::impl_hessian | ( | hessian_ref | , |
const_argument_ref | , | ||
size_type | |||
) | const [inline, protected] |
void roboptim::CachedFunction< DifferentiableFunction >::impl_hessian | ( | hessian_ref | , |
const_argument_ref | , | ||
size_type | |||
) | const [inline, protected] |
void roboptim::CachedFunction< DifferentiableSparseFunction >::impl_hessian | ( | hessian_ref | , |
const_argument_ref | , | ||
size_type | |||
) | const [inline, protected] |
void roboptim::CachedFunction< T >::impl_jacobian | ( | jacobian_ref | jacobian, |
const_argument_ref | arg | ||
) | const [protected, virtual] |
References roboptim::LRUCache< K, V >::find().
void roboptim::CachedFunction< Function >::impl_jacobian | ( | jacobian_ref | , |
const_argument_ref | |||
) | const [inline, protected] |
void roboptim::CachedFunction< SparseFunction >::impl_jacobian | ( | jacobian_ref | , |
const_argument_ref | |||
) | const [inline, protected] |
void roboptim::CachedFunction< T >::reset | ( | ) |
Reset the caches.
roboptim::CachedFunction< T >::ROBOPTIM_TWICE_DIFFERENTIABLE_FUNCTION_FWD_TYPEDEFS_ | ( | GenericTwiceDifferentiableFunction< traits_t > | ) |
std::vector<functionCache_t> roboptim::CachedFunction< T >::cache_ [mutable, protected] |
boost::shared_ptr<const T> roboptim::CachedFunction< T >::function_ [protected] |
std::vector<gradientCache_t> roboptim::CachedFunction< T >::gradientCache_ [mutable, protected] |
std::vector<hessianCache_t> roboptim::CachedFunction< T >::hessianCache_ [mutable, protected] |
jacobianCache_t roboptim::CachedFunction< T >::jacobianCache_ [mutable, protected] |