1
/*------------------------------------------------------------------------
5
* TSP mutation routines
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"
39
geqo_mutation(Gene *tour, int num_gene)
43
int num_swaps = geqo_randint(num_gene / 3, 0);
49
swap1 = geqo_randint(num_gene - 1, 0);
50
swap2 = geqo_randint(num_gene - 1, 0);
52
while (swap1 == swap2)
53
swap2 = geqo_randint(num_gene - 1, 0);
56
tour[swap1] = tour[swap2];