| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #pragma once | ||
| 2 | |||
| 3 | #include <cmath> | ||
| 4 | #include <functional> | ||
| 5 | #include <string> | ||
| 6 | #include <tuple> | ||
| 7 | |||
| 8 | #include "task/include/task.hpp" | ||
| 9 | |||
| 10 | namespace klimenko_v_multistep_2d_parallel_sad { | ||
| 11 | |||
| 12 |
3/5✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 30 times.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
|
90 | struct OptimizationInput { |
| 13 | std::function<double(double, double)> func; | ||
| 14 | |||
| 15 | double x_min{0.0}; | ||
| 16 | double x_max{1.0}; | ||
| 17 | double y_min{0.0}; | ||
| 18 | double y_max{1.0}; | ||
| 19 | |||
| 20 | double epsilon{0.01}; | ||
| 21 | double r_param{2.0}; | ||
| 22 | int max_iterations{1000}; | ||
| 23 | |||
| 24 |
1/2✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
|
60 | OptimizationInput() : func(nullptr) {} |
| 25 | }; | ||
| 26 | |||
| 27 | struct OptimizationResult { | ||
| 28 | double x_opt{0.0}; | ||
| 29 | double y_opt{0.0}; | ||
| 30 | double func_min{0.0}; | ||
| 31 | |||
| 32 | int iterations{0}; | ||
| 33 | bool converged{false}; | ||
| 34 | |||
| 35 | bool operator==(const OptimizationResult &other) const { | ||
| 36 | const double tol = 1e-3; | ||
| 37 | return std::abs(x_opt - other.x_opt) < tol && std::abs(y_opt - other.y_opt) < tol && | ||
| 38 | std::abs(func_min - other.func_min) < tol; | ||
| 39 | } | ||
| 40 | }; | ||
| 41 | |||
| 42 | struct Region { | ||
| 43 | double x_min, x_max; | ||
| 44 | double y_min, y_max; | ||
| 45 | |||
| 46 | double f_center; | ||
| 47 | double characteristic; | ||
| 48 | }; | ||
| 49 | |||
| 50 | using InType = OptimizationInput; | ||
| 51 | using OutType = OptimizationResult; | ||
| 52 | using TestType = std::tuple<int, std::string>; | ||
| 53 | using BaseTask = ppc::task::Task<InType, OutType>; | ||
| 54 | |||
| 55 | } // namespace klimenko_v_multistep_2d_parallel_sad | ||
| 56 |