-
Notifications
You must be signed in to change notification settings - Fork 79
Expand file tree
/
Copy pathops_seq.cpp
More file actions
47 lines (39 loc) · 1.1 KB
/
ops_seq.cpp
File metadata and controls
47 lines (39 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include "../include/ops_seq.hpp"
#include <limits>
#include <vector>
namespace bruskova_v_global_optimization {
BruskovaVGlobalOptimizationSEQ::BruskovaVGlobalOptimizationSEQ(const InType &in) : BaseTask() {
this->GetInput() = in;
}
bool BruskovaVGlobalOptimizationSEQ::ValidationImpl() {
const auto &in = this->GetInput();
return in.size() == 5 && in[4] > 0;
}
bool BruskovaVGlobalOptimizationSEQ::PreProcessingImpl() {
const auto &in = this->GetInput();
x_min_ = in[0];
x_max_ = in[1];
y_min_ = in[2];
y_max_ = in[3];
step_ = in[4];
result_ = {std::numeric_limits<double>::max(), 0.0, 0.0};
return true;
}
bool BruskovaVGlobalOptimizationSEQ::RunImpl() {
for (double x = x_min_; x <= x_max_; x += step_) {
for (double y = y_min_; y <= y_max_; y += step_) {
double val = x * x + y * y;
if (val < result_[0]) {
result_[0] = val;
result_[1] = x;
result_[2] = y;
}
}
}
return true;
}
bool BruskovaVGlobalOptimizationSEQ::PostProcessingImpl() {
this->GetOutput() = result_;
return true;
}
} // namespace bruskova_v_global_optimization