A path that visits each vertex exactly once is a path

Similar documents
A path that visits each vertex exactly once is a Hamiltonian path. A circuit that visits each vertex exactly once is a Hamiltonian circuit.

Check off these skills when you feel that you have mastered them. Write in your own words the definition of a Hamiltonian circuit.

Intro to Contemporary Math

Warm-up Find the shortest trip (total distance) starting and ending in Chicago and visiting each other city once.

Mathematical Thinking Exam 2 20 November 2017

Algorithm Design Strategies V

Traveling Salesman Problem (TSP) - Visit every city and then go home.

Chapter 2. Business Efficiency. Chapter Outline. Chapter Summary

CS/COE

VIII. NP-completeness

Optimization Prof. A. Goswami Department of Mathematics Indian Institute of Technology, Kharagpur. Lecture - 20 Travelling Salesman Problem

1 Heuristics for the Traveling Salesman Problem

Covers: Midterm Review

Data Structures and Algorithms

Data Structures in Java

Tractable & Intractable Problems

8.3 Hamiltonian Paths and Circuits

FINAL EXAM PRACTICE PROBLEMS CMSC 451 (Spring 2016)

D1 Discrete Mathematics The Travelling Salesperson problem. The Nearest Neighbour Algorithm The Lower Bound Algorithm The Tour Improvement Algorithm

P, NP, NP-Complete. Ruth Anderson

Data Structures and Algorithms

Bounds on the Traveling Salesman Problem

CSCI3390-Lecture 17: A sampler of NP-complete problems

NP-Complete Problems and Approximation Algorithms

Nondeterministic Polynomial Time

NP-Completeness. Until now we have been designing algorithms for specific problems

SAT, Coloring, Hamiltonian Cycle, TSP

NP-Completeness. CptS 223 Advanced Data Structures. Larry Holder School of Electrical Engineering and Computer Science Washington State University

Algorithms Design & Analysis. Approximation Algorithm

Combinatorial optimization problems

CSE 326: Data Structures NP Completeness

Applied Integer Programming: Modeling and Solution

Graph Theory and Optimization Computational Complexity (in brief)

ECS122A Handout on NP-Completeness March 12, 2018

NP-Completeness. Andreas Klappenecker. [based on slides by Prof. Welch]

NP-complete problems. CSE 101: Design and Analysis of Algorithms Lecture 20

July 18, Approximation Algorithms (Travelling Salesman Problem)

Hamiltonian Cycle. Hamiltonian Cycle

COSE215: Theory of Computation. Lecture 20 P, NP, and NP-Complete Problems

P P P NP-Hard: L is NP-hard if for all L NP, L L. Thus, if we could solve L in polynomial. Cook's Theorem and Reductions

CS 583: Algorithms. NP Completeness Ch 34. Intractability

Polynomial-time reductions. We have seen several reductions:

CS 320, Fall Dr. Geri Georg, Instructor 320 NP 1

NP-Complete Problems. More reductions

Edge Elimination for the Hamiltonian Cycle problem

Algebra I EOC Review (Part 3)

Lecture 4: NP and computational intractability

NP and Computational Intractability

Part III: Traveling salesman problems

Automata Theory CS S-18 Complexity Theory II: Class NP

Theoretical computer science: Turing machines

Computer Science 385 Analysis of Algorithms Siena College Spring Topic Notes: Limitations of Algorithms

Question Paper Code :

ABHELSINKI UNIVERSITY OF TECHNOLOGY

Practice Final Solutions. 1. Consider the following algorithm. Assume that n 1. line code 1 alg(n) { 2 j = 0 3 if (n = 0) { 4 return j

CS Analysis of Recursive Algorithms and Brute Force

CS Algorithms and Complexity

Scheduling and Optimization Course (MPRI)

(c) Give a proof of or a counterexample to the following statement: (3n 2)= n(3n 1) 2

12-4 Law of Sines. Find the area of ABC to the nearest tenth, if necessary. SOLUTION: Substitute c = 7, b = 8 and A = 86º in the area. formula.

2 hours THE UNIVERSITY OF MANCHESTER. 6 June :45 11:45

CSL 356: Analysis and Design of Algorithms. Ragesh Jaiswal CSE, IIT Delhi

Limitations of Algorithm Power

Trees/Intro to counting

Combinatorial Optimization

Chapter 34: NP-Completeness

Algorithms and Theory of Computation. Lecture 22: NP-Completeness (2)

Counting Strategies: Inclusion-Exclusion, Categories

Outline. 1 NP-Completeness Theory. 2 Limitation of Computation. 3 Examples. 4 Decision Problems. 5 Verification Algorithm

2 Notation and Preliminaries

HOMEWORK #2 - MATH 3260

Unit 7 Day 4 Section 4.5 & Practice Hamiltonian Circuits and Paths

Graduate Algorithms CS F-21 NP & Approximation Algorithms

Introduction to Complexity Theory

Planar Graphs (1) Planar Graphs (3) Planar Graphs (2) Planar Graphs (4)

Data Structures and Algorithms (CSCI 340)

Problem Complexity Classes

Unit 1A: Computational Complexity

Polynomial-time Reductions

Chapter 3: Proving NP-completeness Results

10.3 Matroids and approximation

CHAPTER 3 FUNDAMENTALS OF COMPUTATIONAL COMPLEXITY. E. Amaldi Foundations of Operations Research Politecnico di Milano 1

Single Machine Models

Approximation of Euclidean k-size cycle cover problem

CS483 Design and Analysis of Algorithms

University of Washington March 21, 2013 Department of Computer Science and Engineering CSEP 521, Winter Exam Solution, Monday, March 18, 2013

Football Solar System Lab

Circuits. CSE 373 Data Structures

2. A vertex in G is central if its greatest distance from any other vertex is as small as possible. This distance is the radius of G.

Branch-and-Bound for the Travelling Salesman Problem

Computers and Intractability. The Bandersnatch problem. The Bandersnatch problem. The Bandersnatch problem. A Guide to the Theory of NP-Completeness

NP Complete Problems. COMP 215 Lecture 20

Quantum Algorithms for Graph Traversals and Related Problems

Computers and Intractability

Worst Case Performance of Approximation Algorithm for Asymmetric TSP

8.5 Sequencing Problems

Chapter 9: Relations Relations

3.4 Relaxations and bounds

Algorithms and Complexity Theory. Chapter 8: Introduction to Complexity. Computer Science - Durban - September 2005

Transcription:

( c ) p s t e i n, a r t e r, & o l l i n g e r 2016 h a p t e r 2 : u s i n e s s f f i c i e n c y P a g e 1 HPTR 2: USINSS FFIINY 2.1 Hamiltonian ircuits path that visits each vertex exactly once is a path circuit that visits each vertex exactly once (except the beginning point will be visited again) is a circuit. etermine if the graphs below have a Hamiltonian path or circuit.

( c ) p s t e i n, a r t e r, & o l l i n g e r 2016 h a p t e r 2 : u s i n e s s f f i c i e n c y P a g e 2 To find all possible Hamiltonian circuits, you can use the to list all possible paths from a particular starting point. Use the method of trees to find all Hamiltonian circuits starting at. F

( c ) p s t e i n, a r t e r, & o l l i n g e r 2016 h a p t e r 2 : u s i n e s s f f i c i e n c y P a g e 3 n Hamiltonian circuit is the circuit that has the least weight. Represent the data in the map below in a weighted graph. Then use the method of trees to determine the minimum cost (travel time, in hours) to visit Miami, San Juan (Puerto Rico), arbados and elize ity (elize) if you must start and end in Miami. In what order do you visit the cities? 2.0 6.0 3.5 4.0 8.0 3.0

( c ) p s t e i n, a r t e r, & o l l i n g e r 2016 h a p t e r 2 : u s i n e s s f f i c i e n c y P a g e 4 graph is a graph in which every pair of vertices is connected by exactly one edge. etermine which of the graphs below are complete. W V Z Y X How many edges does a complete graph with n vertices have? Fundamental Theorem of ounting: Suppose you have k tasks to be performed. The first task can be completed n 1 ways, the second task n 2 ways, etc. The total number of ways that these k tasks can be performed is the product n 1 n 2 n k s How many outfits can be made from 2 shirts and 5 pairs of pants, if an outfit consists of a shirt and a pair of pants? How many different ways can 5 people stand in a line?

( c ) p s t e i n, a r t e r, & o l l i n g e r 2016 h a p t e r 2 : u s i n e s s f f i c i e n c y P a g e 5 rute Force Method for a omplete Graph with n Vertices: There are n! Hamiltonian circuits in a complete graph. There are n! Hamiltonian circuits in a complete graph, if a circuit 2 and its mirror image are not counted as separate circuits. If a starting point is specified, there are (n 1)! Hamiltonian circuits in a complete graph. If a starting point is specified, there are (n 1)! Hamiltonian circuits 2 in a complete graph, if a circuit and its mirror image are not counted as separate circuits. Use the brute force method to find all different (non-mirror image) Hamiltonian circuits for the complete graphs below starting at.

( c ) p s t e i n, a r t e r, & o l l i n g e r 2016 h a p t e r 2 : u s i n e s s f f i c i e n c y P a g e 6 Use the brute force method to find all different (non-mirror image) Hamiltonian circuits for the complete graphs below starting at.

( c ) p s t e i n, a r t e r, & o l l i n g e r 2016 h a p t e r 2 : u s i n e s s f f i c i e n c y P a g e 7 2.2 Traveling Salesman Problem (TSP) The traveling salesman problem is the problem of finding a least cost Hamiltonian circuit in a complete graph where each edge has been assigned a cost (or weight). Use the brute force method to find the least cost Hamiltonian circuit, starting at, in the graph below. The values are distances between points, in miles. 17 16 13 30 29 15 25 27 12 14 The TSP is an important and common problem to solve, so we need heuristic algorithms. These are algorithms are fast, but they may not be optimal.

( c ) p s t e i n, a r t e r, & o l l i n g e r 2016 h a p t e r 2 : u s i n e s s f f i c i e n c y P a g e 8 2.3 Helping Traveling Salesmen Nearest Neighbor (NN) lgorithm (for finding low-cost Hamiltonian circuits): Starting from the home city, visit the nearest city first. Then visit the nearest city that has not already been visited. Return to the home city when no other choices remain. Note that a algorithm is one in which the choices are made by what is best at the next step. Use the NN algorithm to solve the TSP of finding a low-cost trip starting at Miami (M) and traveling to the other three places. The weights given are the travel times between places, in hours.) M 2 8 6 4 3.5 3 SJ Is the solution you found the same as the optimal solution found when we used brute force?

( c ) p s t e i n, a r t e r, & o l l i n g e r 2016 h a p t e r 2 : u s i n e s s f f i c i e n c y P a g e 9 Use the NN algorithm to find a low-cost Hamiltonian circuit (solve the TSP) given the graph below, starting at and also starting at. The values are distances between points, in miles. Starting at : 17 16 13 30 29 15 25 27 12 14 Starting at : 17 16 13 30 29 15 25 27 12 14 Is the solution you found starting at the same as the optimal solution found when we used brute force?

( c ) p s t e i n, a r t e r, & o l l i n g e r 2016 h a p t e r 2 : u s i n e s s f f i c i e n c y P a g e 10 The following table gives the distances between the different cities, in miles. fton ar Nunn asper Laramie Newcastle Pine luffs Rock Springs Sleepy Hollow fton 0 355 356 387 537 477 180 477 ar Nunn 355 0 7 146 189 227 228 122 asper 356 7 0 142 185 223 228 128 Laramie 387 146 142 0 246 89 207 249 Newcastle 537 189 185 246 0 217 409 78 Pine luffs 477 227 223 89 217 0 296 285 Rock Springs 180 228 228 207 409 296 0 351 Sleepy Hollow 477 122 128 249 78 285 351 0 If the brute force method was used to find the least cost Hamiltonian circuit (solve the TSP) starting at fton, how many different (nonmirror image) circuits would need to be checked? Use the NN algorithm to solve the TSP, starting at fton. Use the NN algorithm to solve the TSP, starting at ar Nunn.

( c ) p s t e i n, a r t e r, & o l l i n g e r 2016 h a p t e r 2 : u s i n e s s f f i c i e n c y P a g e 11 Sorted dges (S) lgorithm (for finding low-cost Hamiltonian circuits): 1. rrange edges of the complete graph in order of increasing cost 2. Select the lowest cost edge that has not already been selected that a. oes not cause a vertex to have 3 edges b. oes not close the circuit unless all vertices have been included. Solve the following TSP using the S algorithm. (Remember this graph represents places and the travel times between them, in hours.) M 2 4 3.5 6 SJ 8 3 Is the solution you found optimal? Solve the following TSP using the S algorithm. (Remember the weights given are distances, in miles.) 17 16 13 30 29 15 25 27 12 14 Is the solution you found optimal?

( c ) p s t e i n, a r t e r, & o l l i n g e r 2016 h a p t e r 2 : u s i n e s s f f i c i e n c y P a g e 12 2.4 Minimum ost Spanning Trees connected graph that has no circuits is a. is a tree that has all the vertices of the original graph. To create a spanning tree from a graph, 1. opy the vertices with no edges 2. dd edges back one by one until you have a connected graph that uses all vertices and contains no circuits For the following graphs, form a subgraph that is a spanning tree. F

( c ) p s t e i n, a r t e r, & o l l i n g e r 2016 h a p t e r 2 : u s i n e s s f f i c i e n c y P a g e 13 spanning tree is a spanning tree with the smallest possible weight. Kruskal s lgorithm for finding minimum-cost spanning trees: Finding a minimum-cost spanning tree by adding edges in order of increasing cost so that no circuit is formed. Use Kruskal s lgorithm to find a minimum-cost spanning tree from the graphs below (in each, the weights given are times, in minutes): 11 8 7 20 25 5 10 Minimum-cost spanning tree has a total cost of. 7 11 3 12 5 K 9 6 4 17 15 J H 8 10 F 2 G Minimum-cost spanning tree has a total cost of. F G K J H

( c ) p s t e i n, a r t e r, & o l l i n g e r 2016 h a p t e r 2 : u s i n e s s f f i c i e n c y P a g e 14 2.5 ritical Path nalysis list of vertices connected by arrows is a graph or. If the tasks cannot be completed in a random order, then the order can be specified in an digraph. If the time to complete a task is shown on the digraph, it is a digraph. Suppose the first task T 1 takes 4 minutes and a second task T 2 takes 6 minutes, and the second task can t be started until the first task is done. This would be represented in a weighted digraph as n task is one that can be done independently of any of the other tasks. So if task T 3 takes 1 minute and is an independent task, the weighted order-requirement digraph would look like

( c ) p s t e i n, a r t e r, & o l l i n g e r 2016 h a p t e r 2 : u s i n e s s f f i c i e n c y P a g e 15 reak down the fajita recipe below into a series of tasks. Show these tasks in a weighted order-requirement digraph. Tortillas hicken 1 onion Seasoning Tomatoes ilantro Slice the onion and chicken into strips. ook chicken 10 minutes then add onions and cook for 5 more minutes. dd seasoning. hop tomatoes and mix with cilantro. Warm tortillas. Serve.

( c ) p s t e i n, a r t e r, & o l l i n g e r 2016 h a p t e r 2 : u s i n e s s f f i c i e n c y P a g e 16 path on the digraph is the longest path and it determines the earliest completion time (the earliest possible time for the completion of all of the tasks making up the job in the digraph). What is the critical path for making fajitas? etermine the critical path in the digraph below. What is the earliest possible time for completion of all of the tasks in the digraph?