55 #if !defined(ERX) && \
61 #error "must choose one GEQO recombination mechanism in geqo.h"
91 int edge_failures = 0;
93 #if defined(CX) || defined(PX) || defined(OX1) || defined(OX2)
102 root->join_search_private = &
private;
103 private.initial_rels = initial_rels;
112 status_interval = 10;
127 elog(
DEBUG1,
"GEQO selected %d pool entries, best %.2f, worst %.2f",
139 elog(
DEBUG2,
"using edge recombination crossover [ERX]");
145 elog(
DEBUG2,
"using partially matched crossover [PMX]");
158 elog(
DEBUG2,
"using position crossover [PX]");
183 for (generation = 0; generation < number_generations; generation++)
203 if (cycle_diffs == 0)
228 if (status_interval && !(generation % status_interval))
229 print_gen(
stdout, pool, generation);
236 #if defined(GEQO_DEBUG)
237 if (edge_failures != 0)
238 elog(
LOG,
"[GEQO] failures: %d, average: %d",
239 edge_failures, (
int) number_generations / edge_failures);
241 elog(
LOG,
"[GEQO] no edge failures detected");
244 (void) edge_failures;
248 #if defined(CX) && defined(GEQO_DEBUG)
250 elog(
LOG,
"[GEQO] mutations: %d, generations: %d",
251 mutations, number_generations);
253 elog(
LOG,
"[GEQO] no mutations processed");
257 print_pool(
stdout, pool, 0, pool_size - 1);
261 elog(
DEBUG1,
"GEQO best is %.2f after %d generations",
262 pool->
data[0].
worth, number_generations);
274 if (best_rel == NULL)
275 elog(
ERROR,
"geqo failed to make a valid plan");
279 print_plan(best_plan,
root);
307 root->join_search_private = NULL;
330 size = pow(2.0, nr_rel + 1.0);
340 return (
int) ceil(
size);
float gimme_edge_table(PlannerInfo *root, Gene *tour1, Gene *tour2, int num_gene, Edge *edge_table)
void free_edge_table(PlannerInfo *root, Edge *edge_table)
int gimme_tour(PlannerInfo *root, Edge *edge_table, Gene *new_gene, int num_gene)
Edge * alloc_edge_table(PlannerInfo *root, int num_gene)
Cost geqo_eval(PlannerInfo *root, Gene *tour, int num_gene)
RelOptInfo * gimme_tree(PlannerInfo *root, Gene *tour, int num_gene)
RelOptInfo * geqo(PlannerInfo *root, int number_of_rels, List *initial_rels)
static int gimme_number_generations(int pool_size)
static int gimme_pool_size(int nr_rel)
double Geqo_selection_bias
void geqo_mutation(PlannerInfo *root, Gene *tour, int num_gene)
void sort_pool(PlannerInfo *root, Pool *pool)
void free_chromo(PlannerInfo *root, Chromosome *chromo)
void free_pool(PlannerInfo *root, Pool *pool)
void random_init_pool(PlannerInfo *root, Pool *pool)
Chromosome * alloc_chromo(PlannerInfo *root, int string_length)
void spread_chromo(PlannerInfo *root, Chromosome *chromo, Pool *pool)
Pool * alloc_pool(PlannerInfo *root, int pool_size, int string_length)
void geqo_set_seed(PlannerInfo *root, double seed)
void free_city_table(PlannerInfo *root, City *city_table)
void pmx(PlannerInfo *root, Gene *tour1, Gene *tour2, Gene *offspring, int num_gene)
void ox1(PlannerInfo *root, Gene *mom, Gene *dad, Gene *offspring, int num_gene, City *city_table)
int cx(PlannerInfo *root, Gene *tour1, Gene *tour2, Gene *offspring, int num_gene, City *city_table)
void ox2(PlannerInfo *root, Gene *mom, Gene *dad, Gene *offspring, int num_gene, City *city_table)
void px(PlannerInfo *root, Gene *tour1, Gene *tour2, Gene *offspring, int num_gene, City *city_table)
City * alloc_city_table(PlannerInfo *root, int num_gene)
void geqo_selection(PlannerInfo *root, Chromosome *momma, Chromosome *daddy, Pool *pool, double bias)
static pg_noinline void Size size