summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
27a0c4b)
… still seg-faulting, though
int move_min = 0;
int move_max = 1;
int move_min = 0;
int move_max = 1;
void labeller_init(void)
{
// mpool_requests = mp_new(BLOCK_SIZE);
void labeller_init(void)
{
// mpool_requests = mp_new(BLOCK_SIZE);
r->sym = sym;
r->object = object;
r->zindex = zindex;
r->sym = sym;
r->object = object;
r->zindex = zindex;
+ ((struct request *)r)->ind = num_requests++;
struct osm_node *n = (struct osm_node *) object;
r->x = n->x;
struct osm_node *n = (struct osm_node *) object;
r->x = n->x;
struct request_area *r = GARY_PUSH(requests_area);
r->o = (struct osm_multipolygon *) o;
r->zindex = zindex;
struct request_area *r = GARY_PUSH(requests_area);
r->o = (struct osm_multipolygon *) o;
r->zindex = zindex;
+ ((struct request *)r)->ind = num_requests++;
struct graph_edge *other = other_node->edges[i];
if (! other->visited)
{
struct graph_edge *other = other_node->edges[i];
if (! other->visited)
{
- printf("Trying to add %dth edge\n", GARY_SIZE(bfs_queue)+1);
struct graph_edge **new = GARY_PUSH(bfs_queue);
*new = other_node->edges[i];
}
struct graph_edge **new = GARY_PUSH(bfs_queue);
*new = other_node->edges[i];
}
{
GARY_PUSH(longlines);
e->longline = num_longlines++;
{
GARY_PUSH(longlines);
e->longline = num_longlines++;
- longlines[num_longlines].first = e;
+ longlines[e->longline].first = e;
struct request_line *request = GARY_PUSH(requests_line);
GARY_INIT(request->segments, 0);
struct graph_edge *e = longlines[i].first;
struct request_line *request = GARY_PUSH(requests_line);
GARY_INIT(request->segments, 0);
struct graph_edge *e = longlines[i].first;
+ if (! e) printf("Oops\n");
while (e)
{
struct request_segment *r = GARY_PUSH(request->segments);
while (e)
{
struct request_segment *r = GARY_PUSH(request->segments);
r->x2 = ((struct osm_node *) e->n2)->x;
r->y2 = ((struct osm_node *) e->n2)->y;
r->sym = e->sym;
r->x2 = ((struct osm_node *) e->n2)->x;
r->y2 = ((struct osm_node *) e->n2)->y;
r->sym = e->sym;
- r->k = abs(r->x2 - r->x1) / abs(r->y2 - r->y1);
+ r->k = abs(r->x2 - r->x1) / (abs(r->y2 - r->y1) + 0.001); // FIXME: Hack to prevent floating point exception when y2 = y1
r->variant = malloc(sizeof(struct point_variant)); // FIXME
r->variant = malloc(sizeof(struct point_variant)); // FIXME
+ ((struct request *)r)->ind = num_requests++;
make_bitmap_label(r->variant, e->text);
e = e->next;
make_bitmap_label(r->variant, e->text);
e = e->next;
- int conf_breed_pop_size = conf_breed_pop_size_perc * conf_pop_size;
+ printf("%.2f\n", ((double) conf_breed_pop_size_perc/100));
+ int conf_breed_pop_size = ((double) conf_breed_pop_size_perc/100) * conf_pop_size;
struct individual **breed_buffer;
while (i < conf_breed_rbest_perc * conf_pop_size)
{
int parent1 = randint(1, conf_breed_pop_size);
int parent2 = randint(1, conf_breed_pop_size);
struct individual **breed_buffer;
while (i < conf_breed_rbest_perc * conf_pop_size)
{
int parent1 = randint(1, conf_breed_pop_size);
int parent2 = randint(1, conf_breed_pop_size);
+ printf("Will breed %d and %d, chosen of %d best of %d population (intended to be %d)\n", parent1, parent2, conf_breed_pop_size, GARY_SIZE(population1), conf_pop_size);
breed_buffer = perform_crossover(population1[parent1], population1[parent2]);
population2[2*i] = breed_buffer[0];
population2[2*i+1] = breed_buffer[1];
breed_buffer = perform_crossover(population1[parent1], population1[parent2]);
population2[2*i] = breed_buffer[0];
population2[2*i+1] = breed_buffer[1];
struct individual **buffer = malloc(2*sizeof(struct individual));
struct individual *child1 = ep_alloc(ep_individuals);
struct individual *child2 = ep_alloc(ep_individuals);
struct individual **buffer = malloc(2*sizeof(struct individual));
struct individual *child1 = ep_alloc(ep_individuals);
struct individual *child2 = ep_alloc(ep_individuals);
+ GARY_INIT(child1->placements, 0);
+ GARY_INIT(child2->placements, 0);
+
+ printf("Performing crossover\n");
for (uns i=0; i<GARY_SIZE(parent1->placements); i++)
{
for (uns i=0; i<GARY_SIZE(parent1->placements); i++)
{
+ printf("%dth placement\n", i);
if (! parent1->placements[i].processed)
{
struct placement **clos_symbols;
if (! parent1->placements[i].processed)
{
struct placement **clos_symbols;
copy_symbols(clos_symbols, parent2, child1);
copy_symbols(clos_symbols, parent1, child2);
}
copy_symbols(clos_symbols, parent2, child1);
copy_symbols(clos_symbols, parent1, child2);
}
+ printf("%lld\n", GARY_SIZE(clos_symbols));
GARY_FREE(clos_symbols);
}
GARY_FREE(clos_symbols);
}
int randint(int min, int max)
{
int r = random();
int randint(int min, int max)
{
int r = random();
+ printf("Returning %d + (%d % (%d - %d)) = %d + %d % %d = %d + %d = %d\n", min, r, max, min, min, r, max-min, min, r%(max-min), min+(r%(max-min)));
+ return min + (r % (max - min));
return (r * (max - min));
}
void get_closure(struct placement **closure UNUSED, struct placement *placement UNUSED, struct individual *parent1 UNUSED, struct individual *parent2 UNUSED)
{
return (r * (max - min));
}
void get_closure(struct placement **closure UNUSED, struct placement *placement UNUSED, struct individual *parent1 UNUSED, struct individual *parent2 UNUSED)
{
+ printf("Getting closure\n");
bool *chosen = malloc(GARY_SIZE(parent1->placements) * sizeof(bool));
chosen[placement->request->ind] = 1;
bool *chosen = malloc(GARY_SIZE(parent1->placements) * sizeof(bool));
chosen[placement->request->ind] = 1;
uns first = 0;
while (first < GARY_SIZE(closure))
{
uns first = 0;
while (first < GARY_SIZE(closure))
{
+ printf("Iterating, first is %d\n", first);
struct placement **overlapping = get_overlapping(placement);
filter(overlapping, chosen);
for (uns j=0; j<GARY_SIZE(overlapping); j++)
struct placement **overlapping = get_overlapping(placement);
filter(overlapping, chosen);
for (uns j=0; j<GARY_SIZE(overlapping); j++)
chosen[overlapping[j]->request->ind] = 1;
}
GARY_FREE(overlapping);
chosen[overlapping[j]->request->ind] = 1;
}
GARY_FREE(overlapping);
}
}
void copy_symbols(struct placement **closure, struct individual *parent, struct individual *child)
{
}
}
void copy_symbols(struct placement **closure, struct individual *parent, struct individual *child)
{
+ printf("%.2f\n", child->penalty);
for (uns i=0; i<GARY_SIZE(closure); i++)
{
int ind = closure[i]->request->ind;
for (uns i=0; i<GARY_SIZE(closure); i++)
{
int ind = closure[i]->request->ind;
p->y += (double) (move_min + randdouble()) * flip(1, -1);
}
p->y += (double) (move_min + randdouble()) * flip(1, -1);
}
-void init_placement(struct placement *p UNUSED, struct request *r UNUSED)
+void init_placement(struct placement *p, struct request *r)
+ p->request = r;
+ p->processed = 0;
}
struct placement **get_overlapping(struct placement *p UNUSED)
}
struct placement **get_overlapping(struct placement *p UNUSED)