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
40
#include "
optimizer/geqo_mutation.h
"
41
#include "
optimizer/geqo_random.h
"
42
43
void
44
geqo_mutation
(
PlannerInfo
*
root
,
Gene
*
tour
,
int
num_gene
)
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
{
54
swap1
=
geqo_randint
(
root
,
num_gene
- 1, 0);
55
swap2
=
geqo_randint
(
root
,
num_gene
- 1, 0);
56
57
while
(
swap1
==
swap2
)
58
swap2
=
geqo_randint
(
root
,
num_gene
- 1, 0);
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) */
geqo.h
Gene
int Gene
Definition
geqo_gene.h:33
geqo_mutation.h
geqo_mutation
void geqo_mutation(PlannerInfo *root, Gene *tour, int num_gene)
geqo_randint
int geqo_randint(PlannerInfo *root, int upper, int lower)
Definition
geqo_random.c:35
geqo_random.h
postgres.h
fb
static int fb(int x)
Definition
preproc-init.c:92
root
tree ctl root
Definition
radixtree.h:1857
PlannerInfo
Definition
pathnodes.h:303
src
backend
optimizer
geqo
geqo_mutation.c
Generated on Sat May 30 2026 12:13:12 for PostgreSQL Source Code by
1.9.8