#include "postgres.h"
#include "optimizer/geqo_random.h"
#include "optimizer/geqo_recombination.h"
Go to the source code of this file.
Functions | |
void | init_tour (PlannerInfo *root, Gene *tour, int num_gene) |
City * | alloc_city_table (PlannerInfo *root, int num_gene) |
void | free_city_table (PlannerInfo *root, City *city_table) |
City* alloc_city_table | ( | PlannerInfo * | root, | |
int | num_gene | |||
) |
void free_city_table | ( | PlannerInfo * | root, | |
City * | city_table | |||
) |
Definition at line 90 of file geqo_recombination.c.
References pfree().
Referenced by geqo().
{ pfree(city_table); }
void init_tour | ( | PlannerInfo * | root, | |
Gene * | tour, | |||
int | num_gene | |||
) |
Definition at line 38 of file geqo_recombination.c.
References geqo_randint, i, palloc(), and pfree().
Referenced by random_init_pool().
{ Gene *tmp; int remainder; int next, i; /* Fill a temp array with the IDs of all not-yet-visited cities */ tmp = (Gene *) palloc(num_gene * sizeof(Gene)); for (i = 0; i < num_gene; i++) tmp[i] = (Gene) (i + 1); remainder = num_gene - 1; for (i = 0; i < num_gene; i++) { /* choose value between 0 and remainder inclusive */ next = geqo_randint(root, remainder, 0); /* output that element of the tmp array */ tour[i] = tmp[next]; /* and delete it */ tmp[next] = tmp[remainder]; remainder--; } pfree(tmp); }