-
Notifications
You must be signed in to change notification settings - Fork 0
/
Evaluator.h
183 lines (103 loc) · 4.56 KB
/
Evaluator.h
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
#ifndef ___EVALUATOR___
#define ___EVALUATOR___
#include "MainKnapsack.h"
#include <map>
#include "Tools.h"
extern int UB_Size;
using namespace std;
class Evaluator{
private:
string filename_instance;
string indicator_file;
list< vector< float > > PFront; //covered pareto front
string PF_filename;
vector< float > OPT_Alternative;
vector<vector<float > > PF_Efficient;
vector<float > WS_DM_vector;
vector< vector< float > > WS_matrix;
float p_criteria;
float n_objective;
float Backpack_capacity;
int K_replication;
int cpt_k = 0;
float time;
vector< float > PF_indicators, Point_indicators;
map<int, map < int, vector< float > > > eval_values; // {size : { INFO : vector of SUM indicators } }
public:
vector< tuple<float, vector< float> > > Items_information;
//CONSTRUCTOR
Evaluator(string filename, string WS_DM_preferences, string INDIC_file="");
Evaluator(string filename, string WS_DM_preferences, string INDIC_file, vector<int> sizes, vector<int> information_rate, int K);
~Evaluator(){
for(list< vector< float > >::iterator i = PFront.begin(); i != PFront.end(); ++i){
(*i).clear();
(*i).shrink_to_fit();
}
PFront.resize(0);
for(int i = 0; i < (int) PF_Efficient.size(); i++)
PF_Efficient.shrink_to_fit();
PF_Efficient.shrink_to_fit();
OPT_Alternative.shrink_to_fit();
for(vector< tuple<float, vector< float> > >::iterator i = Items_information.begin(); i != Items_information.end(); ++i){
get<1>(*i).shrink_to_fit();
}
Items_information.shrink_to_fit();
for(int i = 0; i < (int) WS_matrix.size(); i++){
WS_matrix[i].clear();
WS_matrix[i].shrink_to_fit();
}
WS_matrix.clear();
WS_matrix.shrink_to_fit();
};
void set_WS_matrix(vector< vector< float > > new_ws){
n_objective = new_ws[0].size();
p_criteria = new_ws.size();
WS_matrix.resize(p_criteria);
for(int i = 0 ; i < p_criteria; i++)
WS_matrix[i] = new_ws[i];
};
//SETTERS
void set_K_replication(int k){ K_replication = k;};
//GETTERS
list< vector<float > > get_PFront(){ return PFront; };
int get_p_criteria(){ return p_criteria; };
int get_n_objective(){ return n_objective; };
float get_weight_of(int i) { return std::get<0>(Items_information[i]); };
float get_utility(int i, int j) { return std::get<1>(Items_information[i])[j]; };
float get_capacity(){ return Backpack_capacity; };
vector< vector< float > > get_WS_matrix(){ return WS_matrix; };
//READ FILES
void readParetoFront();
// void readParetoFront_locally();
void update_covered_PFront();
void readFilenameInstance(string filename);
void readWS_matrix(string filename);
//INTERN OPERATIONS
// bool in_search_space(vector<float> v,vector<float> minus, vector<float> maxus);
//EVALUATION
float nearest_alternative(vector< float > & vect_criteria, list< vector< float > > OPT_Solution);
vector< float > OPT_Alternative_PLNE(vector<float> WS_vector);
float evaluate_Dist_ratio(list< vector< float > > OPT_Solution);
void evaluate_PF(list< vector< float > > OPT_Solution, float time_cpu);
void evaluate_PF(list< vector< float > > OPT_Solution, int sizer, int info, float time_cpu);
vector< float > evaluate_standard_deviation_from_OPT_point();
void save_PF_evaluation();
void save_PF_evaluation_map();
void compute_information_rate_front();
float compute_information_rate();
//INDICATORS
float average_distance_D1(list< vector< float > > OPT_Solution);
float maximum_distance_D2(list< vector< float > > OPT_Solution);
float PR_D3(list< vector< float > > OPT_Solution);
void update_covered_OPT_Solution(list< vector< float > > & Opt_Solution);
void readPopulation_File(string file_population, list< vector< float > > & Population,vector< float > & time_exec, vector< int > & index );
void save_information(string file_population, string save_path, string format, vector< string > Informations,
vector< int > UB_Population, vector<int> Budget, int inst_name, int type_instance, string taille,int div);
void save_other_information(string file_population, string save_path, string format);
static void compute_avg_type_instances(string evaluation_save_path, string method_name, string format,
int k_replic, int nb_instances, vector< int > ub_values, vector< int > Info, vector< int > Budget );
void save_best_parameters(string filename_instance, string format_in, string format_out, vector< float > I, vector< int > sizer,
vector< int > budget, int inst_name);
void best_algo_parametrized(string save_data, string filename_algo, string format_in, string format_out, int inst_name,int budget);
};
#endif