File tree Expand file tree Collapse file tree 3 files changed +12
-10
lines changed Expand file tree Collapse file tree 3 files changed +12
-10
lines changed Original file line number Diff line number Diff line change @@ -71,13 +71,8 @@ void run_diff_evolution(struct subset * const ss) {
71
71
minimized_initial = s .population_size ;
72
72
}
73
73
74
-
75
74
//find the best kappa_data
76
- //TODO extract to separate method, also used in kappa.c:find_the_best_parameters
77
- ss -> best = & ss -> data [0 ];
78
- for (i = 0 ; i < ss -> kappa_data_count - 1 ; i ++ )
79
- if (kd_sort_by_is_better (& ss -> data [i ], ss -> best ))
80
- ss -> best = & ss -> data [i ];
75
+ set_the_best (ss );
81
76
82
77
/* Run the optimization for max iterations */
83
78
//TODO include iters_max for DE in limits or use one already there (that is used for discard)
Original file line number Diff line number Diff line change @@ -232,10 +232,7 @@ void find_the_best_parameters_for_subset(struct subset * const ss) {
232
232
/* Determine the best parameters for computed data */
233
233
234
234
if (s .params_method == PARAMS_LR_FULL ) {
235
- ss -> best = & ss -> data [0 ];
236
- for (int i = 0 ; i < ss -> kappa_data_count - 1 ; i ++ )
237
- if (kd_sort_by_is_better (& ss -> data [i ], ss -> best ))
238
- ss -> best = & ss -> data [i ];
235
+ set_the_best (ss );
239
236
}
240
237
else if (s .params_method == PARAMS_LR_FULL_BRENT ){
241
238
/* If Brent is used, the maximum is stored in the last item */
@@ -247,3 +244,12 @@ void find_the_best_parameters_for_subset(struct subset * const ss) {
247
244
248
245
}
249
246
}
247
+
248
+ /* Set the best parameters from subset */
249
+ void set_the_best (struct subset * const ss ) {
250
+ ss -> best = & ss -> data [0 ];
251
+ for (int i = 0 ; i < ss -> kappa_data_count - 1 ; i ++ )
252
+ if (kd_sort_by_is_better (& ss -> data [i ], ss -> best ))
253
+ ss -> best = & ss -> data [i ];
254
+
255
+ }
Original file line number Diff line number Diff line change 12
12
#include "subset.h"
13
13
14
14
void find_the_best_parameters_for_subset (struct subset * const ss );
15
+ void set_the_best (struct subset * const ss );
15
16
16
17
#endif /* __KAPPA_H__ */
You can’t perform that action at this time.
0 commit comments