bpp-core  2.1.0
bpp::Optimizer Class Reference

This is the basal interface for all optimization methods. More...

#include <Bpp/Numeric/Function/Optimizer.h>

+ Inheritance diagram for bpp::Optimizer:
+ Collaboration diagram for bpp::Optimizer:

List of all members.

Public Member Functions

 Optimizer ()
virtual ~Optimizer ()
Optimizerclone () const =0
 Create a copy of this object and send a pointer to it.
virtual void init (const ParameterList &params)=0 throw (Exception)
 Set the initial values of the parameters.
virtual bool isInitialized () const =0
virtual double step ()=0 throw (Exception)
 Perform an optimization step.
virtual const ParameterListgetParameters () const =0
virtual double getParameterValue (const std::string &name) const =0
virtual double getFunctionValue () const =0 throw (NullPointerException)
 Get the current function value.
virtual double optimize ()=0 throw (Exception)
 Perform as many optimization steps untill the stop condition is met.
virtual void setFunction (Function *function)=0
 Set the function to optimize.
virtual const FunctiongetFunction () const =0
 Get the current function being optimized.
virtual FunctiongetFunction ()=0
 Get the current function being optimized.
virtual bool hasFunction () const =0
 Tell if a funciton is associatied to this optimizer.
virtual void setMessageHandler (OutputStream *mh)=0
 Set the message handler for this optimizer.
virtual OutputStreamgetMessageHandler () const =0
virtual void setProfiler (OutputStream *profiler)=0
 Set the profiler for this optimizer.
virtual OutputStreamgetProfiler () const =0
virtual unsigned int getNumberOfEvaluations () const =0
 Get the number of function evaluations performed since the call of the init function.
virtual void setStopCondition (const OptimizationStopCondition &stopCondition)=0
 Set the stop condition of the optimization algorithm.
virtual OptimizationStopConditiongetStopCondition ()=0
 Get the stop condition of the optimization algorithm.
virtual const
OptimizationStopCondition
getStopCondition () const =0
 Get the stop condition of the optimization algorithm.
virtual OptimizationStopConditiongetDefaultStopCondition ()=0
 Get the default stop condition of the optimization algorithm.
virtual const
OptimizationStopCondition
getDefaultStopCondition () const =0
 Get the default stop condition of the optimization algorithm.
virtual bool isToleranceReached () const =0
 Tell if the tolerance level is reached.
virtual bool isMaximumNumberOfEvaluationsReached () const =0
 Tell if the maximum number of function evaluations is reached.
virtual void setMaximumNumberOfEvaluations (unsigned int max)=0
 Set the maximum number of function evaluation to perform during optimization.
virtual void setVerbose (unsigned int v)=0
 Set the verbose level.
virtual unsigned int getVerbose () const =0
 Get the verbose level.
virtual void setConstraintPolicy (const std::string &constraintPolicy)=0
 Set the constraint policy for this optimizer.
virtual std::string getConstraintPolicy () const =0
 Get the constraint policy for this optimizer.
virtual void addOptimizationListener (OptimizationListener *listener)=0
 Register a listener to this class.

Detailed Description

This is the basal interface for all optimization methods.

An optimizer deals with Function objects. Optimizer objects are event-driven: they notify listeners when a step is performed.

Definition at line 125 of file Optimizer.h.


Constructor & Destructor Documentation

Definition at line 129 of file Optimizer.h.

virtual bpp::Optimizer::~Optimizer ( ) [inline, virtual]

Definition at line 130 of file Optimizer.h.


Member Function Documentation

virtual void bpp::Optimizer::addOptimizationListener ( OptimizationListener listener) [pure virtual]

Register a listener to this class.

All registered listeners will be informed when an optimization event occur. See the documentation of the class to know what kind of events are supported.

Parameters:
listenerA listener to be registered with.

Implemented in bpp::AbstractOptimizer.

virtual std::string bpp::Optimizer::getConstraintPolicy ( ) const [pure virtual]

Get the constraint policy for this optimizer.

Returns:
The constraint policy.

Implemented in bpp::AbstractOptimizer.

Get the default stop condition of the optimization algorithm.

Returns:
The default stop condition used while optimizing.

Implemented in bpp::AbstractOptimizer.

virtual const OptimizationStopCondition* bpp::Optimizer::getDefaultStopCondition ( ) const [pure virtual]

Get the default stop condition of the optimization algorithm.

Returns:
The default stop condition used while optimizing.

Implemented in bpp::AbstractOptimizer.

virtual const Function* bpp::Optimizer::getFunction ( ) const [pure virtual]

Get the current function being optimized.

Returns:
A const pointer toward the function being optimized.

Implemented in bpp::AbstractOptimizer, bpp::BfgsMultiDimensions, bpp::ConjugateGradientMultiDimensions, and bpp::NewtonOneDimension.

Referenced by bpp::ParametersStopCondition::init(), and bpp::FunctionStopCondition::init().

virtual Function* bpp::Optimizer::getFunction ( ) [pure virtual]

Get the current function being optimized.

Returns:
A const pointer toward the function being optimized.

Implemented in bpp::AbstractOptimizer, bpp::BfgsMultiDimensions, bpp::ConjugateGradientMultiDimensions, and bpp::NewtonOneDimension.

virtual double bpp::Optimizer::getFunctionValue ( ) const throw (NullPointerException) [pure virtual]

Get the current function value.

Returns:
The value of the function at the point specified by _parameters.
Exceptions:
NullPointerExceptionIf no function is associated with this optimizer.

Implemented in bpp::AbstractOptimizer, and bpp::GoldenSectionSearch.

Referenced by bpp::FunctionStopCondition::init(), and bpp::FunctionStopCondition::isToleranceReached().

virtual OutputStream* bpp::Optimizer::getMessageHandler ( ) const [pure virtual]
Returns:
The stream used for handling messages, if any.

Implemented in bpp::AbstractOptimizer.

virtual unsigned int bpp::Optimizer::getNumberOfEvaluations ( ) const [pure virtual]

Get the number of function evaluations performed since the call of the init function.

Returns:
The number of function evaluations.

Implemented in bpp::AbstractOptimizer.

Referenced by bpp::MetaOptimizer::doStep().

virtual const ParameterList& bpp::Optimizer::getParameters ( ) const [pure virtual]
Returns:
The parameters with their current values.

Implemented in bpp::AbstractOptimizer.

Referenced by bpp::MetaOptimizer::doStep(), bpp::ParametersStopCondition::init(), and bpp::ParametersStopCondition::isToleranceReached().

virtual double bpp::Optimizer::getParameterValue ( const std::string &  name) const [pure virtual]
Returns:
The value associated with a given parameter name.

Implemented in bpp::AbstractOptimizer.

virtual OutputStream* bpp::Optimizer::getProfiler ( ) const [pure virtual]
Returns:
The stream used for profiling, if any.

Implemented in bpp::AbstractOptimizer.

Get the stop condition of the optimization algorithm.

Returns:
The stop condition used while optimizing.

Implemented in bpp::AbstractOptimizer.

Referenced by bpp::MetaOptimizer::doStep().

virtual const OptimizationStopCondition* bpp::Optimizer::getStopCondition ( ) const [pure virtual]

Get the stop condition of the optimization algorithm.

Returns:
The stop condition used while optimizing.

Implemented in bpp::AbstractOptimizer.

virtual unsigned int bpp::Optimizer::getVerbose ( ) const [pure virtual]

Get the verbose level.

Returns:
verbose level.

Implemented in bpp::AbstractOptimizer.

virtual bool bpp::Optimizer::hasFunction ( ) const [pure virtual]

Tell if a funciton is associatied to this optimizer.

Returns:
True if a function has been associated to this optimizer.

Implemented in bpp::AbstractOptimizer.

virtual void bpp::Optimizer::init ( const ParameterList params) throw (Exception) [pure virtual]

Set the initial values of the parameters.

Parameters:
paramsThe initial values of parameters.
Exceptions:
ExceptionIf a problem occured during initialization.

Implemented in bpp::AbstractOptimizer.

Referenced by bpp::MetaOptimizer::doStep().

virtual bool bpp::Optimizer::isInitialized ( ) const [pure virtual]
Returns:
'true' if this optimizer has been initialized.

Implemented in bpp::AbstractOptimizer.

virtual bool bpp::Optimizer::isMaximumNumberOfEvaluationsReached ( ) const [pure virtual]

Tell if the maximum number of function evaluations is reached.

Returns:
Whether the maximum number of function evaluations is reached or not.

Implemented in bpp::AbstractOptimizer.

virtual bool bpp::Optimizer::isToleranceReached ( ) const [pure virtual]

Tell if the tolerance level is reached.

Returns:
Whether the tolerance is reached or not.
See also:
OptimizationStopCondition

Implemented in bpp::AbstractOptimizer.

virtual double bpp::Optimizer::optimize ( ) throw (Exception) [pure virtual]

Perform as many optimization steps untill the stop condition is met.

Returns:
The value of the function after optimization is completed.
Exceptions:
ExceptionIf a problem occured during optimization or if the optimizer has not been initialized.

Implemented in bpp::AbstractOptimizer, bpp::DownhillSimplexMethod, bpp::BrentOneDimension, and bpp::PowellMultiDimensions.

Referenced by bpp::MetaOptimizer::doStep().

virtual void bpp::Optimizer::setConstraintPolicy ( const std::string &  constraintPolicy) [pure virtual]

Set the constraint policy for this optimizer.

Parameters:
constraintPolicyThe constraint policy.

Implemented in bpp::AbstractOptimizer.

Referenced by bpp::MetaOptimizer::doInit().

virtual void bpp::Optimizer::setFunction ( Function function) [pure virtual]

Set the function to optimize.

Parameters:
functionThe function to optimize.

Implemented in bpp::MetaOptimizer, bpp::AbstractOptimizer, bpp::SimpleMultiDimensions, and bpp::SimpleNewtonMultiDimensions.

Referenced by bpp::MetaOptimizer::setFunction().

virtual void bpp::Optimizer::setMaximumNumberOfEvaluations ( unsigned int  max) [pure virtual]

Set the maximum number of function evaluation to perform during optimization.

Parameters:
maxThe maximum number of evaluations to perform.

Implemented in bpp::AbstractOptimizer.

virtual void bpp::Optimizer::setMessageHandler ( OutputStream mh) [pure virtual]

Set the message handler for this optimizer.

The message handler keeps all messages that the optimizer may send. The default handler is set to standard output, but you can pass any ostream object (cerr, ofstream, etc.).

A NULL pointer disables message output.

Parameters:
mhThe message handler to use.

Implemented in bpp::AbstractOptimizer.

Referenced by bpp::MetaOptimizer::doInit().

virtual void bpp::Optimizer::setProfiler ( OutputStream profiler) [pure virtual]

Set the profiler for this optimizer.

The profiler keeps all the intermediate values taken by the parameters. The default profiler is set to standard output, but you can pass any ostream object (cerr, ofstream, etc.).

A NULL pointer disables message output.

Parameters:
profilerThe profiler to use.

Implemented in bpp::AbstractOptimizer.

Referenced by bpp::MetaOptimizer::doInit().

virtual void bpp::Optimizer::setStopCondition ( const OptimizationStopCondition stopCondition) [pure virtual]

Set the stop condition of the optimization algorithm.

Parameters:
stopConditionThe stop condition to use while optimizing.
See also:
OptimizationStopCondition.

Implemented in bpp::AbstractOptimizer.

virtual void bpp::Optimizer::setVerbose ( unsigned int  v) [pure virtual]

Set the verbose level.

0 = off 1 = on 2 = more verbose 3 = even more, etc.

In most cases, only the 0 and 1 levels are implemented.

Parameters:
vverbose level.

Implemented in bpp::AbstractOptimizer.

Referenced by bpp::MetaOptimizer::doInit().

virtual double bpp::Optimizer::step ( ) throw (Exception) [pure virtual]

Perform an optimization step.

Returns:
the value of the function after this step.
Exceptions:
ExceptionIf a problem occured during optimization or if the optimizer has not been initialized.

Implemented in bpp::AbstractOptimizer.

Referenced by bpp::MetaOptimizer::doStep().


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Friends