40 #ifndef _OPTIMIZATIONTOOLS_H_ 41 #define _OPTIMIZATIONTOOLS_H_ 52 #include <Bpp/Io/OutputStream.h> 53 #include <Bpp/App/ApplicationTools.h> 54 #include <Bpp/Numeric/Function/SimpleNewtonMultiDimensions.h> 87 if (std::isnan(
optimizer_->getFunction()->getValue()))
89 cerr <<
"Oups... something abnormal happened!" << endl;
90 function_->getParameters().printParameters(cerr);
91 throw Exception(
"Optimization failed because likelihood function returned NaN.");
138 const ParameterList& parameters,
140 OutputStream* messenger,
141 OutputStream* profiler,
142 unsigned int verbose,
143 const std::string& optMethod,
145 bool reparametrization) :
235 const ParameterList& parameters,
237 OutputStream* messenger,
238 OutputStream* profiler,
239 unsigned int verbose,
240 const std::string& optMethod,
241 bool reparametrization) :
340 const ParameterList& parameters,
341 OptimizationListener* listener = 0,
342 unsigned int nstep = 1,
343 double tolerance = 0.000001,
344 unsigned int tlEvalMax = 1000000,
345 OutputStream* messageHandler = ApplicationTools::message,
346 OutputStream* profiler = ApplicationTools::message,
347 bool reparametrization =
false,
348 unsigned int verbose = 1,
377 const ParameterList& parameters,
378 OptimizationListener* listener = 0,
379 double tolerance = 0.000001,
380 unsigned int tlEvalMax = 1000000,
381 OutputStream* messageHandler = ApplicationTools::message,
382 OutputStream* profiler = ApplicationTools::message,
383 bool reparametrization =
false,
384 bool useClock =
false,
385 unsigned int verbose = 1,
412 const ParameterList& parameters,
413 OptimizationListener* listener = 0,
414 double tolerance = 0.000001,
415 unsigned int tlEvalMax = 1000000,
416 OutputStream* messageHandler = ApplicationTools::message,
417 OutputStream* profiler = ApplicationTools::message,
418 unsigned int verbose = 1,
449 const ParameterList& parameters,
450 OptimizationListener* listener = 0,
451 unsigned int nstep = 1,
452 double tolerance = 0.000001,
453 unsigned int tlEvalMax = 1000000,
454 OutputStream* messageHandler = ApplicationTools::message,
455 OutputStream* profiler = ApplicationTools::message,
456 unsigned int verbose = 1,
482 const ParameterList& parameters,
483 OptimizationListener* listener = 0,
484 double tolerance = 0.000001,
485 unsigned int tlEvalMax = 1000000,
486 OutputStream* messageHandler = ApplicationTools::message,
487 OutputStream* profiler = ApplicationTools::message,
488 unsigned int verbose = 1,
494 public virtual Function,
495 public ParametrizableAdapter
520 #ifndef NO_VIRTUAL_COV 528 void setParameters(
const ParameterList& lambda)
throw (ParameterNotFoundException, ConstraintException);
529 double getValue()
const throw (ParameterException);
531 const Parameter&
getParameter(
const std::string& name)
const throw (ParameterNotFoundException)
533 if (name ==
"lambda")
return lambda_[0];
534 else throw ParameterNotFoundException(
"ScaleFunction::getParameter.", name);
538 return lambda_.getParameter(name).getValue();
569 double tolerance = 0.000001,
570 unsigned int tlEvalMax = 1000000,
571 OutputStream* messageHandler = ApplicationTools::message,
572 OutputStream* profiler = ApplicationTools::message,
573 unsigned int verbose = 1)
617 const ParameterList& parameters,
618 bool optimizeNumFirst = true,
619 double tolBefore = 100,
620 double tolDuring = 100,
621 unsigned int tlEvalMax = 1000000,
622 unsigned int numStep = 1,
623 OutputStream* messageHandler = ApplicationTools::message,
624 OutputStream* profiler = ApplicationTools::message,
625 bool reparametrization = false,
626 unsigned int verbose = 1,
628 unsigned int nStep = 1,
672 const ParameterList& parameters,
673 bool optimizeNumFirst = true,
674 double tolBefore = 100,
675 double tolDuring = 100,
676 unsigned int tlEvalMax = 1000000,
677 unsigned int numStep = 1,
678 OutputStream* messageHandler = ApplicationTools::message,
679 OutputStream* profiler = ApplicationTools::message,
680 bool reparametrization = false,
681 unsigned int verbose = 1,
702 unsigned int verbose = 1);
722 const ParameterList& parametersToIgnore,
724 unsigned int verbose = 0) throw (Exception);
753 const ParameterList& parametersToIgnore,
754 bool optimizeBrLen = false,
756 double tolerance = 0.000001,
757 unsigned int tlEvalMax = 1000000,
758 OutputStream* profiler = 0,
759 OutputStream* messenger = 0,
760 unsigned int verbose = 0) throw (Exception);
769 #endif // _OPTIMIZATIONTOOLS_H_
unsigned int optimizeCounter_
void setNumericalOptimizationCounter(unsigned int c)
void topologyChangeTested(const TopologyChangeEvent &event)
Notify a topology change event.
NNITopologyListener * clone() const
Listener used internally by the optimizeTreeNNI2 method.
NNITopologyListener2(NNITopologySearch *ts, const ParameterList ¶meters, double tolerance, OutputStream *messenger, OutputStream *profiler, unsigned int verbose, const std::string &optMethod, bool reparametrization)
Build a new NNITopologyListener2 object.
unsigned int optimizeNumerical_
NNITopologyListener2(const NNITopologyListener2 &tl)
OutputStream * messenger_
NaNListener(const NaNListener &lr)
The TreeLikelihood interface.
A listener which capture NaN function values and throw an exception in case this happens.
Double recursive implementation of interface TreeParsimonyScore.
The phylogenetic tree class.
This class adds support for NNI topology estimation to the DRHomogeneousTreeLikelihood class...
void topologyChangeTested(const TopologyChangeEvent &event)
Notify a topology change event.
NaNListener & operator=(const NaNListener &lr)
void optimizationStepPerformed(const OptimizationEvent &event)
NNITopologyListener & operator=(const NNITopologyListener &tl)
Interface for agglomerative distance methods.
NNITopologyListener(const NNITopologyListener &tl)
OutputStream * messenger_
NNITopologyListener2 * clone() const
void optimizationInitializationPerformed(const OptimizationEvent &event)
Interface for rate across sites (RAS) implementation.
void setNumericalOptimizationCounter(unsigned int c)
Interface for likelihood computation with a global clock and rate across sites variation.
NNITopologyListener(NNITopologySearch *ts, const ParameterList ¶meters, double tolerance, OutputStream *messenger, OutputStream *profiler, unsigned int verbose, const std::string &optMethod, unsigned int nStep, bool reparametrization)
Build a new NNITopologyListener object.
Class for notifying new toplogy change events.
NNITopologySearch * topoSearch_
void topologyChangeSuccessful(const TopologyChangeEvent &event)
Tell that a topology change is definitive.
The phylogenetic node class.
NNITopologySearch * topoSearch_
bool listenerModifiesParameters() const
virtual ~NNITopologyListener()
NNITopologyListener2 & operator=(const NNITopologyListener2 &tl)
unsigned int optimizeNumerical_
void topologyChangeSuccessful(const TopologyChangeEvent &event)
Tell that a topology change is definitive.
Estimate a distance matrix from sequence data, according to a given model.
virtual ~NNITopologyListener2()
Implement this interface to be notified when the topology of a tree has changed during topology searc...
Listener used internally by the optimizeTreeNNI method.
ParameterList parameters_
ParameterList parameters_
unsigned int optimizeCounter_
NNI topology search method.
NaNListener(Optimizer *optimizer, Function *function)