Excursions in Modern Mathematics, 7e: 6.5 - 2Copyright © 2010 Pearson Education, Inc. 6 The Mathematics of Touring 6.1Hamilton Paths and Hamilton Circuits.

Slides:



Advertisements
Similar presentations
1 NP-Complete Problems. 2 We discuss some hard problems:  how hard? (computational complexity)  what makes them hard?  any solutions? Definitions 
Advertisements

Chapter 15 Graph Theory © 2008 Pearson Addison-Wesley. All rights reserved.
1 Chapter 15.3 Hamilton Paths and Hamilton Circuits Objectives 1.Understand the definitions of Hamilton paths & Hamilton circuits. 2.Find the number of.
Excursions in Modern Mathematics(Tannenbaum) and Thinking Mathematically (Blitzer)
Excursions in Modern Mathematics, 7e: Copyright © 2010 Pearson Education, Inc. 5 The Mathematics of Getting Around 5.1Euler Circuit Problems 5.2What.
Computability and Complexity 23-1 Computability and Complexity Andrei Bulatov Search and Optimization.
The Mathematics of Touring
§ Algorithms, Algorithms, Algorithms Recall that an algorithm is a set of procedures or rules that, when followed, lead to a ‘solution’ to.
A traveling salesman has customers in 5 cities which we will call A, B, C, D, and E. The salesman needs to travel to all 5 cities with his trip starting.
1 Efficiency of Algorithms. 2  Two main issues related to the efficiency of algorithms:  Speed of algorithm  Efficient memory allocation  We will.
Solution methods for Discrete Optimization Problems.
Excursions in Modern Mathematics, 7e: Copyright © 2010 Pearson Education, Inc. 7 The Mathematics of Networks 7.1Trees 7.2Spanning Trees 7.3 Kruskal’s.
Slide 14-1 Copyright © 2005 Pearson Education, Inc. SEVENTH EDITION and EXPANDED SEVENTH EDITION.
Excursions in Modern Mathematics, 7e: Copyright © 2010 Pearson Education, Inc. 6 The Mathematics of Touring 6.1Hamilton Paths and Hamilton Circuits.
Excursions in Modern Mathematics, 7e: Copyright © 2010 Pearson Education, Inc. 6 The Mathematics of Touring 6.1Hamilton Paths and Hamilton Circuits.
Excursions in Modern Mathematics, 7e: Copyright © 2010 Pearson Education, Inc. 5 The Mathematics of Getting Around 5.1Euler Circuit Problems 5.2What.
Graph Theory Hamilton Paths and Hamilton Circuits.
Excursions in Modern Mathematics, 7e: Copyright © 2010 Pearson Education, Inc. 6 The Mathematics of Touring 6.1Hamilton Paths and Hamilton Circuits.
The Traveling-Salesman Problem. Born August 4, 1805 in Dublin, Ireland Died September 2, 1865 in Dublin, Ireland Made many contributions to the Physics.
Discrete Math Unit 6 Set Theory Number Theory Graph Theory.
Excursions in Modern Mathematics, 7e: Copyright © 2010 Pearson Education, Inc. 6 The Mathematics of Touring 6.1Hamilton Paths and Hamilton Circuits.
1 Excursions in Modern Mathematics Sixth Edition Peter Tannenbaum.
6.1 Hamilton Circuits and Paths: Hamilton Circuits and Paths: Hamilton Path: Travels to each vertex once and only once… Hamilton Path: Travels to each.
© 2010 Pearson Prentice Hall. All rights reserved. 1 §15.3, Hamilton Paths and Circuits.
Spring 2015 Mathematics in Management Science Traveling Salesman Problem Approximate solutions for TSP NNA, RNN, SEA Greedy Heuristic Algorithms.
TECH Computer Science NP-Complete Problems Problems  Abstract Problems  Decision Problem, Optimal value, Optimal solution  Encodings  //Data Structure.
Copyright © 2014, 2010, 2007 Pearson Education, Inc. Section 4.2, Slide 1 4 Graph Theory (Networks) The Mathematics of Relationships 4.
Copyright 2013, 2010, 2007, Pearson, Education, Inc. Section 14.3 Hamilton Paths, and Hamilton Circuits.
CSE 589 Part VI. Reading Skiena, Sections 5.5 and 6.8 CLR, chapter 37.
6.4: The Brute-Force Algorithms
Chapter 14 Section 4 - Slide 1 Copyright © 2009 Pearson Education, Inc. AND.
 Graphs  Paths  Circuits  Euler. Traveling Salesman Problems.
Excursions in Modern Mathematics, 7e: Copyright © 2010 Pearson Education, Inc. 6 The Mathematics of Touring 6.1Hamilton Paths and Hamilton Circuits.
EXCURSIONS IN MODERN MATHEMATICS SIXTH EDITION Peter Tannenbaum 1.
CIRCUITS, PATHS, AND SCHEDULES Euler and Königsberg.
Graph Theory Hamilton Paths Hamilton Circuits and.
AND.
Euler Paths and Circuits. The original problem A resident of Konigsberg wrote to Leonard Euler saying that a popular pastime for couples was to try.
Week 13 - Monday.  What did we talk about last time?  B-trees  Hamiltonian tour  Traveling Salesman Problem.
By: Christophe Dufour Chrishon Adams Mischael Joseph.
I can describe the differences between Hamilton and Euler circuits and find efficient Hamilton circuits in graphs. Hamilton Circuits I can compare and.
Excursions in Modern Mathematics, 7e: Copyright © 2010 Pearson Education, Inc. 6 The Mathematics of Touring 6.1Hamilton Paths and Hamilton Circuits.
Chapter 14 Section 3 - Slide 1 Copyright © 2009 Pearson Education, Inc. AND.
Unit 2 Hamiltonian Circuits. Hamiltonian Circuit: A tour that starts at a vertex of a graph and visits each vertex once and only once, returning to where.
The Traveling Salesman Starring: Mr. Brute Force Co Starring: Mrs. Sorted Edge Lord Nearest Neighbor.
1 Euler and Hamilton paths Jorge A. Cobb The University of Texas at Dallas.
Copyright © 2008 Pearson Education, Inc. Slide 13-1 Unit 13B The Traveling Salesman Problem.
Grade 11 AP Mathematics Graph Theory Definition: A graph, G, is a set of vertices v(G) = {v 1, v 2, v 3, …, v n } and edges e(G) = {v i v j where 1 ≤ i,
Mathematical modeling To describe or represent a real-world situation quantitatively, in mathematical language.
Hamilton Paths and Hamilton Circuits
Excursions in Modern Mathematics Sixth Edition
Weighted Graphs and traveling Salesperson problem
6 The Mathematics of Touring
HAMILTONIAN CIRCUIT ALGORITHMS
Week 11 - Monday CS221.
Chapter 2: Business Efficiency Lesson Plan
Section 14.3 Hamilton Paths, and Hamilton Circuits
Chapter 2: Business Efficiency Business Efficiency
Heuristic Algorithms via VBA
A path that uses every vertex of the graph exactly once.
Cheapest-Link Algorithm/Sorted Edges (Unit 10) SOL: DM.2
Nearest Neighbor Repetitive Nearest Neighbor (Unit 10) SOL: DM.2
Chapter 15 Graph Theory © 2008 Pearson Addison-Wesley.
Chapter 15 Graph Theory © 2008 Pearson Addison-Wesley.
Classwork Worksheet Homework (day 67) worksheet
Hamilton Paths and Hamilton Circuits
Heuristic Algorithms via VBA
Heuristic Algorithms via VBA
CSC 380: Design and Analysis of Algorithms
Traveling Salesman Problems Nearest Neighbor Method
Presentation transcript:

Excursions in Modern Mathematics, 7e: Copyright © 2010 Pearson Education, Inc. 6 The Mathematics of Touring 6.1Hamilton Paths and Hamilton Circuits 6.2Complete Graphs? 6.3 Traveling Salesman Problems 6.4Simple Strategies for Solving TSPs 6.5The Brute-Force and Nearest-Neighbor Algorithms 6.6Approximate Algorithms 6.7The Repetitive Nearest-Neighbor Algorithm 6.8The Cheapest-Link Algorithm

Excursions in Modern Mathematics, 7e: Copyright © 2010 Pearson Education, Inc. In this section we will look at the two strategies we informally developed in connection with Willy’s sales trips and recast them in the language of algorithms. The “exhaustive search” strategy can be formalized into an algorithm generally known as the brute-force algorithm; the “go cheap” strategy can be formalized into an algorithm known as the nearest-neighbor algorithm. Algorithms for Solving TSP’s

Excursions in Modern Mathematics, 7e: Copyright © 2010 Pearson Education, Inc. ■ Step 1. Make a list of all the possible Hamilton circuits of the graph. Each of these circuits represents a tour of the vertices of the graph. ■ Step 2. For each tour calculate its weight (i.e., add the weights of all the edges in the circuit). ■ Step 3. Choose an optimal tour (there is always more than one optimal tour to choose from!). ALGORITM 1: THE BRUTE FORCE ALGORITHM

Excursions in Modern Mathematics, 7e: Copyright © 2010 Pearson Education, Inc. ■ Start: Start at the designated starting vertex.If there is no designated starting vertex pick any vertex. ■ First step: From the starting vertex go to its nearest neighbor(i.e.,the vertex for which the corresponding edge has the smallest weight). ALGORITM 2: THE NEAREST NEIGHBOR ALGORITHM

Excursions in Modern Mathematics, 7e: Copyright © 2010 Pearson Education, Inc. ■ Middle steps: From each vertex go to its nearest neighbor, choosing only among the vertices that haven’t been yet visited. (If there is more than one nearest neighbor choose among them at random.) Keep doing this until all the vertices have been visited. ■ Last step: From the last vertex return to the starting vertex. ALGORITM 2: THE NEAREST NEIGHBOR ALGORITHM

Excursions in Modern Mathematics, 7e: Copyright © 2010 Pearson Education, Inc. The positive aspect of the brute-force algorithm is that it is an optimal algorithm. (An optimal algorithm is an algorithm that, when correctly implemented, is guaranteed to produce an optimal solution.) In the case of the brute-force algorithm, we know we are getting an optimal solution because we are choosing from among all possible tours. Pros and Cons

Excursions in Modern Mathematics, 7e: Copyright © 2010 Pearson Education, Inc. The negative aspect of the brute-force algorithm is the amount of effort that goes into implementing the algorithm, which is (roughly) proportional to the number of Hamilton circuits in the graph. As we first saw in Table 6-4, as the number of vertices grows just a little, the number of Hamilton circuits in a complete graph grows at an incredibly fast rate. Pros and Cons

Excursions in Modern Mathematics, 7e: Copyright © 2010 Pearson Education, Inc. What does this mean in practical terms? Let’s start with human computation. To solve a TSP for a graph with 10 vertices (as real-life problems go, that’s puny), the brute- force algorithm requires checking 362,880 Hamilton circuits. To do this by hand, even for a fast and clever human, it would take over 1000 hours. Thus, N =10 at we are already beyond the limit of what can be considered reasonable human effort. Practical Terms of the Pros and Cons

Excursions in Modern Mathematics, 7e: Copyright © 2010 Pearson Education, Inc. Even with the world’s best technology on our side, we very quickly reach the point beyond which using the brute-force algorithm is completely unrealistic. Using a Computer

Excursions in Modern Mathematics, 7e: Copyright © 2010 Pearson Education, Inc. The brute-force algorithm is a classic example of what is formally known as an inefficient algorithm–an algorithm for which the number of steps needed to carry it out grows disproportionately with the size of the problem. The trouble with inefficient algorithms is that they are of limited practical use–they can realistically be carried out only when the problem is small. Using a Computer

Excursions in Modern Mathematics, 7e: Copyright © 2010 Pearson Education, Inc. We hop from vertex to vertex using a simple criterion: Choose the next available “nearest” vertex and go for it. Let’s call the process of checking among the available vertices and finding the nearest one a single computation. Then, for a TSP with N = 5 we need to perform 5 computations. What happens when we double, the number of vertices to N = 10? We now have to perform 10 computations. For N = 30, we perform 30 computations. Pros and Cons - Nearest Neighbor

Excursions in Modern Mathematics, 7e: Copyright © 2010 Pearson Education, Inc. We can summarize the above observations by saying that the nearest-neighbor algorithm is an efficient algorithm. Roughly speaking, an efficient algorithm is an algorithm for which the amount of computational effort required to implement the algorithm grows in some reasonable proportion with the size of the input to the problem. Pros and Cons - Nearest Neighbor

Excursions in Modern Mathematics, 7e: Copyright © 2010 Pearson Education, Inc. The main problem with the nearest-neighbor algorithm is that it is not an optimal algorithm. In Example 6.7, the nearest-neighbor tour had a cost of $773, whereas the optimal tour had a cost of $676. In absolute terms the nearest-neighbor tour is off by $97 (this is called the absolute error). A better way to describe how far “off” this tour is from the optimal tour is to use the concept of relative error. In this example the absolute error is $97 out of $676, giving a relative error of $97/$676 = ≈ 14.35%. Pros and Cons - Nearest Neighbor

Excursions in Modern Mathematics, 7e: Copyright © 2010 Pearson Education, Inc. In general, for any tour that might be proposed as a “solution” to a TSP, we can find its relative error  as follows: RELATIVE ERROR OF A TOUR (e)

Excursions in Modern Mathematics, 7e: Copyright © 2010 Pearson Education, Inc. It is customary to express the relative error as a percentage (usually rounded to two decimal places). By using the notion of relative error, we can characterize the optimal tours as those with relative error of 0%. All other tours give “approximate solutions,” the relative merits of which we can judge by their respective relative errors: tours with “small” relative errors are good, and tours with “large” relative errors are not good. Relative Error - Good or Not Good