An evolutionary approach to the traveling salesman problem

Biological
Cybernetics
Biol. Cybern. 60,139-144 (1988)
9 Springer-Verlag 1988
An Evolutionary Approach to the Traveling Salesman Problem
D. B. Fogel
ORINCON Corporation, 9363 Towne Centre Dr., San Diego, CA 92121, USA
Abstract. Evolutionary optimization has been proposed as a method to generate machine learning
through automated discovery. A simulation of natural
evolution is conducted using the traveling salesman
problem as an artificial environment. For an exact
solution of a traveling salesman problem, the only
known algorithms require the number of steps to grow
at least exponentially with the number of elements in
the problem. Three adaptive techniques are described
and analyzed. Evolutionary adaptation is demonstrated to be worthwhile in a variety of contexts. Local
stagnation is prevented by allowing for the probabilistic survival of the simulated organisms. In complex
problems, the final routing is estimated to be better
than 99.99999999999% of all possible tours, even
though only a small fraction (8.58 x 10-151) of the total
number of tours are examined.
1 Introduction
The optimization of the traveling salesman problem
continues to receive attention for three reasons: (1) its
solution is computationally difficult although the
problem itself is easily expressed, (2) it is broadly
applicable to a variety of engineering problems, and
(3) it has become somewhat of a comparison "benchmark" problem. The task is to arrange a tour of n cities
such that each city is visited only once and the length of
the tour (or some other cost function) is minimized. For
an exact solution, the only known algorithms require
the number of steps to grow at least exponentially with
the number of elements in the problem. Brute force
methods for finding the shortest path by which a
traveling salesman can complete a tour of n cities
require compiling a list of (n - 1)!/2 alternative tours, a
number that grows faster than any finite power of n.
The task quickly becomes unmanageable.
A large volume of literature has been devoted to the
traveling salesman problem (e.g. Christofides 1976;
Karp 1977; Bonomi and Lutton 1984; Golden and
Skiscim 1986; and many others). Most suggested
techniques use heuristics or simulated annealing. This
paper explores approaches based on evolutionary
optimization.
2 Background
Goldberg and Lingle (1985) and Grefenstette et al.
(1985) have addressed the traveling salesman problem
through the use of the genetic algorithm proposed by
Holland (1975). This algorithm is a derivative of the
Evolutionary Programming concept offered by Fogel
(1962, 1964; Fogel et al. 1966). Holland likens the
actual code being mutated to that of the genetic code
that defines a natural organism. While Fogel et al.
(1966) used a variety of "background" mutations,
Holland specifically mimics the operations of biological gene crossover and inversion.
Goldberg and Lingle (1985) suggested a new type of
crossover operator, the "partially-mapped crossover
(PMX)," which they believe will lead to a more efficient
solution of the traveling salesman problem. PMX
proceeds as follows: consider two possible codings of a
tour of eight cities, A 1 and A 2, a return to the initial city
being implicit:
Ax:
3 5 1 27 6 8 4
A2: 1 8 5 4 3 6 2 7.
Two positions are determined randomly along the A1
coding. The actual cities located between these positions along A 1 are exchanged with the cities between
the same positions along A 2. For example, if the
positions three and five are chosen, the sub-coding
along A 1 1-2-7, and the sub-coding along A 2 is 5-4-3.
140
Each of these cities is then exchanged, leading to the
new tours, A*x and A*2:
A*I:
7 1 5 4 3 6 8 2
A*2:
5 8 1 2 7 6 4 3.
Goldberg and Lingle reported two experiments on ten
cities where the P M X operator enabled the search to
efficiently discover either the absolute or near optimum solution.
Grefenstette et al. (1985) have also addressed the
traveling salesman problem using Holland's "simple
crossover." This required the formation of a special
coding structure. Using the crossover operator on two
valid tours could result in an offspring that was not a
valid tour. As Dewdney (1985) has commented, the
authors' method for devising the appropriate coding
was ingenious.
"The representation for a five-city tour such as
a,c,e,d,b turns out to be 12321. To obtain such a
numerical string reference is made to some standard
order for the cities, say, a, b, c, d, e. Given a tour such as
a, c, e, d, b, systematically remove cities from the standard list in the order of the given tour: remove a, then c,
e, and so on. As each city is removed from the special
list, note its position just before removal, a is first, c is
second, e is third, d is second, and, finally, b is first.
Hence the chromosome 12321 emerges. Interestingly,
when two such chromosomes are crossed over, the
result is always a tour."
Grefenstette et al. rejected this mutation operation
noting that the results provided by this ordinal representation performed no better than a random search in
most cases (Grefenstette et al. 1985).
Instead, they explored the use of a heuristic crossover operation. "This operator constructs an offspring
from two parent tours as follows: Pick a random city as
the starting point for the child's tour. Compare the two
edges leaving the starting city in the parents and
choose the shorter edge. Continue to extend the partial
tour by choosing the shorter of the two edges in the
parents which extend the tour. If the shorter parental
edge would introduce a cycle into the partial tour, then
extend the tour by a random edge. Continue until a
complete tour is generated" (Grefenstette et al. 1985).
In several experiments containing a large number of
cities, this heuristic crossover outperformed the previously outlined method.
But heuristic crossover is somewhat analogous to
evaluating the worth of sections of the DNA molecule
before transcription. This does not take place in
natural evolution. Random mutation is just that.
Sexual recombination sorts out slightly varying alleles
in a predetermined manner without regard to the code
undergoing transcription. While the use of a heuristic
crossover operation may lead to improved optimization in some problems, it is essentially an incorporation of the greedy algorithm into evolutionary optimization and may therefore limit robustness.
That Grefenstette et al. achieved no better than a
random search when mutating and selecting between
tours under an ordinal representation is most interesting. It is asserted here that the traveling salesman
problem is difficult to address using Holland's crossover mutation. The crossover operation, as defined by
Holland, does not actually mimic the biological crossover of genes. Natural crossover is a phenomenon
where "old linkages between genes on homologous
chromosomes are broken and new linkages are established. Genes that reside on the same chromosome
and move together are said to be 'linked.' A linkage
group is any group of genes physically linked on one
chromosome .... Changes in linkage groups are not
truly mutations, however, since neither the amount nor
the function of genetic material is altered" (Levy 1982).
Holland's crossover treats the entire tour as a
chromosome and each city in a tour somewhat as a
gene. While this does not change the amount of coding,
it can significantly alter the function of the coding. The
result of Holland's crossover is therefore a near
random search throughout the entire space of possible
tours. As the number of cities grows larger, Holland's
crossover significantly reduces the link between each
parent and its offspring. Schemes incorporating adaptation must retain previous advances and incorporate
them into future solutions.
3 An Alternative Evolutionary Approach
The proposed alternative method does not include the
specific genetic-mimicking operators that Holland has
suggested, but instead emphasizes the behavioral appropriateness (fitness) of the evolved trial solutions.
The algorithm, which is roughly equivalent to
L. Fogel's Evolutionary Programming restricted to
single state machines, only performs a slight mutation
of the existing tours (which are initially chosen at
random from all possible tours) by removing just one
city from a given list and replacing it in a different
randomly chosen position. This mutation is only
mildly more complicated than the simplest possible
mutation, that is, swapping adjacent cities. It is less
complex than either the PMX operator or the modified
crossover operator suggested by Grefenstette et al.;
through multiple mutation, this single alteration can
be made equivalent to either of these crossover
operators. Holland (1975) has stated: "If successive
populations are produced by mutation alone [without
(genetic) reproduction], the result is a random sequence of structures drawn from (all possible strue-
141
tures)." This is only partially correct. The adaptative
algorithm proposed here does result in a random
search, but only in that portion of the space relatively
close to the parents which generate offspring. This
dramatically increases the effectiveness of the search
through the state space of all possible constructions.
In natural evolution, survival is probabilistic.
Those organisms that possess an advantage have a
superior chance to survive. Survival is not guaranteed.
To simulate this effect, provisions are made to occasionally allow for the survival of offspring that are
slightly worse than their parents. What results is
analogous to the searching of a maze; when a dead-end
is reached some backtracking is allowed and the
overall search is reinitiated.
Unfortunately, the topography is much like an
upside-down bed of nails, with some nails being longer
(better) than others. From any given nail, it is possible
to travel to n(n- 1) other nails in a single mutation by
randomly choosing a city and placing it in a different
position. Unlike a maze, when the evolving phyletic
line reaches a non-optimal nail from which no single
mutation results in a better tour, it is impossible to
determine the "direction" in which to backtrack. The
complete prevention of evolutionary stagnation will
always be impossible unless all inheritance is given up
and the search made completely random.
Specifically, the evolutionary procedure is conducted as follows. An initial population of 50 "parent"
tours is taken at random and scored with respect to
their Euclidean length. Offspring are then generated
through random mutation of each parent by choosing
a city in the parent's list and replacing it in a different,
randomly chosen position. These offspring are scored
in a similar manner to the parents. Competition for
survival then takes place. Each tour faces direct
competition against 10% of the other tours in the
population with the probability of attaining a "win" in
each encounter being equal to the opponent's tour
length divided by the sum of the two competing tour
lengths. For example, if a tour with length 1000
competes with a tour of length 2000, the probability of
the first tour obtaining a win is 2000/(2000+1000)
= 2/3. Those tours with the most wins are selected to
become parents of the next generation. Further, in
natural evolution the available finite resources become
increasingly scarce as time proceeds. To simulate this,
the population size is made to decrease linearly over
time at a rate of one tour per 5000 evaluated offspring.
square of perimeter 160 units, the optimum tour
length. In each trial, the optimum solution was discovered after evaluating an average of 4391.2 offspring. This represents 6.716• 10 -7 of all possible
tours.
Another experiment required a tour of 50 uniformly distributed cities. The evolutionary process was
allowed to generate 200,000 offspring. The best surviving tour (Fig. 1) had a length of 596.75 units. Figure 2
indicates the evolutionary improvement over time.
While the optimization appears to have stagnated after
0 I..i.
,i..i-...
0
.5 10 15
20
"l''l'',''
25 30 35
,'','.l-.I.-,',l....-,..I..,--i,-i-....
40 45 50 55 60 65 70 75
80
85
90
95
100 105
X
Fig. I. Fiftycity traveling salesman problem - final routing
2250"
2000"
1750'
1500'
looo
75o
500"
2511"
4 Experimental Findings
Experiments were performed to estimate the effectiveness of the proposed algorithm. Initially, 10 trials
required a tour of 16 cities uniformly placed on a
0
-i
. . . . . . . . .
50000
, . . . . . . . . .
100000
Number
, . . . . . . . . .
150000
of Offspring
Fig. 2. Evolutionaryoptimization- fiftycity problem
,
200000
142
600
length tour when cities are uniformly distributed. This
measure is useful on the average, but does not appear
well suited for judging a given route in any specific
problem. However, quality can be assessed when the
distribution of the ( n - 1 ) ! / 2 tour lengths is approximated. An experiment was performed in this regard.
Ten 100 city problems were addressed wherein the
cities were randomly distributed for each trial. The
evolutionary program evaluated 400,000 offspring in
each trial and the average best tour length over the ten
trials was 966.7602. A computer program was written
to sample 2500 tours at random for each trial and
found an estimated average tour length of 5118.2538
[an average error of 4369.2538 using the expected
optimum length derived from Bonomi and Lutton
(1984)] with an estimated standard deviation of
544.66098. Using a normal approximation to the error
distribution of the tour lengths, the average evolved
solution is 7.6222a below the mean. Thus, the mean
best tour discovered by the algorithm was superior to
99.99999999999% of the possible tours, this after
evaluating 8.58 x 10-151 of the total number of tours.
Figure 4 indicates the average rate of optimization.
An additional set of experiments was conducted to
compare the algorithm directly to the PMX operation.
No comparison was made to the modified crossover of
Grefenstette et al. because it was presumed after
reviewing both publications that the P M X operation
599
~
598
596
~5
.......
, .........
, .........
160000
1~0~
170000
, .........
180000
j .........
,
190000
200000
Number of Offspring
Fig. 3. Evolutionary optimization after 150,000 offspring
120,000 offspring, Fig. 3 indicates improvements were
being made through 180,000 offspring with no reason
to believe further optimization could not take place.
The learning ability of the algorithm was generally
logarithmic. However, the quality of the resulting tours
remains to be determined. Bonomi and Lutton (1984)
have offered a formula for the expected minimum
4000
Z
0
25oo
Z
2ooo
1500
I0~)
5~)
I
51~00
|
I
10130~)
I
15130130
i
20~3~)
i
2.q]~)O
i
I
300~)0
35OOOO
N U M B E R OF E V A L U A T E D O F F S P R I N G
I
~
I
45OOO0
Fig. 4. Evolutionary
optimization one hundred
city problem. Average of ten
trials
143
would yield superior results. Here, 100 cities were
distributed at random and 30 trials were performed
using both methods. The cities were redistributed for
each trial to minimize the effect of an unusual set of
cities. Each algorithm was allowed to generate 20,000
offspring. The population size for the PMX operation
was 100 tours. The results were:
Proposed Algorithm
PMX
x = 2667.3 units
x = 4319.5 units
s = 88.0 units
s = 165.8 units,
5 Conclusions
where x is the average tour length of the thirty trials
and s is the standard deviation of the sample.
As mentioned previously, the PMX operation does
not retain sufficient information between parent and
offspring to perform effectively. The PMX operation is
roughly equivalent to swapping a random number of
cities in a single tour. The number of cities to be
swapped is equal to the length of the section of the tour
chosen at random. The expected number and variability of swaps per mutation are indicated in Figs. 5 and
6. In relatively small problems, on the order of ten
35
Number of Swaps
30
25
20
15
10
5
nl . . . . , . . . . , . . . .
20
30
10
, .... , .... , .... , .... i .
40
50
60
70
80
. . .
I
. . . .
90
100
Number of Cities
Fig. 5. Expected swaps using PMX operation
Number of Swaps
600
500
400
300
200
I
1O0
10
20
30
40
50
Number
Fig.
60
70
cities, the operation averages about three swaps with
minimal variance. In larger problems, however, such as
the 100 city problem performed here, the operation
averages more than 33 swaps per mutation with a
rather high variance. This effectively prevents the
required link between generations.
80
90
1O0
of Cities
6. Variance of expected swaps using P M X operation
Successful adaptation does not require sophisticated
mutations. In an evolutionary scheme only the
"behavior" of a coding structure is scored; the code
itself is basically irrelevant. The bottom-up view that
would emphasize phenomenological mutational operations as the key to adaptative plans is an improper
perspective. Competition occurs not between coding
structures but between expressed behaviors. The particular structure of the code is generally unimportant.
In fact, sophisticated mutation operations can be
detrimental. For adaptation to succeed, a sufficient
link between parent and offspring must be maintained.
When this link is destroyed the results can be worse
than a random search of all possible coding structures.
Because the coding for the traveling salesman's tour is
not analogous to an organism's chromosome, operations mimicking biological crossover are unsuitable.
In general, little emphasis should be placed on specific
mutation operations. It is the mutation and selection of
behavior that is important, not the structure of the
code.
Even when the state space of possible solutions is
immense, evolutionary optimization can discover
near-optimum solutions after examining an extremely
small fraction of possible solutions. While simulated
evolution discovered sub-optimum tours in complex
problems, evolution never requires that the global
optimum solution be discovered. The evolving tours
were not in competition with the true solution, only
with each other. Selection acts only on those solutions
actually in the competition.
In the reported experiments, the evolutionary
algorithm was given no knowledge about the problem
itself. It was only given information about the relative
worth of its proposed solutions. Despite this, it discovered exceedingly appropriate behavior in the context of the given criterion. This suggests that it may be
useful for addressing traveling salesman-like problems
that are unusually constrained, where heuristic procedures are unavailable or lead to unsatisfactory solutions. Further, the parallel nature of the evolutionary
algorithm indicates its suitability for distributed processing machines.
Acknowledgements. The author would like to thank L. J. Fogel,
J. W. Atmar, M. O'Hagan, T. Brotherton, V.W.Porto,
144
V. J. Buonassisi, ORINCON Corporation, and the referee for
their helpful comments, suggestions, and resources.
References
Bonomi E, Lutton J-L (1984) The N-City traveling salesman
problem: statistical mechanics and the metropolis algorithm.
SIAM Rev 26:551 568
Christofides N (1976) Worst-case analysis of a new heuristic for
the traveling salesman problem. Report 388, Graduate
School of Industrial Administration, Carnegie Mellon
University
Dewdney AK (1985) Computer recreations: exploring the field of
genetic algorithms in a primordial computer sea full of flibs.
Sci Am 253:21-31
Fogel LJ (1962) Atonomous automata. Ind Res 4:14-19
Fogel LJ (1964) On the organization of intellect. Ph.D. Dissertation, UCLA
Fogel LJ, Owens AJ, Walsh MJ (1966) Artificial intelligence
through simulated evolution. Wiley, New York
Goldberg DE, Lingle R (1985) Alleles, loci, and the traveling
salesman problem. In: Grefenstette JJ (ed) Proceedings of an
International Conference on Genetic Algorithms and Their
Applications. Carnegie-Mellon University, pp 154-159
Golden BL, Skiscim CC (1986) Using simulated annealing to
solve routing and location problems. Nav Res Log Q
33:261-279
Grefenstette JJ, Gopal R, Rosmaita B, Van Gucht D (1985)
Genetic algorithms for the traveling salesman problem. In:
Grefenstette JJ (ed) Proceedings of an International Conference on Genetic Algorithms and Their Applications.
Carnegie-Mellon University, pp 16(~168
Holland JH (1975) Adaptation in natural and artificial systems.
University of Michigan Press, Ann Arbor, Mich
Karp RM (1977) Probabilistic analysis of partitioning algorithms for the traveling Salesman problems in the plane.
Math Oper Res 2:209-224
Levy CK (1982) Elements of biology (3rd). Addison-Wesley,
Reading, Mass
Received: February 3, 1988
Mr. David B. Fogel
ORINCON Corporation
9363 Towne Centre Dr.
San Diego, CA 92121
USA