bpp-phyl3  3.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
bpp::PseudoNewtonOptimizer Class Reference

This Optimizer implements Newton's algorithm for finding a minimum of a function. This is in fact a modified version of the algorithm, as suggested by Nicolas Galtier, for the purpose of optimizing phylogenetic likelihoods. More...

#include <Bpp/Phyl/PseudoNewtonOptimizer.h>

+ Inheritance diagram for bpp::PseudoNewtonOptimizer:
+ Collaboration diagram for bpp::PseudoNewtonOptimizer:

Classes

class  PNStopCondition
 

Public Member Functions

 PseudoNewtonOptimizer (std::shared_ptr< SecondOrderDerivable > function)
 
virtual ~PseudoNewtonOptimizer ()
 
PseudoNewtonOptimizerclone () const
 
const SecondOrderDerivablesecondOrderDerivableFunction () const
 
SecondOrderDerivablesecondOrderDerivableFunction ()
 
std::shared_ptr< const SecondOrderDerivablegetSecondOrderDerivableFunction () const
 
std::shared_ptr< SecondOrderDerivablegetSecondOrderDerivableFunction ()
 
void doInit (const ParameterList &params)
 
double doStep ()
 
void setMaximumNumberOfCorrections (unsigned int mx)
 
void disableCG ()
 
void updateParameters (bool yn) override
 
bool updateParameters () const override
 
void setOptimizationProgressCharacter (const std::string &c)
 
const std::string & getOptimizationProgressCharacter () const
 
void init (const ParameterList &params) override
 
void init (const ParameterList &params) override
 
double step () override
 
double step () override
 
double optimize () override
 
double optimize () override
 
bool isInitialized () const override
 
bool isInitialized () const override
 
const ParameterListgetParameters () const override
 
const ParameterListgetParameters () const override
 
double getParameterValue (const std::string &name) const override
 
double getParameterValue (const std::string &name) const override
 
void setFunction (std::shared_ptr< FunctionInterface > function) override
 
void setFunction (std::shared_ptr< FunctionInterface > function) override
 
const FunctionInterfacefunction () const override
 
FunctionInterfacefunction () override
 
const FunctionInterfacefunction () const override
 
FunctionInterfacefunction () override
 
std::shared_ptr< const FunctionInterfacegetFunction () const override
 
std::shared_ptr< FunctionInterfacegetFunction () override
 
std::shared_ptr< const FunctionInterfacegetFunction () const override
 
std::shared_ptr< FunctionInterfacegetFunction () override
 
bool hasFunction () const override
 
bool hasFunction () const override
 
void setMessageHandler (std::shared_ptr< OutputStream > mh) override
 
void setMessageHandler (std::shared_ptr< OutputStream > mh) override
 
std::shared_ptr< OutputStreamgetMessageHandler () const override
 
std::shared_ptr< OutputStreamgetMessageHandler () const override
 
void setProfiler (std::shared_ptr< OutputStream > profiler) override
 
void setProfiler (std::shared_ptr< OutputStream > profiler) override
 
std::shared_ptr< OutputStreamgetProfiler () const override
 
std::shared_ptr< OutputStreamgetProfiler () const override
 
unsigned int getNumberOfEvaluations () const override
 
unsigned int getNumberOfEvaluations () const override
 
void setStopCondition (std::shared_ptr< OptimizationStopCondition > stopCondition) override
 
void setStopCondition (std::shared_ptr< OptimizationStopCondition > stopCondition) override
 
std::shared_ptr< OptimizationStopConditiongetStopCondition () override
 
std::shared_ptr< const OptimizationStopConditiongetStopCondition () const override
 
std::shared_ptr< OptimizationStopConditiongetStopCondition () override
 
std::shared_ptr< const OptimizationStopConditiongetStopCondition () const override
 
std::shared_ptr< OptimizationStopConditiongetDefaultStopCondition () override
 
std::shared_ptr< const OptimizationStopConditiongetDefaultStopCondition () const override
 
std::shared_ptr< OptimizationStopConditiongetDefaultStopCondition () override
 
std::shared_ptr< const OptimizationStopConditiongetDefaultStopCondition () const override
 
bool isToleranceReached () const override
 
bool isToleranceReached () const override
 
bool isMaximumNumberOfEvaluationsReached () const override
 
bool isMaximumNumberOfEvaluationsReached () const override
 
void setMaximumNumberOfEvaluations (unsigned int max) override
 
void setMaximumNumberOfEvaluations (unsigned int max) override
 
void setVerbose (unsigned int v) override
 
void setVerbose (unsigned int v) override
 
unsigned int getVerbose () const override
 
unsigned int getVerbose () const override
 
void setConstraintPolicy (const std::string &constraintPolicy) override
 
void setConstraintPolicy (const std::string &constraintPolicy) override
 
std::string getConstraintPolicy () const override
 
std::string getConstraintPolicy () const override
 
void addOptimizationListener (std::shared_ptr< OptimizationListener > listener) override
 
void addOptimizationListener (std::shared_ptr< OptimizationListener > listener) override
 
The Optimizer interface.
double getFunctionValue () const
 

Protected Member Functions

ParameterListgetParameters_ ()
 
ParametergetParameter_ (size_t i)
 
std::shared_ptr< FunctionInterfacegetFunction_ ()
 
void setDefaultStopCondition_ (std::shared_ptr< OptimizationStopCondition > osc)
 
void autoParameter ()
 
void autoParameter ()
 
void ignoreConstraints ()
 
void ignoreConstraints ()
 
void profile (double v)
 
void profile (unsigned int v)
 
void profile (const std::string &s)
 
void profile (double v)
 
void profile (unsigned int v)
 
void profile (const std::string &s)
 
void profileln (double v)
 
void profileln (unsigned int v)
 
void profileln (const std::string &s)
 
void profileln (double v)
 
void profileln (unsigned int v)
 
void profileln (const std::string &s)
 
void printPoint (const ParameterList &params, double value)
 
void printPoint (const ParameterList &params, double value)
 
void printMessage (const std::string &message)
 
void printMessage (const std::string &message)
 
void fireOptimizationInitializationPerformed (const OptimizationEvent &event)
 
void fireOptimizationInitializationPerformed (const OptimizationEvent &event)
 
void fireOptimizationStepPerformed (const OptimizationEvent &event)
 
void fireOptimizationStepPerformed (const OptimizationEvent &event)
 
bool listenerModifiesParameters () const
 
bool listenerModifiesParameters () const
 

Protected Attributes

std::shared_ptr< FunctionInterfacefunction_
 
ParameterList parameters_
 
std::shared_ptr< OutputStreammessageHandler_
 
std::shared_ptr< OutputStreamprofiler_
 
std::string constraintPolicy_
 
std::shared_ptr< OptimizationStopConditionstopCondition_
 
std::shared_ptr< OptimizationStopConditiondefaultStopCondition_
 
unsigned int verbose_
 
bool isInitialized_
 
time_t startTime_
 
std::vector< std::shared_ptr< OptimizationListener > > listeners_
 
bool updateParameters_
 
std::string stepChar_
 
unsigned int nbEvalMax_
 
unsigned int nbEval_
 
double currentValue_
 
bool tolIsReached_
 

Private Attributes

ParameterList previousPoint_
 
double previousValue_
 
size_t n_
 
std::vector< std::string > params_
 
unsigned int maxCorrection_
 
bool useCG_
 

Friends

class PNStopCondition
 

Detailed Description

This Optimizer implements Newton's algorithm for finding a minimum of a function. This is in fact a modified version of the algorithm, as suggested by Nicolas Galtier, for the purpose of optimizing phylogenetic likelihoods.

Only second simple order derivative are computed, no cross derivative, following Galtier's algorithm. Felsenstein and Churchill's (1996) correction is applied when new trial as a likelihood lower than the starting point.

Definition at line 23 of file PseudoNewtonOptimizer.h.

Constructor & Destructor Documentation

◆ PseudoNewtonOptimizer()

PseudoNewtonOptimizer::PseudoNewtonOptimizer ( std::shared_ptr< SecondOrderDerivable function)

◆ ~PseudoNewtonOptimizer()

virtual bpp::PseudoNewtonOptimizer::~PseudoNewtonOptimizer ( )
inlinevirtual

Definition at line 60 of file PseudoNewtonOptimizer.h.

Member Function Documentation

◆ clone()

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

Implements bpp::AbstractOptimizer.

Definition at line 62 of file PseudoNewtonOptimizer.h.

References PseudoNewtonOptimizer().

◆ disableCG()

void bpp::PseudoNewtonOptimizer::disableCG ( )
inline

Definition at line 99 of file PseudoNewtonOptimizer.h.

References useCG_.

◆ doInit()

◆ doStep()

double PseudoNewtonOptimizer::doStep ( )
virtual

Implements bpp::AbstractOptimizer.

Definition at line 63 of file PseudoNewtonOptimizer.cpp.

References count(), bpp::AbstractOptimizer::currentValue_, bpp::SecondOrderDerivable::enableSecondOrderDerivatives(), bpp::AbstractOptimizer::function_, bpp::AbstractOptimizer::getConstraintPolicy(), bpp::SecondOrderDerivable::getFirstOrderDerivative(), bpp::AbstractOptimizer::getFunction(), bpp::ConjugateGradientMultiDimensions::getFunctionValue(), bpp::AbstractOptimizer::getMessageHandler(), bpp::AbstractOptimizer::getParameters(), bpp::ConjugateGradientMultiDimensions::getParameters(), bpp::AbstractOptimizer::getParameters_(), bpp::AbstractOptimizer::getProfiler(), bpp::SecondOrderDerivable::getSecondOrderDerivative(), bpp::ConjugateGradientMultiDimensions::getStopCondition(), bpp::AbstractOptimizer::getStopCondition(), bpp::ConjugateGradientMultiDimensions::init(), maxCorrection_, n_, bpp::AbstractOptimizer::nbEvalMax_, bpp::ConjugateGradientMultiDimensions::optimize(), params_, previousPoint_, previousValue_, bpp::AbstractOptimizer::printMessage(), secondOrderDerivableFunction(), bpp::ConjugateGradientMultiDimensions::setConstraintPolicy(), bpp::ConjugateGradientMultiDimensions::setMaximumNumberOfEvaluations(), bpp::ConjugateGradientMultiDimensions::setMessageHandler(), bpp::SecondOrderDerivable::setParameters(), bpp::ConjugateGradientMultiDimensions::setProfiler(), bpp::ConjugateGradientMultiDimensions::setVerbose(), bpp::TextTools::toString(), bpp::AbstractOptimizer::updateParameters(), and useCG_.

◆ getFunctionValue()

double bpp::PseudoNewtonOptimizer::getFunctionValue ( ) const
inlinevirtual

Reimplemented from bpp::AbstractOptimizer.

Definition at line 90 of file PseudoNewtonOptimizer.h.

References bpp::AbstractOptimizer::currentValue_.

◆ getSecondOrderDerivableFunction() [1/2]

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

Definition at line 80 of file PseudoNewtonOptimizer.h.

References bpp::AbstractOptimizer::function_.

◆ getSecondOrderDerivableFunction() [2/2]

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

Definition at line 75 of file PseudoNewtonOptimizer.h.

References bpp::AbstractOptimizer::function_.

◆ secondOrderDerivableFunction() [1/2]

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

Definition at line 70 of file PseudoNewtonOptimizer.h.

References bpp::AbstractOptimizer::function_.

◆ secondOrderDerivableFunction() [2/2]

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

Definition at line 65 of file PseudoNewtonOptimizer.h.

References bpp::AbstractOptimizer::function_.

Referenced by doInit(), and doStep().

◆ setMaximumNumberOfCorrections()

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

Definition at line 97 of file PseudoNewtonOptimizer.h.

References maxCorrection_.

Friends And Related Function Documentation

◆ PNStopCondition

friend class PNStopCondition
friend

Definition at line 42 of file PseudoNewtonOptimizer.h.

Member Data Documentation

◆ maxCorrection_

unsigned int bpp::PseudoNewtonOptimizer::maxCorrection_
private

Definition at line 53 of file PseudoNewtonOptimizer.h.

Referenced by doStep(), and setMaximumNumberOfCorrections().

◆ n_

size_t bpp::PseudoNewtonOptimizer::n_
private

Definition at line 49 of file PseudoNewtonOptimizer.h.

Referenced by doInit(), and doStep().

◆ params_

std::vector<std::string> bpp::PseudoNewtonOptimizer::params_
private

Definition at line 51 of file PseudoNewtonOptimizer.h.

Referenced by doInit(), and doStep().

◆ previousPoint_

ParameterList bpp::PseudoNewtonOptimizer::previousPoint_
private

Definition at line 45 of file PseudoNewtonOptimizer.h.

Referenced by doStep().

◆ previousValue_

double bpp::PseudoNewtonOptimizer::previousValue_
private

◆ useCG_

bool bpp::PseudoNewtonOptimizer::useCG_
private

Definition at line 55 of file PseudoNewtonOptimizer.h.

Referenced by disableCG(), and doStep().


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