The Traveling Salesman Problem Brute Force Method

Similar documents
The Traveling Salesman Problem Nearest-Neighbor Algorithm

The Critical-Path Algorithm

Minimal Spanning Trees

Street-Routing Problems

The Traveling Salesman Problem Cheapest-Link Algorithm

Solving Recursive Sequences by Iteration

Nondeterministic Programming in C++

Scheduling and Digraphs

Recursive Sequences. Lecture 24 Section 5.6. Robb T. Koether. Hampden-Sydney College. Wed, Feb 26, 2014

Rotations and Translations

Magnification and Minification

Recursive Sequences. Lecture 24 Section 5.6. Robb T. Koether. Hampden-Sydney College. Wed, Feb 27, 2013

LR Parsing - Conflicts

The Decreasing-Time Algorithm

The Pairwise-Comparison Method

The Class Construct Part 1

The Plurality-with-Elimination Method

Sampling Distribution Examples Sections 15.4, 15.5

The Graphics Pipeline

Scope and Parameter Passing

The CYK Parsing Algorithm

while Loops Lecture 13 Sections Robb T. Koether Wed, Sep 26, 2018 Hampden-Sydney College

Stack Applications. Lecture 27 Sections Robb T. Koether. Hampden-Sydney College. Wed, Mar 29, 2017

Operators. Lecture 12 Section Robb T. Koether. Hampden-Sydney College. Fri, Feb 9, 2018

Scope and Parameter Passing

Friends and Unary Operators

Recursive Descent Parsers

The Graphics Pipeline

Recursive Linked Lists

XQuery FLOWR Expressions Lecture 35

Density Curves Sections

Boxplots. Lecture 17 Section Robb T. Koether. Hampden-Sydney College. Wed, Feb 10, 2010

Total Orders. Lecture 41 Section 8.5. Robb T. Koether. Hampden-Sydney College. Mon, Apr 8, 2013

List Iterator Implementation

Boolean Expressions. Lecture 31 Sections 6.6, 6.7. Robb T. Koether. Hampden-Sydney College. Wed, Apr 8, 2015

XPath Lecture 34. Robb T. Koether. Hampden-Sydney College. Wed, Apr 11, 2012

Shading Triangles. Lecture 37. Robb T. Koether. Hampden-Sydney College. Mon, Nov 30, 2015

The Coefficient of Determination

Programming Languages

Displaying Distributions - Quantitative Variables

Mipmaps. Lecture 35. Robb T. Koether. Hampden-Sydney College. Wed, Nov 18, 2015

Recognition of Tokens

Relational Databases Lecture 2

Pointers. Lecture 2 Sections Robb T. Koether. Hampden-Sydney College. Fri, Jan 18, 2013

The string Class. Lecture 21 Sections 2.9, 3.9, Robb T. Koether. Wed, Oct 17, Hampden-Sydney College

Webpage Navigation. Lecture 27. Robb T. Koether. Hampden-Sydney College. Mon, Apr 2, 2018

Binary Tree Applications

Stacks and their Applications

Linked Lists. Lecture 16 Sections Robb T. Koether. Hampden-Sydney College. Wed, Feb 22, 2017

The Normal Distribution

Stack Applications. Lecture 25 Sections Robb T. Koether. Hampden-Sydney College. Mon, Mar 30, 2015

Implementing Linked Lists

Array Lists. Lecture 15. Robb T. Koether. Hampden-Sydney College. Fri, Feb 16, 2018

Building the Abstract Syntax Trees

Introduction to Databases

XML Attributes. Lecture 33. Robb T. Koether. Hampden-Sydney College. Wed, Apr 25, 2018

Regular Expressions. Lecture 10 Sections Robb T. Koether. Hampden-Sydney College. Wed, Sep 14, 2016

Pointers. Lecture 1 Sections Robb T. Koether. Hampden-Sydney College. Wed, Jan 14, 2015

The Projection Matrix

Review. Lecture 39. Robb T. Koether. Mon, Dec 5, Hampden-Sydney College. Robb T. Koether (Hampden-Sydney College) Review Mon, Dec 5, / 14

XPath. Lecture 36. Robb T. Koether. Wed, Apr 16, Hampden-Sydney College. Robb T. Koether (Hampden-Sydney College) XPath Wed, Apr 16, / 28

Dynamic Allocation of Memory

LR Parsing - The Items

The Projection Matrix

Applying Textures. Lecture 27. Robb T. Koether. Hampden-Sydney College. Fri, Nov 3, 2017

Integer Overflow. Lecture 8 Section 2.5. Robb T. Koether. Hampden-Sydney College. Mon, Jan 27, 2014

Recursion. Lecture 26 Sections , Robb T. Koether. Hampden-Sydney College. Mon, Apr 6, 2015

Recursion. Lecture 2 Sections Robb T. Koether. Hampden-Sydney College. Wed, Jan 17, 2018

Specular Reflection. Lecture 19. Robb T. Koether. Hampden-Sydney College. Wed, Oct 4, 2017

Ambient and Diffuse Light

Function Definition Syntax Tree

Basic PHP Lecture 17

Aggregation. Lecture 7 Section Robb T. Koether. Hampden-Sydney College. Wed, Jan 29, 2014

Introduction to Databases

Programming Languages

PHP Queries and HTML Forms Lecture 23

Function Usage. Lecture 15 Sections 6.3, 6.4. Robb T. Koether. Hampden-Sydney College. Mon, Oct 1, 2018

Relational Databases

Abstract Data Types. Lecture 23 Section 7.1. Robb T. Koether. Hampden-Sydney College. Wed, Oct 24, 2012

The x86 Architecture

The x86 Instruction Set

DTDs and XML Attributes

Introduction to Compiler Design

Pointer Arithmetic. Lecture 4 Chapter 10. Robb T. Koether. Hampden-Sydney College. Wed, Jan 25, 2017

Pointers. Lecture 2 Sections Robb T. Koether. Hampden-Sydney College. Mon, Jan 20, 2014

Chapter 14 Section 3 - Slide 1

Form Validation. Lecture 25. Robb T. Koether. Hampden-Sydney College. Wed, Mar 23, 2018

The Constructors. Lecture 6 Sections Robb T. Koether. Hampden-Sydney College. Fri, Jan 26, 2018

Shader Programs. Lecture 30 Subsections 2.8.2, Robb T. Koether. Hampden-Sydney College. Wed, Nov 16, 2011

Inheritance: The Fundamental Functions

MySQL Creating a Database Lecture 3

Triggers. Lecture 14. Robb T. Koether. Hampden-Sydney College. Wed, Feb 14, 2018

List Iterators. Lecture 27 Section Robb T. Koether. Hampden-Sydney College. Wed, Apr 8, 2015

Inheritance: The Fundamental Functions

AJAX. Lecture 26. Robb T. Koether. Fri, Mar 21, Hampden-Sydney College. Robb T. Koether (Hampden-Sydney College) AJAX Fri, Mar 21, / 16

CUP. Lecture 18 CUP User s Manual (online) Robb T. Koether. Hampden-Sydney College. Fri, Feb 27, 2015

The Class Construct Part 2

PHP Arrays. Lecture 18. Robb T. Koether. Hampden-Sydney College. Mon, Mar 4, 2013

The Constructors. Lecture 7 Sections Robb T. Koether. Hampden-Sydney College. Wed, Feb 1, 2017

List Iterators. Lecture 34 Section Robb T. Koether. Hampden-Sydney College. Wed, Apr 24, 2013

Transcription:

The Traveling Salesman Problem Brute Force Method Lecture 30 Sections 6.1, 6.3 Robb T. Koether Hampden-Sydney College Fri, Nov 3, 2017 Robb T. Koether (Hampden-Sydney College)The Traveling Salesman Problem Brute Force Method Fri, Nov 3, 2017 1 / 13

1 The Traveling Salesman Problem 2 The Brute-Force Algorithm 3 Assignment Robb T. Koether (Hampden-Sydney College)The Traveling Salesman Problem Brute Force Method Fri, Nov 3, 2017 2 / 13

Outline 1 The Traveling Salesman Problem 2 The Brute-Force Algorithm 3 Assignment Robb T. Koether (Hampden-Sydney College)The Traveling Salesman Problem Brute Force Method Fri, Nov 3, 2017 3 / 13

The Traveling Salesman Problem Definition (Traveling Salesman Problem) The Traveling Salesman Problem is to find the circuit that visits every vertex (at least once) and minimizes the total weight of its edges. Robb T. Koether (Hampden-Sydney College)The Traveling Salesman Problem Brute Force Method Fri, Nov 3, 2017 4 / 13

The Traveling Salesman Problem The Traveling Salesman Problem could also be called the UPS Deliveryman Problem. There is a weight (or cost) to each edge of the graph. The weight could be expressed as Distance Find the shortest circuit. Time Find the fastest circuit. Dollars (fuel, pay) Find the least expensive circuit. Robb T. Koether (Hampden-Sydney College)The Traveling Salesman Problem Brute Force Method Fri, Nov 3, 2017 5 / 13

The Traveling Salesman Problem 10 11 9 10 4 7 8 7 9 A B C D E F G H I J 3 6 6 14 8 7 9 3 3 2 2 4 10 1 Robb T. Koether (Hampden-Sydney College)The Traveling Salesman Problem Brute Force Method Fri, Nov 3, 2017 6 / 13

The Traveling Salesman Problem B 8 A 25 15 17 10 C 14 4 11 9 21 9 13 24 21 7 15 J 14 11 11 18 25 14 9 E I 17 2819 24 14 17 22 14 19 29 F 25 11 32 10 19 15 19 28 25 11 D H 19 9 G Robb T. Koether (Hampden-Sydney College)The Traveling Salesman Problem Brute Force Method Fri, Nov 3, 2017 6 / 13

The Traveling Salesman Problem A 8 11 B 6 7 C 10 D 9 I 10 11 15 J 17 4 14 11 11 F 9 14 E 7 H 9 G Robb T. Koether (Hampden-Sydney College)The Traveling Salesman Problem Brute Force Method Fri, Nov 3, 2017 6 / 13

The Traveling Salesman Problem A B C D E F G H I J A - 8 15 25 24 25 28 19 9 11 B 8-7 17 16 18 29 21 17 6 C 15 7-10 9 11 22 19 15 4 D 25 17 10-7 21 32 29 25 14 E 24 16 9 7-14 25 28 24 13 F 25 18 11 21 14-11 20 17 14 G 28 29 22 32 25 11-9 19 25 H 19 21 19 29 28 20 9-10 15 I 9 17 15 25 24 17 19 10-11 J 11 6 4 14 13 14 25 15 11 - Robb T. Koether (Hampden-Sydney College)The Traveling Salesman Problem Brute Force Method Fri, Nov 3, 2017 7 / 13

Outline 1 The Traveling Salesman Problem 2 The Brute-Force Algorithm 3 Assignment Robb T. Koether (Hampden-Sydney College)The Traveling Salesman Problem Brute Force Method Fri, Nov 3, 2017 8 / 13

Definition (Brute-Force Algorithm) A brute-force algorithm is an algorithm that tries exhaustively every possibility, and then chooses the best one. Robb T. Koether (Hampden-Sydney College)The Traveling Salesman Problem Brute Force Method Fri, Nov 3, 2017 9 / 13

Definition (Brute-Force Algorithm) A brute-force algorithm is an algorithm that tries exhaustively every possibility, and then chooses the best one. If there are n cities, then there are (n 1)! possible circuits. Robb T. Koether (Hampden-Sydney College)The Traveling Salesman Problem Brute Force Method Fri, Nov 3, 2017 9 / 13

Definition (Brute-Force Algorithm) A brute-force algorithm is an algorithm that tries exhaustively every possibility, and then chooses the best one. If there are n cities, then there are (n 1)! possible circuits. That is, n 1 choices for the first city. Robb T. Koether (Hampden-Sydney College)The Traveling Salesman Problem Brute Force Method Fri, Nov 3, 2017 9 / 13

Definition (Brute-Force Algorithm) A brute-force algorithm is an algorithm that tries exhaustively every possibility, and then chooses the best one. If there are n cities, then there are (n 1)! possible circuits. That is, n 1 choices for the first city. Followed by n 2 choices for the second city. Robb T. Koether (Hampden-Sydney College)The Traveling Salesman Problem Brute Force Method Fri, Nov 3, 2017 9 / 13

Definition (Brute-Force Algorithm) A brute-force algorithm is an algorithm that tries exhaustively every possibility, and then chooses the best one. If there are n cities, then there are (n 1)! possible circuits. That is, n 1 choices for the first city. Followed by n 2 choices for the second city. Followed by n 3 choices for the third city. Robb T. Koether (Hampden-Sydney College)The Traveling Salesman Problem Brute Force Method Fri, Nov 3, 2017 9 / 13

Definition (Brute-Force Algorithm) A brute-force algorithm is an algorithm that tries exhaustively every possibility, and then chooses the best one. If there are n cities, then there are (n 1)! possible circuits. That is, n 1 choices for the first city. Followed by n 2 choices for the second city. Followed by n 3 choices for the third city. And so on, until only 1 choice for the last city. Robb T. Koether (Hampden-Sydney College)The Traveling Salesman Problem Brute Force Method Fri, Nov 3, 2017 9 / 13

Definition (Brute-Force Algorithm) A brute-force algorithm is an algorithm that tries exhaustively every possibility, and then chooses the best one. If there are n cities, then there are (n 1)! possible circuits. That is, n 1 choices for the first city. Followed by n 2 choices for the second city. Followed by n 3 choices for the third city. And so on, until only 1 choice for the last city. Altogether choices. (n 1)(n 2)(n 3) 3 2 1 = (n 1)! Robb T. Koether (Hampden-Sydney College)The Traveling Salesman Problem Brute Force Method Fri, Nov 3, 2017 9 / 13

If a computer could process 1,000,000,000 possibilities per second, how long would it take if there were Robb T. Koether (Hampden-Sydney College)The Traveling Salesman Problem Brute Force Method Fri, Nov 3, 2017 10 / 13

If a computer could process 1,000,000,000 possibilities per second, how long would it take if there were 10 cities? Robb T. Koether (Hampden-Sydney College)The Traveling Salesman Problem Brute Force Method Fri, Nov 3, 2017 10 / 13

If a computer could process 1,000,000,000 possibilities per second, how long would it take if there were 10 cities? 15 cities? Robb T. Koether (Hampden-Sydney College)The Traveling Salesman Problem Brute Force Method Fri, Nov 3, 2017 10 / 13

If a computer could process 1,000,000,000 possibilities per second, how long would it take if there were 10 cities? 15 cities? 20 cities? Robb T. Koether (Hampden-Sydney College)The Traveling Salesman Problem Brute Force Method Fri, Nov 3, 2017 10 / 13

If a computer could process 1,000,000,000 possibilities per second, how long would it take if there were 10 cities? 15 cities? 20 cities? 25 cities? Robb T. Koether (Hampden-Sydney College)The Traveling Salesman Problem Brute Force Method Fri, Nov 3, 2017 10 / 13

If a computer could process 1,000,000,000 possibilities per second, how long would it take if there were 10 cities? 15 cities? 20 cities? 25 cities? 30 cities? Robb T. Koether (Hampden-Sydney College)The Traveling Salesman Problem Brute Force Method Fri, Nov 3, 2017 10 / 13

Clearly, the brute-force algorithm is not adequate to solve the Traveling Salesman Problem. Robb T. Koether (Hampden-Sydney College)The Traveling Salesman Problem Brute Force Method Fri, Nov 3, 2017 11 / 13

Clearly, the brute-force algorithm is not adequate to solve the Traveling Salesman Problem. What is the UPS driver to do? Robb T. Koether (Hampden-Sydney College)The Traveling Salesman Problem Brute Force Method Fri, Nov 3, 2017 11 / 13

Outline 1 The Traveling Salesman Problem 2 The Brute-Force Algorithm 3 Assignment Robb T. Koether (Hampden-Sydney College)The Traveling Salesman Problem Brute Force Method Fri, Nov 3, 2017 12 / 13

Assignment Assignment Chapter 6: Exercises 27, 28, 29, 31, 33. Robb T. Koether (Hampden-Sydney College)The Traveling Salesman Problem Brute Force Method Fri, Nov 3, 2017 13 / 13