-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmep_parameters.h
250 lines (182 loc) · 8.1 KB
/
mep_parameters.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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
// Multi Expression Programming library
// Author: Mihai Oltean, [email protected]
// https://mepx.org
// https://github.com/mepx
// License: MIT
//-----------------------------------------------------------------
#ifndef mep_parameters_H
#define mep_parameters_H
//-----------------------------------------------------------------
#include "utils/pugixml.hpp"
//-----------------------------------------------------------------
#define MEP_PROBLEM_REGRESSION 0
#define MEP_PROBLEM_BINARY_CLASSIFICATION 1
#define MEP_PROBLEM_MULTICLASS_CLASSIFICATION 2
#define MEP_PROBLEM_TIME_SERIE 3
//-----------------------------------------------------------------
#define MEP_REGRESSION_MEAN_ABSOLUTE_ERROR 0
#define MEP_REGRESSION_MEAN_SQUARED_ERROR 1
#define MEP_BINARY_CLASSIFICATION_AUTOMATIC_THRESHOLD 2
#define MEP_MULTICLASS_CLASSIFICATION_WINNER_TAKES_ALL_ERROR 3
#define MEP_MULTICLASS_CLASSIFICATION_SMOOTH_ERROR 4
#define MEP_MULTICLASS_CLASSIFICATION_WINNER_TAKES_ALL_DYNAMIC_ERROR 5
#define MEP_MULTICLASS_CLASSIFICATION_CLOSEST_CENTER_ERROR 6
//-----------------------------------------------------------------
#define MEP_TIME_SERIES_TEST 0
#define MEP_TIME_SERIES_PREDICTION 1
//-----------------------------------------------------------------
#define MEP_CROSSOVER_UNIFORM 0
#define MEP_CROSSOVER_ONE_CUTTING_POINT 1
//-----------------------------------------------------------------
class t_mep_parameters{
private:
char data_type;
double mutation_probability; // mutation probability
double crossover_probability; // crossover probability
unsigned int code_length; // the number of genes
unsigned int subpopulation_size; // the number of individuals in population (must be an odd number!!!)
unsigned int tournament_size;
unsigned int num_generations;
unsigned int problem_type; // 0- regression, 1-binary classification, 2- multi class, 3- time series
unsigned int num_subpopulations;
double operators_probability, variables_probability, constants_probability;
bool use_validation_data;
unsigned int crossover_type;
unsigned int random_subset_selection_size_percent;
unsigned int num_generations_for_which_random_subset_is_kept_fixed;
unsigned int random_seed;
unsigned int num_threads;
unsigned int num_runs;
bool simplified_programs;
bool modified;
unsigned int error_measure;
unsigned int num_predictions;
unsigned int time_series_mode;
unsigned int window_size;
unsigned int num_problem_outputs;
double precision;
public:
t_mep_parameters(void);
void init (void);
void to_xml_node(pugi::xml_node parent);
bool from_xml_node(pugi::xml_node parent);
bool operator ==(const t_mep_parameters&) const;
// returns the mutation probability
double get_mutation_probability(void) const;
// returns crossover probability
double get_crossover_probability(void) const;
// returns the length of a chromosome (the number of genes)
unsigned int get_code_length(void) const;
// returns the number of individuals in a (sub)population
unsigned int get_subpopulation_size(void) const;
// returns the number of threads of the program. On each thread a subpopulation is evolved
unsigned int get_num_threads(void) const;
// returns the tournament size
unsigned int get_tournament_size(void) const;
// returns the number of generations
unsigned int get_num_generations(void) const;
// returns the problem type
// 0 - symbolic regression,
// 1 - classification
unsigned int get_problem_type(void) const;
// returns the number of sub-populations
unsigned int get_num_subpopulations(void) const;
// returns the probability of operators occurence
double get_operators_probability(void) const;
// returns the probability of variables occurence
double get_variables_probability(void) const;
// returns the probability of constants occurence
double get_constants_probability(void) const;
// returns true if the validation data is used
bool get_use_validation_data(void) const;
// returns the crossover type
// 0 UNIFORM_CROSSOVER
// 1 ONE_CUTTING_POINT_CROSSOVER
unsigned int get_crossover_type(void) const;
// returns the seed for generating random numbers
unsigned int get_random_seed(void) const;
// returns the number of runs
unsigned int get_num_runs(void) const;
// returns true if the programs are returned in the simplified form (introns are removed)
bool get_simplified_programs(void) const;
// sets the mutation probability
void set_mutation_probability(double value);
// sets the crossover probability
void set_crossover_probability(double value);
// sets the number of genes in a chromosome
void set_code_length(unsigned int value);
// sets the number of individuals in population
void set_subpopulation_size(unsigned int value);
// sets the number of threads
void set_num_threads(unsigned int value);
// sets the tournament size
void set_tournament_size(unsigned int value);
// sets the number of generations
void set_num_generations(unsigned int value);
// sets the problem type
// 0- regression,
// 1- binary classification
// 2- multi class classification
// 3- time series
void set_problem_type(unsigned int value);
// sets the number of subpopulations
void set_num_subpopulations(unsigned int value);
// sets the operators probability
void set_operators_probability(double value);
// sets the variables probability
void set_variables_probability(double value);
// sets the constants probability
void set_constants_probability(double value);
// sets the utilization of validation data
void set_use_validation_data(bool value);
// sets the crossover type
void set_crossover_type(unsigned int value);
// sets the random seed
void set_random_seed(unsigned int value);
// sets the number of runs
void set_num_runs(unsigned int value);
// sets the simplified programs parameters
void set_simplified_programs(bool value);
// set the size of the random subset on which the training is performed.
// this must be called after calling set_training_data from the t_mep class because set_training_data sets this value to the size of the training data
void set_random_subset_selection_size_percent(unsigned int value);
// returns the size of the random subset on which the training is performed
unsigned int get_random_subset_selection_size_percent(void) const;
// sets the error measure type
// for regression and time series it can be: MEP_REGRESSION_MEAN_ABSOLUTE_ERROR 0 or MEP_REGRESSION_MEAN_SQUARED_ERROR 1
// for classification it can be: MEP_CLASSIFICATION_MEAN_ERROR 2
void set_error_measure(unsigned int value);
// returns the error measure type
// for regression and time series it can be: MEP_REGRESSION_MEAN_ABSOLUTE_ERROR 0 or MEP_REGRESSION_MEAN_SQUARED_ERROR 1
// for classification it can be: MEP_CLASSIFICATION_MEAN_ERROR 2
unsigned int get_error_measure(void) const;
// get the number of generations for which the random subset of data is kept fixed
unsigned int get_num_generations_for_which_random_subset_is_kept_fixed(void) const;
// set the number of generations for which the random subset of data is kept fixed
void set_num_generations_for_which_random_subset_is_kept_fixed(unsigned int);
// get the number of predictions for time series
unsigned int get_num_predictions(void) const;
// set the number of predictions for time series
void set_num_predictions(unsigned int);
// get time series mode
unsigned int get_time_series_mode(void) const;
// set time series mode
void set_time_series_mode(unsigned int new_value);
// time series window size
unsigned int get_window_size(void) const;
// time series window size
void set_window_size(unsigned int window_size);
// data type
void set_data_type(char _new_data_type);
char get_data_type(void) const;
// returns the number of outputs of the program
unsigned int get_num_outputs(void) const;
// sets the number of outputs of the program
void set_num_outputs(unsigned int new_num);
// precision to compare values
double get_precision(void) const;
// precision to compare values
void set_precision(double new_precision);
};
//-----------------------------------------------------------------
#endif // PARAMETERS_CLASS_H_INCLUDED