24
Decision 1:: Route Inspection [email protected] With A2 content from Damien Medhurst [email protected] Last modified: 13 th November 2020

Decision 1:: Route Inspection

  • Upload
    others

  • View
    7

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Decision 1:: Route Inspection

Decision 1:: Route [email protected]

With A2 content from Damien Medhurst [email protected]

Last modified: 13th November 2020

Page 2: Decision 1:: Route Inspection

1:: Algorithms

Sorting and bin packing.

4:: Route inspection

Find the shortest route which travels along all roads

2:: Graphs and networks

What is a graph and how they represent things.

5:: The Travelling Salesman

Find the shortest route which visits all places.

3:: Algorithms on graphs

What algorithms do I need to be able to apply?

6:: Linear Programming

How to find an optimal solution graphically

7:: The simplex algorithm

How to find an optimal solution algebraically.

8:: Critical path analysis

How to plan a project.

Decision 1 Overview

Page 3: Decision 1:: Route Inspection

The Seven Bridges of Konigsberg

No course on graph theory would be complete without exploring this problem, its solution was first published by Leonhard Euler (pronounced Oiler) in 1736, and is considered to be the first problem in Graph Theory.

“This question is so banal, but seemed to me worthy of attention in that [neither]

geometry, nor algebra, nor even the art of counting was sufficient to solve it.”

Leohnard Euler, 1736.

The (very much non-banal) problem we will go on to explore is as follows. Can a resident of Konigsberg, take a walk around the city, finishing where they start and crossing all 7 bridges over the Pregal river?

Before we go any further, I invite you to have a go.

Page 4: Decision 1:: Route Inspection

The Seven Bridges of Konigsberg

Euler reduced the map to a graph, with the vertices representing the 4 land masses, and the edges representing the 7 bridges.

If you aren’t going to get ‘stuck’ on a landmass (vertex), then you have to leave it the same number of times you enter it.What does this mean for the degree of each vertex? What does it mean for the residents of Konigsberg?

Each vertex has to have even degree if the 7 bridges problem is solvable. Because each vertex is odd the problem can’t be solved.

Page 5: Decision 1:: Route Inspection

Eulerian or Semi-Eulerian graphsOf the graphs below, which ones can you draw without taking your pen off the paper?

When you have had a go, explore the number of odd vertices each graph has.

1 2

4

3

5

Page 6: Decision 1:: Route Inspection

Eulerian or Semi-Eulerian graphsYou should have found that you could draw graphs 4 and 5 without taking your pen off and that you could draw graphs 2 and 3 without taking your pen off if you start and finish at one of the odd (red) vertices, you can’t draw 1 without taking your pen off.

1 2

4

3

5 A connected graph with no odd vertices is know as “Eulerian”.A connected graph with 2 odd vertices is know as “Semi-Eulerian”

Page 7: Decision 1:: Route Inspection

Source, https://www.youtube.com/watch?v=CQNH2ifOAQE&version=3&hl=en%5FUS&rel=0

Another Eulerian trail challenge.Can you find an Eulerian trail around the following pattern crossing every line segment once?

When you have tried, then turn it into a graph where the regions are vertices, and the routes between them are edges (don’t forget the outside region).

Explain what the degree of the vertices tells you about the impossibility (or not!) of this problem.

There are more than 2 odd vertices so the problem isn’t possible.

Page 8: Decision 1:: Route Inspection

Test your understanding

In which cases is the complete graph 𝐾𝑛 Eulerian or Semi-Eulerian?

𝐾2 𝐾3 𝐾4

𝐾5 𝐾6

Semi-Eulerian (2 odd vertices)

𝐾1

Eulerian (all even)Non-Eulerian (all odd)

Eulerian (all even) Non-Eulerian (all odd)

Eulerian (1 vertex with degree zero, which is even)

𝐾2𝑛+1 ∀ 𝑛 ∈ ℤ+

Eulerian (2n+1 vertices with degree 2n)

Page 9: Decision 1:: Route Inspection

A connected graph has 4 nodes and 8 edges.

The nodes have degree 2𝑛 − 2, 𝑛 − 1, 𝑛 − 1, 𝑛

State if the graph is Eulerian, Semi-Eulerian or neither. You must fully explain your answer.

Further test your understanding

Each edge adds 2 to the total valency, so the 8 edges give a total valency of 16.

2𝑛 − 2 + 𝑛 − 1 + 𝑛 − 1 + 𝑛 = 165𝑛 − 4 = 16

5𝑛 = 20𝑛 = 4

So the nodes have degree 6, 3, 3, 4.

So there are 2 nodes of odd degree so the graph is semi-Eulerian.

An alternative approach here uses the Handshake Lemma (Ch2). We note that if n was odd there would be one odd vertex, which isn’t possible by the Handshake Lemma, therefore n is even, there are 2 odd vertices and the graph is semi-Eulerian.

Alternative approach using the handshake lemma.

Page 10: Decision 1:: Route Inspection

Pearson Decision 1, Page 87-89

Exercise 4A

Page 11: Decision 1:: Route Inspection

The route inspection algorithm

The Route Inspection Algorithm, also known as the Chinese Postman Problem - in honour of Kwan Mei-Ko, who first studied the problem in 1960, finds the length of the shortest route in a network that traverses every arc at least once, and returns to its starting point.

If the network is Eulerian, then the length of the shortest route will be equal to the total weight of the network.

The Route Inspection algorithm doesn’t tell you what the shortest route is, only how long it is.

The algorithm can be used for more than planning postal routes. Snow plough routes, inspection of pipes or roads, or designing an optimal process to check all the links on a website (making sure you ‘travel along’ every link) could all use this algorithm.

Page 12: Decision 1:: Route Inspection

The route inspection algorithm – All even vertices.

12

4

9

3

12 68 7

10

11

8

3 2

9

Postman pat wants to deliver letters to all the houses in Greendale.

The length of time (in minutes) it takes him to deliver to each street is shown on the graph.

Calculate the time taken for Pat to complete his round. You may assume he starts and finishes at the depot.

Depot

As all the vertices are even, the graph is Eulerian and the length of the shortest route is just the sum of all the weights. In this case this is 104 minutes.

Click on Pat to see one suggested route!

Page 13: Decision 1:: Route Inspection

The route inspection algorithm – Two odd vertices

Now Pat has another round to complete in Bluedale

a) Calculate the time taken for Pat to complete his round, starting and finishing at A.

b) Describe a possible route.c) What would be the length of the route if he could start at G and finish at C?

DepotWe now have 2 odd vertices, the shortest route between them is 1 +1 + 1 = 3, and the length of the shortest route is equal to the total weight which is 57 plus 3 = 60

A

F

D

HB E

4

53

1

1

3

7 3

72

1

5

3

8

4

G

C

If a network has exactly two odd vertices (Semi-Eulerian), then the length of the shortest route will be equal to the total weight of the network, plus the length of the shortest path between the two odd vertices.

The roads Pat takes twice are the ones on the shortest path between the two odd vertices.

You could find the shortest path between the odd vertices using Dijkstra’s algorithm, but you wouldn’t be asked to do this in your exam.

b) ABCBAGACDFCEFGHFGEAc) If he could start at G and finish at C the route would be length 57, being the total weight of the graph.

Page 14: Decision 1:: Route Inspection

Test your understanding

A

D

FE

B

C

G

2

53

7

31

12

9

154

211

10

5 14

The network shown represents the walking time between a network of lookouts in a forest. The edges represent the possible paths between them.

i) Using the Route Inspection Algorithm, determine the length of the shortest route which traverses all of the paths, which starts and finishes at the same vertex.

ii) The route inspector can arrange to be picked up from a point other than his starting point. Where would you advise he starts and finishes his inspection in order to minimise the inspection time.

iii) A new route of length 7 is added between E and F which needs to be added to the inspection regime. Explain the effect this has on the total inspection time.

Total weight = 103

i) Odd vertices are E and F, shortest route between them is EBACF = length 8, so total length of inspection is 103 + 8 = 111

ii) He should start and finish at the odd vertices, so start at E and finish at F, or vice versa.iii) All vertices are now even, so the graph is Eulerian and the inspection time is reduced

from 111 to 103 + 7 = 110.

Page 15: Decision 1:: Route Inspection

Four odd vertices

• Identify any vertices with odd degree• Consider all possible complete pairings of these vertices• Select the complete pairing that has the least sum• Add a repeat of the arcs indicated by this pairing to the network.

Calculate the length of the shortest walk which will traverse all edges and finishes where it started.

1) Identify all possible pairings of odd vertices.

AD, CGAC, DGAG, DC

2) Work out the shortest path between each pair, add these together to find the total additional length that will be needed for each pairing.

7+4=119+9=1813+7=20

3) Add in arcs from A-D and C-G.4) The length of the shortest possible route is 72 + 11 = 83

A

D

F

E

B

C

G

5

3

7

1

9

12

4

2

5

93

7

5

Total weight =72

7

4

Total weight = 72A

D

F

E

B

C

G

5

3

7

1

9

12

4

2

5

93

7

5

Page 16: Decision 1:: Route Inspection

Test your understanding

Page 17: Decision 1:: Route Inspection

Pearson Decision 1, Page 92

Exercise 4D

https://www.activeteachonline.com/default/player/document/id/763124/external/0/uid/1258

Answer templates…

Page 18: Decision 1:: Route Inspection

(A Level Only) Networks with more than four odd nodes

If the network has more than 4 odd nodes then additional information will be provided that will restrict the number of pairings that will need to be considered.

With 4 odd nodes there are 3 possible parings. With 6 odd nodes we have 15 possible pairings and beyond 6 odd nodes the possible number of pairs increases very quickly.

It’s an interesting (although not examinable) question of how to calculate the number of possible pairings – I’ll just leave this here for those who are keen!

Number of odd vertices

Number of possible pairings

2 1

4 3

6 15

8 28

𝑛𝑛 𝑛 − 1

2

Page 19: Decision 1:: Route Inspection

Example (text book)

A

D

F

E

B

C

G

1115

6

19

21

18

9

16

25

14

a) There are 6 odd nodes A,B,C,E,F,G

The restriction we are given is we must start at A and end at C. Therefore we focus on the other 4 odd nodes (B,E,F,G) and their pairs:BE & FG, BF & EG, BG & EF

BE+FG= 20+25=45BF+EG=29+15=44BG+EF=21+15=36Therefore repeating BG and EF minimises the time taken.

Total network weight = 154Minimum time taken = 154+36 = 190 minutes

A night watchman has to patrol a network of paths as shown in the diagram. Labels represent the number of minutes to walk between the points.a) Use the route inspection algorithm, starting at A and finishing

at C to find the minimum time taken to traverse each arc at least once.

b) State a possible route.

Total network weight = 154

Page 20: Decision 1:: Route Inspection

A

D

F

E

B

C

G

1115

6

19

21

18

9

16

25

14

21

15

Example

b) Adding in the repeated arcs the modified network is:

a possible route is: ABGAEFGBCFEDC

A

D

F

E

B

C

G

1115

6

19

21

18

9

16

25

14

Page 21: Decision 1:: Route Inspection

ExampleAn extra path is added joining B and F directly. After the addition of this path, the minimum time needed to traverse all the paths, starting at A and finishing at C, is reduced by twice the length of the time needed to traverse this path.

c) Calculate the time needed to traverse the new path BF.

A

D

F

E

B

C

G

1115

6

19

21

18

9

16

25

14

𝑥

A,C,E,G are the remaining odd vertices. A and C remain the start and the end so must remain odd. We need to find the shortest route from E to G.

EA+AG=6+9=15So we need to repeat arcs EA and AG

Total time = 154 + 15 + 𝑥So

169 + 𝑥 = 190 − 2𝑥𝑥 = 7

So BF takes 7 minutes to travel

A

D

F

E

B

C

G

1115

6

19

21

18

9

16

25

14

Page 22: Decision 1:: Route Inspection

Example (text book)

A

DF

E

B

C

G

4

102

6

12

5

7

11

6

8

9

a) We have 6 odd nodes A,C,D,E,F,G.We must start at A and end at D or G

Starting at A and ending at G leaves C,D,E&F to be paired

CD+EF=9+4=13CE+DF=15+10=25CF+DE=16+6=22

Starting at A and ending at G leaves C,E,F&G to be paired

CE+FG=15+9=24CF+EG=16+11=27CG+EF=6+4=10

So the minimum added distance is 10

We need to consider ending at D & G separately

So the minimum distance=80+10=90km

b) The car finishes at D andrepeats CG and EF

The network represents the roads which that must be travelled by a police patrol car. The length of each road in km is shown on each arc. The patrol car starts at A and can finish at either of G or D.a) Find the length of the shortest route such at every road is

traversed at least once.b) State which police station the patrol car finishes at, and which

roads must be traversed twice.

Page 23: Decision 1:: Route Inspection

Test Your Understanding

[Edexcel D1 June 2019]On a particular day, Naasir needs to check the paintwork along each corridor. Naasirmust find a route of minimum length. It must traverse each corridor at least once,starting at B and finishing at G.

(b) Use an appropriate algorithm to find the arcs that will need to be traversed twice.You must make your method and working clear.

(4)(c) Find the length of Naasir's route.

(1)On a different day, all the corridors that start or finish at B are closed for redecorating.Naasir needs to check all the remaining corridors and may now start at any vertex andfinish at any vertex. A route is required that excludes all those corridors that start orfinish at B.

(d) (i) Determine the possible starting and finishing points so that the length of Naasir's route is minimised. You must give reasons for your answer.

(ii) Find the length of Naasir's new route.(3)

Page 24: Decision 1:: Route Inspection

Pearson Decision 1, Page 96

Exercise 4C

Answer templates…

https://www.activeteachonline.com/default/player/document/id/763125/external/0/uid/1258