]> mj.ucw.cz Git - leo.git/blobdiff - lab-evolution.c
Labelling: Bugfixes in get_closure
[leo.git] / lab-evolution.c
index 5b0bd71e45fa3e7cd93cf9b978c73280f36cf2e2..8f91446c8caaf08635f95ae64eb5e75bc482f602 100644 (file)
@@ -78,6 +78,8 @@ static int conf_pop_size = 200, conf_fit_size = 1, conf_term_cond = TERM_COND_IT
 static double conf_penalty_bound = 100, conf_stagnation_bound = 10;
 static int conf_iteration_limit = 200;
 
+static double conf_rank_distance_w = 1, conf_rank_overlap_w = 1, conf_rank_omittment_w = 1;
+
 static int breed_pop_size;
 static int breed_rbest_size;
 
@@ -113,6 +115,9 @@ static struct cf_section evolution_cf = {
     CF_DOUBLE("MutateRegenBound", &conf_mutate_regen_bound),
     CF_DOUBLE("MutateChvarBound", &conf_mutate_chvar_bound),
     CF_DOUBLE("ElitePopSize", &conf_elite_pop_size),
+    CF_DOUBLE("DistanceWeight", &conf_rank_distance_w),
+    CF_DOUBLE("OverlapWeight", &conf_rank_overlap_w),
+    CF_DOUBLE("OmittmentWeight", &conf_rank_omittment_w),
     CF_END
   }
 };
@@ -452,7 +457,7 @@ static struct individual **perform_crossover(struct individual *parent1, struct
     {
       DEBUG(dbg_breeding, VERBOSITY_PLACEMENT, "Creating symbol closure for placement %u\n", i);
 
-      struct placement **clos_symbols = get_closure(&(parent1->placements[i]));
+      struct placement **clos_symbols = get_closure(&(parent1->placements[i]), parent2);
       int x = randint(0, 2);
 
       if (x == 0)
@@ -577,15 +582,15 @@ static void rank_population(void)
     DEBUG(dbg_rank, VERBOSITY_INDIVIDUAL, "Individual %d\n", i);
     population1[i]->penalty = 0;
 
-    penalty = individual_omittment(population1[i]);
+    penalty = conf_rank_omittment_w * individual_omittment(population1[i]);
     DEBUG(dbg_rank, VERBOSITY_INDIVIDUAL, "Increasing penalty by %d for omittment\n", penalty);
     population1[i]->penalty += penalty;
 
-    penalty = individual_overlap(population1[i]);
+    penalty = conf_rank_overlap_w * individual_overlap(population1[i]);
     DEBUG(dbg_rank, VERBOSITY_INDIVIDUAL, "Increasing penalty by %d for overlap\n", penalty);
     population1[i]->penalty += penalty;
 
-    penalty = individual_distances(population1[i]);
+    penalty = conf_rank_distance_w * individual_distances(population1[i]);
     DEBUG(dbg_rank, VERBOSITY_INDIVIDUAL, "Increasing penalty by %d for distances\n", penalty);
     population1[i]->penalty += penalty;
   }
@@ -692,10 +697,17 @@ static void move_symbol_point(struct placement *p)
 
 static void move_symbol_segment(struct placement *p)
 {
+  struct request_segment *rs = (struct request_segment *) p->request;
   double m = gen_movement_uniform();
-  // CHECK ME
-  p->x += m;
-  p->y += m * ((struct request_segment *) p->request)->slope;
+  if (fabs(rs->x2 - rs->x1) > 0.01)
+  {
+    p->x += m;
+    p->y += m * rs->slope;
+  }
+  else
+  {
+    p->x += m;
+  }
 }
 
 static void hide_segment_labels(struct individual *individual)
@@ -744,7 +756,7 @@ static void init_placement(struct placement *p, struct individual *individual, s
       break;
     case REQUEST_SECTION: ;
       struct request_section *rls = (struct request_section *) r;
-      p->variant_used = randint(0, rls->num_segments);
+      p->variant_used = randint(0, GARY_SIZE(rls->segments));
       break;
     case REQUEST_SEGMENT: ;
       struct request_segment *rs = (struct request_segment *) r;