]> mj.ucw.cz Git - leo.git/commitdiff
Labelling: Option to complete population by elitism
authorKarryanna <karry@karryanna.cz>
Tue, 9 Jun 2015 11:07:31 +0000 (13:07 +0200)
committerKarryanna <karry@karryanna.cz>
Tue, 9 Jun 2015 11:07:31 +0000 (13:07 +0200)
Mostly a hot-fix to situation when rounding causes the sum of individuals
created by specific methods not to fit the desired population size

labeller.c

index bfd67518a7c7a516807c0e1ff0e6557bef79ee0d..644fa775edb89fc898e79f9dbb3a3ea43cc4bb8b 100644 (file)
@@ -60,6 +60,7 @@ int num_edges = 0;
 int dbg_num_hits = 0;
 
 int conf_pop_size = 50;
+int conf_fit_size = 1;
 
 int conf_penalty_bound = 0;
 int conf_stagnation_bound = 0;
@@ -1095,9 +1096,16 @@ void compute_sizes(void)
 
   if (breed_pop_size + mutate_pop_size + elite_pop_size != conf_pop_size)
   {
-    fprintf(stderr, "Breeding + mutation + elitism won't create correct number of individuals\n");
-    fprintf(stderr, "Please fix conf_breed_pop_size, conf_mutate_pop_size and conf_elite_pop_size parameters\n");
-    exit(2);
+    if (conf_fit_size)
+    {
+      elite_pop_size += conf_pop_size - (breed_pop_size + mutate_pop_size + elite_pop_size);
+    }
+    else
+    {
+      fprintf(stderr, "Breeding + mutation + elitism won't create correct number of individuals\n");
+      fprintf(stderr, "Please fix conf_breed_pop_size, conf_mutate_pop_size and conf_elite_pop_size parameters\n");
+      exit(2);
+    }
   }
 }