bpp-core3  3.0.0
GoldenSectionSearch.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_GOLDENSECTIONSEARCH_H
6 #define BPP_NUMERIC_FUNCTION_GOLDENSECTIONSEARCH_H
7 
8 
9 #include "AbstractOptimizer.h"
10 
11 namespace bpp
12 {
25  public AbstractOptimizer
26 {
27 public:
30  {
31 public:
34  virtual ~GSSStopCondition() {}
35 
36  GSSStopCondition* clone() const { return new GSSStopCondition(*this); }
37 
38 public:
39  bool isToleranceReached() const;
40  double getCurrentTolerance() const;
41  };
42 
43  friend class GSSStopCondition;
44 
45 private:
46  double f1, f2, x0, x1, x2, x3;
47  double xinf_, xsup_;
49 
50 public:
51  GoldenSectionSearch(std::shared_ptr<FunctionInterface> function);
52  virtual ~GoldenSectionSearch() {}
53 
54  GoldenSectionSearch* clone() const override { return new GoldenSectionSearch(*this); }
55 
56 public:
74  double getFunctionValue() const override;
77  void doInit(const ParameterList& params) override;
78 
79  double doStep() override;
80 
93  void setInitialInterval(double inf, double sup);
100 
101 protected:
102 };
103 } // end of namespace bpp.
104 #endif // BPP_NUMERIC_FUNCTION_GOLDENSECTIONSEARCH_H
void doInit(const ParameterList &params) override
This function is called by the init() method and contains all calculations.
bool isToleranceReached() const
Tell if the we reached the desired tolerance with a given new set of estimates.
double doStep() override
This function is called by the step() method and contains all calculations.
double getCurrentTolerance() const
Get the current tolerance.
The parameter list object.
Definition: ParameterList.h:27
GoldenSectionSearch(std::shared_ptr< FunctionInterface > function)
Golden Section Search optimization algorithm for one parameter.
double getFunctionValue() const override
Initialize optimizer.
GSSStopCondition * clone() const
Create a copy of this object and send a pointer to it.
Partial implementation of the Optimizer interface.
Partial implementation of the OptimizationStopCondition interface.
void setInitialInterval(double inf, double sup)
Set intial search interval.
GoldenSectionSearch * clone() const override
Create a copy of this object and send a pointer to it.