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

Go to the source code of this file.

Functions

void geqo_mutation (PlannerInfo *root, Gene *tour, int num_gene)
 

Function Documentation

void geqo_mutation ( PlannerInfo root,
Gene tour,
int  num_gene 
)

Definition at line 39 of file geqo_mutation.c.

References geqo_randint.

Referenced by geqo().

40 {
41  int swap1;
42  int swap2;
43  int num_swaps = geqo_randint(root, num_gene / 3, 0);
44  Gene temp;
45 
46 
47  while (num_swaps > 0)
48  {
49  swap1 = geqo_randint(root, num_gene - 1, 0);
50  swap2 = geqo_randint(root, num_gene - 1, 0);
51 
52  while (swap1 == swap2)
53  swap2 = geqo_randint(root, num_gene - 1, 0);
54 
55  temp = tour[swap1];
56  tour[swap1] = tour[swap2];
57  tour[swap2] = temp;
58 
59 
60  num_swaps -= 1;
61  }
62 }
#define geqo_randint(root, upper, lower)
Definition: geqo_random.h:38
int Gene
Definition: geqo_gene.h:30