Assignment No 2 (Group B)

Similar documents
Branch and Bound. Live-node: A node that has not been expanded. It is similar to backtracking technique but uses BFS-like search.

[Mondal*, 5(2): February, 2016] ISSN: (I2OR), Publication Impact Factor: 3.785

More NP-complete Problems. CS255 Chris Pollett May 3, 2006.

UNIT 4 Branch and Bound

Coping with the Limitations of Algorithm Power Exact Solution Strategies Backtracking Backtracking : A Scenario

6. Algorithm Design Techniques

Notes for Lecture 24

Practice Final Exam 1

CSC Design and Analysis of Algorithms. Lecture 4 Brute Force, Exhaustive Search, Graph Traversal Algorithms. Brute-Force Approach

Chapter 9 Graph Algorithms

NP-complete Reductions

Chapter 9 Graph Algorithms

Worksheet for the Final Exam - Part I. Graphs

Traveling Salesperson Problem (TSP)

NP-Complete Problems

PSD1A. DESIGN AND ANALYSIS OF ALGORITHMS Unit : I-V

Lecture 8: The Traveling Salesman Problem

Brute Force: Selection Sort

Search means finding a path or traversal between a start node and one of a set of goal nodes. Search is a study of states and their transitions.

Backtracking. Chapter 5

Introduction to Approximation Algorithms

COMP 355 Advanced Algorithms Approximation Algorithms: VC and TSP Chapter 11 (KT) Section (CLRS)

Reference Sheet for CO142.2 Discrete Mathematics II

INSTITUTE OF AERONAUTICAL ENGINEERING

CSE 417 Branch & Bound (pt 4) Branch & Bound

Module 6 NP-Complete Problems and Heuristics

Backtracking and Branch-and-Bound

CSCE 350: Chin-Tser Huang. University of South Carolina

Algorithm Design and Analysis

Backtracking is a refinement of the brute force approach, which systematically searches for a

Lecture 3. Brute Force

IV/IV B.Tech (Regular) DEGREE EXAMINATION. Design and Analysis of Algorithms (CS/IT 414) Scheme of Evaluation

6.2. Paths and Cycles

Best known solution time is Ω(V!) Check every permutation of vertices to see if there is a graph edge between adjacent vertices

1 The Traveling Salesperson Problem (TSP)

Module 6 P, NP, NP-Complete Problems and Approximation Algorithms

Unit 8: Coping with NP-Completeness. Complexity classes Reducibility and NP-completeness proofs Coping with NP-complete problems. Y.-W.

CS 440 Theory of Algorithms /

Chapter 3: Solving Problems by Searching

Theorem 2.9: nearest addition algorithm

Methods and Models for Combinatorial Optimization Exact methods for the Traveling Salesman Problem

NP-Complete Problems

Introduction to Algorithms

11/22/2016. Chapter 9 Graph Algorithms. Introduction. Definitions. Definitions. Definitions. Definitions

Chapter 9 Graph Algorithms

Module 6 NP-Complete Problems and Heuristics

Searching in Graphs (cut points)

Graph Theory. Part of Texas Counties.

CMSC 451: Lecture 22 Approximation Algorithms: Vertex Cover and TSP Tuesday, Dec 5, 2017

CSE 548: Analysis of Algorithms. Lecture 13 ( Approximation Algorithms )

Module 11: Additional Topics Graph Theory and Applications

P and NP (Millenium problem)

IE 102 Spring Routing Through Networks - 1

Module 6 NP-Complete Problems and Heuristics

CS6402 DESIGN AND ANALYSIS OF ALGORITHMS QUESTION BANK UNIT I

Computer Science 385 Design and Analysis of Algorithms Siena College Spring Topic Notes: Brute-Force Algorithms

val(y, I) α (9.0.2) α (9.0.3)

Travelling Salesman Problem. Algorithms and Networks 2015/2016 Hans L. Bodlaender Johan M. M. van Rooij

Lecture 13. Reading: Weiss, Ch. 9, Ch 8 CSE 100, UCSD: LEC 13. Page 1 of 29

CS 441 Discrete Mathematics for CS Lecture 26. Graphs. CS 441 Discrete mathematics for CS. Final exam


Data Structures (CS 1520) Lecture 28 Name:

Notes for Recitation 9

TOTAL CREDIT UNITS L T P/ S SW/F W. Course Title: Analysis & Design of Algorithm. Course Level: UG Course Code: CSE303 Credit Units: 5

Optimal tour along pubs in the UK

Vertex Cover Approximations

1 5,9,2,7,6,10,4,3,8,1 The first number (5) is automatically the first number of the sorted list

Chapter-6 Backtracking

of optimization problems. In this chapter, it is explained that what network design

Graphs Introduction and Depth first algorithm

Spanning Tree. Lecture19: Graph III. Minimum Spanning Tree (MSP)

CS161 - Final Exam Computer Science Department, Stanford University August 16, 2008

Department of Computer Applications. MCA 312: Design and Analysis of Algorithms. [Part I : Medium Answer Type Questions] UNIT I

Trees. Arash Rafiey. 20 October, 2015

Exercise 1. D-ary Tree

1 The Traveling Salesman Problem

University of New Mexico Department of Computer Science. Final Examination. CS 362 Data Structures and Algorithms Spring, 2006

Theory of Computing. Lecture 10 MAS 714 Hartmut Klauck

Data Structures (CS 1520) Lecture 28 Name:

Computational problems. Lecture 2: Combinatorial search and optimisation problems. Computational problems. Examples. Example

(Refer Slide Time: 01:00)

V1.0: Seth Gilbert, V1.1: Steven Halim August 30, Abstract. d(e), and we assume that the distance function is non-negative (i.e., d(x, y) 0).

DESIGN AND ANALYSIS OF ALGORITHMS

Graph Theory CS/Math231 Discrete Mathematics Spring2015

Traveling Salesman Problem (TSP) Input: undirected graph G=(V,E), c: E R + Goal: find a tour (Hamiltonian cycle) of minimum cost

Introduction to Algorithms. Lecture 24. Prof. Patrick Jaillet

Examples of P vs NP: More Problems

Algorithm Design Techniques. Hwansoo Han

CS270 Combinatorial Algorithms & Data Structures Spring Lecture 19:

Assignment 5: Solutions

Chapter 5 Backtracking 1

Further Mathematics 2016 Module 2: NETWORKS AND DECISION MATHEMATICS Chapter 9 Undirected Graphs and Networks

Hardness of Approximation for the TSP. Michael Lampis LAMSADE Université Paris Dauphine

Math 443/543 Graph Theory Notes 2: Transportation problems

Computer Science and Software Engineering University of Wisconsin - Platteville. 3. Search (Part 1) CS 3030 Lecture Notes Yan Shi UW-Platteville

LECTURE 26 PRIM S ALGORITHM

8 NP-complete problem Hard problems: demo

Questions? You are given the complete graph of Facebook. What questions would you ask? (What questions could we hope to answer?)

Introduction to Optimization

Elements of Graph Theory

Transcription:

Assignment No 2 (Group B) 1 Problem Statement : Concurrent Implementation of Travelling Salesman Problem. 2 Objective : To develop problem solving abilities using Mathematical Modeling. To apply algorithmic strategies, Software Engineering and Testing while solving problems. To develop time and space efficient algorithms. To study algorithmic examples in distributed concurrent and parallel environments. 3 Theory : Given a set of cities and distance between every pair of cities, the problem is to find the shortest possible route that visits every city exactly once and returns to the starting point.in other words the traveling salesman problem consists of a salesman and a set of cities. The salesman has to visit each one of the cities starting from a certain one (e.g. the hometown) and returning to the same city. The challenge of the problem is that the travelling salesman wants to minimize the total length of the trip. TSP can be modelled as an undirected weighted graph, such that cities are the graph s vertices, paths are the graph s edges, and a path s distance is the edge s length. It is a minimization problem starting and finishing at a specified vertex after having visited each other vertex exactly once. Often, the model is a complete graph (i.e. each pair of vertices is connected by an edge). If no path exists between two cities, adding an arbitrarily long edge will complete the graph without affecting the optimal tour. 3.1 TSP using Branch and Bound : The method we are proposing to solve the problem is Branch and Bound Method. The term branch and bound refers to all state space search methods in which all the children of E-node are generated before any other live node can become the E-node. E-node is the node, which is being expanded. State space tree can be expanded in any method i.e. BFS or DFS.Both start with the root node and generate other nodes. A node which has been generated and all of whose children are not yet been expanded is called live-node. A node is 1

called dead node, which has been generated, but it cannot be expanded further. The concept of dead node gives the birth to a new concept known as backtracking which says once we have traversed a node and its a dead node and still we could not find the solution? So we need to come back to its parent and traverse its(parents) another children for the solution. If it has no more children unexpanded then we need to reach its parent (grand parent of dead node) and expand its children and so on. And we do so until we get the solution or complete tree is traversed. In this method at each node tree is de we need to expand the node, which is most promising, means the node which promises that expanding or choosing it will give us the optimal solution. So we prepare the tree starting form root then we expand it. 4 Algorithm : 1. Let A be the cost matrix of a G = ( V, E ). 2. Get the reduced matrix A of A. 3. The cost of each node in the search tree is computed as follows: Loop until all vertices are visited. Begin : Let R be a node in the tree and A(R) its reduced matrix The cost of the child (R), S: Set row i and column j to infinity Set A(j,1) to infinity Reduced S and let RCL be the reduced cost. C(S) = C(R) + RCL+A(i,j) 4. Select the node with the minimum C(S) value. 5. Continue this process of reduction and selection of child node with minimum value until all nodes are visited. 6. End. 2

5 Example : Here in this problem V = 6. Which is the number of total nodes on the graph or the cities in the map. 1 5 2 5 4 5 3 3 6 7 6 2 4 3 1 4 Figure 1: Graph Representation The input array for the method is given by : Figure 2: Adjacency Matrix 3

Step 1 : Reduce each row and column in such a way that there must be at least one zero in each row and column.for doing this, we need to reduce the minimum value from each element in each row and column. After reducing the row and column we get So the total expected cost at the root node is the sum of all reductions. Total expected cost of expanding root node : L(1)=4+2+1+1+3+3+1=15.Because we have to plan the path starting from V1, so V1 will be the root of the tree and it would be the first node to be expanded. Step 2 : We have discovered the root node V1 so the next node to be expanded will be any node from V2, V3, V4, V5, V6. So we have to find out the expanding cost of each node. So which one would be the minimum we are going to expand it further. We will repeat a procedure for every node to find the expanding cost for its expansion. The formula for finding the cost is: L (node)=l (parent node)+p arent (i, j) + total cost of reduction A. Obtain cost of expanding using cost matrix for node 2 in the tree.change all the elements in 1 st row and 2 nd column and M 1(2,1) to. Reduce M2 in row and columns. As each row and column already has a zero so it cannot be reduced more. So reduction cost = 0 4

B. Obtain cost of expanding using cost matrix for node 3 in the tree.change all the elements in 1 st row and 3 rd column and M 1 (3,1) to. Reduce M3 in row and columns. So the total cost of expanding node 3, L (3)= L (1)+ M 1 (1,3)+r=15+ +4= C. Obtain cost of expanding using cost matrix for node 4 in the tree. Change all the elements in 1 st row and 4 th column and M 1 (4,1) to.reduce M3 in row and columns. So the total cost of expanding node 4, L (4)= L (1)+ M 1 (1,4)+r=15+2+1=18. D. Obtain cost of expanding using cost matrix for node 5 in the tree. Change all the elements in 1 st row and 5 th column and M 1 (5,1) to. Reduce M2 in row and columns. As each row and column already has a zero so it cannot be reduced more.so reduction cost = 0. So the total cost of expanding node 5, L(5)= L(1)+ M 1 (1,5)+r=15+2+0=17. 5

E. Obtain cost of expanding using cost matrix for node 6 in the tree. Change all the elements in 1 st row and 6 th column and M 1 (6,1) to. Reduce M6 in row and columns.so the total cost of expanding node 6, L (6)= L (1)+ M 1 (1,6)+r=15+0+1=16 Now we have two most promising V2 and V6. Suppose we choose V6 as the next node. So we will expand the tree on node 6, which belongs to V6. Till now two nodes have been traversed V1 and V6. So we have to find out the next node to be traversed. Step 3 :As we are choosing V6 as the next node to be expand. So M6 will work as input matrix for this step. And we have 4 nodes still to be traversed. So we can expand V2, V3, V4, and V5 as the next node. So using the same method we can find the expansion cost of each of these nodes and go on selecting the node with minimum cost until we traverse all the nodes. 6

6 State Space Tree : 1 15 16 16 2 inf 18 17 3 4 5 6 8 15 8 8 7 8 9 10 11 17 19 21 inf 22 12 13 14 15 14 16 7 Mathematical Model : The traveling salesman problem can be described as a problem space P : where P = { S, I, O, F, E } S = { Start state consisting of the graph of the city } I = { Input state : I1, I2 } where I1 = { A Graph G = (V, E) consisting of vertices along with the cost of the Edges } I2 = { Graph is converted to Adjacency Matrix and given as input to program } 7

O = { Output state : O1, O2 } where O1 = { The shortest path (v1 v2 v3) } O2 = { Minimin path cost } F = { Functions used : f1, f2, f3 } where f1 = { Row reduction of matrix } f2 = { Column reduction of matrix } f3 = { Finding minimum cost unvisited node } E = { End state : All vertices are visited and minimum path selected } 7.1 TSP as NP-Complete Problem : First, we have to prove that TSP belongs to NP. If we want to check a tour for credibility, we check that the tour contains each vertex once. Then we sum the total cost of the edges and finally we check if the cost is minimum. This can be completed in polynomial time, thus TSP belongs to NP. Secondly we prove that TSP is NP-hard. One way to prove this is to show that Hamiltonian cycle reduces to TSP (given that the Hamiltonian cycle problem is NP-complete). Assume G = (V, E) to be an instance of Hamiltonian cycle. An instance of TSP is then constructed. We create the complete graph G = (V, E ), where E = { (i, j):i, j V and i j } Thus, the cost function is defined as: t(i,j ) = { 0 if (i, j) E 1 if (i, j) E. } Now suppose that a Hamiltonian cycle h exists in G. It is clear that the cost of each edge in h is 0 in G as each edge belongs to E. Therefore, h has a cost of 0 in G. Thus, if graph G has a Hamiltonian cycle then graph G has a tour of 0 cost. Conversely, we assume that G has a tour h of cost at most 0. The cost of edges in E are 0 and 1 by definition. So each edge must have a cost of 0 as the cost of h is 0. We conclude that h contains only edges in E. So we have proven that G has a Hamiltonian cycle if and only if G has a tour of cost at most 0. Thus TSP is NP-complete. 8 Test cases : Test Case 1 : Input : Negative Edges (Cost < 0 ). Expected Output : Not allowed to enter negative cost edges. 8

Test Case 2 : Input : Alphabets/Characters as cost of edges. Expected Output : Only Integers weights allowed. 9 Conclusion : An O(n 2 2n) dynamic programming algorithm for the traveling salesperson problem exists We proposed to use branch-and-bound algorithms for this problem. While the worst case complexity of these algorithms will not be any better than O(n 2 2n), the use of good bounding functions will enable these branchand-bound algorithms to solve some problem instances in much less time than required by the dynamic programming algorithm. The proposed method, which is using Branch and Bound, is better because it prepares the matrices in different steps. At each step the cost matrix is calculated. From the initial point we come to know that what can be the minimum cost of the tour. The cost in the initial stages is not exact cost but it gives some idea because it is the approximated cost. At each step it gives us the strong reason that which node we should travel the next and which one not. It gives this fact in terms of the cost of expanding a particular node. At every step when we need to calculate the cost of the unvisited nodes to select the next node, we have used the concept of concurrency.threads are created to calculate the cost of the nodes in parallel. After the calculation the minimum cost node is selected as the next node. Due to the parallelism the time taken to execute the algorithm is reduced. Hence we have successfully implemented Travelling Salesman Problem using Branch and Bound Algorithmic paradigm using OPENMP in C++. 10 Outcomes Acheived : CO-I :To demonstrate efficient design, analysis and testing of algorithmic assignments. CO-III : To effectively use Concurrent/Parallel environments. 9