1
1
/*------------------------------------------------------------------------
2
2
*
3
3
* geqo_main.c
4
- * solution of the query optimization problem
4
+ * solution to the query optimization problem
5
5
* by means of a Genetic Algorithm (GA)
6
6
*
7
7
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
8
8
* Portions Copyright (c) 1994, Regents of the University of California
9
9
*
10
- * $Id: geqo_main.c,v 1.31 2002/06 /20 20:29:29 momjian Exp $
10
+ * $Id: geqo_main.c,v 1.32 2002/07 /20 04:59:10 momjian Exp $
11
11
*
12
12
*-------------------------------------------------------------------------
13
13
*/
29
29
30
30
#include "optimizer/geqo.h"
31
31
#include "optimizer/geqo_misc.h"
32
+ #include "optimizer/geqo_mutation.h"
32
33
#include "optimizer/geqo_pool.h"
33
34
#include "optimizer/geqo_selection.h"
34
35
@@ -46,7 +47,6 @@ int Geqo_random_seed;
46
47
static int gimme_pool_size (int nr_rel );
47
48
static int gimme_number_generations (int pool_size , int effort );
48
49
49
-
50
50
/* define edge recombination crossover [ERX] per default */
51
51
#if !defined(ERX ) && \
52
52
!defined(PMX ) && \
@@ -120,30 +120,30 @@ geqo(Query *root, int number_of_rels, List *initial_rels)
120
120
daddy = alloc_chromo (pool -> string_length );
121
121
122
122
#if defined (ERX )
123
- elog (LOG , "geqo_main: using edge recombination crossover [ERX]" );
123
+ elog (DEBUG1 , "geqo_main: using edge recombination crossover [ERX]" );
124
124
/* allocate edge table memory */
125
125
edge_table = alloc_edge_table (pool -> string_length );
126
126
#elif defined(PMX )
127
- elog (LOG , "geqo_main: using partially matched crossover [PMX]" );
127
+ elog (DEBUG1 , "geqo_main: using partially matched crossover [PMX]" );
128
128
/* allocate chromosome kid memory */
129
129
kid = alloc_chromo (pool -> string_length );
130
130
#elif defined(CX )
131
- elog (LOG , "geqo_main: using cycle crossover [CX]" );
131
+ elog (DEBUG1 , "geqo_main: using cycle crossover [CX]" );
132
132
/* allocate city table memory */
133
133
kid = alloc_chromo (pool -> string_length );
134
134
city_table = alloc_city_table (pool -> string_length );
135
135
#elif defined(PX )
136
- elog (LOG , "geqo_main: using position crossover [PX]" );
136
+ elog (DEBUG1 , "geqo_main: using position crossover [PX]" );
137
137
/* allocate city table memory */
138
138
kid = alloc_chromo (pool -> string_length );
139
139
city_table = alloc_city_table (pool -> string_length );
140
140
#elif defined(OX1 )
141
- elog (LOG , "geqo_main: using order crossover [OX1]" );
141
+ elog (DEBUG1 , "geqo_main: using order crossover [OX1]" );
142
142
/* allocate city table memory */
143
143
kid = alloc_chromo (pool -> string_length );
144
144
city_table = alloc_city_table (pool -> string_length );
145
145
#elif defined(OX2 )
146
- elog (LOG , "geqo_main: using order crossover [OX2]" );
146
+ elog (DEBUG1 , "geqo_main: using order crossover [OX2]" );
147
147
/* allocate city table memory */
148
148
kid = alloc_chromo (pool -> string_length );
149
149
city_table = alloc_city_table (pool -> string_length );
@@ -155,19 +155,13 @@ geqo(Query *root, int number_of_rels, List *initial_rels)
155
155
156
156
for (generation = 0 ; generation < number_generations ; generation ++ )
157
157
{
158
-
159
- /* SELECTION */
160
- geqo_selection (momma , daddy , pool , Geqo_selection_bias ); /* using linear bias
161
- * function */
162
-
163
-
158
+ /* SELECTION: using linear bias function */
159
+ geqo_selection (momma , daddy , pool , Geqo_selection_bias );
164
160
165
161
#if defined (ERX )
166
162
/* EDGE RECOMBINATION CROSSOVER */
167
163
difference = gimme_edge_table (momma -> string , daddy -> string , pool -> string_length , edge_table );
168
164
169
- /* let the kid grow in momma's womb (storage) for nine months ;-) */
170
- /* sleep(23328000) -- har har har */
171
165
kid = momma ;
172
166
173
167
/* are there any edge failures ? */
@@ -209,7 +203,7 @@ geqo(Query *root, int number_of_rels, List *initial_rels)
209
203
print_gen (stdout , pool , generation );
210
204
#endif
211
205
212
- } /* end of iterative optimization */
206
+ }
213
207
214
208
215
209
#if defined(ERX ) && defined(GEQO_DEBUG )
@@ -289,14 +283,7 @@ gimme_pool_size(int nr_rel)
289
283
double size ;
290
284
291
285
if (Geqo_pool_size != 0 )
292
- {
293
- if (Geqo_pool_size < MIN_GEQO_POOL_SIZE )
294
- return MIN_GEQO_POOL_SIZE ;
295
- else if (Geqo_pool_size > MAX_GEQO_POOL_SIZE )
296
- return MAX_GEQO_POOL_SIZE ;
297
- else
298
- return Geqo_pool_size ;
299
- }
286
+ return Geqo_pool_size ;
300
287
301
288
size = pow (2.0 , nr_rel + 1.0 );
302
289
0 commit comments