int dbg_map_parts = VERBOSITY_NONE;
int dbg_movement = VERBOSITY_NONE;
int dbg_init = VERBOSITY_NONE;
-int dbg_overlaps = VERBOSITY_NONE;
+int dbg_overlaps = VERBOSITY_GENERAL;
int dbg_rank = VERBOSITY_NONE;
-int dbg_evolution = VERBOSITY_INDIVIDUAL;
+int dbg_evolution = VERBOSITY_POPULATION;
int dbg_mutation = VERBOSITY_NONE;
int dbg_breeding = VERBOSITY_NONE;
int conf_penalty_bound = 0;
int conf_stagnation_bound = 0;
-int conf_iteration_limit = 100;
+int conf_iteration_limit = 10;
int conf_term_cond = TERM_COND_ITERATIONS;
-double conf_breed_pop_size = 0.4;
-double conf_breed_rbest = 0.2;
+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 = 1.0;
+double conf_mutate_children_prob = 0.6;
-double conf_mutate_pop_size = 0.4;
+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.0;
+double conf_mutate_chvar_bound = 0.1;
int mutate_pop_size;
int mutate_rbest_size;
-double conf_elite_pop_size = 0.2;
+double conf_elite_pop_size = 0.1;
int elite_pop_size;
-double conf_max_section_length = 100;
+double conf_max_section_length = 80;
double conf_max_section_overlay = 10;
int old_best = INT_MAX;
void dump_individual(struct individual *individual);
void dump_label(struct symbol *sym);
void dump_penalties(struct individual **population);
+void dump_placements(struct individual *individual);
+void dump_placement_links(struct placement *p);
+void dump_part_links(struct map_part *part);
+void dump_links(struct individual *individual);
int randint(int min, int max);
int flip(int a, int b);
struct mempool *mp_edges = mp_new(BLOCK_SIZE);
if (dbg_graph >= VERBOSITY_GENERAL)
- printf("Extracting nodes, will iterate over %lld ways\n", GARY_SIZE(buffer_line));
+ printf("Extracting nodes, will iterate over %zu ways\n", GARY_SIZE(buffer_line));
for (uns i=0; i<GARY_SIZE(buffer_line); i++)
{
struct osm_way *way = (struct osm_way *) buffer_line[i].line->s.o;
void label_graph(void)
{
if (dbg_graph >= VERBOSITY_GENERAL)
- printf("There are %u line labels requested\n", GARY_SIZE(buffer_linelabel));
+ printf("There are %zu line labels requested\n", GARY_SIZE(buffer_linelabel));
for (uns i=0; i<GARY_SIZE(buffer_linelabel); i++)
{
if (buffer_linelabel[i].label->type == SYMBOLIZER_TEXT)
else
{
if (dbg_graph >= VERBOSITY_ALL)
- printf("Searching among %u edges\n", GARY_SIZE(n->edges));
+ printf("Searching among %zu edges\n", GARY_SIZE(n->edges));
for (uns j=0; j<GARY_SIZE(n->edges); j++)
{
if (n->edges[j]->id == buffer_linelabel[i].way->o.id)
if (dbg_bfs >= VERBOSITY_INDIVIDUAL)
{
printf("BFS called for longline %u\n", longline);
- printf("%d longlines exist\n", GARY_SIZE(longlines));
+ printf("%zu longlines exist\n", GARY_SIZE(longlines));
}
for (uns i=0; i<GARY_SIZE(bfs_queue); i++)
{
struct graph_edge *cur = bfs_queue[i];
if (dbg_bfs >= VERBOSITY_PLACEMENT)
- printf("Exploring new edge %d; %d remaining\n", cur->num, GARY_SIZE(bfs_queue));
+ printf("Exploring new edge %d; %zu remaining\n", cur->num, GARY_SIZE(bfs_queue));
cur->visited = longline;
if (dbg_bfs >= VERBOSITY_INDIVIDUAL)
{
printf("Running new BFS\n");
- printf("Creating longline %u\n", GARY_SIZE(longlines)-1);
+ printf("Creating longline %zu\n", GARY_SIZE(longlines)-1);
}
GARY_RESIZE(bfs_queue, 0);
if (dbg_bfs >= VERBOSITY_INDIVIDUAL)
{
printf("Joined %d edges\n", dbg_num_hits); dbg_num_hits = 0;
- printf("Planned %u edges\n", GARY_SIZE(bfs_queue));
+ printf("Planned %zu edges\n", GARY_SIZE(bfs_queue));
}
}
}
continue;
}
- printf("Request for linelabel, %d sections\n", GARY_SIZE(requests_line[i].sections));
+ printf("Request for linelabel, %zu sections\n", GARY_SIZE(requests_line[i].sections));
dump_label(requests_line[i].sections[0].segments[0].label);
for (uns j=0; j<GARY_SIZE(requests_line[i].sections); j++)
{
- printf("%d section, %d segments\n", j, GARY_SIZE(requests_line[i].sections[j].segments));
+ printf("%u section, %zu segments [%d]\n", j, GARY_SIZE(requests_line[i].sections[j].segments), requests_line[i].sections[j].request.ind);
for (uns k=0; k<GARY_SIZE(requests_line[i].sections[j].segments); k++)
{
struct request_segment *rs = &requests_line[i].sections[j].segments[k];
- printf("[%.2f; %.2f] -- [%.2f; %.2f]\n", rs->x1, rs->y1, rs->x2, rs->y2);
+ printf("[%.2f; %.2f] -- [%.2f; %.2f]\t\t[%d]\n", rs->x1, rs->y1, rs->x2, rs->y2, rs->request.ind);
}
}
printf("\n");
printf("\nTotal penalty: %d\n", individual->penalty);
}
+void dump_placements(struct individual *individual)
+{
+ printf("*** Individual placements dump\n");
+
+ for (uns i=0; i<GARY_SIZE(individual->placements); i++)
+ {
+ struct placement *p = &individual->placements[i];
+ printf("Placement %d:\tPlacet at [%.2f; %.2f] using variant %d\n", p->ind, p->x, p->y, p->variant_used);
+ }
+}
+
void plan_individual(struct individual *individual)
{
for (uns i=0; i<GARY_SIZE(individual->placements); i++)
{
struct symbol *s = NULL;
z_index_t zindex = 0;
+ /**
+ if (individual->placements[i].variant_used < 0)
+ {
+ printf("Skipping placement of request %d\n", individual->placements[i].request->ind);
+ }
+ **/
if (individual->placements[i].variant_used < 0) continue;
switch (individual->placements[i].request->type)
{
}
if (dbg_plan >= VERBOSITY_PLACEMENT)
- printf("Will plan symbol at [%.2f; %.2f] on %u\n", individual->placements[i].x, individual->placements[i].y, zindex);
+ printf("Will plan symbol of request %d at [%.2f; %.2f] on %u\n", individual->placements[i].request->ind, individual->placements[i].x, individual->placements[i].y, zindex);
if (s) switch (s->type)
{
}
}
+void dump_placement_links(struct placement *p)
+{
+ struct map_placement *mp = p->map_links;
+
+ while (mp)
+ {
+ printf(" %d", mp->part->ind);
+ mp = mp->next_in_placement;
+ }
+
+ printf("\n");
+}
+
+void dump_part_links(struct map_part *part)
+{
+ struct map_placement *mp = part->placement->next_in_map;
+
+ while (mp)
+ {
+ printf(" %d", mp->placement->ind);
+ mp = mp->next_in_map;
+ }
+
+ printf("\n");
+}
+
+void dump_links(struct individual *individual)
+{
+ printf("Dumping links in individual\n");
+ for (uns i=0; i<GARY_SIZE(individual->placements); i++)
+ {
+ dump_placement_links(&individual->placements[i]);
+ }
+}
+
void compute_sizes(void)
{
page_width_int = floor(page_width);
void labeller_label(void)
{
+//srandom(29011992);
make_graph();
label_graph();
bfs_wrapper();
make_segments();
+ printf("Will deal with %d requests\n", num_requests);
+
GARY_INIT(population1, conf_pop_size);
GARY_INIT(population2, conf_pop_size);
make_population();
rank_population();
+ if (dbg_evolution >= VERBOSITY_INDIVIDUAL)
+ {
+ printf("Penalties before sort\n");
+ dump_penalties(population1);
+ }
+
if (dbg_evolution >= VERBOSITY_GENERAL)
printf("Sorting population\n");
qsort(population1, conf_pop_size, sizeof(struct individual *), cmp_individual);
{
for (int i=0; i<elite_pop_size; i++)
{
+ if (dbg_evolution >= VERBOSITY_INDIVIDUAL)
+ {
+ printf("Iteration %d: Copying individual #%d from pop 1 to #%d in pop 2\n", iteration, i, pop2_ind);
+ }
population2[pop2_ind] = ep_alloc(ep_individuals);
copy_individual(population1[i], population2[pop2_ind++]);
}
planned[p->request->ind] = 1;
GARY_INIT(others, 0);
+//printf("Iterating over parts of placement %d (at [%.2f; %.2f] / %d)\n", p->ind, p->x, p->y, p->variant_used);
for (uns i=0; i<GARY_SIZE(parts); i++)
{
+ //printf("%d:\t", parts[i]->ind);
+ //dump_part_links(parts[i]);
struct map_placement *mp = parts[i]->placement->next_in_map;
while (mp)
{
GARY_FREE(others);
if (dbg_overlaps >= VERBOSITY_PLACEMENT)
- printf("Placement of request %d add %d to overlaps\n", p->request->ind, overlap);
+ {
+ printf("Placement %d (of request %d) add %d to overlaps", p->ind, p->request->ind, overlap);
+ dump_placement_links(p);
+ }
if (p->x < 0) overlap += 0 - p->x;
if (p->x + p->request->variants[p->variant_used].width > page_width_int)
overlap += get_overlap(&individual->placements[i]);
}
+// printf("Total overlap is %d\n", overlap);
+
return overlap;
}
{
struct map_part **m = GARY_PUSH(buffer);
if (dbg_map_parts >= VERBOSITY_ALL)
- printf("Asking for %d of %u\n", y * num_map_parts_row + x, GARY_SIZE(p->individual->map));
+ printf("Asking for %d of %zu\n", y * num_map_parts_row + x, GARY_SIZE(p->individual->map));
*m = p->individual->map[y * num_map_parts_row + x];
}
if (dbg_map_parts >= VERBOSITY_PLACEMENT)
- printf("Returning %u map parts potentially containing the symbol\n", GARY_SIZE(buffer));
+ printf("Returning %zu map parts potentially containing the symbol\n", GARY_SIZE(buffer));
return buffer;
}
while (first < GARY_SIZE(closure))
{
if (dbg_breeding >= VERBOSITY_ALL)
- printf("Iterating, first is %d of current %u\n", first, GARY_SIZE(closure));
+ printf("Iterating, first is %u of current %zu\n", first, GARY_SIZE(closure));
struct placement **overlapping = get_overlapping(placement);
if (! overlapping) { first++; continue; }
struct placement **filtered = filter(overlapping, &chosen);
if (dbg_breeding >= VERBOSITY_ALL)
- printf("There are %u new overlapping symbols\n", GARY_SIZE(filtered));
+ printf("There are %zu new overlapping symbols\n", GARY_SIZE(filtered));
GARY_FREE(overlapping);
overlapping = filtered;
for (uns j=0; j<GARY_SIZE(overlapping); j++)
{
bool *processed = *processed_ptr;
if (dbg_breeding >= VERBOSITY_ALL)
- printf("Will copy %u symbols\n", GARY_SIZE(closure));
+ printf("Will copy %zu symbols\n", GARY_SIZE(closure));
for (uns i=0; i<GARY_SIZE(closure); i++)
{
printf("Inited placement to [%.2f; %.2f]\n", p->x, p->y);
}
+/**
void reset_individual_map(struct individual *i)
{
for (uns j=0; j<num_map_parts; j++)
i->map[j] = part;
}
}
+**/
+/**
void update_individual(struct individual *individual)
{
for (uns i=0; i<GARY_SIZE(individual->placements); i++)
update_map_parts_delete(&individual->placements[i]);
}
}
+**/
void clear_individual(struct individual *individual)
{
GARY_FREE(parts);
if (dbg_map_parts >= VERBOSITY_PLACEMENT)
- printf("Returning %u potentially overlapping placements\n", GARY_SIZE(buffer));
+ printf("Returning %zu potentially overlapping placements\n", GARY_SIZE(buffer));
return buffer;
}