bpp-core3
3.0.0
|
Partial implementation of the Optimizer interface. More...
#include <Bpp/Numeric/Function/AbstractOptimizer.h>
Public Member Functions | |
AbstractOptimizer (std::shared_ptr< FunctionInterface > function=nullptr) | |
AbstractOptimizer (const AbstractOptimizer &opt) | |
AbstractOptimizer & | operator= (const AbstractOptimizer &opt) |
virtual | ~AbstractOptimizer () |
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 |
OptimizerInterface * | clone () const =0 |
Create a copy of this object and send a pointer to it. More... | |
The Optimizer interface. | |
void | init (const ParameterList ¶ms) override |
Basic implementation. More... | |
double | step () override |
Basic implementation. More... | |
double | optimize () override |
Basic implementation. More... | |
bool | isInitialized () const override |
const ParameterList & | getParameters () 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 FunctionInterface & | function () const override |
Get the current function being optimized. More... | |
FunctionInterface & | function () override |
Get the current function being optimized. More... | |
std::shared_ptr< const FunctionInterface > | getFunction () const override |
Get the current function being optimized. More... | |
std::shared_ptr< FunctionInterface > | getFunction () 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< OutputStream > | getMessageHandler () const override |
void | setProfiler (std::shared_ptr< OutputStream > profiler) override |
Set the profiler for this optimizer. More... | |
std::shared_ptr< OutputStream > | getProfiler () 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< OptimizationStopCondition > | getStopCondition () override |
Get the stop condition of the optimization algorithm. More... | |
std::shared_ptr< const OptimizationStopCondition > | getStopCondition () const override |
Get the stop condition of the optimization algorithm. More... | |
std::shared_ptr< OptimizationStopCondition > | getDefaultStopCondition () override |
Get the default stop condition of the optimization algorithm. More... | |
std::shared_ptr< const OptimizationStopCondition > | getDefaultStopCondition () 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 | |
virtual void | doInit (const ParameterList ¶ms)=0 |
This function is called by the init() method and contains all calculations. More... | |
virtual double | doStep ()=0 |
This function is called by the step() method and contains all calculations. More... | |
ParameterList & | getParameters_ () |
Parameter & | getParameter_ (size_t i) |
std::shared_ptr< FunctionInterface > | getFunction_ () |
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 ¶ms, 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< FunctionInterface > | function_ |
The function to optimize. More... | |
ParameterList | parameters_ |
The parameters that will be optimized. More... | |
std::shared_ptr< OutputStream > | messageHandler_ |
The message handler. More... | |
std::shared_ptr< OutputStream > | profiler_ |
The profiler. More... | |
std::string | constraintPolicy_ |
The constraint policy. More... | |
std::shared_ptr< OptimizationStopCondition > | stopCondition_ |
The stoping condition to use while optimizing. More... | |
std::shared_ptr< OptimizationStopCondition > | defaultStopCondition_ |
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... | |
Partial implementation of the Optimizer interface.
This implementation is designed for unconstrained or simple-bounded optimization. You should not use it with global contraints. It also enables the gestion of listeners by maintaining a vector of pointers toward the listener. Important note: this list of listener is not duplicated in cas of copy of the Optimizer, as listeners are expected to be bounded ot a particular instance.:if expand("%") == ""|browse confirm w|else|confirm w|endif
Definition at line 22 of file AbstractOptimizer.h.
AbstractOptimizer::AbstractOptimizer | ( | std::shared_ptr< FunctionInterface > | function = nullptr | ) |
Definition at line 19 of file AbstractOptimizer.cpp.
AbstractOptimizer::AbstractOptimizer | ( | const AbstractOptimizer & | opt | ) |
Definition at line 34 of file AbstractOptimizer.cpp.
References autoParameter(), constraintPolicy_, bpp::AutoParameter::CONSTRAINTS_AUTO, bpp::AutoParameter::CONSTRAINTS_IGNORE, defaultStopCondition_, ignoreConstraints(), isInitialized_, and stopCondition_.
|
inlinevirtual |
Definition at line 119 of file AbstractOptimizer.h.
References init(), optimize(), and step().
|
inlineoverridevirtual |
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.
listener | A listener to be registered with. |
Implements bpp::OptimizerInterface.
Definition at line 235 of file AbstractOptimizer.h.
|
protected |
Build a list of AutoParameter instead of Parameter.
Definition at line 273 of file AbstractOptimizer.cpp.
References messageHandler_, parameters_, bpp::AutoParameter::setMessageHandler(), bpp::ParameterList::setParameter(), and bpp::ParameterList::size().
Referenced by AbstractOptimizer(), getOptimizationProgressCharacter(), init(), and operator=().
|
pure virtualinherited |
Create a copy of this object and send a pointer to it.
Implements bpp::Clonable.
Implemented in bpp::MetaOptimizer, bpp::DownhillSimplexMethod, bpp::BrentOneDimension, bpp::NewtonBacktrackOneDimension, bpp::PowellMultiDimensions, bpp::GoldenSectionSearch, bpp::BfgsMultiDimensions, bpp::ConjugateGradientMultiDimensions, bpp::SimpleMultiDimensions, bpp::SimpleNewtonMultiDimensions, and bpp::NewtonOneDimension.
|
protectedpure virtual |
This function is called by the init() method and contains all calculations.
params | The parameters to use for initialization. |
Implemented in bpp::MetaOptimizer, bpp::DownhillSimplexMethod, bpp::BrentOneDimension, bpp::GoldenSectionSearch, bpp::NewtonBacktrackOneDimension, bpp::PowellMultiDimensions, bpp::BfgsMultiDimensions, bpp::ConjugateGradientMultiDimensions, bpp::SimpleMultiDimensions, bpp::SimpleNewtonMultiDimensions, and bpp::NewtonOneDimension.
Referenced by getOptimizationProgressCharacter(), and init().
|
protectedpure virtual |
This function is called by the step() method and contains all calculations.
Implemented in bpp::MetaOptimizer, bpp::DownhillSimplexMethod, bpp::BrentOneDimension, bpp::GoldenSectionSearch, bpp::NewtonBacktrackOneDimension, bpp::PowellMultiDimensions, bpp::BfgsMultiDimensions, bpp::ConjugateGradientMultiDimensions, bpp::SimpleMultiDimensions, bpp::SimpleNewtonMultiDimensions, and bpp::NewtonOneDimension.
Referenced by getOptimizationProgressCharacter(), and step().
|
protected |
Notify all listeners that optimizer initialization was performed.
This method should be called by the init method.
event | An OptimizationEvent object. |
Definition at line 295 of file AbstractOptimizer.cpp.
References listeners_.
Referenced by getOptimizationProgressCharacter(), and init().
|
protected |
Notify all listeners that an optimization step was performed.
This method should be called by the step method.
event | An OptimizationEvent object. |
Definition at line 305 of file AbstractOptimizer.cpp.
References listeners_.
Referenced by getOptimizationProgressCharacter(), and step().
|
inlineoverridevirtual |
Get the current function being optimized.
NullPointerException | if no function is associated with the optimizer. |
Implements bpp::OptimizerInterface.
Definition at line 162 of file AbstractOptimizer.h.
References function_.
|
inlineoverridevirtual |
Get the current function being optimized.
NullPointerException | if no function is associated with the optimizer. |
Implements bpp::OptimizerInterface.
Definition at line 174 of file AbstractOptimizer.h.
References function_.
|
inlineoverridevirtual |
Get the constraint policy for this optimizer.
Implements bpp::OptimizerInterface.
Definition at line 233 of file AbstractOptimizer.h.
References constraintPolicy_.
Referenced by bpp::SimpleNewtonMultiDimensions::doInit(), bpp::SimpleMultiDimensions::doInit(), and bpp::MetaOptimizer::doInit().
|
inlineoverridevirtual |
Get the default stop condition of the optimization algorithm.
Implements bpp::OptimizerInterface.
Definition at line 217 of file AbstractOptimizer.h.
References defaultStopCondition_.
Referenced by bpp::BfgsMultiDimensions::BfgsMultiDimensions(), bpp::BrentOneDimension::BrentOneDimension(), bpp::ConjugateGradientMultiDimensions::ConjugateGradientMultiDimensions(), bpp::DownhillSimplexMethod::DownhillSimplexMethod(), bpp::GoldenSectionSearch::GoldenSectionSearch(), bpp::MetaOptimizer::MetaOptimizer(), bpp::NewtonBacktrackOneDimension::NewtonBacktrackOneDimension(), bpp::NewtonOneDimension::NewtonOneDimension(), bpp::PowellMultiDimensions::PowellMultiDimensions(), bpp::SimpleMultiDimensions::SimpleMultiDimensions(), and bpp::SimpleNewtonMultiDimensions::SimpleNewtonMultiDimensions().
|
inlineoverridevirtual |
Get the default stop condition of the optimization algorithm.
Implements bpp::OptimizerInterface.
Definition at line 219 of file AbstractOptimizer.h.
References defaultStopCondition_.
|
inlineoverridevirtual |
Get the current function being optimized.
Implements bpp::OptimizerInterface.
Definition at line 186 of file AbstractOptimizer.h.
References function_.
Referenced by bpp::NewtonOneDimension::doInit(), bpp::SimpleNewtonMultiDimensions::doInit(), bpp::SimpleMultiDimensions::doInit(), bpp::PowellMultiDimensions::doInit(), bpp::NewtonBacktrackOneDimension::doInit(), bpp::GoldenSectionSearch::doInit(), bpp::BrentOneDimension::doInit(), bpp::DownhillSimplexMethod::doInit(), bpp::MetaOptimizer::doInit(), bpp::NewtonOneDimension::doStep(), bpp::SimpleNewtonMultiDimensions::doStep(), bpp::SimpleMultiDimensions::doStep(), bpp::ConjugateGradientMultiDimensions::doStep(), bpp::BfgsMultiDimensions::doStep(), bpp::PowellMultiDimensions::doStep(), bpp::NewtonBacktrackOneDimension::doStep(), bpp::GoldenSectionSearch::doStep(), bpp::BrentOneDimension::doStep(), bpp::DownhillSimplexMethod::doStep(), bpp::MetaOptimizer::doStep(), bpp::PowellMultiDimensions::optimize(), bpp::BrentOneDimension::optimize(), bpp::DownhillSimplexMethod::optimize(), and bpp::DownhillSimplexMethod::tryExtrapolation().
|
inlineoverridevirtual |
Get the current function being optimized.
Implements bpp::OptimizerInterface.
Definition at line 188 of file AbstractOptimizer.h.
References function_.
|
inlineprotected |
Definition at line 389 of file AbstractOptimizer.h.
References function_.
|
inlineoverridevirtual |
Get the current function value.
NullPointerException | If no function is associated with this optimizer. |
Implements bpp::OptimizerInterface.
Reimplemented in bpp::GoldenSectionSearch.
Definition at line 192 of file AbstractOptimizer.h.
References currentValue_.
|
inlineoverridevirtual |
Implements bpp::OptimizerInterface.
Definition at line 200 of file AbstractOptimizer.h.
References messageHandler_.
Referenced by bpp::SimpleNewtonMultiDimensions::doInit(), bpp::SimpleMultiDimensions::doInit(), bpp::MetaOptimizer::doInit(), and bpp::PowellMultiDimensions::doStep().
|
inlineoverridevirtual |
Get the number of function evaluations performed since the call of the init function.
Implements bpp::OptimizerInterface.
Definition at line 206 of file AbstractOptimizer.h.
References nbEval_.
Referenced by bpp::SimpleNewtonMultiDimensions::doStep(), bpp::SimpleMultiDimensions::doStep(), bpp::OneDimensionOptimizationTools::lineMinimization(), and bpp::OneDimensionOptimizationTools::lineSearch().
|
inline |
Definition at line 273 of file AbstractOptimizer.h.
References autoParameter(), doInit(), doStep(), fireOptimizationInitializationPerformed(), fireOptimizationStepPerformed(), ignoreConstraints(), listenerModifiesParameters(), printMessage(), printPoint(), profile(), profileln(), and stepChar_.
|
inlineprotected |
Definition at line 387 of file AbstractOptimizer.h.
Referenced by bpp::GoldenSectionSearch::doInit(), bpp::BrentOneDimension::doInit(), bpp::NewtonBacktrackOneDimension::doStep(), bpp::GoldenSectionSearch::doStep(), and bpp::BrentOneDimension::doStep().
|
inlineoverridevirtual |
Implements bpp::OptimizerInterface.
Definition at line 149 of file AbstractOptimizer.h.
References parameters_.
Referenced by bpp::NewtonOneDimension::doInit(), bpp::SimpleNewtonMultiDimensions::doInit(), bpp::SimpleMultiDimensions::doInit(), bpp::BfgsMultiDimensions::doInit(), bpp::NewtonBacktrackOneDimension::doInit(), bpp::PowellMultiDimensions::doInit(), bpp::GoldenSectionSearch::doInit(), bpp::BrentOneDimension::doInit(), bpp::DownhillSimplexMethod::doInit(), bpp::MetaOptimizer::doInit(), bpp::NewtonOneDimension::doStep(), bpp::SimpleNewtonMultiDimensions::doStep(), bpp::SimpleMultiDimensions::doStep(), bpp::ConjugateGradientMultiDimensions::doStep(), bpp::BfgsMultiDimensions::doStep(), bpp::NewtonBacktrackOneDimension::doStep(), bpp::PowellMultiDimensions::doStep(), bpp::GoldenSectionSearch::doStep(), bpp::BrentOneDimension::doStep(), bpp::MetaOptimizer::doStep(), bpp::ConjugateGradientMultiDimensions::getGradient(), bpp::BfgsMultiDimensions::getGradient(), bpp::DownhillSimplexMethod::getPSum(), bpp::PowellMultiDimensions::optimize(), bpp::BrentOneDimension::optimize(), bpp::BfgsMultiDimensions::setDirection(), and bpp::DownhillSimplexMethod::tryExtrapolation().
|
inlineprotected |
Definition at line 385 of file AbstractOptimizer.h.
References parameters_.
Referenced by bpp::MetaOptimizer::doInit(), bpp::NewtonOneDimension::doStep(), bpp::SimpleNewtonMultiDimensions::doStep(), bpp::SimpleMultiDimensions::doStep(), bpp::ConjugateGradientMultiDimensions::doStep(), bpp::BfgsMultiDimensions::doStep(), bpp::PowellMultiDimensions::doStep(), bpp::DownhillSimplexMethod::doStep(), and bpp::MetaOptimizer::doStep().
|
inlineoverridevirtual |
Implements bpp::OptimizerInterface.
Definition at line 151 of file AbstractOptimizer.h.
References bpp::ParameterList::getParameterValue().
|
inlineoverridevirtual |
Implements bpp::OptimizerInterface.
Definition at line 204 of file AbstractOptimizer.h.
References profiler_.
Referenced by bpp::SimpleNewtonMultiDimensions::doInit(), bpp::SimpleMultiDimensions::doInit(), and bpp::MetaOptimizer::doInit().
|
inlineoverridevirtual |
Get the stop condition of the optimization algorithm.
Implements bpp::OptimizerInterface.
Definition at line 213 of file AbstractOptimizer.h.
References stopCondition_.
Referenced by bpp::NewtonOneDimension::doInit(), bpp::SimpleNewtonMultiDimensions::doInit(), bpp::SimpleMultiDimensions::doInit(), bpp::NewtonBacktrackOneDimension::doInit(), bpp::MetaOptimizer::doInit(), bpp::SimpleMultiDimensions::doStep(), bpp::ConjugateGradientMultiDimensions::doStep(), bpp::PowellMultiDimensions::doStep(), bpp::GoldenSectionSearch::doStep(), bpp::BrentOneDimension::doStep(), bpp::MetaOptimizer::doStep(), bpp::OneDimensionOptimizationTools::lineMinimization(), bpp::OneDimensionOptimizationTools::lineSearch(), bpp::MetaOptimizer::MetaOptimizer(), and bpp::SimpleMultiDimensions::setFunction().
|
inlineoverridevirtual |
Get the stop condition of the optimization algorithm.
Implements bpp::OptimizerInterface.
Definition at line 215 of file AbstractOptimizer.h.
References stopCondition_.
|
inlineoverridevirtual |
Get the verbose level.
Implements bpp::OptimizerInterface.
Definition at line 229 of file AbstractOptimizer.h.
References verbose_.
Referenced by bpp::SimpleNewtonMultiDimensions::doInit(), bpp::SimpleMultiDimensions::doInit(), bpp::GoldenSectionSearch::doInit(), bpp::BrentOneDimension::doInit(), bpp::MetaOptimizer::doInit(), bpp::SimpleNewtonMultiDimensions::doStep(), bpp::SimpleMultiDimensions::doStep(), bpp::ConjugateGradientMultiDimensions::doStep(), bpp::BfgsMultiDimensions::doStep(), bpp::PowellMultiDimensions::doStep(), and bpp::MetaOptimizer::doStep().
|
inlineoverridevirtual |
Tell if a funciton is associatied to this optimizer.
Implements bpp::OptimizerInterface.
Definition at line 190 of file AbstractOptimizer.h.
Referenced by bpp::GoldenSectionSearch::getFunctionValue().
|
protected |
Remove the constraints of all the arguments.
Definition at line 285 of file AbstractOptimizer.cpp.
References parameters_, and bpp::ParameterList::size().
Referenced by AbstractOptimizer(), getOptimizationProgressCharacter(), init(), and operator=().
|
overridevirtual |
Basic implementation.
Store all parameters, call the doInit method, print to profiler, initialize timer and notify all listeners.
Implements bpp::OptimizerInterface.
Definition at line 125 of file AbstractOptimizer.cpp.
References autoParameter(), constraintPolicy_, bpp::AutoParameter::CONSTRAINTS_AUTO, bpp::AutoParameter::CONSTRAINTS_IGNORE, currentValue_, doInit(), fireOptimizationInitializationPerformed(), function_, ignoreConstraints(), isInitialized_, nbEval_, parameters_, printPoint(), profile(), profileln(), bpp::ParameterList::size(), startTime_, stopCondition_, and tolIsReached_.
Referenced by bpp::SimpleNewtonMultiDimensions::doStep(), bpp::SimpleMultiDimensions::doStep(), bpp::OneDimensionOptimizationTools::lineMinimization(), bpp::OneDimensionOptimizationTools::lineSearch(), and ~AbstractOptimizer().
|
inlineoverridevirtual |
Implements bpp::OptimizerInterface.
Definition at line 147 of file AbstractOptimizer.h.
References isInitialized_.
|
inlineoverridevirtual |
Tell if the maximum number of function evaluations is reached.
Implements bpp::OptimizerInterface.
Definition at line 223 of file AbstractOptimizer.h.
References nbEvalMax_.
|
inlineoverridevirtual |
Tell if the tolerance level is reached.
Implements bpp::OptimizerInterface.
Definition at line 221 of file AbstractOptimizer.h.
References tolIsReached_.
|
protected |
Definition at line 315 of file AbstractOptimizer.cpp.
References listeners_.
Referenced by getOptimizationProgressCharacter(), and step().
AbstractOptimizer & AbstractOptimizer::operator= | ( | const AbstractOptimizer & | opt | ) |
Definition at line 80 of file AbstractOptimizer.cpp.
References autoParameter(), constraintPolicy_, bpp::AutoParameter::CONSTRAINTS_AUTO, bpp::AutoParameter::CONSTRAINTS_IGNORE, defaultStopCondition_, function_, ignoreConstraints(), isInitialized_, listeners_, messageHandler_, nbEval_, nbEvalMax_, parameters_, profiler_, startTime_, stepChar_, stopCondition_, tolIsReached_, updateParameters_, and verbose_.
Referenced by bpp::MetaOptimizer::operator=().
|
overridevirtual |
Basic implementation.
Call the step method untill tolerance is reached.
Implements bpp::OptimizerInterface.
Reimplemented in bpp::DownhillSimplexMethod, bpp::BrentOneDimension, and bpp::PowellMultiDimensions.
Definition at line 183 of file AbstractOptimizer.cpp.
References currentValue_, bpp::ApplicationTools::displayUnlimitedGauge(), isInitialized_, nbEval_, nbEvalMax_, step(), tolIsReached_, and verbose_.
Referenced by bpp::SimpleNewtonMultiDimensions::doStep(), bpp::OneDimensionOptimizationTools::lineSearch(), bpp::PowellMultiDimensions::optimize(), bpp::BrentOneDimension::optimize(), bpp::DownhillSimplexMethod::optimize(), and ~AbstractOptimizer().
|
protected |
Give a message to print to the message handler.
message | The message to print. |
Definition at line 265 of file AbstractOptimizer.cpp.
References messageHandler_.
Referenced by bpp::GoldenSectionSearch::doInit(), bpp::BrentOneDimension::doInit(), bpp::NewtonOneDimension::doStep(), bpp::BfgsMultiDimensions::doStep(), and getOptimizationProgressCharacter().
|
protected |
Print parameters and corresponding function evaluation to profiler.
params | The parameters to print. |
value | The function evaluation. |
Definition at line 246 of file AbstractOptimizer.cpp.
References nbEval_, profile(), profileln(), bpp::ParameterList::size(), startTime_, and bpp::TextTools::toString().
Referenced by bpp::PowellMultiDimensions::doStep(), getOptimizationProgressCharacter(), init(), and step().
|
protected |
Print to the profile if there is one.
v | The double value to print. |
Definition at line 199 of file AbstractOptimizer.cpp.
References profiler_.
Referenced by getOptimizationProgressCharacter(), init(), and printPoint().
|
protected |
Print to the profile if there is one.
v | The unsigned int value to print. |
Definition at line 215 of file AbstractOptimizer.cpp.
References profiler_.
|
protected |
Print to the profile if there is one.
s | The string to print to the profile. |
Definition at line 230 of file AbstractOptimizer.cpp.
References profiler_.
|
protected |
Print to the profile if there is one and end line.
v | The double value to print. |
Definition at line 207 of file AbstractOptimizer.cpp.
References profiler_.
Referenced by getOptimizationProgressCharacter(), init(), and printPoint().
|
protected |
Print to the profile if there is one and end line.
v | The unsigned int value to print. |
Definition at line 222 of file AbstractOptimizer.cpp.
References profiler_.
|
protected |
Print to the profile if there is one and end line.
s | The string to print to the profile. |
Definition at line 238 of file AbstractOptimizer.cpp.
References profiler_.
|
inlineoverridevirtual |
Set the constraint policy for this optimizer.
constraintPolicy | The 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().
|
inlineprotected |
Definition at line 391 of file AbstractOptimizer.h.
Referenced by bpp::BfgsMultiDimensions::BfgsMultiDimensions(), bpp::BrentOneDimension::BrentOneDimension(), bpp::ConjugateGradientMultiDimensions::ConjugateGradientMultiDimensions(), bpp::DownhillSimplexMethod::DownhillSimplexMethod(), bpp::GoldenSectionSearch::GoldenSectionSearch(), bpp::MetaOptimizer::MetaOptimizer(), bpp::NewtonBacktrackOneDimension::NewtonBacktrackOneDimension(), bpp::NewtonOneDimension::NewtonOneDimension(), bpp::PowellMultiDimensions::PowellMultiDimensions(), bpp::SimpleMultiDimensions::SimpleMultiDimensions(), and bpp::SimpleNewtonMultiDimensions::SimpleNewtonMultiDimensions().
|
inlineoverridevirtual |
Set the function to optimize.
function | The 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().
|
inlineoverridevirtual |
Set the maximum number of function evaluation to perform during optimization.
max | The 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().
|
inlineoverridevirtual |
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.
mh | The 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().
|
inline |
Set the character to be displayed during optimization.
c | A character. |
Definition at line 269 of file AbstractOptimizer.h.
Referenced by bpp::BfgsMultiDimensions::BfgsMultiDimensions(), bpp::OneDimensionOptimizationTools::lineMinimization(), bpp::OneDimensionOptimizationTools::lineSearch(), bpp::MetaOptimizer::MetaOptimizer(), bpp::SimpleMultiDimensions::SimpleMultiDimensions(), and bpp::SimpleNewtonMultiDimensions::SimpleNewtonMultiDimensions().
|
inlineoverridevirtual |
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.
profiler | The 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().
|
inlineoverridevirtual |
Set the stop condition of the optimization algorithm.
stopCondition | The stop condition to use while optimizing. |
Implements bpp::OptimizerInterface.
Definition at line 208 of file AbstractOptimizer.h.
Referenced by bpp::BfgsMultiDimensions::BfgsMultiDimensions(), bpp::BrentOneDimension::BrentOneDimension(), bpp::ConjugateGradientMultiDimensions::ConjugateGradientMultiDimensions(), bpp::DownhillSimplexMethod::DownhillSimplexMethod(), bpp::GoldenSectionSearch::GoldenSectionSearch(), bpp::MetaOptimizer::MetaOptimizer(), bpp::NewtonBacktrackOneDimension::NewtonBacktrackOneDimension(), bpp::NewtonOneDimension::NewtonOneDimension(), bpp::PowellMultiDimensions::PowellMultiDimensions(), bpp::SimpleMultiDimensions::SimpleMultiDimensions(), and bpp::SimpleNewtonMultiDimensions::SimpleNewtonMultiDimensions().
|
inlineoverridevirtual |
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.
v | verbose 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().
|
overridevirtual |
Basic implementation.
Check if the optimizer is initialized, check if parameters need update because of listeners, call the doStep method, print the current point to the profiler, notify all listeners and return the current value of the function.
Implements bpp::OptimizerInterface.
Definition at line 163 of file AbstractOptimizer.cpp.
References currentValue_, doStep(), fireOptimizationStepPerformed(), function_, listenerModifiesParameters(), bpp::ParameterList::matchParametersValues(), parameters_, printPoint(), stopCondition_, tolIsReached_, and updateParameters_.
Referenced by optimize(), and ~AbstractOptimizer().
|
inlineoverridevirtual |
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.
yn | true/false |
Implements bpp::OptimizerInterface.
Definition at line 251 of file AbstractOptimizer.h.
|
inlineoverridevirtual |
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.
Implements bpp::OptimizerInterface.
Definition at line 262 of file AbstractOptimizer.h.
References updateParameters_.
Referenced by bpp::MetaOptimizer::doInit().
|
protected |
The constraint policy.
Must be one the following:
Definition at line 56 of file AbstractOptimizer.h.
Referenced by AbstractOptimizer(), getConstraintPolicy(), init(), and operator=().
|
protected |
The current value of the function.
Definition at line 102 of file AbstractOptimizer.h.
Referenced by bpp::NewtonOneDimension::doInit(), bpp::NewtonOneDimension::doStep(), bpp::BfgsMultiDimensions::doStep(), bpp::GoldenSectionSearch::getFunctionValue(), getFunctionValue(), init(), bpp::BrentOneDimension::optimize(), optimize(), and step().
|
protected |
The default stoping condition to use while optimizing.
Definition at line 66 of file AbstractOptimizer.h.
Referenced by AbstractOptimizer(), getDefaultStopCondition(), and operator=().
|
protected |
The function to optimize.
Definition at line 29 of file AbstractOptimizer.h.
Referenced by bpp::NewtonOneDimension::firstOrderDerivableFunction(), bpp::ConjugateGradientMultiDimensions::firstOrderDerivableFunction(), bpp::BfgsMultiDimensions::firstOrderDerivableFunction(), bpp::NewtonBacktrackOneDimension::firstOrderDerivableFunction(), function(), bpp::NewtonOneDimension::getFirstOrderDerivableFunction(), bpp::ConjugateGradientMultiDimensions::getFirstOrderDerivableFunction(), bpp::BfgsMultiDimensions::getFirstOrderDerivableFunction(), bpp::NewtonBacktrackOneDimension::getFirstOrderDerivableFunction(), getFunction(), getFunction_(), bpp::NewtonOneDimension::getSecondOrderDerivableFunction(), init(), operator=(), bpp::NewtonOneDimension::secondOrderDerivableFunction(), and step().
|
protected |
Check if the optimizer have been feeded with initial parameters values.
Definition at line 78 of file AbstractOptimizer.h.
Referenced by AbstractOptimizer(), init(), isInitialized(), operator=(), and optimize().
|
protected |
Definition at line 82 of file AbstractOptimizer.h.
Referenced by fireOptimizationInitializationPerformed(), fireOptimizationStepPerformed(), listenerModifiesParameters(), and operator=().
|
protected |
The message handler.
Definition at line 39 of file AbstractOptimizer.h.
Referenced by autoParameter(), getMessageHandler(), operator=(), and printMessage().
|
protected |
The current number of function evaluations achieved.
Definition at line 97 of file AbstractOptimizer.h.
Referenced by bpp::DownhillSimplexMethod::doInit(), bpp::SimpleNewtonMultiDimensions::doStep(), bpp::SimpleMultiDimensions::doStep(), bpp::ConjugateGradientMultiDimensions::doStep(), bpp::BfgsMultiDimensions::doStep(), bpp::PowellMultiDimensions::doStep(), bpp::GoldenSectionSearch::doStep(), bpp::DownhillSimplexMethod::doStep(), bpp::MetaOptimizer::doStep(), getNumberOfEvaluations(), init(), operator=(), optimize(), printPoint(), and bpp::DownhillSimplexMethod::tryExtrapolation().
|
protected |
The maximum number of function evaluations allowed.
Definition at line 92 of file AbstractOptimizer.h.
Referenced by bpp::SimpleNewtonMultiDimensions::doInit(), bpp::SimpleMultiDimensions::doInit(), bpp::DownhillSimplexMethod::DownhillSimplexMethod(), bpp::GoldenSectionSearch::GoldenSectionSearch(), isMaximumNumberOfEvaluationsReached(), bpp::NewtonOneDimension::NewtonOneDimension(), operator=(), and optimize().
|
protected |
The parameters that will be optimized.
Definition at line 34 of file AbstractOptimizer.h.
Referenced by autoParameter(), getParameters(), getParameters_(), ignoreConstraints(), init(), operator=(), and step().
|
protected |
The profiler.
Definition at line 44 of file AbstractOptimizer.h.
Referenced by getProfiler(), operator=(), profile(), and profileln().
|
protected |
Definition at line 80 of file AbstractOptimizer.h.
Referenced by init(), operator=(), and printPoint().
|
protected |
Definition at line 86 of file AbstractOptimizer.h.
Referenced by getOptimizationProgressCharacter(), and operator=().
|
protected |
The stoping condition to use while optimizing.
Definition at line 61 of file AbstractOptimizer.h.
Referenced by AbstractOptimizer(), getStopCondition(), init(), operator=(), and step().
|
protected |
Tell if the tolerance level has been reached.
This field is initilaised by the init() method, maintained by the step() method and used in the optimize() method.
Definition at line 110 of file AbstractOptimizer.h.
Referenced by bpp::NewtonOneDimension::doStep(), bpp::SimpleNewtonMultiDimensions::doStep(), bpp::SimpleMultiDimensions::doStep(), bpp::ConjugateGradientMultiDimensions::doStep(), bpp::BfgsMultiDimensions::doStep(), bpp::NewtonBacktrackOneDimension::doStep(), bpp::GoldenSectionSearch::doStep(), bpp::MetaOptimizer::doStep(), init(), isToleranceReached(), operator=(), optimize(), and step().
|
protected |
Definition at line 84 of file AbstractOptimizer.h.
Referenced by operator=(), step(), and updateParameters().
|
protected |
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 getVerbose(), operator=(), and optimize().