]> mj.ucw.cz Git - leo.git/commitdiff
Labelling: Introducing new enum for verbosity
authorKarryanna <karry@karryanna.cz>
Wed, 13 May 2015 21:54:57 +0000 (23:54 +0200)
committerKarryanna <karry@karryanna.cz>
Wed, 13 May 2015 21:54:57 +0000 (23:54 +0200)
labeller.c
labeller.h

index 5348737b10899e4ebb3a23aa441a3dd570966f13..58fa844e0e2197752a84b1607a149895f2f1e14c 100644 (file)
@@ -41,19 +41,19 @@ struct eltpool *ep_individuals;
 struct individual **population1;
 struct individual **population2;
 
-int dbg_segments = 0;
-int dbg_plan = 0;
-int dbg_requests = 0;
-int dbg_graph = 0;
-int dbg_bfs = 0;
-int dbg_map_parts = 0;
-int dbg_movement = 0;
-int dbg_init = 0;
-int dbg_overlaps = 0;
-int dbg_rank = 0;
-int dbg_evolution = 0;
-int dbg_mutation = 0;
-int dbg_breeding = 0;
+int dbg_segments = VERBOSITY_NONE;
+int dbg_plan = VERBOSITY_NONE;
+int dbg_requests = VERBOSITY_NONE;
+int dbg_graph = VERBOSITY_NONE;
+int dbg_bfs = VERBOSITY_NONE;
+int dbg_map_parts = VERBOSITY_NONE;
+int dbg_movement = VERBOSITY_NONE;
+int dbg_init = VERBOSITY_NONE;
+int dbg_overlaps = VERBOSITY_NONE;
+int dbg_rank = VERBOSITY_NONE;
+int dbg_evolution = VERBOSITY_NONE;
+int dbg_mutation = VERBOSITY_NONE;
+int dbg_breeding = VERBOSITY_NONE;
 
 int page_width_int;
 int page_height_int;
@@ -1184,7 +1184,7 @@ void breed(void)
   {
     int parent1 = randint(0, breed_rbest_size-1);
     int parent2 = randint(0, breed_rbest_size-1);
-    if (dbg_breeding)
+    if (dbg_breeding >= VERBOSITY_INDIVIDUAL)
       printf("Will breed %d and %d\n", parent1, parent2);
 
     breed_buffer = perform_crossover(population1[parent1], population1[parent2]);
@@ -1210,7 +1210,7 @@ struct individual **perform_crossover(struct individual *parent1, struct individ
   {
     if (! processed[parent1->placements[i].ind])
     {
-      if (dbg_breeding)
+      if (dbg_breeding >= VERBOSITY_PLACEMENT)
         printf("Creating symbol closure for placement %u\n", i);
 
       struct placement **clos_symbols = get_closure(&(parent1->placements[i]));
@@ -1218,14 +1218,14 @@ struct individual **perform_crossover(struct individual *parent1, struct individ
 
       if (x == 1)
       {
-        if (dbg_breeding)
+        if (dbg_breeding >= VERBOSITY_PLACEMENT)
           printf("Copying parent->child 1->1 and 2->2\n");
         copy_symbols(clos_symbols, parent1, child1, &processed);
         copy_symbols(clos_symbols, parent2, child2, &processed);
       }
       else
       {
-        if (dbg_breeding)
+        if (dbg_breeding >= VERBOSITY_PLACEMENT)
           printf("Copying parent->child 2->1 and 1->2\n");
         copy_symbols(clos_symbols, parent2, child1, &processed);
         copy_symbols(clos_symbols, parent1, child2, &processed);
@@ -1623,13 +1623,13 @@ struct placement **get_closure(struct placement *placement)
   uns first = 0;
   while (first < GARY_SIZE(closure))
   {
-    if (dbg_breeding)
+    if (dbg_breeding >= VERBOSITY_ALL)
       printf("Iterating, first is %d of current %u\n", first, GARY_SIZE(closure));
     struct placement **overlapping = get_overlapping(placement);
     if (! overlapping) { first++; continue; }
 
     struct placement **filtered = filter(overlapping, &chosen);
-    if (dbg_breeding)
+    if (dbg_breeding >= VERBOSITY_ALL)
       printf("There are %u new overlapping symbols\n", GARY_SIZE(filtered));
     GARY_FREE(overlapping);
     overlapping = filtered;
@@ -1640,7 +1640,7 @@ struct placement **get_closure(struct placement *placement)
         if (overlaps(*p, overlapping[j]))
         {
          p = GARY_PUSH(closure); *p = overlapping[j];
-         if (dbg_breeding)
+         if (dbg_breeding >= VERBOSITY_ALL)
             printf("Adding placement of request %d (in fact at [%.2f; %.2f] of size %d x %d)\n", overlapping[j]->request->ind, overlapping[j]->x, overlapping[j]->y, overlapping[j]->request->variants[overlapping[j]->variant_used].width, overlapping[j]->request->variants[overlapping[j]->variant_used].height);
          chosen[overlapping[j]->request->ind] = 1;
        }
@@ -1656,7 +1656,7 @@ struct placement **get_closure(struct placement *placement)
 void copy_symbols(struct placement **closure, struct individual *parent, struct individual *child, bool **processed_ptr)
 {
   bool *processed = *processed_ptr;
-  if (dbg_breeding)
+  if (dbg_breeding >= VERBOSITY_ALL)
     printf("Will copy %u symbols\n", GARY_SIZE(closure));
 
   for (uns i=0; i<GARY_SIZE(closure); i++)
index e0088173446a392a2f6a4661bd17310b3caa423f..c03a80e0f40dde3ba20aab4cff9e151fdeffaeb8 100644 (file)
@@ -1,6 +1,16 @@
 #ifndef _LEO_LABELLER_H
 #define _LEO_LABELLER_H
 
+enum verbosity
+{
+  VERBOSITY_NONE,
+  VERBOSITY_GENERAL,
+  VERBOSITY_POPULATION,
+  VERBOSITY_INDIVIDUAL,
+  VERBOSITY_PLACEMENT,
+  VERBOSITY_ALL,
+};
+
 enum edge_dir
 {
   DIR_INVALID,