From 91ef1ec01dc27bc779abca5f9a0fe9b6d4e4d181 Mon Sep 17 00:00:00 2001 From: Karolina Buresova Date: Sun, 26 Jul 2015 02:17:28 +0200 Subject: [PATCH] Labelling: Bugfixes in get_closure Ooops --- lab-bitmaps.c | 13 +++++++------ lab-bitmaps.h | 2 +- lab-evolution.c | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/lab-bitmaps.c b/lab-bitmaps.c index f5822e6..51d1da8 100644 --- a/lab-bitmaps.c +++ b/lab-bitmaps.c @@ -21,7 +21,7 @@ static void make_bitmap_label(struct variant *v, struct sym_text *text); static int overlaps(struct placement *p1, struct placement *p2); static struct map_part **get_map_parts(struct placement *p); -static struct placement **get_overlapping(struct placement *p); +static struct placement **get_overlapping_in(struct placement *p, struct individual *individual); double bitmap_granularity = 1; @@ -266,7 +266,7 @@ void update_map_parts(struct placement *p) update_map_parts_create(p); } -struct placement **get_closure(struct placement *placement) +struct placement **get_closure(struct placement *placement, struct individual *other) { struct placement **closure; GARY_INIT(closure, 0); @@ -280,7 +280,7 @@ struct placement **get_closure(struct placement *placement) while (first < GARY_SIZE(closure)) { DEBUG(dbg_breeding, VERBOSITY_ALL, "Iterating, first is %u of current %zu\n", first, GARY_SIZE(closure)); - struct placement **overlapping = get_overlapping(placement); + struct placement **overlapping = get_overlapping_in(closure[first], other); if (! overlapping) { first++; continue; } struct placement **filtered = filter(overlapping, &chosen); @@ -293,7 +293,8 @@ struct placement **get_closure(struct placement *placement) { if (overlaps(*p, overlapping[j])) { - p = GARY_PUSH(closure); *p = overlapping[j]; + p = GARY_PUSH(closure); + *p = &(placement->individual->placements[overlapping[j]->request->ind]); DEBUG(dbg_breeding, VERBOSITY_ALL, "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; } @@ -308,7 +309,7 @@ struct placement **get_closure(struct placement *placement) return closure; } -static struct placement **get_overlapping(struct placement *p) +static struct placement **get_overlapping_in(struct placement *p, struct individual *individual) { struct placement **buffer; GARY_INIT(buffer, 0); @@ -318,7 +319,7 @@ static struct placement **get_overlapping(struct placement *p) for (uns i=0; iplacement->next_in_map; + struct map_placement *mp = individual->map[parts[i]->ind]->placement->next_in_map; while (mp) { if (p->variant_used >= 0) diff --git a/lab-bitmaps.h b/lab-bitmaps.h index b178272..c4b1676 100644 --- a/lab-bitmaps.h +++ b/lab-bitmaps.h @@ -8,7 +8,7 @@ int get_overlap(struct placement *p, int **planed_ptr, int iteration); void update_map_parts(struct placement *p); void update_map_parts_delete(struct placement *p); void update_map_parts_create(struct placement *p); -struct placement **get_closure(struct placement *placement); +struct placement **get_closure(struct placement *placement, struct individual *other); void dump_bitmaps(struct individual *individual); void dump_label(struct symbol *sym); diff --git a/lab-evolution.c b/lab-evolution.c index 169a9bc..8f91446 100644 --- a/lab-evolution.c +++ b/lab-evolution.c @@ -457,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) -- 2.39.2