bpp-phyl
2.2.0
|
Optimization methods for phylogenetic inference. More...
#include <Bpp/Phyl/OptimizationTools.h>
Classes | |
class | ScaleFunction |
Public Member Functions | |
OptimizationTools () | |
virtual | ~OptimizationTools () |
Static Public Member Functions | |
static unsigned int | optimizeNumericalParameters (DiscreteRatesAcrossSitesTreeLikelihood *tl, const ParameterList ¶meters, OptimizationListener *listener=0, unsigned int nstep=1, double tolerance=0.000001, unsigned int tlEvalMax=1000000, OutputStream *messageHandler=ApplicationTools::message, OutputStream *profiler=ApplicationTools::message, bool reparametrization=false, unsigned int verbose=1, const std::string &optMethodDeriv=OPTIMIZATION_NEWTON, const std::string &optMethodModel=OPTIMIZATION_BRENT) throw (Exception) |
Optimize numerical parameters (branch length, substitution model & rate distribution) of a TreeLikelihood function. More... | |
static unsigned int | optimizeNumericalParameters2 (DiscreteRatesAcrossSitesTreeLikelihood *tl, const ParameterList ¶meters, OptimizationListener *listener=0, double tolerance=0.000001, unsigned int tlEvalMax=1000000, OutputStream *messageHandler=ApplicationTools::message, OutputStream *profiler=ApplicationTools::message, bool reparametrization=false, bool useClock=false, unsigned int verbose=1, const std::string &optMethodDeriv=OPTIMIZATION_NEWTON) throw (Exception) |
Optimize numerical parameters (branch length, substitution model & rate distribution) of a TreeLikelihood function. More... | |
static unsigned int | optimizeBranchLengthsParameters (DiscreteRatesAcrossSitesTreeLikelihood *tl, const ParameterList ¶meters, OptimizationListener *listener=0, double tolerance=0.000001, unsigned int tlEvalMax=1000000, OutputStream *messageHandler=ApplicationTools::message, OutputStream *profiler=ApplicationTools::message, unsigned int verbose=1, const std::string &optMethodDeriv=OPTIMIZATION_NEWTON) throw (Exception) |
Optimize branch lengths parameters of a TreeLikelihood function. More... | |
static unsigned int | optimizeNumericalParametersWithGlobalClock (DiscreteRatesAcrossSitesClockTreeLikelihood *cl, const ParameterList ¶meters, OptimizationListener *listener=0, unsigned int nstep=1, double tolerance=0.000001, unsigned int tlEvalMax=1000000, OutputStream *messageHandler=ApplicationTools::message, OutputStream *profiler=ApplicationTools::message, unsigned int verbose=1, const std::string &optMethodDeriv=OPTIMIZATION_GRADIENT) throw (Exception) |
Optimize numerical parameters assuming a global clock (branch heights, substitution model & rate distribution) of a ClockTreeLikelihood function. More... | |
static unsigned int | optimizeNumericalParametersWithGlobalClock2 (DiscreteRatesAcrossSitesClockTreeLikelihood *cl, const ParameterList ¶meters, OptimizationListener *listener=0, double tolerance=0.000001, unsigned int tlEvalMax=1000000, OutputStream *messageHandler=ApplicationTools::message, OutputStream *profiler=ApplicationTools::message, unsigned int verbose=1, const std::string &optMethodDeriv=OPTIMIZATION_GRADIENT) throw (Exception) |
Optimize numerical parameters assuming a global clock (branch heights, substitution model & rate distribution) of a ClockTreeLikelihood function. More... | |
static unsigned int | optimizeTreeScale (TreeLikelihood *tl, double tolerance=0.000001, unsigned int tlEvalMax=1000000, OutputStream *messageHandler=ApplicationTools::message, OutputStream *profiler=ApplicationTools::message, unsigned int verbose=1) throw (Exception) |
Optimize the scale of a TreeLikelihood. More... | |
static NNIHomogeneousTreeLikelihood * | optimizeTreeNNI (NNIHomogeneousTreeLikelihood *tl, const ParameterList ¶meters, bool optimizeNumFirst=true, double tolBefore=100, double tolDuring=100, unsigned int tlEvalMax=1000000, unsigned int numStep=1, OutputStream *messageHandler=ApplicationTools::message, OutputStream *profiler=ApplicationTools::message, bool reparametrization=false, unsigned int verbose=1, const std::string &optMethod=OptimizationTools::OPTIMIZATION_NEWTON, unsigned int nStep=1, const std::string &nniMethod=NNITopologySearch::PHYML) throw (Exception) |
Optimize all parameters from a TreeLikelihood object, including tree topology using Nearest Neighbor Interchanges. More... | |
static NNIHomogeneousTreeLikelihood * | optimizeTreeNNI2 (NNIHomogeneousTreeLikelihood *tl, const ParameterList ¶meters, bool optimizeNumFirst=true, double tolBefore=100, double tolDuring=100, unsigned int tlEvalMax=1000000, unsigned int numStep=1, OutputStream *messageHandler=ApplicationTools::message, OutputStream *profiler=ApplicationTools::message, bool reparametrization=false, unsigned int verbose=1, const std::string &optMethod=OptimizationTools::OPTIMIZATION_NEWTON, const std::string &nniMethod=NNITopologySearch::PHYML) throw (Exception) |
Optimize all parameters from a TreeLikelihood object, including tree topology using Nearest Neighbor Interchanges. More... | |
static DRTreeParsimonyScore * | optimizeTreeNNI (DRTreeParsimonyScore *tp, unsigned int verbose=1) |
Optimize tree topology from a DRTreeParsimonyScore using Nearest Neighbor Interchanges. More... | |
static DistanceMatrix * | estimateDistanceMatrix (DistanceEstimation &estimationMethod, const ParameterList ¶metersToIgnore, const std::string ¶m=DISTANCEMETHOD_INIT, unsigned int verbose=0) throw (Exception) |
Estimate a distance matrix using maximum likelihood. More... | |
static TreeTemplate< Node > * | buildDistanceTree (DistanceEstimation &estimationMethod, AgglomerativeDistanceMethod &reconstructionMethod, const ParameterList ¶metersToIgnore, bool optimizeBrLen=false, const std::string ¶m=DISTANCEMETHOD_INIT, double tolerance=0.000001, unsigned int tlEvalMax=1000000, OutputStream *profiler=0, OutputStream *messenger=0, unsigned int verbose=0) throw (Exception) |
Build a tree using a distance method. More... | |
Static Public Attributes | |
static std::string | OPTIMIZATION_GRADIENT = "gradient" |
static std::string | OPTIMIZATION_NEWTON = "newton" |
static std::string | OPTIMIZATION_BRENT = "Brent" |
static std::string | OPTIMIZATION_BFGS = "BFGS" |
static std::string | DISTANCEMETHOD_INIT = "init" |
static std::string | DISTANCEMETHOD_PAIRWISE = "pairwise" |
static std::string | DISTANCEMETHOD_ITERATIONS = "iterations" |
Optimization methods for phylogenetic inference.
This class provides optimization methods for phylogenetics. Parameters of the optimization methods are set to work with TreeLikelihood object. Some non trivial parameters are left to the user choice (tolerance, maximum number of function evaluation, output streams).
Definition at line 300 of file OptimizationTools.h.
OptimizationTools::OptimizationTools | ( | ) |
Definition at line 64 of file OptimizationTools.cpp.
|
virtual |
Definition at line 66 of file OptimizationTools.cpp.
|
static |
Build a tree using a distance method.
This method estimate a distance matrix using a DistanceEstimation object, and then builds the phylogenetic tree using a AgglomerativeDistanceMethod object. The main issue here is to estimate non-branch lengths parameters, as substitution model and rate distribution parameters. Three options are provideed here:
estimationMethod | The distance estimation object to use. |
reconstructionMethod | The tree reconstruction object to use. |
parametersToIgnore | A list of parameters to ignore while optimizing parameters. |
optimizeBrLen | Tell if branch lengths should be optimized together with other parameters. This may lead to more accurate parameter estimation, but is slower. |
param | String describing the type of optimization to use. |
tolerance | Threshold on likelihood for stopping the iterative procedure. Used only with param=DISTANCEMETHOD_ITERATIONS. |
tlEvalMax | Maximum number of likelihood computations to perform when optimizing parameters. Used only with param=DISTANCEMETHOD_ITERATIONS. |
profiler | Output stream used by optimizer. Used only with param=DISTANCEMETHOD_ITERATIONS. |
messenger | Output stream used by optimizer. Used only with param=DISTANCEMETHOD_ITERATIONS. |
verbose | Verbose level. |
Definition at line 677 of file OptimizationTools.cpp.
References DISTANCEMETHOD_ITERATIONS, DISTANCEMETHOD_PAIRWISE, bpp::AbstractHomogeneousTreeLikelihood::initialize(), optimizeNumericalParameters(), and bpp::TreeTools::robinsonFouldsDistance().
|
static |
Estimate a distance matrix using maximum likelihood.
This method estimate a distance matrix using a DistanceEstimation object. The main issue here is to estimate non-branch lengths parameters, as substitution model and rate distribution parameters. Twoe options are provideed here:
estimationMethod | The distance estimation object to use. |
parametersToIgnore | A list of parameters to ignore while optimizing parameters. |
param | String describing the type of optimization to use. |
verbose | Verbose level. |
Definition at line 647 of file OptimizationTools.cpp.
References DISTANCEMETHOD_INIT, and DISTANCEMETHOD_PAIRWISE.
|
static |
Optimize branch lengths parameters of a TreeLikelihood function.
Uses Newton's method.
A condition over function values is used as a stop condition for the algorithm.
tl | A pointer toward the TreeLikelihood object to optimize. |
parameters | The list of parameters to optimize. The intersection of branch length parameters and the input set will be used. Use tl->getBranchLengthsParameters() in order to estimate all branch length parameters. |
listener | A pointer toward an optimization listener, if needed. |
tolerance | The tolerance to use in the algorithm. |
tlEvalMax | The maximum number of function evaluations. |
messageHandler | The massage handler. |
profiler | The profiler. |
verbose | The verbose level. |
optMethodDeriv | Optimization type for derivable parameters (first or second order derivatives). |
Exception | any exception thrown by the Optimizer. |
Definition at line 348 of file OptimizationTools.cpp.
References OPTIMIZATION_BFGS, OPTIMIZATION_GRADIENT, and OPTIMIZATION_NEWTON.
|
static |
Optimize numerical parameters (branch length, substitution model & rate distribution) of a TreeLikelihood function.
Uses Newton's method for branch length and Brent or BFGS one dimensional method for other parameters.
A condition over function values is used as a stop condition for the algorithm.
tl | A pointer toward the TreeLikelihood object to optimize. |
parameters | The list of parameters to optimize. Use tl->getIndependentParameters() in order to estimate all parameters. |
listener | A pointer toward an optimization listener, if needed. |
nstep | The number of progressive steps to perform (see NewtonBrentMetaOptimizer). 1 means full precision from start. |
tolerance | The tolerance to use in the algorithm. |
tlEvalMax | The maximum number of function evaluations. |
messageHandler | The massage handler. |
profiler | The profiler. |
reparametrization | Tell if parameters should be transformed in order to remove constraints. This can improve optimization, but is a bit slower. |
verbose | The verbose level. |
optMethodDeriv | Optimization type for derivable parameters (first or second order derivatives). |
optMethodModel | Optimization type for model parameters (Brent or BFGS). |
Exception | any exception thrown by the Optimizer. |
Definition at line 150 of file OptimizationTools.cpp.
References OPTIMIZATION_BFGS, OPTIMIZATION_BRENT, OPTIMIZATION_GRADIENT, and OPTIMIZATION_NEWTON.
Referenced by buildDistanceTree(), bpp::PhylogeneticsApplicationTools::optimizeParameters(), optimizeTreeNNI(), and bpp::NNITopologyListener::topologyChangeSuccessful().
|
static |
Optimize numerical parameters (branch length, substitution model & rate distribution) of a TreeLikelihood function.
Uses Newton's method for all parameters, branch length derivatives are computed analytically, derivatives for other parameters numerically.
tl | A pointer toward the TreeLikelihood object to optimize. |
parameters | The list of parameters to optimize. Use tl->getIndependentParameters() in order to estimate all parameters. |
listener | A pointer toward an optimization listener, if needed. |
tolerance | The tolerance to use in the algorithm. |
tlEvalMax | The maximum number of function evaluations. |
messageHandler | The massage handler. |
profiler | The profiler. |
reparametrization | Tell if parameters should be transformed in order to remove constraints. This can improve optimization, but is a bit slower. |
useClock | Tell if branch lengths have to be optimized under a global molecular clock constraint. |
verbose | The verbose level. |
optMethodDeriv | Optimization type for derivable parameters (first or second order derivatives). |
Exception | any exception thrown by the Optimizer. |
Definition at line 255 of file OptimizationTools.cpp.
References bpp::GlobalClockTreeLikelihoodFunctionWrapper::getHeightParameters(), OPTIMIZATION_BFGS, OPTIMIZATION_GRADIENT, and OPTIMIZATION_NEWTON.
Referenced by bpp::PhylogeneticsApplicationTools::optimizeParameters(), optimizeTreeNNI2(), and bpp::NNITopologyListener2::topologyChangeSuccessful().
|
static |
Optimize numerical parameters assuming a global clock (branch heights, substitution model & rate distribution) of a ClockTreeLikelihood function.
Uses Newton or conjugate gradient method for branch length and Brent's one dimensional method for other parameters (NewtonBrentMetaOptimizer). Derivatives are computed analytically.
A condition over function values is used as a stop condition for the algorithm.
cl | A pointer toward the ClockTreeLikelihood object to optimize. |
parameters | The list of parameters to optimize. Use cl->getIndependentParameters() in order to estimate all parameters. |
listener | A pointer toward an optimization listener, if needed. |
nstep | The number of progressive steps to perform (see NewtonBrentMetaOptimizer). 1 means full precision from start. |
tolerance | The tolerance to use in the algorithm. |
tlEvalMax | The maximum number of function evaluations. |
messageHandler | The massage handler. |
profiler | The profiler. |
verbose | The verbose level. |
optMethodDeriv | Optimization type for derivable parameters (first or second order derivatives). |
Exception | any exception thrown by the Optimizer. |
Definition at line 406 of file OptimizationTools.cpp.
References OPTIMIZATION_GRADIENT, and OPTIMIZATION_NEWTON.
Referenced by bpp::PhylogeneticsApplicationTools::optimizeParameters().
|
static |
Optimize numerical parameters assuming a global clock (branch heights, substitution model & rate distribution) of a ClockTreeLikelihood function.
Uses Newton or conjugate gradient method for all parameters, branch length derivatives are computed analytically, derivatives for other parameters numerically.
cl | A pointer toward the ClockTreeLikelihood object to optimize. |
parameters | The list of parameters to optimize. Use cl->getIndependentParameters() in order to estimate all parameters. |
listener | A pointer toward an optimization listener, if needed. |
tolerance | The tolerance to use in the algorithm. |
tlEvalMax | The maximum number of function evaluations. |
messageHandler | The massage handler. |
profiler | The profiler. |
verbose | The verbose level. |
optMethodDeriv | Optimization type for derivable parameters (first or second order derivatives). |
Exception | any exception thrown by the Optimizer. |
Definition at line 476 of file OptimizationTools.cpp.
References OPTIMIZATION_GRADIENT, and OPTIMIZATION_NEWTON.
Referenced by bpp::PhylogeneticsApplicationTools::optimizeParameters().
|
static |
Optimize all parameters from a TreeLikelihood object, including tree topology using Nearest Neighbor Interchanges.
This function takes as input a TreeLikelihood object implementing the NNISearchable interface.
Details: A NNITopologySearch object is instanciated and is associated an additional TopologyListener. This listener is used to re-estimate numerical parameters after one or several topology change. By default, the PHYML option is used for the NNITopologySearch object, and numerical parameters are re-estimated every 4 NNI runs (as in the phyml software).
The optimizeNumericalParameters method is used for estimating numerical parameters. The tolerance passed to this function is specified as input parameters. They are generally very high to avoid local optima.
tl | A pointer toward the TreeLikelihood object to optimize. |
parameters | The list of parameters to optimize. Use tl->getIndependentParameters() in order to estimate all parameters. |
optimizeNumFirst | Tell if we must optimize numerical parameters before searching topology. |
tolBefore | The tolerance to use when estimating numerical parameters before topology search (if optimizeNumFirst is set to 'true'). |
tolDuring | The tolerance to use when estimating numerical parameters during the topology search. |
tlEvalMax | The maximum number of function evaluations. |
numStep | Number of NNI rounds before re-estimating numerical parameters. |
messageHandler | The massage handler. |
profiler | The profiler. |
reparametrization | Tell if parameters should be transformed in order to remove constraints. This can improve optimization, but is a bit slower. |
verbose | The verbose level. |
optMethod | Option passed to optimizeNumericalParameters. |
nStep | Option passed to optimizeNumericalParameters. |
nniMethod | NNI algorithm to use. |
Exception | any exception thrown by the optimizer. |
Definition at line 564 of file OptimizationTools.cpp.
References bpp::NNITopologySearch::addTopologyListener(), bpp::NNITopologySearch::getSearchableObject(), optimizeNumericalParameters(), bpp::NNITopologySearch::search(), and bpp::NNITopologyListener::setNumericalOptimizationCounter().
Referenced by bpp::TreeTools::MRP(), bpp::TreeTools::MRPMultilabel(), and bpp::PhylogeneticsApplicationTools::optimizeParameters().
|
static |
Optimize tree topology from a DRTreeParsimonyScore using Nearest Neighbor Interchanges.
tp | A pointer toward the DRTreeParsimonyScore object to optimize. |
verbose | The verbose level. |
Definition at line 629 of file OptimizationTools.cpp.
References bpp::NNITopologySearch::getSearchableObject(), bpp::NNITopologySearch::PHYML, and bpp::NNITopologySearch::search().
|
static |
Optimize all parameters from a TreeLikelihood object, including tree topology using Nearest Neighbor Interchanges.
This function takes as input a TreeLikelihood object implementing the NNISearchable interface.
Details: A NNITopologySearch object is instanciated and is associated an additional TopologyListener. This listener is used to re-estimate numerical parameters after one or several topology change. By default, the PHYML option is used for the NNITopologySearch object, and numerical parameters are re-estimated every 4 NNI runs (as in the phyml software).
The optimizeNumericalParameters2 method is used for estimating numerical parameters. The tolerance passed to this function is specified as input parameters. They are generally very high to avoid local optima.
tl | A pointer toward the TreeLikelihood object to optimize. |
parameters | The list of parameters to optimize. Use tl->getIndependentParameters() in order to estimate all parameters. |
optimizeNumFirst | Tell if we must optimize numerical parameters before searching topology. |
tolBefore | The tolerance to use when estimating numerical parameters before topology search (if optimizeNumFirst is set to 'true'). |
tolDuring | The tolerance to use when estimating numerical parameters during the topology search. |
tlEvalMax | The maximum number of function evaluations. |
numStep | Number of NNI rounds before re-estimating numerical parameters. |
messageHandler | The massage handler. |
profiler | The profiler. |
reparametrization | Tell if parameters should be transformed in order to remove constraints. This can improve optimization, but is a bit slower. |
verbose | The verbose level. |
optMethod | Option passed to optimizeNumericalParameters2. |
nniMethod | NNI algorithm to use. |
Exception | any exception thrown by the optimizer. |
Definition at line 597 of file OptimizationTools.cpp.
References bpp::NNITopologySearch::addTopologyListener(), bpp::NNITopologySearch::getSearchableObject(), optimizeNumericalParameters2(), bpp::NNITopologySearch::search(), and bpp::NNITopologyListener2::setNumericalOptimizationCounter().
Referenced by bpp::PhylogeneticsApplicationTools::optimizeParameters().
|
static |
Optimize the scale of a TreeLikelihood.
This method only works on branch lengths parameters. It multiply all branch length by a factor 'x' which is optimized using Brent's algorithm in one dimension. This method may be usefull for scaling a tree whose branch lengths come from the Neighbor-Joining algorithm for instance.
Practically, and contrarily to what one may expect, this does not speed up the optimization!
A condition over parameters is used as a stop condition for the algorithm.
tl | A pointer toward the TreeLikelihood object to optimize. |
tolerance | The tolerance to use in the algorithm. |
tlEvalMax | The maximum number of function evaluations. |
messageHandler | The massage handler. |
profiler | The profiler. |
verbose | The verbose level. |
Exception | any exception thrown by the optimizer. |
Definition at line 121 of file OptimizationTools.cpp.
References bpp::OptimizationTools::ScaleFunction::getParameters().
Referenced by bpp::PhylogeneticsApplicationTools::optimizeParameters().
|
static |
Definition at line 763 of file OptimizationTools.h.
Referenced by estimateDistanceMatrix().
|
static |
Definition at line 765 of file OptimizationTools.h.
Referenced by buildDistanceTree().
|
static |
Definition at line 764 of file OptimizationTools.h.
Referenced by buildDistanceTree(), and estimateDistanceMatrix().
|
static |
Definition at line 310 of file OptimizationTools.h.
Referenced by optimizeBranchLengthsParameters(), optimizeNumericalParameters(), optimizeNumericalParameters2(), and bpp::PhylogeneticsApplicationTools::optimizeParameters().
|
static |
Definition at line 309 of file OptimizationTools.h.
Referenced by optimizeNumericalParameters(), and bpp::PhylogeneticsApplicationTools::optimizeParameters().
|
static |
Definition at line 307 of file OptimizationTools.h.
Referenced by optimizeBranchLengthsParameters(), optimizeNumericalParameters(), optimizeNumericalParameters2(), optimizeNumericalParametersWithGlobalClock(), optimizeNumericalParametersWithGlobalClock2(), and bpp::PhylogeneticsApplicationTools::optimizeParameters().
|
static |
Definition at line 308 of file OptimizationTools.h.
Referenced by optimizeBranchLengthsParameters(), optimizeNumericalParameters(), optimizeNumericalParameters2(), optimizeNumericalParametersWithGlobalClock(), optimizeNumericalParametersWithGlobalClock2(), and bpp::PhylogeneticsApplicationTools::optimizeParameters().