Header And Logo

PostgreSQL
| The world's most advanced open source database.

Functions

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().

{
    int         swap1;
    int         swap2;
    int         num_swaps = geqo_randint(root, num_gene / 3, 0);
    Gene        temp;


    while (num_swaps > 0)
    {
        swap1 = geqo_randint(root, num_gene - 1, 0);
        swap2 = geqo_randint(root, num_gene - 1, 0);

        while (swap1 == swap2)
            swap2 = geqo_randint(root, num_gene - 1, 0);

        temp = tour[swap1];
        tour[swap1] = tour[swap2];
        tour[swap2] = temp;


        num_swaps -= 1;
    }
}