You are on page 1of 7

Traveling Salesman Problem

Introduction
The Traveling Salesman Problem (TSP) is the problem of finding a least-cost sequence in
which to visit a set of cities, starting and ending at the same city, and in such a way that each
city is visited exactly once. This problem has received a tremendous amount of attention over
the years due in part to its wide applicability in practice.

History
The Traveling Salesman Problem was mathematically formulated in the 1800s by the Irish
mathematician W.R. Hamilton and by the British mathematician Thomas Kirkman.
Hamilton’s Icosian Game was a recreational puzzle based on finding a Hamiltonian Cycle.
The general form of the TSP appears to have been first studied by mathematicians during the
1930s in Vienna and at Harvard, notably by Karl Menger, who defines the problem, considers
the obvious brute-force algorithm, and observes the non-optimality of the nearest neighbor
heuristic.

Application
The TSP has several applications even in its purest formulation, such as planning, logistics,
and the manufacture of microchips. Slightly modified, it appears as a sub-problem in many
areas, such as DNA sequencing. In these applications, the concept city represents, for
example, customers, soldering points, or DNA fragments, and the concept distance represents
travelling times or cost, or a similarity measure between DNA fragments. The TSP also
appears in astronomy, as astronomers observing many sources would want to minimize the
time spent moving the telescope between the sources.
Traveling Salesman Problem
The Traveling Salesman Problem may be solved as an assignment problem, with two
additional conditions on the choice of assignment. That is, how should a traveling salesman
travel starting from his home city (the city from where he started), visiting each city only
once and returning to his home city, so that the total distance (cost or time) covered is
minimum.

For example, given n-cities and distances dij (cost Cij or time tij) from city i to city j, the
salesman starts from city 1, then any permutation of 2,3,…,n represents the number of
possible ways of his tour. Thus, there are (n-1)! possible ways of his tour. Now the problem is
to select an optimal route that is able to achieve the objective of the salesman.

To formulate and solve this problem, let us define :

Xij = 1, if salesman travels from city i to city j

0, otherwise

Since, each city can be visited only once, we have

∑𝑛−1
𝑖=1 𝑋𝑖𝑗 = 1, j=1,2,…n; i ≠ j

Again, since the salesman has to leave each city except city n, we have

∑𝑛−1
𝑗=1 𝑋𝑖𝑗 = 1 , i= 1,2,….n ; i ≠ j

The objective function is then

Minimize = ∑𝑛−1
𝑖=1 ∑n−1
𝑗=1 dijXij

Here we do not require dij = dij , therefore dij = ∞ for i = j. However all dij’s must be non-
negative, i.e. dij≥0 and dij+djk ≥ dik for all i, j, k.

Next, we use a real time scenario to get a better understanding of Traveling Salesman
Problem.
Scenario
The Stagecoach Shipping company transports stationary by using a truck from New Delhi to
four cities around it. Given below is a matrix displaying the traveling time (in hrs) of each
city from a particular city. It is assumed that truck covers a distance of 20 km in 1 hr taking
traffic into consideration.

To

Delhi Rohtak Sonipat Meerut Gurugram

From Delhi -- 3 2 4 2

Rohtak 3 -- 2 8 4

Sonipat 2 4 -- 4 4

Meerut 4 8 4 -- 5

Gurugram 2 4 4 5 --

The shipping company manager wants to determine the best route (in terms of minimum
travel distance) for the truck to take to reach its destinations so that the total distance travelled
is minimum.

Solution
Step 1: Row Reduction

Find out the each row minimum element and subtract it from that row.

Delhi Rohtak Sonipat Meerut Gurugram

Delhi -- 1 0 2 0 (-2)

Rohtak 1 -- 0 6 2 (-2)

Sonipat 0 2 -- 2 2 (-2)

Meerut 0 4 0 -- 1 (-4)

Gurugram 0 2 2 3 -- (-2)
Step 2: Column Reduction

Find out each column minimum element and subtract it from that column

Delhi Rohtak Sonipat Meerut Gurugram


Delhi -- 0 0 0 0
Rohtak 1 -- 0 4 2
Sonipat 0 1 -- 0 2
Meerut 0 3 0 -- 1
Gurugram 0 1 2 1 --
(0) (-1) (0) (-2) (0)

Step 3: Make assignment in the opportunity cost table

a) Row wise assignment

Delhi Rohtak Sonipat Meerut Gurugram

Delhi -- 0 0× 0× 0

Rohtak 1 -- [0] 4 2

Sonipat 0× 1 -- [0] 2

Meerut [0] 3 0× -- 1

Gurugram 0× 1 2 1 --

b) Column wise assignment

Delhi Rohtak Sonipat Meerut Gurugram

Delhi -- [0] 0× 0× 0×

Rohtak 1 -- [0] 4 2

Sonipat 0× 1 -- [0] 2

Meerut [0] 3 0× -- 1

Gurugram 0× 1 2 1 --
Step 4: number of assignments = 4 , number of rows = 5

This is not equal, so solution is not optimal.

Step 5: Cover the zeros with minimum number of lines

Delhi Rohtak Sonipat Meerut Gurugram


Delhi -- [0] 0× 0× 0×
Rohtak 1 -- [0] 4 2
Sonipat 0× 1 -- [0] 2
Meerut [0] 3 0× -- 1
Gurugram 0× 1 2 1 --

Step 6: Develop the new revised table by selecting the smallest element among the cells not
covered by any line. In this case, it is 1. Subtract 1 from every element in the cell not covered
by a line.

Add 1 to every element in the intersection cell of two lines.

Delhi Rohtak Sonipat Meerut Gurugram

Delhi -- 0 1 1 0

Rohtak 1 -- 0 4 1

Sonipat 0 0 -- 0 1

Meerut 0 2 0 -- 0

Gurugram 0 0 2 1 --
Step 7: Row wise and column wise assignment

Delhi Rohtak Sonipat Meerut Gurugram

Delhi -- 0 1 1 0

Rohtak 1 -- [0] 4 1

Sonipat 0× 0× -- [0] 1

Meerut 0 2 0× -- 0

Gurugram 0 0 2 1 --

Step 8: Since, after row wise and column wise assignment, we are left with two zeros in the
1st, 4th and 5th row, so will arbitrarily select any row for assigning a zero. Here, we select 1st
row.

Delhi Rohtak Sonipat Meerut Gurugram

Delhi -- [0] 1 1 0×

Rohtak 1 -- [0] 4 1

Sonipat 0× 0× -- [0] 1

Meerut 0× 2 0× -- [0]

Gurugram [0] 0× 2 1 --

Step 9: now we have reached to a condition where number of assignment = number of rows =
5.

The solution gives the sequence,

Delhi Rohtak Sonipat Meerut Gurugram Delhi


Step 10: The optimal solution is

From To Time (hrs)


Delhi Rohtak 3
Rohtak Sonipat 2
Sonipat Meerut 8
Meerut Gurugram 5
Gurugram Delhi 2
Total (hrs) = 20

Conclusion
The above problem was solved using Hungarian Assignment Method, and the optimal
solution obtained was the same as above. The solution that we get is the minimum number of
total hours that it would take company’s truck to cover four cities from Delhi, i.e. 20 hrs.

You might also like