-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFunction.h
More file actions
61 lines (45 loc) · 1.61 KB
/
Copy pathFunction.h
File metadata and controls
61 lines (45 loc) · 1.61 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#ifndef BEESALGO_FUNCTION_H
#define BEESALGO_FUNCTION_H
#include <utility>
#include <vector>
#include <functional>
class Function {
public:
Function() = default;
Function(double (*objective_func)(std::vector<double>), int variables_amount,
const std::vector<double>& min_X, const std::vector<double>& max_X, double global_min):
objective_func_(objective_func), max_X_(max_X), min_X_(min_X), variables_amount_(variables_amount),
global_min_(global_min), objective_func_2d_(nullptr){ }
Function(double (*objective_func_2d)(double, double), const std::vector<double>& min_X,
const std::vector<double>& max_X, double global_min):
objective_func_2d_(objective_func_2d), max_X_(max_X), min_X_(min_X), global_min_(global_min){
variables_amount_ = 2;
objective_func_ = [this](std::vector<double> X) {return objective_func_2d_(X[0], X[1]);};
}
std::vector<double> get_max_X(){
return max_X_;
}
std::vector<double> get_min_X(){
return min_X_;
}
int get_variables_amount(){
return variables_amount_;
}
auto get_objective_func_(){
return objective_func_;
}
auto get_objective_func_2d_(){
return objective_func_2d_;
}
double get_global_min(){
return global_min_;
}
private:
std::function<double(std::vector<double>)> objective_func_;
std::function<double(double, double)> objective_func_2d_;
std::vector<double> min_X_;
std::vector<double> max_X_;
int variables_amount_;
double global_min_;
};
#endif //BEESALGO_FUNCTION_H