# Solving Tsp Using Branch & Bound

Topics: Berlin U-Bahn, Travelling salesman problem, Prime number Pages: 31 (7620 words) Published: March 18, 2013
King Fahd University of Petroleum & Minerals

ISE 421 - Section 02
Term 121
TSP Project

TRAVELLING SALESMAN PROBLEM

A traveler wants to travel across eight cities with minimum time. He wants to visit each city exactly once and then return to the the starting city. Your task is to generate the best tour for him. Following are the travel times it takes to move from any city i to another city j.

0| 10| 12| 5| 17| 9| 13| 7|
10| 0| 9| 20| 8| 11| 3| 6|
12| 9| 0| 14| 4| 10| 1| 16|
5| 20| 14| 0| 20| 5| 28| 10|
17| 8| 4| 20| 0| 21| 4| 9|
9| 11| 10| 5| 21| 0| 2| 3|
13| 3| 1| 28| 4| 2| 0| 2|
7| 5| 16| 10| 9| 3| 2| 0|

i) Start by solving the corresponding assignment problem to get the starting solution. Then use Branch and Bound to eliminate any sub-tours.

Solution:

The Hungarian assignment algorithm was implemented using excel:

The following table was the input:
| City 1| City 2| City 3| City 4| City 5| City 6| City 7| City 8| City 1| 100| 10| 12| 5| 17| 9| 13| 7|
City 2| 10| 100| 9| 20| 8| 11| 3| 5|
City 3| 12| 9| 100| 14| 4| 10| 1| 16|
City 4| 5| 20| 14| 100| 20| 5| 28| 10|
City 5| 17| 8| 4| 20| 100| 21| 4| 9|
City 6| 9| 11| 10| 5| 21| 100| 2| 3|
City 7| 13| 3| 1| 28| 4| 2| 100| 2|
City 8| 7| 5| 16| 10| 9| 3| 2| 100|

Note: Cost of travelling from a city to the same city was penalized by 100.

Solving Assignment Problem using Excel Solver:

1) An table containing the assignments is made (see A1-I9). This table is initially empty. An assignment is made if the cell is equal to 1, otherwise 0 – this will be solved by “solver”. Call this the “binary table”. 2) Another table containing the costs of travelling from one city to another is written into the spreadsheet. 3) A cell which determines the total cost is needed (see B12). The function used is “sumproduct”, which multiplies each value in the cost table with its respective binary value (0 or 1). 4) A supply column and a demand row may be introduced (see column J & row 10). In this case they are not needed, since every city has a “demand” of one visit and a “supply” – to a neighboring city – of one. They are used nonetheless in this problem, for clarity of formulation.

The data needed to use excel solver is now complete. Solver is an add-in that can be found in the data tab. The target cell (to be minimized is total cost (B2). The variable cells are the cells in the binary table. Therefore, set “by changing cells” to the binary table.

There are three constraints:
1) Each city must be assigned to just 1 other city (Column J all = 1) 2) Each city must have just 1 other city assigned to it (Row 10 all =1) 3) The binary table must consist entirely of binary numbers (B2-I9 all = bin)

The solver options must be changed to “assume linear model” and “assume non-negative”. Click solve.

The following solution is obtained:
| City 1| City 2| City 3| City 4| City 5| City 6| City 7| City 8| City 1| 0| 0| 0| 1| 0| 0| 0| 0|
City 2| 0| 0| 0| 0| 0| 0| 1| 0|
City 3| 0| 0| 0| 0| 1| 0| 0| 0|
City 4| 1| 0| 0| 0| 0| 0| 0| 0|
City 5| 0| 0| 1| 0| 0| 0| 0| 0|
City 6| 0| 0| 0| 0| 0| 0| 0| 1|
City 7| 0| 1| 0| 0| 0| 0| 0| 0|
City 8| 0| 0| 0| 0| 0| 1| 0| 0|

(1-4-1)(2-7-2)(3-5-3)(6-8-6) Cost =30

Z=30 is now the lower bound.
Start by using branching the 1-4-1 subtour

Z=30
(1-4-1)(2-7-2)
(3-5-3)(6-8-6)
Z=30
(1-4-1)(2-7-2)
(3-5-3)(6-8-6)

X41=0
X14=0
X41=0
X14=0

We can solve the branches using the same algorithm as before, with the addition of a penalty cost to 1-4 or 4-1. X14=0:
| City 1| City 2| City 3| City 4| City 5| City 6| City 7| City 8| City 1| 0| 0| 0| 0| 0| 0| 0| 1|
City 2| 0| 0| 0| 0| 0| 0...