bpp-core  2.2.0
bpp::Optimizer Class Referenceabstract

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:

Public Member Functions

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

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

◆ Optimizer()

bpp::Optimizer::Optimizer ( )
inline

Definition at line 129 of file Optimizer.h.

◆ ~Optimizer()

virtual bpp::Optimizer::~Optimizer ( )
inlinevirtual

Definition at line 130 of file Optimizer.h.

Member Function Documentation

◆ addOptimizationListener()

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.

◆ clone()

◆ getConstraintPolicy()

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

Get the constraint policy for this optimizer.

Returns
The constraint policy.

Implemented in bpp::AbstractOptimizer.

◆ getDefaultStopCondition() [1/2]

virtual OptimizationStopCondition* bpp::Optimizer::getDefaultStopCondition ( )
pure virtual

Get the default stop condition of the optimization algorithm.

Returns
The default stop condition used while optimizing.

Implemented in bpp::AbstractOptimizer.

◆ getDefaultStopCondition() [2/2]

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.

◆ getFunction() [1/2]

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().

◆ getFunction() [2/2]

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.

◆ getFunctionValue()

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().

◆ getMessageHandler()

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

Implemented in bpp::AbstractOptimizer.

◆ getNumberOfEvaluations()

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().

◆ getParameters()

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().

◆ getParameterValue()

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.

◆ getProfiler()

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

Implemented in bpp::AbstractOptimizer.

◆ getStopCondition() [1/2]

virtual OptimizationStopCondition* bpp::Optimizer::getStopCondition ( )
pure virtual

Get the stop condition of the optimization algorithm.

Returns
The stop condition used while optimizing.

Implemented in bpp::AbstractOptimizer.

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

◆ getStopCondition() [2/2]

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.

◆ getVerbose()

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

Get the verbose level.

Returns
verbose level.

Implemented in bpp::AbstractOptimizer.

◆ hasFunction()

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.

◆ init()

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().

◆ isInitialized()

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

Implemented in bpp::AbstractOptimizer.

◆ isMaximumNumberOfEvaluationsReached()

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.

◆ isToleranceReached()

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.

◆ optimize()

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().

◆ setConstraintPolicy()

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().

◆ setFunction()

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().

◆ setMaximumNumberOfEvaluations()

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.

◆ setMessageHandler()

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().

◆ setProfiler()

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().

◆ setStopCondition()

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.

◆ setVerbose()

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().

◆ step()

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: