MCPcopy Create free account
hub / github.com/davisking/dlib / upper_bound_function

Class upper_bound_function

dlib/global_optimization/upper_bound_function.h:33–285  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

31 }
32
33 class upper_bound_function
34 {
35
36 public:
37
38 upper_bound_function(
39 ) = default;
40
41 upper_bound_function(
42 const double relative_noise_magnitude,
43 const double solver_eps
44 ) : relative_noise_magnitude(relative_noise_magnitude), solver_eps(solver_eps)
45 {
46 DLIB_CASSERT(relative_noise_magnitude >= 0);
47 DLIB_CASSERT(solver_eps > 0);
48 }
49
50 explicit upper_bound_function(
51 const std::vector<function_evaluation>& _points,
52 const double relative_noise_magnitude = 0.001,
53 const double solver_eps = 0.0001
54 ) : relative_noise_magnitude(relative_noise_magnitude), solver_eps(solver_eps), points(_points)
55 {
56 DLIB_CASSERT(relative_noise_magnitude >= 0);
57 DLIB_CASSERT(solver_eps > 0);
58
59 if (points.size() > 1)
60 {
61 DLIB_CASSERT(points[0].x.size() > 0, "The vectors can't be empty.");
62
63 const long dims = points[0].x.size();
64 for (auto& p : points)
65 DLIB_CASSERT(p.x.size() == dims, "All the vectors given to upper_bound_function must have the same dimensionality.");
66
67 learn_params();
68 }
69
70 }
71
72 void add (
73 const function_evaluation& point
74 )
75 {
76 DLIB_CASSERT(point.x.size() != 0, "The vectors can't be empty.");
77 if (points.size() == 0)
78 {
79 points.push_back(point);
80 return;
81 }
82
83 DLIB_CASSERT(point.x.size() == dimensionality(), "All the vectors given to upper_bound_function must have the same dimensionality.");
84
85 if (points.size() < 4)
86 {
87 points.push_back(point);
88 *this = upper_bound_function(points, relative_noise_magnitude, solver_eps);
89 return;
90 }

Callers 3

addMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected