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

Class upper_bound_function

dlib/global_optimization/upper_bound_function.h:28–278  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 3

addMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected