~StrokePattern() { delete_groups(); }
void clear() { delete_groups(); _bbox.reset(); _complete=true; }
void create_generations(int fitness,float lamda,int num_of_parents,int number_of_groups_wanted,int row_swapping, int min_gene_R1R2,int max_gene_R1R2,int freq, int min_count,int max_count,int generations_wanted, int generation_change,int pop_size_change,double mutation_rate, int robustness, int robust_changes,int robust_last_bit, gsl_rng *r, FILE *r1Output, FILE *r2Output,FILE *matrixOutput, FILE *countsOutput,FILE *fitnessOutput, FILE *discreteOutput,FILE *robustOutput){ int i,k,l,p,f; population *robust_population; group* temp_robust_group,*temp_normal_group; int temp; for(i=0;i<generations_wanted;i++){ if(i==0){ generation_array[i%2]=create_population(number_of_groups_wanted,min_gene_R1R2,max_gene_R1R2,min_count,max_count,1); } else{ if (i%2==0) temp=2; else temp=1; if(fitness){ generation_array[i%2]=create_gen_population_fit(temp,num_of_parents,row_swapping,min_count,max_count,mutation_rate,r); } else{ generation_array[i%2]=create_gen_population_no_fit(temp,num_of_parents,row_swapping,min_count,max_count,mutation_rate,r); } } if(i==generation_change){ if(curr_num_of_groups*persons_per_group>pop_size_change){ delete_groups(curr_num_of_groups-(pop_size_change/persons_per_group),i%2); } else{ insert_groups((pop_size_change/persons_per_group)-curr_num_of_groups,lamda,i%2,num_of_parents,fitness,row_swapping,min_count,max_count,mutation_rate,r); } } /* ROBUSTNESS */ if(i%freq==0 && robustness) { robust_population = create_population(curr_num_of_groups,min_gene_R1R2,max_gene_R1R2,min_count,max_count,0); temp_robust_group=robust_population->groups_list; temp_normal_group=generation_array[i%2]->groups_list; for(k=0;k<curr_num_of_groups;k++){ /*sarwse olo ton pli8ismo kai deep copy*/ /*deep copy atomou*/ for(l=0;l<persons_per_group;l++){ temp_robust_group->person_in_group[l]=deep_copy_person_robust(temp_robust_group->person_in_group[l],temp_normal_group->person_in_group[l]); } if(temp_robust_group->next!=NULL&&temp_normal_group->next!=NULL){ temp_robust_group=temp_robust_group->next; temp_normal_group=temp_normal_group->next; } } for(k=0;k<curr_num_of_groups-1;k++){ temp_robust_group=temp_robust_group->prev; } robust_population->groups_list=temp_robust_group; check_robustness(robustOutput,robust_population,robust_changes,robust_last_bit,1,r); /*freeing memory from robustness*/ for(k=0;k<curr_num_of_groups;k++){ for(l=0;l<persons_per_group;l++){ free(temp_robust_group->person_in_group[l]); } if(temp_robust_group->next!=NULL){ temp_robust_group=temp_robust_group->next; } } free(robust_population); } /*END OF ROBUSTNESS*/ /*FREEING MEMORY*/ if(i!=0){ for(p=0;p<curr_num_of_groups;p++){ for(f=0;f<persons_per_group;f++){ free(generation_array[temp-1]->groups_list->person_in_group[f]); } if(generation_array[temp-1]->groups_list->next!=NULL){ generation_array[temp-1]->groups_list=generation_array[temp-1]->groups_list->next; free(generation_array[temp-1]->groups_list->prev); } } free(generation_array[temp-1]->groups_list); free(generation_array[temp-1]); } mature_generation(generation_array[i%2],1); calculate_fitness(i%2,lamda); if(i%freq==0){ printf("Generation %d Simulated. \n",i); extract_R1R2_generation(r1Output, r2Output,i%2); extract_gene_dependancies_matrix_generation(matrixOutput, i%2); extract_gene_counts_generation(countsOutput, i%2); extract_discrete_generation(discreteOutput,i%2); extract_fitness_generation(fitnessOutput,i%2); } } }