22 dup_tree->
insert(field, result);
32 for (
int i=0; i<probe_combi_array_length; i++)
33 probe_combi_stat_array[i]->
print();
37 for (
int i=0; i<probe_combi_array_length; i++) {
38 if (probe_combi_stat_array[i]) {
49 arb_progress progress(static_cast<long>(probe_combi_array_length));
52 for (
int i=0; i<probe_combi_array_length; i++) {
57 min_fit = max_fit = dummy;
61 else if (dummy > max_fit)
64 if (
MP_aborted(generation_counter, old_avg_fit, min_fit, max_fit, progress)) {
65 probe_combi_array_length = i-1;
71 if (use_genetic_algo) {
72 average_fitness = fitness / (double)probe_combi_array_length;
77 #ifdef USE_LINEARSCALING
81 #ifdef USE_SIGMATRUNCATION
82 for (i=0; i<probe_combi_array_length; i++) {
83 dev = probe_combi_stat_array[i]->
get_fitness() - average_fitness;
87 deviation = (1.0 / (double)((
double)i - 1.0)) * deviation;
88 deviation = sqrt(deviation);
90 for (i=0; i<probe_combi_array_length; i++)
91 probe_combi_stat_array[i]->sigma_truncation(average_fitness, deviation);
99 for (
int i=0; i<probe_combi_array_length; i++) {
100 #ifdef USE_LINEARSCALING
101 probe_combi_stat_array[i]->
scale(a, b);
111 void Generation::prescale(
double *a,
double *b) {
114 if ((min_fit >
C_MULT * average_fitness - max_fit) / (
C_MULT - 1.0)) {
115 delta = max_fit - average_fitness;
116 *a = (
C_MULT - 1.0) * average_fitness / delta;
117 *b = average_fitness * (max_fit -
C_MULT * average_fitness) / delta;
120 delta = average_fitness - min_fit;
121 *a = average_fitness / delta;
122 *b = -min_fit * average_fitness / delta;
129 len_roulette_wheel = 0;
130 while (i<probe_combi_array_length)
131 len_roulette_wheel += (
int)(
MULTROULETTEFACTOR * (probe_combi_stat_array[i++]->get_expected_children()));
135 int random_help =
get_random(0, len_roulette_wheel-1),
138 for (i=0; i<probe_combi_array_length; i++) {
141 if (random_help <= 0) {
142 if (probe_combi_stat_array[i]->ok_for_next_gen(len_roulette_wheel)) {
143 return probe_combi_stat_array[i];
146 random_help =
get_random(0, len_roulette_wheel-1);
158 *second_child_pcs =
NULp,
166 while (len_roulette_wheel > 1) {
168 orig1 = choose_combi_for_next_generation();
169 orig2 = choose_combi_for_next_generation();
171 if (! orig1 && ! orig2)
break;
172 else if (!orig1 && orig2) {
177 delete first_child_pcs;
178 delete second_child_pcs;
179 first_child_pcs = second_child_pcs =
NULp;
188 second_child_pcs->init_life_counter();
189 len_roulette_wheel -= orig1->sub_expected_children(0.5);
190 len_roulette_wheel -= orig2->sub_expected_children(0.5);
194 len_roulette_wheel -= orig1->sub_expected_children(1.0);
197 second_child_pcs->sub_life_counter();
198 len_roulette_wheel -= orig2->sub_expected_children(1.0);
204 second_child_pcs->mutate_Probe();
210 if (!child_generation->
insert(first_child_pcs))
216 if (orig2 && !child_generation->
insert(second_child_pcs))
break;
220 if (!child_generation->
insert(first_child_pcs))
224 if (!child_generation->
insert(second_child_pcs))
230 delete first_child_pcs;
231 delete second_child_pcs;
233 if (len_roulette_wheel <= 1)
236 return child_generation;
244 probe_combi_stat_array[pos_counter++] = p;
264 delete bastel_probe_combi;
272 probe_combi_stat_array[last_elem++] = pcs->
duplicate();
273 probe_combi_array_length = last_elem;
289 probe_combi_array_length = pos;
297 while (counter < probe_combi_array_length) {
305 probe_combi_stat_array[counter++] = pcs;
306 if (counter < probe_combi_array_length)
315 probe_combi_array_length = len;
319 generation_counter = gen_nr;
331 for (i=0; i<probe_combi_array_length; i++)
332 delete probe_combi_stat_array[i];
334 delete [] probe_combi_stat_array;
GenerationDuplicates * get_dup_tree()
void gen_determ_combis(int beg, int len, int &pos_counter, probe_combi_statistic *p)
#define MAXINITPOPULATION
bool insert(probe_combi_statistic *pcs)
void init_roulette_wheel()
int get_size_sondenarray()
void scale(double a, double b)
double calc_fitness(int len_of_field)
probe ** get_probe_pool()
ProbeValuation * get_p_eval()
probe_combi_statistic * single_in_generation(probe_combi_statistic *field)
bool MP_aborted(int gen_cnt, double avg_fit, double min_fit, double max_fit, arb_progress &progress)
void set_probe_combi(int j, probe *f)
Generation * create_next_generation()
void insert_in_result_list(probe_combi_statistic *pcs)
double calc_expected_children(double average_fitness)
bool insert(probe_combi_statistic *sondenkombi, bool &result, int depth=0)
probe * get_probe_combi(int j)
bool calcFitness(bool use_genetic_algo, double old_avg_fit)
probe_combi_statistic * check_duplicates(GenerationDuplicates *dup_tree=NULp)
void crossover_Probes(probe_combi_statistic *pcombi2)
#define MULTROULETTEFACTOR
probe_combi_statistic * duplicate()
int get_random(int min, int max)
Generation(int len, int gen_nr)