Index: src/backend/optimizer/geqo/Makefile =================================================================== RCS file: /var/lib/cvs/pgsql/src/backend/optimizer/geqo/Makefile,v retrieving revision 1.16 diff -c -r1.16 Makefile *** src/backend/optimizer/geqo/Makefile 31 Aug 2000 16:10:08 -0000 1.16 --- src/backend/optimizer/geqo/Makefile 16 Jul 2002 17:27:47 -0000 *************** *** 14,20 **** include $(top_builddir)/src/Makefile.global OBJS = geqo_copy.o geqo_eval.o geqo_main.o geqo_misc.o \ ! geqo_pool.o geqo_recombination.o \ geqo_selection.o \ geqo_erx.o geqo_pmx.o geqo_cx.o geqo_px.o geqo_ox1.o geqo_ox2.o --- 14,20 ---- include $(top_builddir)/src/Makefile.global OBJS = geqo_copy.o geqo_eval.o geqo_main.o geqo_misc.o \ ! geqo_mutation.o geqo_pool.o geqo_recombination.o \ geqo_selection.o \ geqo_erx.o geqo_pmx.o geqo_cx.o geqo_px.o geqo_ox1.o geqo_ox2.o Index: src/backend/optimizer/geqo/geqo_main.c =================================================================== RCS file: /var/lib/cvs/pgsql/src/backend/optimizer/geqo/geqo_main.c,v retrieving revision 1.31 diff -c -r1.31 geqo_main.c *** src/backend/optimizer/geqo/geqo_main.c 20 Jun 2002 20:29:29 -0000 1.31 --- src/backend/optimizer/geqo/geqo_main.c 16 Jul 2002 17:27:47 -0000 *************** *** 1,7 **** /*------------------------------------------------------------------------ * * geqo_main.c ! * solution of the query optimization problem * by means of a Genetic Algorithm (GA) * * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group --- 1,7 ---- /*------------------------------------------------------------------------ * * geqo_main.c ! * solution to the query optimization problem * by means of a Genetic Algorithm (GA) * * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group *************** *** 29,34 **** --- 29,35 ---- #include "optimizer/geqo.h" #include "optimizer/geqo_misc.h" + #include "optimizer/geqo_mutation.h" #include "optimizer/geqo_pool.h" #include "optimizer/geqo_selection.h" *************** *** 46,52 **** static int gimme_pool_size(int nr_rel); static int gimme_number_generations(int pool_size, int effort); - /* define edge recombination crossover [ERX] per default */ #if !defined(ERX) && \ !defined(PMX) && \ --- 47,52 ---- *************** *** 120,149 **** daddy = alloc_chromo(pool->string_length); #if defined (ERX) ! elog(LOG, "geqo_main: using edge recombination crossover [ERX]"); /* allocate edge table memory */ edge_table = alloc_edge_table(pool->string_length); #elif defined(PMX) ! elog(LOG, "geqo_main: using partially matched crossover [PMX]"); /* allocate chromosome kid memory */ kid = alloc_chromo(pool->string_length); #elif defined(CX) ! elog(LOG, "geqo_main: using cycle crossover [CX]"); /* allocate city table memory */ kid = alloc_chromo(pool->string_length); city_table = alloc_city_table(pool->string_length); #elif defined(PX) ! elog(LOG, "geqo_main: using position crossover [PX]"); /* allocate city table memory */ kid = alloc_chromo(pool->string_length); city_table = alloc_city_table(pool->string_length); #elif defined(OX1) ! elog(LOG, "geqo_main: using order crossover [OX1]"); /* allocate city table memory */ kid = alloc_chromo(pool->string_length); city_table = alloc_city_table(pool->string_length); #elif defined(OX2) ! elog(LOG, "geqo_main: using order crossover [OX2]"); /* allocate city table memory */ kid = alloc_chromo(pool->string_length); city_table = alloc_city_table(pool->string_length); --- 120,149 ---- daddy = alloc_chromo(pool->string_length); #if defined (ERX) ! elog(DEBUG1, "geqo_main: using edge recombination crossover [ERX]"); /* allocate edge table memory */ edge_table = alloc_edge_table(pool->string_length); #elif defined(PMX) ! elog(DEBUG1, "geqo_main: using partially matched crossover [PMX]"); /* allocate chromosome kid memory */ kid = alloc_chromo(pool->string_length); #elif defined(CX) ! elog(DEBUG1, "geqo_main: using cycle crossover [CX]"); /* allocate city table memory */ kid = alloc_chromo(pool->string_length); city_table = alloc_city_table(pool->string_length); #elif defined(PX) ! elog(DEBUG1, "geqo_main: using position crossover [PX]"); /* allocate city table memory */ kid = alloc_chromo(pool->string_length); city_table = alloc_city_table(pool->string_length); #elif defined(OX1) ! elog(DEBUG1, "geqo_main: using order crossover [OX1]"); /* allocate city table memory */ kid = alloc_chromo(pool->string_length); city_table = alloc_city_table(pool->string_length); #elif defined(OX2) ! elog(DEBUG1, "geqo_main: using order crossover [OX2]"); /* allocate city table memory */ kid = alloc_chromo(pool->string_length); city_table = alloc_city_table(pool->string_length); *************** *** 155,173 **** for (generation = 0; generation < number_generations; generation++) { ! ! /* SELECTION */ ! geqo_selection(momma, daddy, pool, Geqo_selection_bias); /* using linear bias ! * function */ ! ! #if defined (ERX) /* EDGE RECOMBINATION CROSSOVER */ difference = gimme_edge_table(momma->string, daddy->string, pool->string_length, edge_table); - /* let the kid grow in momma's womb (storage) for nine months ;-) */ - /* sleep(23328000) -- har har har */ kid = momma; /* are there any edge failures ? */ --- 155,167 ---- for (generation = 0; generation < number_generations; generation++) { ! /* SELECTION: using linear bias function */ ! geqo_selection(momma, daddy, pool, Geqo_selection_bias); #if defined (ERX) /* EDGE RECOMBINATION CROSSOVER */ difference = gimme_edge_table(momma->string, daddy->string, pool->string_length, edge_table); kid = momma; /* are there any edge failures ? */ *************** *** 209,215 **** print_gen(stdout, pool, generation); #endif ! } /* end of iterative optimization */ #if defined(ERX) && defined(GEQO_DEBUG) --- 203,209 ---- print_gen(stdout, pool, generation); #endif ! } #if defined(ERX) && defined(GEQO_DEBUG) *************** *** 289,302 **** double size; if (Geqo_pool_size != 0) ! { ! if (Geqo_pool_size < MIN_GEQO_POOL_SIZE) ! return MIN_GEQO_POOL_SIZE; ! else if (Geqo_pool_size > MAX_GEQO_POOL_SIZE) ! return MAX_GEQO_POOL_SIZE; ! else ! return Geqo_pool_size; ! } size = pow(2.0, nr_rel + 1.0); --- 283,289 ---- double size; if (Geqo_pool_size != 0) ! return Geqo_pool_size; size = pow(2.0, nr_rel + 1.0); Index: src/backend/optimizer/geqo/geqo_misc.c =================================================================== RCS file: /var/lib/cvs/pgsql/src/backend/optimizer/geqo/geqo_misc.c,v retrieving revision 1.32 diff -c -r1.32 geqo_misc.c *** src/backend/optimizer/geqo/geqo_misc.c 20 Jun 2002 20:29:29 -0000 1.32 --- src/backend/optimizer/geqo/geqo_misc.c 16 Jul 2002 17:27:47 -0000 *************** *** 26,31 **** --- 26,32 ---- #include "optimizer/geqo_misc.h" #include "nodes/print.h" + #ifdef GEQO_DEBUG static float avg_pool(Pool *pool); *************** *** 92,98 **** lowest = pool->size > 1 ? pool->size - 2 : 0; fprintf(fp, ! "%5d | Bst: %f Wst: %f Mean: %f Avg: %f\n", generation, pool->data[0].worth, pool->data[lowest].worth, --- 93,99 ---- lowest = pool->size > 1 ? pool->size - 2 : 0; fprintf(fp, ! "%5d | Best: %f Worst: %f Mean: %f Avg: %f\n", generation, pool->data[0].worth, pool->data[lowest].worth, *************** *** 248,250 **** --- 249,253 ---- printf("\n\tcheapest total path:\n"); geqo_print_path(root, rel->cheapest_total_path, 1); } + + #endif /* GEQO_DEBUG */ Index: src/include/optimizer/geqo.h =================================================================== RCS file: /var/lib/cvs/pgsql/src/include/optimizer/geqo.h,v retrieving revision 1.28 diff -c -r1.28 geqo.h *** src/include/optimizer/geqo.h 20 Jun 2002 20:29:51 -0000 1.28 --- src/include/optimizer/geqo.h 16 Jul 2002 17:27:51 -0000 *************** *** 28,34 **** /* GEQO debug flag */ /* #define GEQO_DEBUG ! */ /* recombination mechanism */ /* --- 28,34 ---- /* GEQO debug flag */ /* #define GEQO_DEBUG ! */ /* recombination mechanism */ /* Index: src/include/optimizer/geqo_misc.h =================================================================== RCS file: /var/lib/cvs/pgsql/src/include/optimizer/geqo_misc.h,v retrieving revision 1.19 diff -c -r1.19 geqo_misc.h *** src/include/optimizer/geqo_misc.h 20 Jun 2002 20:29:51 -0000 1.19 --- src/include/optimizer/geqo_misc.h 16 Jul 2002 17:27:51 -0000 *************** *** 22,30 **** --- 22,33 ---- #ifndef GEQO_MISC_H #define GEQO_MISC_H + #include "optimizer/geqo.h" #include "optimizer/geqo_recombination.h" #include "nodes/relation.h" + #ifdef GEQO_DEBUG + extern void print_pool(FILE *fp, Pool *pool, int start, int stop); extern void print_gen(FILE *fp, Pool *pool, int generation); extern void print_edge_table(FILE *fp, Edge *edge_table, int num_gene); *************** *** 33,36 **** extern void geqo_print_path(Query *root, Path *path, int indent); extern void geqo_print_joinclauses(Query *root, List *clauses); ! #endif /* GEQO_MISC_H */ --- 36,41 ---- extern void geqo_print_path(Query *root, Path *path, int indent); extern void geqo_print_joinclauses(Query *root, List *clauses); ! #endif /* GEQO_DEBUG */ ! ! #endif /* GEQO_MISC_H */