Define an abstract mathematical function (
).
More...
#include <roboptim/core/function.hh>
Public Types | |
| typedef double | value_type |
| Values type. | |
| typedef std::size_t | size_type |
| Size type. | |
| typedef ublas::vector< value_type > | vector_t |
| Basic vector type. | |
| typedef ublas::matrix< value_type > | matrix_t |
| Basic matrix type. | |
| typedef vector_t | result_t |
| Type of a function evaluation result. | |
| typedef vector_t | argument_t |
| Type of a function evaluation argument. | |
Public Member Functions | |
| bool | isValidResult (const result_t &result) const throw () |
| Check the given result size is valid. | |
| size_type | inputSize () const throw () |
| Return the input size (i.e. argument's vector size). | |
| size_type | outputSize () const throw () |
| Return the output size (i.e. result's vector size). | |
| virtual | ~Function () throw () |
| Trivial destructor. | |
| result_t | operator() (const argument_t &argument) const throw () |
| Evaluate the function at a specified point. | |
| void | operator() (result_t &result, const argument_t &argument) const throw () |
| Evaluate the function at a specified point. | |
| const std::string & | getName () const throw () |
| Get function name. | |
| virtual std::ostream & | print (std::ostream &) const throw () |
| Display the function on the specified output stream. | |
Static Public Member Functions | |
| static const value_type | infinity () throw () |
| Get the value that symbolizes positive infinity. | |
Protected Member Functions | |
| Function (size_type inputSize, size_type outputSize=1, std::string name=std::string()) throw () | |
| Concrete class constructor should call this constructor. | |
| virtual void | impl_compute (result_t &result, const argument_t &argument) const =0 throw () |
| Function evaluation. | |
Interval | |
|
| |
| typedef std::pair< value_type, value_type > | interval_t |
| Interval type (lower, upper). Use negative or positive infinity to respectively disable the lower or upper bound. | |
| typedef std::vector< interval_t > | intervals_t |
| Vector of intervals. | |
| static interval_t | makeInterval (value_type l, value_type u) throw () |
| Construct an interval from a lower and upper bound. | |
| static interval_t | makeInfiniteInterval () throw () |
| Construct an infinite interval. | |
| static interval_t | makeLowerInterval (value_type l) throw () |
| Construct an interval from a lower bound. | |
| static interval_t | makeUpperInterval (value_type u) throw () |
| Construct an interval from an upper bound. | |
| static double | getLowerBound (const interval_t &interval) throw () |
| Get the lower bound of an interval. | |
| static double | getUpperBound (const interval_t &interval) throw () |
| Get the upper bound of an interval. | |
Discrete interval | |
|
| |
| typedef boost::tuple < value_type, value_type, value_type > | discreteInterval_t |
Types representing a discrete interval. A discrete interval is a triplet of values:
| |
| static discreteInterval_t | makeDiscreteInterval (value_type min, value_type max, value_type step) |
| Construct a discrete interval. | |
| static discreteInterval_t | makeDiscreteInterval (interval_t interval, value_type step) |
| Construct a discrete interval. | |
| static double | getLowerBound (const discreteInterval_t &interval) throw () |
| Get the lower bound of a discrete interval. | |
| static double | getUpperBound (const discreteInterval_t &interval) throw () |
| Get the upper bound of a discrete interval. | |
| static double | getStep (const discreteInterval_t &interval) throw () |
| Get the upper step of a discrete interval. | |
| template<typename F > | |
| static void | foreach (const discreteInterval_t interval, F functor) |
| Iterate on an interval. | |
| template<typename F > | |
| static void | foreach (const interval_t interval, const size_type n, F functor) |
| Iterate on an interval. | |
Define an abstract mathematical function (
).
A function is an object that can be evaluated for a given point.
,
where
is the input size and
is the output size.
Functions are pure immutable objects: evaluating a function twice at a given point must give the same result.
Type of a function evaluation argument.
| typedef boost::tuple<value_type, value_type, value_type> roboptim::Function::discreteInterval_t |
Types representing a discrete interval. A discrete interval is a triplet of values:
| typedef std::pair<value_type, value_type> roboptim::Function::interval_t |
Interval type (lower, upper). Use negative or positive infinity to respectively disable the lower or upper bound.
| typedef std::vector<interval_t> roboptim::Function::intervals_t |
Vector of intervals.
| typedef ublas::matrix<value_type> roboptim::Function::matrix_t |
Basic matrix type.
This basic matrix type is used each time a two dimensional matrix of values is needed.
| typedef vector_t roboptim::Function::result_t |
Type of a function evaluation result.
| typedef std::size_t roboptim::Function::size_type |
Size type.
This type is used to represent sizes, indexes, etc.
| typedef double roboptim::Function::value_type |
Values type.
Represents the numerical type (i.e. float, double, int...) used for computations.
| typedef ublas::vector<value_type> roboptim::Function::vector_t |
Basic vector type.
This basic vector type is used each time a vector of values is required.
| roboptim::Function::~Function | ( | ) | throw () [virtual] |
Trivial destructor.
| roboptim::Function::Function | ( | size_type | inputSize, | |
| size_type | outputSize = 1, |
|||
| std::string | name = std::string () | |||
| ) | throw () [protected] |
Concrete class constructor should call this constructor.
| inputSize | function arity | |
| outputSize | result size | |
| name | function's name |
| static void roboptim::Function::foreach | ( | const interval_t | interval, | |
| const size_type | n, | |||
| F | functor | |||
| ) | [inline, static] |
Iterate on an interval.
Call the functor regularly n times on an interval.
| interval | interval on which the method iterates | |
| n | number of discretization points | |
| functor | unary function that will be applied |
| F | functor type (has to satisfy the STL unary function concept) |
| static void roboptim::Function::foreach | ( | const discreteInterval_t | interval, | |
| F | functor | |||
| ) | [inline, static] |
Iterate on an interval.
Call the functor to each discretization point of the discrete interval.
| interval | interval on which the method iterates | |
| functor | unary function that will be applied |
| F | functor type (has to satisfy the STL unary function concept) |
| static double roboptim::Function::getLowerBound | ( | const discreteInterval_t & | interval | ) | throw () [inline, static] |
Get the lower bound of a discrete interval.
| interval | accessed discrete interval |
| static double roboptim::Function::getLowerBound | ( | const interval_t & | interval | ) | throw () [inline, static] |
Get the lower bound of an interval.
| interval | accessed interval |
| const std::string& roboptim::Function::getName | ( | ) | const throw () [inline] |
Get function name.
Referenced by roboptim::visualization::gnuplot::plot(), and roboptim::visualization::gnuplot::plot_xy().
| static double roboptim::Function::getStep | ( | const discreteInterval_t & | interval | ) | throw () [inline, static] |
Get the upper step of a discrete interval.
| interval | accessed discrete interval |
| static double roboptim::Function::getUpperBound | ( | const discreteInterval_t & | interval | ) | throw () [inline, static] |
Get the upper bound of a discrete interval.
| interval | accessed discrete interval |
| static double roboptim::Function::getUpperBound | ( | const interval_t & | interval | ) | throw () [inline, static] |
Get the upper bound of an interval.
| interval | accessed interval |
| virtual void roboptim::Function::impl_compute | ( | result_t & | result, | |
| const argument_t & | argument | |||
| ) | const throw () [protected, pure virtual] |
Function evaluation.
Evaluate the function, has to be implemented in concrete classes.
| result | result will be stored in this vector | |
| argument | point at which the function will be evaluated |
Implemented in roboptim::ConstantFunction, roboptim::FiniteDifferenceGradient< FdgPolicy >, roboptim::IdentityFunction, roboptim::NTimesDerivableFunction< 2 >, roboptim::NumericLinearFunction, and roboptim::NumericQuadraticFunction.
| static const value_type roboptim::Function::infinity | ( | ) | throw () [inline, static] |
Get the value that symbolizes positive infinity.
Referenced by makeInfiniteInterval(), makeLowerInterval(), makeUpperInterval(), and roboptim::Problem< F, CLIST >::print().
| size_type roboptim::Function::inputSize | ( | ) | const throw () [inline] |
Return the input size (i.e. argument's vector size).
Referenced by roboptim::finiteDifferenceGradientPolicies::Simple::computeGradient(), roboptim::visualization::gnuplot::plot(), and roboptim::visualization::gnuplot::plot_xy().
| bool roboptim::Function::isValidResult | ( | const result_t & | result | ) | const throw () [inline] |
Check the given result size is valid.
| result | result that will be checked |
| static discreteInterval_t roboptim::Function::makeDiscreteInterval | ( | interval_t | interval, | |
| value_type | step | |||
| ) | [inline, static] |
Construct a discrete interval.
| interval | continuous interval | |
| step | discretization step |
| static discreteInterval_t roboptim::Function::makeDiscreteInterval | ( | value_type | min, | |
| value_type | max, | |||
| value_type | step | |||
| ) | [inline, static] |
Construct a discrete interval.
| min | miminum value of the interval | |
| max | maxinum value of the interval | |
| step | discretization step |
| static interval_t roboptim::Function::makeInfiniteInterval | ( | ) | throw () [inline, static] |
Construct an infinite interval.
References infinity().
Referenced by roboptim::Problem< F, CLIST >::Problem().
| static interval_t roboptim::Function::makeInterval | ( | value_type | l, | |
| value_type | u | |||
| ) | throw () [inline, static] |
Construct an interval from a lower and upper bound.
| l | lower bound | |
| u | upper bound |
| static interval_t roboptim::Function::makeLowerInterval | ( | value_type | l | ) | throw () [inline, static] |
Construct an interval from a lower bound.
| l | lower bound |
References infinity().
| static interval_t roboptim::Function::makeUpperInterval | ( | value_type | u | ) | throw () [inline, static] |
Construct an interval from an upper bound.
| u | upper bound |
References infinity().
| void roboptim::Function::operator() | ( | result_t & | result, | |
| const argument_t & | argument | |||
| ) | const throw () [inline] |
Evaluate the function at a specified point.
The program will abort if the argument does not have the expected size.
| result | result will be stored in this vector | |
| argument | point at which the function will be evaluated |
References RoboptimCoreDout.
| result_t roboptim::Function::operator() | ( | const argument_t & | argument | ) | const throw () [inline] |
Evaluate the function at a specified point.
The program will abort if the argument does not have the expected size.
| argument | point at which the function will be evaluated |
| size_type roboptim::Function::outputSize | ( | ) | const throw () [inline] |
Return the output size (i.e. result's vector size).
Referenced by roboptim::finiteDifferenceGradientPolicies::FivePointsRule::computeGradient(), roboptim::finiteDifferenceGradientPolicies::Simple::computeGradient(), roboptim::visualization::gnuplot::plot(), and roboptim::visualization::gnuplot::plot_xy().
| std::ostream & roboptim::Function::print | ( | std::ostream & | o | ) | const throw () [virtual] |
Display the function on the specified output stream.
| o | output stream used for display |
Reimplemented in roboptim::ConstantFunction, roboptim::DerivableFunction, roboptim::IdentityFunction, roboptim::LinearFunction, roboptim::NTimesDerivableFunction< 2 >, roboptim::NumericLinearFunction, roboptim::NumericQuadraticFunction, roboptim::QuadraticFunction, and roboptim::TwiceDerivableFunction.
Referenced by roboptim::operator<<().