]> mj.ucw.cz Git - leo.git/commitdiff
Labelling: Evolution parameters can be set in config file
authorKarryanna <karry@karryanna.cz>
Tue, 30 Jun 2015 13:03:25 +0000 (15:03 +0200)
committerKarryanna <karry@karryanna.cz>
Tue, 30 Jun 2015 13:03:25 +0000 (15:03 +0200)
labeller.c
labeller.h
leo.c
map.cf

index a709ccd8f187f82295dde09c21c4e6e94cc74be0..61dd53ecbd5913758d9f1b81ed30a8cac1c37530 100644 (file)
@@ -1,4 +1,5 @@
 #include <ucw/lib.h>
+#include <ucw/conf.h>
 #include <ucw/gary.h>
 #include <ucw/mempool.h>
 #include <ucw/eltpool.h>
@@ -61,39 +62,14 @@ int num_nodes;
 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;
-int conf_iteration_limit = 10;
-
-int conf_term_cond = TERM_COND_ITERATIONS;
-
-double conf_breed_pop_size = 0.45;
-double conf_breed_rbest = 0.3;
-
 int breed_pop_size;
 int breed_rbest_size;
 
-bool conf_mutate_children = 1;
-double conf_mutate_children_prob = 0.6;
-
-double conf_mutate_pop_size = 0.45;
-double conf_mutate_rbest = 0.2;
-
-double conf_mutate_move_bound = 0.1;
-double conf_mutate_regen_bound = 0.0;
-double conf_mutate_chvar_bound = 0.1;
-
 int mutate_pop_size;
 int mutate_rbest_size;
 
-double conf_elite_pop_size = 0.1;
 int elite_pop_size;
 
-double conf_max_section_length = 80;
-double conf_max_section_overlay = 10;
 
 int old_best = INT_MAX;
 int iteration = 0;
@@ -114,6 +90,42 @@ uns num_map_parts_row;
 uns num_map_parts_col;
 uns num_map_parts;
 
+int conf_pop_size = 200, conf_fit_size = 1, conf_term_cond = TERM_COND_ITERATIONS;
+
+double conf_penalty_bound = 100, conf_stagnation_bound = 10;
+int conf_iteration_limit = 200;
+
+double conf_breed_pop_size = 0.45, conf_breed_rbest = 1,
+       conf_mutate_children, conf_mutate_children_prob = 0.6,
+       conf_mutate_pop_size = 0.45, conf_mutate_rbest = 1,
+       conf_mutate_move_bound = 0.1, conf_mutate_regen_bound = 0.05, conf_mutate_chvar_bound = 0.1,
+       conf_elite_pop_size = 0.1;
+
+double conf_max_section_length = 80, conf_max_section_overlay = 10;
+
+static struct cf_section evolution_cf = {
+  CF_ITEMS {
+    CF_INT("PopSize", &conf_pop_size),
+    CF_INT("FitSize", &conf_fit_size),
+    CF_INT("TermCond", &conf_term_cond),
+    CF_DOUBLE("PenaltyBound", &conf_penalty_bound),
+    CF_DOUBLE("StagnationBound", &conf_stagnation_bound),
+    CF_INT("IterationLimit", &conf_iteration_limit),
+    CF_DOUBLE("BreedPopSize", &conf_breed_pop_size),
+    CF_DOUBLE("BreedNumBest", &conf_breed_rbest),
+    CF_DOUBLE("MutateChild", &conf_mutate_children_prob),
+    CF_DOUBLE("MutatePopSize", &conf_mutate_pop_size),
+    CF_DOUBLE("MutateNumBest", &conf_mutate_rbest),
+    CF_DOUBLE("MutateMoveBound", &conf_mutate_move_bound),
+    CF_DOUBLE("MutateRegenBound", &conf_mutate_regen_bound),
+    CF_DOUBLE("MutateChvarBound", &conf_mutate_chvar_bound),
+    CF_DOUBLE("ElitePopSize", &conf_elite_pop_size),
+    CF_DOUBLE("MaxSectionLenght", &conf_max_section_length),
+    CF_DOUBLE("MaxSectionOverlay", &conf_max_section_overlay),
+    CF_END
+  }
+};
+
 void compute_sizes(void);
 
 void make_population(void);
@@ -239,6 +251,11 @@ void dump_label(struct symbol *sym)
   }
 }
 
+void labeller_conf(void)
+{
+  cf_declare_section("Evolution", &evolution_cf, 0);
+}
+
 void labeller_init(void)
 {
   GARY_INIT(requests_point, 0);
index 4fe0d922b12ff5cf57394368244486374dbe5b56..8a486318d81c31d114936df49bd4d255dc638d29 100644 (file)
@@ -32,6 +32,7 @@ enum request_type
 
 enum term_cond
 {
+  TERM_COND_UNDEF,
   TERM_COND_PENALTY,
   TERM_COND_STAGNATION,
   TERM_COND_ITERATIONS,
@@ -186,6 +187,7 @@ struct individual
   int penalty;
 };
 
+void labeller_conf(void);
 void labeller_init(void);
 void labeller_cleanup(void);
 
diff --git a/leo.c b/leo.c
index 5888fec7c4674de0cf4b3621c8b90be3c34a56cd..003a2c55024af9b1787ca739283a19ad60c4fb49 100644 (file)
--- a/leo.c
+++ b/leo.c
@@ -117,6 +117,9 @@ int main(int argc UNUSED, char **argv)
 // HACKING
   cf_def_file = argv[1];
   cf_declare_section("Debug", &debug_cf, 0);
+
+  labeller_conf();
+
   opt_parse(&options, argv+2);
 // TILL HERE
 
diff --git a/map.cf b/map.cf
index 809f77f50f31db1b66f3a410b38e73bbc5b423d9..145ea6565e6e355c47be8cffc14ff5e9b31acd16 100644 (file)
--- a/map.cf
+++ b/map.cf
@@ -81,3 +81,43 @@ Debug {
        # Dump planning and drawing of symbols
        DumpSymbols 0
 }
+
+Evolution {
+       # Number of individuals in each generation
+       PopSize 50
+
+       # Enhance number of individuals created by elitisc to fit population size
+       FitSize 1
+
+       # Terminating condition
+       # 1 -- penalty reached, 2 -- stagnation, 3 -- iteration limit
+       TermCond 3
+       PenaltyBound 100
+       StagnationBound 10
+       IterationLimit 200
+
+       # Create that part of generation by breeding
+       BreedPopSize 0.45
+       # Use that part of best individuals for parent selection
+       BreedNumBest 0.9
+       # Probability of children mutation
+       MutateChild 0.6
+
+       # Create that part of generation by mutation
+       MutatePopSize 0.45
+       # Use that part of best individuals for individual selection
+       MutateNumBest 0.9
+       # Probability of moving label
+       MutateMoveBound 0.1
+       # Probability of regeneration label coordinates
+       MutateRegenBound 0.05
+       # Probability of changing label variant
+       MutateChvarBound 0.1
+
+       ElitePopSize 0.1
+
+       # Maximal length of line section in milimeters
+       MaxSectionLenght 80
+       # Section's length may exceed limit by at most [mm]
+       MaxSectionOverlay 10
+}