You are on page 1of 27

Presented By

Md. Rafsan Jani


Md. Ashraful Islam
Fuad Hasan
Abdur Rahim
Dept. Of CSE, Jahangirnagar University

The "Traveling Salesman Problem" (TSP) is a


common
problem
applied
to
artificial
intelligence. It is a
NP-hard problem.
Lots of researches are going on in this topic.

Dept. Of CSE, Jahangirnagar University

Dept. Of CSE, Jahangirnagar University

Given a list of cities and their pair wise


distances, the task is to find the shortest
possible route that visits each city exactly
once and returns to the origin city.

What is the minimum distance


tour??
What is the sequence??

Dept. Of CSE, Jahangirnagar University

of the

Why don't we just check all possible tours using


a computer?
Given n cities and the distances di,j between all of
them, we wish to find the shortest tour going through
all cities and back to the starting city.
Usually the TSP is given as a Graph(G),G = (V,D)
where V = {1, 2, . . . , n} is the set of cities, and D is
the adjacency distance matrix, with i, j V, i != j, di,j
> 0, the problem is to find the tour with minimal
distance/cost of travelling , starting in 1 goes through
all n cities and returns to the city 1.
Dept. Of CSE, Jahangirnagar University

Given S V with 1 S and given j = 1, j S,


let C(S, j) be
the shortest path
that starting at 1, visits all nodes in S and
ends at j.
Observation:
If |S| = 2, then C(S, k) = d1,k for k = 2,
3, . . . , n
If |S| > 2, then C(S, k) = the optimal tour
from 1 to m, +dm,k, m S {k}
Dept. Of CSE, Jahangirnagar University

Dept. Of CSE, Jahangirnagar University

If there are n cities, the number of possible tours


is (n - 1)!.
No. of cities
5
8
10
12
15
18
20

No. of Tour
24
5040
2*181,440
2*19,958,400
2*87,178,291,200
2*177,843,714,048,0
00
2*60,822,550,204,41
6,000

Dept. Of CSE, Jahangirnagar University

Time
12
microsecs
2.5 millisecs
0.18 secs
20 secs
12.1 hours
5.64 years
1927 years

Dept. Of CSE, Jahangirnagar University

1) Approximate. Use heuristics!


Nearest neighbour, nearest merger,
Love & Norback (angles), Lin-Kernighan (3opt),
min spanning tree + shortcuts (Christofides),
and many others.

Spend a lot of time at it.


Enumeration!
2)

Cutting planes,
branch & bound,
dynamic programming.

Dept. Of CSE, Jahangirnagar University

Dept. Of CSE, Jahangirnagar University

Observation:
1.From starting node visit all the adjacent
node
2. Repeat step 1 until all nodes are visited.
Recurrence:

Dept. Of CSE, Jahangirnagar University

Dept. Of CSE, Jahangirnagar University

Lets , consider there are four city in our


example. Given the adjacency matrix , which
depicts the distance between each cities.
Distance between city i to j is equal to the
distance between city j to i .

Dept. Of CSE, Jahangirnagar University

Lets , consider there are four city in our example. Given the adjacency matrix
, which depicts the distance between each cities. Distance between city i to j
is equal to the distance between city j to i .

75

70

30

20

80

90

Dept. Of CSE, Jahangirnagar University

Adjacency Matrix Representation :

70

30

75

70

80

20

30

80

90

75

20

90

Dept. Of CSE, Jahangirnagar University

Figure : graphical representation of all possible


tour.
Dept. Of CSE, Jahangirnagar University

TSP tour optimal distance :205


And traverse sequence is
0->2->1->3->0
Or,
0
0->3->1->2->0

75

70

30

20

80

90

Dept. Of CSE, Jahangirnagar University

TSP tour optimal distance :205


And traverse sequence is
0->2->1->3->0
Or,
0
0->3->1->2->0

75

70

30

20

80

90

Dept. Of CSE, Jahangirnagar University

TSP tour optimal distance :205


And traverse sequence is
0->2->1->3->0
Or,
0
0->3->1->2->0

75

70

30

20

80

90

Dept. Of CSE, Jahangirnagar University

TSP tour optimal distance :205


And traverse sequence is
0->2->1->3->0
Or,
0
0->3->1->2->0

75

70

30

20

80

90

Dept. Of CSE, Jahangirnagar University

Dept. Of CSE, Jahangirnagar University

a+bc
For example, cost of an edge as the euclidian
distance between two points.
Metric Traveling Salesman Problem (metric
TSP): Given a complete graph with edge costs
satisfying triangle inequalities. So, if we visit
one city more than once , it will certainly cost
more.
As we are visiting all the cities once and we
will come back to the start position , it will
Dept. Of CSE, Jahangirnagar University
create a cycle.

Time complexity of naive approach is : O(n!)


Space complexity of naive approach is : O(n)
Time complexity of dynamic programming
approach is :
O(
)
Space complexity of dynamic programming
approach is : O(
)
Dept. Of CSE, Jahangirnagar University

scheduling jobs on machines


controlling satellites, telescopes, microscopes,

lasers...
computing DNA sequences
designing telecommunications networks
designing and testing VLSI circuits

Dept. Of CSE, Jahangirnagar University

Dept. Of CSE, Jahangirnagar University

Dept. Of CSE, Jahangirnagar University

You might also like