bpp-core3  3.0.0
OneDimensionOptimizationTools.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_ONEDIMENSIONOPTIMIZATIONTOOLS_H
6 #define BPP_NUMERIC_FUNCTION_ONEDIMENSIONOPTIMIZATIONTOOLS_H
7 
8 
9 #include "../../Io/OutputStream.h"
10 #include "DirectionFunction.h"
11 #include "Functions.h"
12 
13 namespace bpp
14 {
16 {
17 public:
18  double x;
19  double f;
20 
21 public:
22  // Constructor and destructor:
23  BracketPoint() : x(0),
24  f(0) {}
25  BracketPoint(double xval, double fval) : x(xval),
26  f(fval) {}
27  virtual ~BracketPoint() {}
28 
29 public:
30  void set(double x, double f);
31 };
32 
33 class Bracket
34 {
35 public:
36  // Constructor and destructor::
37  Bracket() : a(),
38  b(),
39  c() {}
40  virtual ~Bracket() {}
41 
42 public:
43  // Methods:
44  void setA(double xa, double fa);
45  void setB(double xb, double fb);
46  void setC(double xc, double fc);
47 
48 public:
49  BracketPoint a, b, c;
50 };
51 
58 {
59 public:
62 
63 public:
78  static Bracket bracketMinimum(double a, double b, FunctionInterface& function, ParameterList parameters);
79 
92  static Bracket inwardBracketMinimum(double a, double b, FunctionInterface& function, ParameterList parameters, unsigned int intervalsNum = 10);
93 
94 
95  static unsigned int lineMinimization(
96  std::shared_ptr<DirectionFunction> f1dim,
97  ParameterList& parameters,
98  std::vector<double>& xi,
99  double tolerance,
100  std::shared_ptr<OutputStream> profiler = nullptr,
101  std::shared_ptr<OutputStream> messenger = nullptr,
102  unsigned int verbose = 2);
103 
116  static unsigned int lineSearch(
117  std::shared_ptr<DirectionFunction> f1dim,
118  ParameterList& parameters,
119  std::vector<double>& xi,
120  std::vector<double>& gradient,
121  std::shared_ptr<OutputStream> profiler = nullptr,
122  std::shared_ptr<OutputStream> messenger = nullptr,
123  unsigned int verbose = 2);
124 
125 public:
129  static double GLIMIT;
130 };
131 } // end of namespace bpp.
132 #endif // BPP_NUMERIC_FUNCTION_ONEDIMENSIONOPTIMIZATIONTOOLS_H
This is the function abstract class.
Definition: Functions.h:52
The parameter list object.
Definition: ParameterList.h:27
BracketPoint(double xval, double fval)
Tools of one parameter-functions optimizations.
static double GLIMIT
Maximum magnification allowed for a parabolic-fit step.