PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
geqo_selection.h File Reference
#include "optimizer/geqo.h"
Include dependency graph for geqo_selection.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.


void geqo_selection (PlannerInfo *root, Chromosome *momma, Chromosome *daddy, Pool *pool, double bias)

Function Documentation

void geqo_selection ( PlannerInfo root,
Chromosome momma,
Chromosome daddy,
Pool pool,
double  bias 

Definition at line 54 of file geqo_selection.c.

References Pool::data, geqo_copy(), linear_rand(), Pool::size, and Pool::string_length.

Referenced by geqo().

56 {
57  int first,
58  second;
60  first = linear_rand(root, pool->size, bias);
61  second = linear_rand(root, pool->size, bias);
63  /*
64  * Ensure we have selected different genes, except if pool size is only
65  * one, when we can't.
66  *
67  * This code was observed to hang up in an infinite loop when the
68  * platform's implementation of erand48() was broken. We now always use
69  * our own version.
70  */
71  if (pool->size > 1)
72  {
73  while (first == second)
74  second = linear_rand(root, pool->size, bias);
75  }
77  geqo_copy(root, momma, &pool->data[first], pool->string_length);
78  geqo_copy(root, daddy, &pool->data[second], pool->string_length);
79 }
int size
Definition: geqo_gene.h:41
static int linear_rand(PlannerInfo *root, int max, double bias)
int string_length
Definition: geqo_gene.h:42
void geqo_copy(PlannerInfo *root, Chromosome *chromo1, Chromosome *chromo2, int string_length)
Definition: geqo_copy.c:45
Chromosome * data
Definition: geqo_gene.h:40