1 /*------------------------------------------------------------------------
5 * TSP mutation routines
7 * src/backend/optimizer/geqo/geqo_mutation.c
9 *-------------------------------------------------------------------------
13 =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=
14 * Martin Utesch * Institute of Automatic Control *
15 = = University of Mining and Technology =
16 * utesch@aut.tu-freiberg.de * Freiberg, Germany *
17 =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=
20 /* this is adopted from Genitor : */
21 /*************************************************************/
23 /* Copyright (c) 1990 */
24 /* Darrell L. Whitley */
25 /* Computer Science Department */
26 /* Colorado State University */
28 /* Permission is hereby granted to copy all or any part of */
29 /* this program for free distribution. The author's name */
30 /* and this copyright notice must be included in any copy. */
32 /*************************************************************/
35 #include "optimizer/geqo_mutation.h"
36 #include "optimizer/geqo_random.h"
38 #if defined(CX) /* currently used only in CX mode */
41 geqo_mutation(PlannerInfo *root, Gene *tour, int num_gene)
45 int num_swaps = geqo_randint(root, num_gene / 3, 0);
51 swap1 = geqo_randint(root, num_gene - 1, 0);
52 swap2 = geqo_randint(root, num_gene - 1, 0);
54 while (swap1 == swap2)
55 swap2 = geqo_randint(root, num_gene - 1, 0);
58 tour[swap1] = tour[swap2];
66 #endif /* defined(CX) */