bpp-core3  3.0.0
bpp::NewtonOneDimension Class Reference

Newton's optimization for one parameter. More...

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

+ Inheritance diagram for bpp::NewtonOneDimension:
+ Collaboration diagram for bpp::NewtonOneDimension:

Public Member Functions

 NewtonOneDimension (std::shared_ptr< SecondOrderDerivable > function=nullptr)
 
virtual ~NewtonOneDimension ()
 
NewtonOneDimensionclone () const
 Create a copy of this object and send a pointer to it. More...
 
void doInit (const ParameterList &params)
 This function is called by the init() method and contains all calculations. More...
 
double doStep ()
 This function is called by the step() method and contains all calculations. More...
 
void setMaximumNumberOfCorrections (unsigned int mx)
 
const FirstOrderDerivablefirstOrderDerivableFunction () const
 
FirstOrderDerivablefirstOrderDerivableFunction ()
 
std::shared_ptr< const FirstOrderDerivablegetFirstOrderDerivableFunction () const
 
std::shared_ptr< FirstOrderDerivablegetFirstOrderDerivableFunction ()
 
const SecondOrderDerivablesecondOrderDerivableFunction () const
 
SecondOrderDerivablesecondOrderDerivableFunction ()
 
std::shared_ptr< const SecondOrderDerivablegetSecondOrderDerivableFunction () const
 
std::shared_ptr< SecondOrderDerivablegetSecondOrderDerivableFunction ()
 
void updateParameters (bool yn) override
 Tell if we shall update all parameters after one optimization step. More...
 
bool updateParameters () const override
 Tell if we shall update all parameters after one optimization step. More...
 
void setOptimizationProgressCharacter (const std::string &c)
 Set the character to be displayed during optimization. More...
 
const std::string & getOptimizationProgressCharacter () const
 
The Optimizer interface.
void init (const ParameterList &params) override
 Basic implementation. More...
 
double step () override
 Basic implementation. More...
 
double optimize () override
 Basic implementation. More...
 
bool isInitialized () const override
 
const ParameterListgetParameters () const override
 
double getParameterValue (const std::string &name) const override
 
void setFunction (std::shared_ptr< FunctionInterface > function) override
 Set the function to optimize. More...
 
const FunctionInterfacefunction () const override
 Get the current function being optimized. More...
 
FunctionInterfacefunction () override
 Get the current function being optimized. More...
 
std::shared_ptr< const FunctionInterfacegetFunction () const override
 Get the current function being optimized. More...
 
std::shared_ptr< FunctionInterfacegetFunction () override
 Get the current function being optimized. More...
 
bool hasFunction () const override
 Tell if a funciton is associatied to this optimizer. More...
 
double getFunctionValue () const override
 Get the current function value. More...
 
void setMessageHandler (std::shared_ptr< OutputStream > mh) override
 Set the message handler for this optimizer. More...
 
std::shared_ptr< OutputStreamgetMessageHandler () const override
 
void setProfiler (std::shared_ptr< OutputStream > profiler) override
 Set the profiler for this optimizer. More...
 
std::shared_ptr< OutputStreamgetProfiler () const override
 
unsigned int getNumberOfEvaluations () const override
 Get the number of function evaluations performed since the call of the init function. More...
 
void setStopCondition (std::shared_ptr< OptimizationStopCondition > stopCondition) override
 Set the stop condition of the optimization algorithm. More...
 
std::shared_ptr< OptimizationStopConditiongetStopCondition () override
 Get the stop condition of the optimization algorithm. More...
 
std::shared_ptr< const OptimizationStopConditiongetStopCondition () const override
 Get the stop condition of the optimization algorithm. More...
 
std::shared_ptr< OptimizationStopConditiongetDefaultStopCondition () override
 Get the default stop condition of the optimization algorithm. More...
 
std::shared_ptr< const OptimizationStopConditiongetDefaultStopCondition () const override
 Get the default stop condition of the optimization algorithm. More...
 
bool isToleranceReached () const override
 Tell if the tolerance level is reached. More...
 
bool isMaximumNumberOfEvaluationsReached () const override
 Tell if the maximum number of function evaluations is reached. More...
 
void setMaximumNumberOfEvaluations (unsigned int max) override
 Set the maximum number of function evaluation to perform during optimization. More...
 
void setVerbose (unsigned int v) override
 Set the verbose level. More...
 
unsigned int getVerbose () const override
 Get the verbose level. More...
 
void setConstraintPolicy (const std::string &constraintPolicy) override
 Set the constraint policy for this optimizer. More...
 
std::string getConstraintPolicy () const override
 Get the constraint policy for this optimizer. More...
 
void addOptimizationListener (std::shared_ptr< OptimizationListener > listener) override
 Register a listener to this class. More...
 

Protected Member Functions

ParameterListgetParameters_ ()
 
ParametergetParameter_ (size_t i)
 
std::shared_ptr< FunctionInterfacegetFunction_ ()
 
void setDefaultStopCondition_ (std::shared_ptr< OptimizationStopCondition > osc)
 
Inner utilitary functions
void autoParameter ()
 Build a list of AutoParameter instead of Parameter. More...
 
void ignoreConstraints ()
 Remove the constraints of all the arguments. More...
 
void profile (double v)
 Print to the profile if there is one. More...
 
void profile (unsigned int v)
 Print to the profile if there is one. More...
 
void profile (const std::string &s)
 Print to the profile if there is one. More...
 
void profileln (double v)
 Print to the profile if there is one and end line. More...
 
void profileln (unsigned int v)
 Print to the profile if there is one and end line. More...
 
void profileln (const std::string &s)
 Print to the profile if there is one and end line. More...
 
void printPoint (const ParameterList &params, double value)
 Print parameters and corresponding function evaluation to profiler. More...
 
void printMessage (const std::string &message)
 Give a message to print to the message handler. More...
 
void fireOptimizationInitializationPerformed (const OptimizationEvent &event)
 Notify all listeners that optimizer initialization was performed. More...
 
void fireOptimizationStepPerformed (const OptimizationEvent &event)
 Notify all listeners that an optimization step was performed. More...
 
bool listenerModifiesParameters () const
 

Protected Attributes

std::shared_ptr< FunctionInterfacefunction_
 The function to optimize. More...
 
ParameterList parameters_
 The parameters that will be optimized. More...
 
std::shared_ptr< OutputStreammessageHandler_
 The message handler. More...
 
std::shared_ptr< OutputStreamprofiler_
 The profiler. More...
 
std::string constraintPolicy_
 The constraint policy. More...
 
std::shared_ptr< OptimizationStopConditionstopCondition_
 The stoping condition to use while optimizing. More...
 
std::shared_ptr< OptimizationStopConditiondefaultStopCondition_
 The default stoping condition to use while optimizing. More...
 
unsigned int verbose_
 State of the verbose mode: > 0 = enabled. More...
 
bool isInitialized_
 Check if the optimizer have been feeded with initial parameters values. More...
 
time_t startTime_
 
std::vector< std::shared_ptr< OptimizationListener > > listeners_
 
bool updateParameters_
 
std::string stepChar_
 
unsigned int nbEvalMax_
 The maximum number of function evaluations allowed. More...
 
unsigned int nbEval_
 The current number of function evaluations achieved. More...
 
double currentValue_
 The current value of the function. More...
 
bool tolIsReached_
 Tell if the tolerance level has been reached. More...
 

Private Attributes

std::string _param
 
unsigned int _maxCorrection
 

Detailed Description

Newton's optimization for one parameter.

Definition at line 16 of file NewtonOneDimension.h.

Constructor & Destructor Documentation

◆ NewtonOneDimension()

NewtonOneDimension::NewtonOneDimension ( std::shared_ptr< SecondOrderDerivable function = nullptr)

◆ ~NewtonOneDimension()

virtual bpp::NewtonOneDimension::~NewtonOneDimension ( )
inlinevirtual

Definition at line 25 of file NewtonOneDimension.h.

Member Function Documentation

◆ addOptimizationListener()

void bpp::AbstractOptimizer::addOptimizationListener ( std::shared_ptr< OptimizationListener listener)
inlineoverridevirtualinherited

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.

Implements bpp::OptimizerInterface.

Definition at line 235 of file AbstractOptimizer.h.

◆ autoParameter()

◆ clone()

NewtonOneDimension* bpp::NewtonOneDimension::clone ( ) const
inlinevirtual

Create a copy of this object and send a pointer to it.

Returns
A pointer toward the copy object.

Implements bpp::OptimizerInterface.

Definition at line 27 of file NewtonOneDimension.h.

References doInit(), doStep(), and NewtonOneDimension().

◆ doInit()

void NewtonOneDimension::doInit ( const ParameterList params)
virtual

This function is called by the init() method and contains all calculations.

Parameters
paramsThe parameters to use for initialization.

Implements bpp::AbstractOptimizer.

Definition at line 25 of file NewtonOneDimension.cpp.

References _param, bpp::AbstractOptimizer::currentValue_, bpp::AbstractOptimizer::getFunction(), bpp::AbstractOptimizer::getParameters(), bpp::AbstractOptimizer::getStopCondition(), and bpp::ParameterList::size().

Referenced by clone().

◆ doStep()

◆ fireOptimizationInitializationPerformed()

void AbstractOptimizer::fireOptimizationInitializationPerformed ( const OptimizationEvent event)
protectedinherited

Notify all listeners that optimizer initialization was performed.

This method should be called by the init method.

Parameters
eventAn OptimizationEvent object.

Definition at line 295 of file AbstractOptimizer.cpp.

References bpp::AbstractOptimizer::listeners_.

Referenced by bpp::AbstractOptimizer::getOptimizationProgressCharacter(), and bpp::AbstractOptimizer::init().

◆ fireOptimizationStepPerformed()

void AbstractOptimizer::fireOptimizationStepPerformed ( const OptimizationEvent event)
protectedinherited

Notify all listeners that an optimization step was performed.

This method should be called by the step method.

Parameters
eventAn OptimizationEvent object.

Definition at line 305 of file AbstractOptimizer.cpp.

References bpp::AbstractOptimizer::listeners_.

Referenced by bpp::AbstractOptimizer::getOptimizationProgressCharacter(), and bpp::AbstractOptimizer::step().

◆ firstOrderDerivableFunction() [1/2]

const FirstOrderDerivable& bpp::NewtonOneDimension::firstOrderDerivableFunction ( ) const
inline

Definition at line 36 of file NewtonOneDimension.h.

References bpp::AbstractOptimizer::function_.

Referenced by doStep().

◆ firstOrderDerivableFunction() [2/2]

FirstOrderDerivable& bpp::NewtonOneDimension::firstOrderDerivableFunction ( )
inline

Definition at line 48 of file NewtonOneDimension.h.

References bpp::AbstractOptimizer::function_.

◆ function() [1/2]

const FunctionInterface& bpp::AbstractOptimizer::function ( ) const
inlineoverridevirtualinherited

Get the current function being optimized.

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

Implements bpp::OptimizerInterface.

Definition at line 162 of file AbstractOptimizer.h.

References bpp::AbstractOptimizer::function_.

◆ function() [2/2]

FunctionInterface& bpp::AbstractOptimizer::function ( )
inlineoverridevirtualinherited

Get the current function being optimized.

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

Implements bpp::OptimizerInterface.

Definition at line 174 of file AbstractOptimizer.h.

References bpp::AbstractOptimizer::function_.

◆ getConstraintPolicy()

std::string bpp::AbstractOptimizer::getConstraintPolicy ( ) const
inlineoverridevirtualinherited

Get the constraint policy for this optimizer.

Returns
The constraint policy.

Implements bpp::OptimizerInterface.

Definition at line 233 of file AbstractOptimizer.h.

References bpp::AbstractOptimizer::constraintPolicy_.

Referenced by bpp::SimpleNewtonMultiDimensions::doInit(), bpp::SimpleMultiDimensions::doInit(), and bpp::MetaOptimizer::doInit().

◆ getDefaultStopCondition() [1/2]

◆ getDefaultStopCondition() [2/2]

std::shared_ptr<const OptimizationStopCondition> bpp::AbstractOptimizer::getDefaultStopCondition ( ) const
inlineoverridevirtualinherited

Get the default stop condition of the optimization algorithm.

Returns
The default stop condition used while optimizing.

Implements bpp::OptimizerInterface.

Definition at line 219 of file AbstractOptimizer.h.

References bpp::AbstractOptimizer::defaultStopCondition_.

◆ getFirstOrderDerivableFunction() [1/2]

std::shared_ptr<const FirstOrderDerivable> bpp::NewtonOneDimension::getFirstOrderDerivableFunction ( ) const
inline

Definition at line 60 of file NewtonOneDimension.h.

References bpp::AbstractOptimizer::function_.

◆ getFirstOrderDerivableFunction() [2/2]

std::shared_ptr<FirstOrderDerivable> bpp::NewtonOneDimension::getFirstOrderDerivableFunction ( )
inline

Definition at line 65 of file NewtonOneDimension.h.

References bpp::AbstractOptimizer::function_.

◆ getFunction() [1/2]

◆ getFunction() [2/2]

std::shared_ptr<FunctionInterface> bpp::AbstractOptimizer::getFunction ( )
inlineoverridevirtualinherited

Get the current function being optimized.

Returns
A const pointer toward the function being optimized.

Implements bpp::OptimizerInterface.

Definition at line 188 of file AbstractOptimizer.h.

References bpp::AbstractOptimizer::function_.

◆ getFunction_()

std::shared_ptr<FunctionInterface> bpp::AbstractOptimizer::getFunction_ ( )
inlineprotectedinherited

Definition at line 389 of file AbstractOptimizer.h.

References bpp::AbstractOptimizer::function_.

◆ getFunctionValue()

double bpp::AbstractOptimizer::getFunctionValue ( ) const
inlineoverridevirtualinherited

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.

Implements bpp::OptimizerInterface.

Reimplemented in bpp::GoldenSectionSearch.

Definition at line 192 of file AbstractOptimizer.h.

References bpp::AbstractOptimizer::currentValue_.

◆ getMessageHandler()

std::shared_ptr<OutputStream> bpp::AbstractOptimizer::getMessageHandler ( ) const
inlineoverridevirtualinherited

◆ getNumberOfEvaluations()

unsigned int bpp::AbstractOptimizer::getNumberOfEvaluations ( ) const
inlineoverridevirtualinherited

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

Returns
The number of function evaluations.

Implements bpp::OptimizerInterface.

Definition at line 206 of file AbstractOptimizer.h.

References bpp::AbstractOptimizer::nbEval_.

Referenced by bpp::SimpleNewtonMultiDimensions::doStep(), bpp::SimpleMultiDimensions::doStep(), bpp::OneDimensionOptimizationTools::lineMinimization(), and bpp::OneDimensionOptimizationTools::lineSearch().

◆ getOptimizationProgressCharacter()

◆ getParameter_()

Parameter& bpp::AbstractOptimizer::getParameter_ ( size_t  i)
inlineprotectedinherited

◆ getParameters()

◆ getParameters_()

◆ getParameterValue()

double bpp::AbstractOptimizer::getParameterValue ( const std::string &  name) const
inlineoverridevirtualinherited
Returns
The value associated with a given parameter name.

Implements bpp::OptimizerInterface.

Definition at line 151 of file AbstractOptimizer.h.

References bpp::ParameterList::getParameterValue().

◆ getProfiler()

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

Implements bpp::OptimizerInterface.

Definition at line 204 of file AbstractOptimizer.h.

References bpp::AbstractOptimizer::profiler_.

Referenced by bpp::SimpleNewtonMultiDimensions::doInit(), bpp::SimpleMultiDimensions::doInit(), and bpp::MetaOptimizer::doInit().

◆ getSecondOrderDerivableFunction() [1/2]

std::shared_ptr<const SecondOrderDerivable> bpp::NewtonOneDimension::getSecondOrderDerivableFunction ( ) const
inline

Definition at line 94 of file NewtonOneDimension.h.

References bpp::AbstractOptimizer::function_.

◆ getSecondOrderDerivableFunction() [2/2]

std::shared_ptr<SecondOrderDerivable> bpp::NewtonOneDimension::getSecondOrderDerivableFunction ( )
inline

Definition at line 99 of file NewtonOneDimension.h.

References bpp::AbstractOptimizer::function_.

◆ getStopCondition() [1/2]

◆ getStopCondition() [2/2]

std::shared_ptr<const OptimizationStopCondition> bpp::AbstractOptimizer::getStopCondition ( ) const
inlineoverridevirtualinherited

Get the stop condition of the optimization algorithm.

Returns
The stop condition used while optimizing.

Implements bpp::OptimizerInterface.

Definition at line 215 of file AbstractOptimizer.h.

References bpp::AbstractOptimizer::stopCondition_.

◆ getVerbose()

◆ hasFunction()

bool bpp::AbstractOptimizer::hasFunction ( ) const
inlineoverridevirtualinherited

Tell if a funciton is associatied to this optimizer.

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

Implements bpp::OptimizerInterface.

Definition at line 190 of file AbstractOptimizer.h.

Referenced by bpp::GoldenSectionSearch::getFunctionValue().

◆ ignoreConstraints()

void AbstractOptimizer::ignoreConstraints ( )
protectedinherited

◆ init()

◆ isInitialized()

bool bpp::AbstractOptimizer::isInitialized ( ) const
inlineoverridevirtualinherited
Returns
'true' if this optimizer has been initialized.

Implements bpp::OptimizerInterface.

Definition at line 147 of file AbstractOptimizer.h.

References bpp::AbstractOptimizer::isInitialized_.

◆ isMaximumNumberOfEvaluationsReached()

bool bpp::AbstractOptimizer::isMaximumNumberOfEvaluationsReached ( ) const
inlineoverridevirtualinherited

Tell if the maximum number of function evaluations is reached.

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

Implements bpp::OptimizerInterface.

Definition at line 223 of file AbstractOptimizer.h.

References bpp::AbstractOptimizer::nbEvalMax_.

◆ isToleranceReached()

bool bpp::AbstractOptimizer::isToleranceReached ( ) const
inlineoverridevirtualinherited

Tell if the tolerance level is reached.

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

Implements bpp::OptimizerInterface.

Definition at line 221 of file AbstractOptimizer.h.

References bpp::AbstractOptimizer::tolIsReached_.

◆ listenerModifiesParameters()

bool AbstractOptimizer::listenerModifiesParameters ( ) const
protectedinherited

◆ optimize()

◆ printMessage()

void AbstractOptimizer::printMessage ( const std::string &  message)
protectedinherited

Give a message to print to the message handler.

Parameters
messageThe message to print.

Definition at line 265 of file AbstractOptimizer.cpp.

References bpp::AbstractOptimizer::messageHandler_.

Referenced by bpp::GoldenSectionSearch::doInit(), bpp::BrentOneDimension::doInit(), doStep(), bpp::BfgsMultiDimensions::doStep(), and bpp::AbstractOptimizer::getOptimizationProgressCharacter().

◆ printPoint()

void AbstractOptimizer::printPoint ( const ParameterList params,
double  value 
)
protectedinherited

◆ profile() [1/3]

void AbstractOptimizer::profile ( double  v)
protectedinherited

Print to the profile if there is one.

Parameters
vThe double value to print.

Definition at line 199 of file AbstractOptimizer.cpp.

References bpp::AbstractOptimizer::profiler_.

Referenced by bpp::AbstractOptimizer::getOptimizationProgressCharacter(), bpp::AbstractOptimizer::init(), and bpp::AbstractOptimizer::printPoint().

◆ profile() [2/3]

void AbstractOptimizer::profile ( unsigned int  v)
protectedinherited

Print to the profile if there is one.

Parameters
vThe unsigned int value to print.

Definition at line 215 of file AbstractOptimizer.cpp.

References bpp::AbstractOptimizer::profiler_.

◆ profile() [3/3]

void AbstractOptimizer::profile ( const std::string &  s)
protectedinherited

Print to the profile if there is one.

Parameters
sThe string to print to the profile.

Definition at line 230 of file AbstractOptimizer.cpp.

References bpp::AbstractOptimizer::profiler_.

◆ profileln() [1/3]

void AbstractOptimizer::profileln ( double  v)
protectedinherited

Print to the profile if there is one and end line.

Parameters
vThe double value to print.

Definition at line 207 of file AbstractOptimizer.cpp.

References bpp::AbstractOptimizer::profiler_.

Referenced by bpp::AbstractOptimizer::getOptimizationProgressCharacter(), bpp::AbstractOptimizer::init(), and bpp::AbstractOptimizer::printPoint().

◆ profileln() [2/3]

void AbstractOptimizer::profileln ( unsigned int  v)
protectedinherited

Print to the profile if there is one and end line.

Parameters
vThe unsigned int value to print.

Definition at line 222 of file AbstractOptimizer.cpp.

References bpp::AbstractOptimizer::profiler_.

◆ profileln() [3/3]

void AbstractOptimizer::profileln ( const std::string &  s)
protectedinherited

Print to the profile if there is one and end line.

Parameters
sThe string to print to the profile.

Definition at line 238 of file AbstractOptimizer.cpp.

References bpp::AbstractOptimizer::profiler_.

◆ secondOrderDerivableFunction() [1/2]

const SecondOrderDerivable& bpp::NewtonOneDimension::secondOrderDerivableFunction ( ) const
inline

Definition at line 70 of file NewtonOneDimension.h.

References bpp::AbstractOptimizer::function_.

Referenced by doStep().

◆ secondOrderDerivableFunction() [2/2]

SecondOrderDerivable& bpp::NewtonOneDimension::secondOrderDerivableFunction ( )
inline

Definition at line 82 of file NewtonOneDimension.h.

References bpp::AbstractOptimizer::function_.

◆ setConstraintPolicy()

void bpp::AbstractOptimizer::setConstraintPolicy ( const std::string &  constraintPolicy)
inlineoverridevirtualinherited

Set the constraint policy for this optimizer.

Parameters
constraintPolicyThe constraint policy.

Implements bpp::OptimizerInterface.

Definition at line 231 of file AbstractOptimizer.h.

Referenced by bpp::SimpleNewtonMultiDimensions::doInit(), bpp::SimpleMultiDimensions::doInit(), bpp::OneDimensionOptimizationTools::lineMinimization(), and bpp::OneDimensionOptimizationTools::lineSearch().

◆ setDefaultStopCondition_()

◆ setFunction()

void bpp::AbstractOptimizer::setFunction ( std::shared_ptr< FunctionInterface function)
inlineoverridevirtualinherited

Set the function to optimize.

Parameters
functionThe function to optimize.

Implements bpp::OptimizerInterface.

Reimplemented in bpp::MetaOptimizer, bpp::SimpleMultiDimensions, and bpp::SimpleNewtonMultiDimensions.

Definition at line 156 of file AbstractOptimizer.h.

Referenced by bpp::SimpleNewtonMultiDimensions::setFunction(), bpp::SimpleMultiDimensions::setFunction(), and bpp::MetaOptimizer::setFunction().

◆ setMaximumNumberOfCorrections()

void bpp::NewtonOneDimension::setMaximumNumberOfCorrections ( unsigned int  mx)
inline

Definition at line 34 of file NewtonOneDimension.h.

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

◆ setMaximumNumberOfEvaluations()

void bpp::AbstractOptimizer::setMaximumNumberOfEvaluations ( unsigned int  max)
inlineoverridevirtualinherited

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

Parameters
maxThe maximum number of evaluations to perform.

Implements bpp::OptimizerInterface.

Definition at line 225 of file AbstractOptimizer.h.

Referenced by bpp::BrentOneDimension::BrentOneDimension(), bpp::SimpleNewtonMultiDimensions::doInit(), bpp::SimpleMultiDimensions::doInit(), and bpp::NewtonBacktrackOneDimension::NewtonBacktrackOneDimension().

◆ setMessageHandler()

void bpp::AbstractOptimizer::setMessageHandler ( std::shared_ptr< OutputStream mh)
inlineoverridevirtualinherited

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.

Implements bpp::OptimizerInterface.

Definition at line 198 of file AbstractOptimizer.h.

Referenced by bpp::SimpleNewtonMultiDimensions::doInit(), bpp::SimpleMultiDimensions::doInit(), bpp::OneDimensionOptimizationTools::lineMinimization(), and bpp::OneDimensionOptimizationTools::lineSearch().

◆ setOptimizationProgressCharacter()

void bpp::AbstractOptimizer::setOptimizationProgressCharacter ( const std::string &  c)
inlineinherited

◆ setProfiler()

void bpp::AbstractOptimizer::setProfiler ( std::shared_ptr< OutputStream profiler)
inlineoverridevirtualinherited

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.

Implements bpp::OptimizerInterface.

Definition at line 202 of file AbstractOptimizer.h.

Referenced by bpp::SimpleNewtonMultiDimensions::doInit(), bpp::SimpleMultiDimensions::doInit(), bpp::OneDimensionOptimizationTools::lineMinimization(), and bpp::OneDimensionOptimizationTools::lineSearch().

◆ setStopCondition()

◆ setVerbose()

void bpp::AbstractOptimizer::setVerbose ( unsigned int  v)
inlineoverridevirtualinherited

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.

Implements bpp::OptimizerInterface.

Definition at line 227 of file AbstractOptimizer.h.

Referenced by bpp::SimpleNewtonMultiDimensions::doInit(), bpp::SimpleMultiDimensions::doInit(), bpp::OneDimensionOptimizationTools::lineMinimization(), and bpp::OneDimensionOptimizationTools::lineSearch().

◆ step()

double AbstractOptimizer::step ( )
overridevirtualinherited

◆ updateParameters() [1/2]

void bpp::AbstractOptimizer::updateParameters ( bool  yn)
inlineoverridevirtualinherited

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

Implements bpp::OptimizerInterface.

Definition at line 251 of file AbstractOptimizer.h.

◆ updateParameters() [2/2]

bool bpp::AbstractOptimizer::updateParameters ( ) const
inlineoverridevirtualinherited

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

Implements bpp::OptimizerInterface.

Definition at line 262 of file AbstractOptimizer.h.

References bpp::AbstractOptimizer::updateParameters_.

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

Member Data Documentation

◆ _maxCorrection

unsigned int bpp::NewtonOneDimension::_maxCorrection
private

Definition at line 21 of file NewtonOneDimension.h.

Referenced by doStep().

◆ _param

std::string bpp::NewtonOneDimension::_param
private

Definition at line 20 of file NewtonOneDimension.h.

Referenced by doInit(), and doStep().

◆ constraintPolicy_

std::string bpp::AbstractOptimizer::constraintPolicy_
protectedinherited

The constraint policy.

Must be one the following:

  • CONSTRAINTS_KEEP: keep the constraint associated to the parameters (default).
  • CONSTRAINTS_IGNORE: remove all constraints.
  • CONSTRAINTS_AUTO: use AutoParameters to deal with constraints.
See also
AutoParameter

Definition at line 56 of file AbstractOptimizer.h.

Referenced by bpp::AbstractOptimizer::AbstractOptimizer(), bpp::AbstractOptimizer::getConstraintPolicy(), bpp::AbstractOptimizer::init(), and bpp::AbstractOptimizer::operator=().

◆ currentValue_

◆ defaultStopCondition_

std::shared_ptr<OptimizationStopCondition> bpp::AbstractOptimizer::defaultStopCondition_
protectedinherited

The default stoping condition to use while optimizing.

Definition at line 66 of file AbstractOptimizer.h.

Referenced by bpp::AbstractOptimizer::AbstractOptimizer(), bpp::AbstractOptimizer::getDefaultStopCondition(), and bpp::AbstractOptimizer::operator=().

◆ function_

◆ isInitialized_

bool bpp::AbstractOptimizer::isInitialized_
protectedinherited

◆ listeners_

◆ messageHandler_

std::shared_ptr<OutputStream> bpp::AbstractOptimizer::messageHandler_
protectedinherited

◆ nbEval_

◆ nbEvalMax_

◆ parameters_

◆ profiler_

std::shared_ptr<OutputStream> bpp::AbstractOptimizer::profiler_
protectedinherited

◆ startTime_

time_t bpp::AbstractOptimizer::startTime_
protectedinherited

◆ stepChar_

std::string bpp::AbstractOptimizer::stepChar_
protectedinherited

◆ stopCondition_

std::shared_ptr<OptimizationStopCondition> bpp::AbstractOptimizer::stopCondition_
protectedinherited

◆ tolIsReached_

◆ updateParameters_

bool bpp::AbstractOptimizer::updateParameters_
protectedinherited

◆ verbose_

unsigned int bpp::AbstractOptimizer::verbose_
protectedinherited

State of the verbose mode: > 0 = enabled.

This may not be used by the Optimizer.

Definition at line 73 of file AbstractOptimizer.h.

Referenced by bpp::AbstractOptimizer::getVerbose(), bpp::AbstractOptimizer::operator=(), and bpp::AbstractOptimizer::optimize().


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