PostgreSQL Source Code git master
Loading...
Searching...
No Matches
geqo_mutation.c
Go to the documentation of this file.
1/*------------------------------------------------------------------------
2*
3* geqo_mutation.c
4*
5* TSP mutation routines
6*
7* src/backend/optimizer/geqo/geqo_mutation.c
8*
9*-------------------------------------------------------------------------
10*/
11
12/*
13 * contributed by:
14 * =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=
15 * * Martin Utesch * Institute of Automatic Control *
16 * = = University of Mining and Technology =
17 * * utesch@aut.tu-freiberg.de * Freiberg, Germany *
18 * =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=
19 */
20
21/* this is adopted from Genitor : */
22/*************************************************************/
23/* */
24/* Copyright (c) 1990 */
25/* Darrell L. Whitley */
26/* Computer Science Department */
27/* Colorado State University */
28/* */
29/* Permission is hereby granted to copy all or any part of */
30/* this program for free distribution. The author's name */
31/* and this copyright notice must be included in any copy. */
32/* */
33/*************************************************************/
34
35#include "postgres.h"
36#include "optimizer/geqo.h"
37
38#if defined(CX) /* currently used only in CX mode */
39
42
43void
45{
46 int swap1;
47 int swap2;
48 int num_swaps = geqo_randint(root, num_gene / 3, 0);
49 Gene temp;
50
51
52 while (num_swaps > 0)
53 {
56
57 while (swap1 == swap2)
59
60 temp = tour[swap1];
61 tour[swap1] = tour[swap2];
62 tour[swap2] = temp;
63
64
65 num_swaps -= 1;
66 }
67}
68
69#endif /* defined(CX) */
int Gene
Definition geqo_gene.h:33
void geqo_mutation(PlannerInfo *root, Gene *tour, int num_gene)
int geqo_randint(PlannerInfo *root, int upper, int lower)
Definition geqo_random.c:35
static int fb(int x)
tree ctl root
Definition radixtree.h:1857