bpp-core3  3.0.0
bpp::OptimizerInterface Class Referenceabstract

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

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

+ Inheritance diagram for bpp::OptimizerInterface:
+ Collaboration diagram for bpp::OptimizerInterface:

Public Member Functions

 OptimizerInterface ()
 
virtual ~OptimizerInterface ()
 
OptimizerInterfaceclone () const =0
 Create a copy of this object and send a pointer to it. More...
 
virtual void init (const ParameterList &params)=0
 Set the initial values of the parameters. More...
 
virtual bool isInitialized () const =0
 
virtual double step ()=0
 Perform an optimization step. More...
 
virtual const ParameterListgetParameters () const =0
 
virtual double getParameterValue (const std::string &name) const =0
 
virtual double getFunctionValue () const =0
 Get the current function value. More...
 
virtual double optimize ()=0
 Perform as many optimization steps untill the stop condition is met. More...
 
virtual void setFunction (std::shared_ptr< FunctionInterface > function)=0
 Set the function to optimize. More...
 
virtual const FunctionInterfacefunction () const =0
 Get the current function being optimized. More...
 
virtual FunctionInterfacefunction ()=0
 Get the current function being optimized. More...
 
virtual std::shared_ptr< const FunctionInterfacegetFunction () const =0
 Get the current function being optimized. More...
 
virtual std::shared_ptr< FunctionInterfacegetFunction ()=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 (std::shared_ptr< OutputStream > mh)=0
 Set the message handler for this optimizer. More...
 
virtual std::shared_ptr< OutputStreamgetMessageHandler () const =0
 
virtual void setProfiler (std::shared_ptr< OutputStream > profiler)=0
 Set the profiler for this optimizer. More...
 
virtual std::shared_ptr< 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 (std::shared_ptr< OptimizationStopCondition > stopCondition)=0
 Set the stop condition of the optimization algorithm. More...
 
virtual std::shared_ptr< OptimizationStopConditiongetStopCondition ()=0
 Get the stop condition of the optimization algorithm. More...
 
virtual std::shared_ptr< const OptimizationStopConditiongetStopCondition () const =0
 Get the stop condition of the optimization algorithm. More...
 
virtual std::shared_ptr< OptimizationStopConditiongetDefaultStopCondition ()=0
 Get the default stop condition of the optimization algorithm. More...
 
virtual std::shared_ptr< 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 (std::shared_ptr< OptimizationListener > listener)=0
 Register a listener to this class. More...
 
virtual void updateParameters (bool yn)=0
 Tell if we shall update all parameters after one optimization step. More...
 
virtual bool updateParameters () const =0
 Tell if we shall update all parameters after one optimization step. 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 88 of file Optimizer.h.

Constructor & Destructor Documentation

◆ OptimizerInterface()

bpp::OptimizerInterface::OptimizerInterface ( )
inline

Definition at line 92 of file Optimizer.h.

◆ ~OptimizerInterface()

virtual bpp::OptimizerInterface::~OptimizerInterface ( )
inlinevirtual

Definition at line 93 of file Optimizer.h.

Member Function Documentation

◆ addOptimizationListener()

virtual void bpp::OptimizerInterface::addOptimizationListener ( std::shared_ptr< 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()

◆ function() [1/2]

virtual const FunctionInterface& bpp::OptimizerInterface::function ( ) const
pure virtual

Get the current function being optimized.

Returns
A const reference toward the function being optimized.
Exceptions
NullPointerExceptionif no function is associated with the optimizer.

Implemented in bpp::AbstractOptimizer.

◆ function() [2/2]

virtual FunctionInterface& bpp::OptimizerInterface::function ( )
pure virtual

Get the current function being optimized.

Returns
A const reference toward the function being optimized.
Exceptions
NullPointerExceptionif no function is associated with the optimizer.

Implemented in bpp::AbstractOptimizer.

◆ getConstraintPolicy()

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

Get the constraint policy for this optimizer.

Returns
The constraint policy.

Implemented in bpp::AbstractOptimizer.

◆ getDefaultStopCondition() [1/2]

virtual std::shared_ptr<OptimizationStopCondition> bpp::OptimizerInterface::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 std::shared_ptr<const OptimizationStopCondition> bpp::OptimizerInterface::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 std::shared_ptr<const FunctionInterface> bpp::OptimizerInterface::getFunction ( ) const
pure virtual

Get the current function being optimized.

Returns
A const pointer toward the function being optimized.

Implemented in bpp::AbstractOptimizer.

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

◆ getFunction() [2/2]

virtual std::shared_ptr<FunctionInterface> bpp::OptimizerInterface::getFunction ( )
pure virtual

Get the current function being optimized.

Returns
A const pointer toward the function being optimized.

Implemented in bpp::AbstractOptimizer.

◆ getFunctionValue()

virtual double bpp::OptimizerInterface::getFunctionValue ( ) const
pure virtual

Get the current function value.

Returns
The value of the function at the point specified by the current 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 std::shared_ptr<OutputStream> bpp::OptimizerInterface::getMessageHandler ( ) const
pure virtual
Returns
The stream used for handling messages, if any.

Implemented in bpp::AbstractOptimizer.

◆ getNumberOfEvaluations()

virtual unsigned int bpp::OptimizerInterface::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::OptimizerInterface::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::OptimizerInterface::getParameterValue ( const std::string &  name) const
pure virtual
Returns
The value associated with a given parameter name.

Implemented in bpp::AbstractOptimizer.

◆ getProfiler()

virtual std::shared_ptr<OutputStream> bpp::OptimizerInterface::getProfiler ( ) const
pure virtual
Returns
The stream used for profiling, if any.

Implemented in bpp::AbstractOptimizer.

◆ getStopCondition() [1/2]

virtual std::shared_ptr<OptimizationStopCondition> bpp::OptimizerInterface::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 std::shared_ptr<const OptimizationStopCondition> bpp::OptimizerInterface::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::OptimizerInterface::getVerbose ( ) const
pure virtual

Get the verbose level.

Returns
verbose level.

Implemented in bpp::AbstractOptimizer.

◆ hasFunction()

virtual bool bpp::OptimizerInterface::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::OptimizerInterface::init ( const ParameterList params)
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::OptimizerInterface::isInitialized ( ) const
pure virtual
Returns
'true' if this optimizer has been initialized.

Implemented in bpp::AbstractOptimizer.

◆ isMaximumNumberOfEvaluationsReached()

virtual bool bpp::OptimizerInterface::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::OptimizerInterface::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::OptimizerInterface::optimize ( )
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::OptimizerInterface::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::OptimizerInterface::setFunction ( std::shared_ptr< FunctionInterface function)
pure virtual

Set the function to optimize.

Parameters
functionThe function to optimize.

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

◆ setMaximumNumberOfEvaluations()

virtual void bpp::OptimizerInterface::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::OptimizerInterface::setMessageHandler ( std::shared_ptr< 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::OptimizerInterface::setProfiler ( std::shared_ptr< 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::OptimizerInterface::setStopCondition ( std::shared_ptr< 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::OptimizerInterface::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::OptimizerInterface::step ( )
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().

◆ updateParameters() [1/2]

virtual void bpp::OptimizerInterface::updateParameters ( bool  yn)
pure virtual

Tell if we shall update all parameters after one optimization step.

This is required only for functions that have non-independent parameters, which means that setting one parameter value may modify one or several other parameters. Depending on the optimizer, this may have no effect.

Parameters
yntrue/false

Implemented in bpp::AbstractOptimizer.

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

◆ updateParameters() [2/2]

virtual bool bpp::OptimizerInterface::updateParameters ( ) const
pure virtual

Tell if we shall update all parameters after one optimization step.

This is required only for functions that have non-independent parameters, which means that setting one parameter value may modify one or several other parameters. Depending on the optimizer, this may have no effect.

Returns
yn true/false

Implemented in bpp::AbstractOptimizer.


The documentation for this class was generated from the following file: