| 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 | } |
no outgoing calls
no test coverage detected