You are on page 1of 21

Performance Evaluation of Some Solutions of the Travelling Salesman Problem

Suvankar Khan Wangchuk Janardan Mandal


Guided by : Prof: S. Pal

Overview
Traveling Salesman Problem (TSP): Given a complete graph with nonnegative edge costs, Find a minimum cost cycle visiting every vertex exactly once.

Application (Example): Given a number of cities and the costs of traveling from any city to any other city, what is the cheapest round-trip route that visits each city exactly once and then returns to the starting city.
The goal of the Travelling Salesman Problem (TSP) is to find the cheapest tour of a select number of cities with the following restrictions: We must visit each city once and only once We must return to the original starting point

Why Study TSPs?


NP-complete problems are the hardest problems in NP, in the sense that they are the ones most likely not to be in P. The reason is that if you could find a way to solve an NP-complete problem quickly, then we could use that algorithm to solve all NP problems quickly. Common NP-complete problems:
* Boolean satisfiability problem (SAT) * Fifteen puzzle * Knapsack problem * Minesweeper * Tetris * Hamiltonian cycle problem * Traveling salesman problem * Subgraph isomorphism problem * Subset sum problem * Clique problem * Vertex cover problem * Independent Set problem

Hamiltonian Circuit
Hamiltonian circuit (HC): is a cycle which passes once and exactly once through every vertex of G (G can be digraph). Hamiltonian path: is a path which passes once and exactly once through every vertex of G (G can be digraph).

A graph is Hamiltonian iff a Hamiltonian circuit (HC) exists.


TSP is similar to these variations of Hamiltonian Circuit problems:

Find the shortest Hamiltonian cycle in a weighted graph.

Find the Hamiltonian cycle in a weighted graph with the minimal length of the longest edge. (bottleneck TSP).

Nearest Neighbor
The nearest neighbor algorithm was one of the first algorithms used to determine a solution to the travelling salesman problem. In it, the salesman starts at a random city and repeatedly visits the nearest city until all have been visited. It quickly yields a short tour, but usually not the optimal one.

Nearest Neighbor 1st Construction heuristic


Start at some vertex s; v=s; While not all vertices visited
Select closest unvisited neighbor w of v Go from v to w; v=w

Go from v to s.
It is depth first priority based search

Vertex Insertion
Insertion Construction Heuristic n In each step, extend partial tour p by inserting a vertex v that leads to minimal increase Types of insertion heuristics .. Nearest Insertion .. Farthest Insertion .. Random Insertion Nearest and cheapest and provably at most twice as long as optimal tour

Vertex Insertion
Input: N*N distance matrix Output: TSP tour Let V1 and V2 vertices are chosen randomly from the set of vertices according to some rules. Initialize cycle c=<V1,V2,V1>. For s=3,4,5,n.
Let Vs be a vertex not on cycle c, chosen by the rule. Insert vertex Vs at an arc (a*,b*) of cycle. c=<V1,V2,..,Vs,V1> such that c=<a*,Vs,b*> is minimum among the cycle c(a,Vs,b) for all arcs (a,b) is c.

Consider all the vertices to complete the Euler Path that is the TSP tour.

Vertex Insertion
The rules are: Random vertex insertion (RVI) : chosen vertex Vs is randomly Nearest Vertex Insertion (NVI) : chosen vertex Vs so that its distance to cycle C is minimum that is, d(Vs,c)= min d(V,c). Furthest Vertex Insertion (FVI) : chosen vertex Vs so that its distance to cycle c is maximum that is, d(Vs,c)= max d(V,c).

TWO-OPTIMAL METHOD ALGORITHM


In the two-optimal method, we begin by choosing a Hamiltonian cycle C of the complete weighted graph G. Thereafter we perform a sequence of modification to C in the hope of finding a cycle of smaller weight.

TWO-OPTIMAL METHOD ALGORITHM


Take two edges (v,w) and (x,y) and replace them by (v,x) and (w,y) OR (v,y) and (w,x) to get a tour again. Costly: part of tour should be turned around

11

TWO-OPTIMAL METHOD ALGORITHM


This process is called the two-optimal method since at each stage we are choosing optimal form two pairs of edges. We carry out the procedure systematically, first by taking i=1 and looking at the j values 3,4,..,n in turn, then taking i=2 and looking at the j values 4,5,,n in turn, and so on until we reach i=n-2, the final step having i=n-2,j=n.

TWO-OPTIMAL METHOD ALGORITHM


Reversing shorter part of the tour Clever search to improving moves Look only to subset of candidate improvements Postpone correcting tour Combine with node insertion

13

Double the tree algorithm


Double the tree algorithm is most efficient if a weighted simple graph satisfy Triangle Inequality. Triangle inequality : a weighted simple graph is said to satisfy Triangle inequality if : Wij Wik + Wkj k for all vertices i ,j, k.
ii
j

Double the tree algorithm contd..


Input : A weighted complete graph G. Output :A sequence of vertices and edges that form a Hamiltonian cycle. Objective :The figure represents N numbers of cities and we need to find shortest(minimum cost) path that connect every city once.

Double the tree algorithm contd..


Step 1: find a minimum spanning tree T* of G.

MST T* of GRAPH G

Double the tree algorithm contd..


Step 2: create an eulerian graph H by using two copies of each edge of T*.Construct an eulerian cycle W of H.

EULERIAN GRAPH H and EULERIAN CYCLE W

Double the tree algorithm contd..


Step 3: Construct a Hamiltonian cycle as follows.

HAMILTONIAN CYCLE

Steps followed for Generation of Inputs for the programs


An n*n matrix is generated to represent the undirected graph. Such as each row of the matrix will represent the set of start vertex and each column will represent the destination vertex. Each element of that matrix represents a cost of the edge. e.g.: Mat[i+*j+=18; means to travel from vertex i to vertex j the cost will be 18. As the graph is simple connected graph so there is no self loop. That is diagonal values of the matrix are zero. As the graph is undirected so for same pair of vertices the cost is same. To represent it the upper triangular matrix is created first and a mirror image is made in to the lower triangular matrix of that. The upper triangular matrix was generated randomly with the values between s to s*s where the value of s is total number of vertices.

Parameters for Performance Evaluation


We will study with a similar set of vertices for each algorithm and compare the execution time for all the algorithms of the set of vertices. And the cost of each edge will be generated randomly with respect to number of vertices. We will again study for every similar set of graphs the accuracy of shortest path hit for each algorithms defined by us. We will study with more number of algorithms if time permits.

THANK YOU

You might also like