# the traveling salesman problem

Document Sample

```					          the traveling salesman problem                                           •   Choose the vertex before last lexicographically, in such a way
that is does not appear earlier than the second vertex in the
Input:   A complete graph (Kn ) with non-negative costs associated                     alphabet.
with the edges.
•   The intermediate vertices are now chosen by considering all
Output:    All the cycles of minimal cost (some algorithms return one                  permutations of the remaining vertices, permutations which
minimal cost cycle instead of all of them).                                     must be enumerated in lexicographic order.

Brute force algorithm: enumeration of all (essen-
tially) distinct hamiltonian cycles
Homework questions
Reading the discussion of the traveling salesman problem in        Rosen        Here are the questions to be answered in this homework (with the
9.6 (p. 653655)/8.6 (p. 599601)/N.D. may be helpful.                        exception of the very last ones):
Each permutation of the vertices of          Kn   corresponds to an hamil-
Solve the traveling salesman problem for the valued complete graph
tonian graph (repeating the rst vertex at the end).          There are     n
described by the given table of costs, given that the traveling sales-
vertices; this gives, in principle,   n!   permutations to be considered.
man lives at the given city. Give:
However, we can choose the start vertex any way we want (in the
following problems, I want you to choose the city of residence of the              •   the number of essentially distinct hamiltonian cycles;
traveling salesman). Fixing the start vertex reduces to      (n − 1)! the
number of permutations to consider.                                                •   a table giving every hamiltonian cycle which we must consider;

Furthermore, by reversing the direction of the cycle if necessary, we
•   for every one of these hamiltonian cycle, enough edge costs to
can always x things so that the second vertex of the cycle come
determine whether the cycle is (one of ) the cheapest ones so
before the one before last in lexicographic order. This divides the
far;
2:
number of hamiltonian cycles to consider by
The number of hamiltonian circuits of Kn which are essen-                          •   the cost of every best so far hamiltonian cycle;
tially distinct is (n − 1)!/2.
Here is a systematic way of enumerating all the hamiltonian circuits
•   all the least cost itineraries for the traveling salesman.

which start and end at a given vertex, and which satisfy the above
Note that although itineraries must start and end at the city of
lexicographic condition:
residence, they do not necessarily need to satisfy the second visited
before last visited condition, since as far as the traveling salesman
•   The rst (= last) vertex is xed;
is concerned both directions are a priori equally acceptable.

•   Choose the second vertex lexicographically;
Problem 1:     The traveling salesman lives at D.

the traveling salesman problem                                                                                                                      1
\$                                                              Comment 1:        The total cost is larger than the smallest one so far,
{D, G}   147                                                             and consequently can be omitted (if you put it down, it's OK too).
{D, K}   135                                                             Comment 2:        The cost of this cycle,     682,   is larger than   576,   and
{D, S}    98                                                             consequently can be omitted. Actually, the four rst costs are enough
{D, T}    58                                                             to realize that, so they are sucient. But if you ll the line com-
{G, K}    56                                                             pletely, this is also ne.
{G, S}   113                                                             Comment 4:        The cost of this cycle is larger than      540,   and conse-
{G, T}   167                                                             quently can be omitted.
{K, S}   137                                                             Comment 5:        The cost of this cycle is   610 > 504,    and consequently
{K, T}   133                                                             can be omitted.
{S, T}   142                                                             Comment 6:        The total cost,   516,   is larger than   458,    and conse-
Answer:                                                                   quently can be omitted.

(n − 1)!   4!   24
2
=
2
=
2
= 12.                           Problem 2:     The traveling salesman lives at L
\$
Comment :       Five cities are involved: D, G, K, S and T. Conse-         {D, G}    3
quently, the valued graph which corresponds to this problem is a   K5 .    {D, L}    1
D,G,S,T,K,D :     147 + 113 + 142 + 133 + 135 = 670                      {D, S}    6
D,G,T,S,K,D :     147 + 167 + 142 + 137 + 135       Comment 1            {D, U}    3
D,G,K,T,S,D :     147 + 56 + 133 + 142 + 98 = 576                        {G, L}    4
D,G,T,K,S,D :     147 + 167 + 133 + 137...          Comment 2            {G, S}    4
D,G,K,S,T,D :     540                                                    {G, U}    1
D,G,S,K,T,D :                                          Comment 4         {L, S}    2
D,K,G,T,S,D :                                          Comment 4         {L, U}    1
D,K,T,G,S,D :                                          Comment 4         {S, U}    7
D,K,G,S,T,D :     504                                                   Answer:
D,K,S,G,T,D :                                          Comment 5
D,S,G,K,T,D :     458                                                                           (n − 1)!   4!   24
=    =    = 12.
D,S,K,G,T,D :                                          Comment 6                                   2       2     2
Minimal itineraries:      D,S,G,K,T,D   and   D,T,K,G,S,D .
In the present graph, we pretty much have to compute all
the sums in order to know whether we have found a cheap
circuit. So, edge costs are almost never omitted.

the traveling salesman problem                                                                                                                           2
L,D,S,U,G,L :    1 + 6 + 7 + 1 + 4 = 19                                        \$
L,D,U,S,G,L :    1 + 3 + 7 + 4 + 4 = 19                             {A, G}     2
L,D,G,U,S,L :    1 + 3 + 1 + 7 + 2 = 14                             {A, L}     8
L,D,U,G,S,L :    1 + 3 + 1 + 4 + 2 = 11                              {A, S}    2
L,D,G,S,U,L :    1 + 3 + 4 + 7...                                   {A, W}     8
L,D,S,G,U,L :    1 + 6 + 4...                                       {G, L}     2
L,G,D,U,S,L :    4 + 3 + 3...                                       {G, S}     2
L,G,U,D,S,L :    4 + 1 + 3 + 6...                                   {G, W}    11
L,G,D,S,U,L :    4 + 3 + 6...                                        {L, S}    2
L,G,S,D,U,L :    4 + 4 + 6...                                       {L, W}     7
L,S,D,G,U,L :    2 + 6 + 3...                                       {S, W}     7
L,S,G,D,U,L :    2 + 4 + 3 + 3...                                  Answer:
Minimal itineraries:    L,D,U,G,S,L   and   L,S,G,U,D,L .                                    (n − 1)!      4!    24
=    =     = 12.
Comment :    Again, many of the numbers written above can be omit-                               2         2      2
ted. Here is an acceptably terse version of the above table:
W,A,L,S,G,W :        8 + 8 + 2 + 2 + 11 = 32
L,D,S,U,G,L :    19                                                  W,A,S,L,G,W :        8 + 2 + 2 + 2 + 11 = 25
L,D,U,S,G,L :    19                                                  W,A,G,S,L,W :        8 + 2 + 2 + 2 + 7 = 21
L,D,G,U,S,L :    14                                                  W,A,S,G,L,W :        8 + 2 + 2 + 2 + 7 = 21
L,D,U,G,S,L :    11                                                  W,A,G,L,S,W :        8 + 2 + 2 + 2 + 7 = 21
L,D,G,S,U,L :                                                        W,A,L,G,S,W :        8 + 8...                    Comment 1
L,D,S,G,U,L :                                                        W,G,A,S,L,W :        11 + 7 . . .                Comment 2
L,G,D,U,S,L :                                                        W,G,S,A,L,W :        11 + 2 + 2 + 8 . . .
L,G,U,D,S,L :                                                        W,G,A,L,S,W :        11 + 2 + 8 . . .
L,G,D,S,U,L :                                                        W,G,L,A,S,W :        11 + 2 + 8 . . .
L,G,S,D,U,L :                                                        W,L,A,G,S,W :        7+8+2+2+7
L,S,D,G,U,L :                                                        W,L,G,A,S,W :        7 + 2 + 2 + 2 + 7 = 20
L,S,G,D,U,L :
Minimal itineraries:     W,L,G,A,S,W      and   W,S,A,G,L,W .

Problem 3:    The traveling salesman lives at W.                     Comment 1:      We know immediately that this can't be a minimal
cycle because every edge costs at least   2 and we    must add to   16   the
cost of three edges, which gives at least  22 > 21.
Comment 2:      We know immediately that this can't be a minimal
cycle because every edge costs at least   2 and we    must add to   18   the
cost of three edges, which gives at least  24 > 21.

the traveling salesman problem                                                                                                                 3
Problem 5:    For how many essentially distinct hamiltonian cycles
Problem 4:       The traveling salesman lives at S.                   must we compute costs for in order to solve the traveling salesman

\$                                                          problem for a traveling salesman living in Sudbury who must visit

{A, G}     3                                                          Londres, Miami, Paris, New York, Vancouver and Chicoutimi?

{A, L}     8                                                          Answer:
{A, S}    3                                                                                   (7 − 1)!   6!
{A, W}     7
=    = 360.
2       2
{G, L}     3
{G, S}     3
Problem 6:    For how many essentially distinct hamiltonian cycles
{G, W}    11
must we compute costs for in order to solve the traveling salesman
{L, S}    3
problem for a traveling salesman living in Toronto who must visit
{L, W}     7
Timmins, Hearst, Ottawa, Val Caron, Thunder Bay, Chibougamau,
{S, W}     7
Trois-Rivières and Winnipeg?
(n − 1)!   4!   24                                                   (9 − 1)!   8!
=    =    = 12.                                                      =    = 20160.
2       2    2                                                       2       2
S,A,L,W,G,S :       3 + 8 + 7 + 11 + 3 = 32
Problem 7:    For how many essentially distinct hamiltonian cycles
S,A,W,L,G,S :       3 + 7 + 7 + 3 + 3 = 23
must we compute costs for in order to solve the traveling salesman
S,A,G,W,L,S :       3 + 3 + 11 + 7 . . .
problem for a traveling salesman living in Toronto who must visit
S,A,W,G,L,S :       3 + 7 + 11 . . .
Timmins, Hearst, Ottawa, Val Caron, Thunder Bay, Chibougamau,
S,A,G,L,W,S :       3 + 3 + 3 + 7 + 7 = 23
Trois-Rivières, Winnipeg, Calgary et Fort McMurray?
S,A,L,G,W,S :       3 + 8 + 3 + 11 . . .
S,G,A,W,L,S :       3 + 3 + 7 + 7 + 3 = 23
S,G,W,A,L,S :       3 + 11 + 7 . . .                                                      (11 − 1)!   10!
=     = 1814400.
S,G,A,L,W,S :       3 + 3 + 8 + 7...                                                          2        2
S,G,L,A,W,S :       3 + 3 + 8 + 7...                                 Comment :     Even for a problem of moderate size (ten cities to visit),
S,L,A,G,W,S :       3 + 8 + 3 + 11 . . .                             the brute force solution of the traveling salesman problem requires the
S,L,G,A,W,S :       3 + 3 + 3 + 7 + 7 = 23                           computation of the costs of almost two million dierent cycles. For
Minimal   cost    itineraries:       S,A,W,L,G,S ,    S,G,L,W,A,S ,   graphs with special features (satisfying the triangle inequality, for
S,A,G,L,W,S ,        S,W,L,G,A,S ,    S,G,A,W,L,S ,   S,L,W,A,G,S ,   example) there are better exact and approximate methods than brute
S,L,G,A,W,S       and   S,W,A,G,L,S .                                 force. No algorithm is lightning fast.
end of the document
the traveling salesman problem                                                                                                              4

```
DOCUMENT INFO
Shared By:
Categories:
Stats:
 views: 103 posted: 3/29/2010 language: English pages: 4
How are you planning on using Docstoc?