bpp-core3  3.0.0
BrentOneDimension.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: The Bio++ Development Group
2 //
3 // SPDX-License-Identifier: CECILL-2.1
4 
5 #ifndef BPP_NUMERIC_FUNCTION_BRENTONEDIMENSION_H
6 #define BPP_NUMERIC_FUNCTION_BRENTONEDIMENSION_H
7 
8 
9 #include "AbstractOptimizer.h"
10 
11 namespace bpp
12 {
24  public AbstractOptimizer
25 {
26 public:
29  {
30 public:
33  {
34  tolerance_ = bod->tol2;
35  burnin_ = 3;
36  }
37  virtual ~BODStopCondition() {}
38 
39  BODStopCondition* clone() const { return new BODStopCondition(*this); }
40 
41 public:
42  bool isToleranceReached() const;
43  double getCurrentTolerance() const;
44  };
45 
47  {
50  };
51 
52  friend class BODStopCondition;
53 
54 protected:
55  double a, b, d, e, etemp, fu, fv, fw, fx, p, q, r, tol1, tol2, u, v, w, x, xm;
56  double _xinf, _xsup;
59 
60 public:
61  BrentOneDimension(std::shared_ptr<FunctionInterface> function = nullptr);
62  virtual ~BrentOneDimension() {}
63 
64  BrentOneDimension* clone() const { return new BrentOneDimension(*this); }
65 
66 public:
84  double optimize(); // redefinition
87  void doInit(const ParameterList& params);
88 
89  double doStep();
90 
91 public:
104  void setInitialInterval(double inf, double sup);
111 
116 
120  void setBracketing(BrentOneDimension::Bracketing bracketing) { bracketing_ = bracketing; }
121 
122 public:
123  static double ZEPS;
124 };
125 } // end of namespace bpp.
126 #endif // BPP_NUMERIC_FUNCTION_BRENTONEDIMENSION_H
void setBracketing(BrentOneDimension::Bracketing bracketing)
Set the brackeitng method.
The parameter list object.
Definition: ParameterList.h:27
BrentOneDimension(std::shared_ptr< FunctionInterface > function=nullptr)
BODStopCondition * clone() const
Create a copy of this object and send a pointer to it.
bool isToleranceReached() const
Tell if the we reached the desired tolerance with a given new set of estimates.
bool isInitialIntervalSet() const
double getCurrentTolerance() const
Get the current tolerance.
double optimize()
Initialize optimizer.
Brent&#39;s optimization for one parameter.
Partial implementation of the Optimizer interface.
void doInit(const ParameterList &params)
This function is called by the init() method and contains all calculations.
BrentOneDimension::Bracketing getBracketing() const
Get the brackeitng method.
double doStep()
This function is called by the step() method and contains all calculations.
void setInitialInterval(double inf, double sup)
Set intial search interval.
Partial implementation of the OptimizationStopCondition interface.
BrentOneDimension * clone() const
Create a copy of this object and send a pointer to it.