Chapter 6 Modelling Results
Total Page:16
File Type:pdf, Size:1020Kb
Chapter 6 Modelling results In this chapter the algorithm discussed in the previous chapter will be used to solve problems. For a directed acyclic graph with a sink and source node the weight matrix will always have the form 0 w(1, 2) w(1, 3) w(1, 4) w(1, n) ··· 0 w(2, 3) w(2, 4) w(2, n) ∞ ··· w(3, 2) 0 w(3, 4) w(3, n) ∞ ··· W = . w(4, 2) w(4, 3) 0 w(4, n) ∞ ··· . .. . 0 ∞ ∞ ∞ ∞ ··· In matrix W the first element in the first column, the last element in the last row and the diagonal contains zeros; the remaining elements in the last row and first column are . ∞ 55 6.1 Problem 1 6.1.1 Part A We apply the algorithms discussed in the previous chapter on a real world problem. Let the problem be an owner of a transport company requiring the shortest route from Potchefstroom to Bethlehem. Therefore in a directed graph Potchefstroom will be the source node and Bethlehem the sink. Be- tween the sink and the source there are 6 nodes (cities). Label the cities as follows: Node number City 1 Potchefstroom 2 Parys 3 Sasolburg 4 Viljoenskroon 5 Heilbron 6 Kroonstad 7 Frankfort 8 Bethlehem The distances between the cities are From To Distance Potchefstroom Parys 49.3 Potchefstroom Sasolburg 100 Potchefstroom Viljoenskroon 62.5 Parys Sasolburg 42.8 Sasolburg Heilbron 58.4 Sasolburg Kroonstad 124 Sasolburg Frankfort 111 Viljoenskroon Kroonstad 59.7 Heilbron Kroonstad 94.3 Heilbron Bethlehem 133 Kroonstad Bethlehem 140 Frankfort Bethlehem 118 56 This data are available on google maps. The data in matrix form will be 0 49.3 100 62.5 ∞ ∞ ∞∞ 0 42.8 ∞ ∞ ∞ ∞∞∞ 0 58.4 124 111 ∞ ∞ ∞ ∞ 0 59.7 W = ∞ ∞ ∞ ∞ ∞ ∞ 0 94.3 133 ∞∞ ∞ ∞ ∞ 0 140 ∞∞ ∞ ∞ ∞ ∞ 0 118 ∞∞ ∞ ∞ ∞ ∞ 0 ∞∞∞∞∞∞∞ and the tree graph is as shown in figure 6.1. 1 1 0.9 0.8 2 0.7 0.6 3 3 0.5 5 5 4 0.4 0.3 6 6 7 6 6 0.2 8 8 8 8 8 8 8 0.1 0 0 0.2 0.4 0.6 0.8 1 height = 5 Figure 6.1: Tree graph Application of the two algorithms Matlab codes 7.1.1 and 7.1.2 provide the following results 57 Dijkstra’s algorithm shortest path cost = 262.2000 and path = 9 1 2 1 3 4 3 6. The sequence path illustrates the best previous node, which can be inter- preted as the shortest path is 1 4 6 8 with cost 262.2. → → → Floyd-Warshall algorithm The new weight matrix will be 0 49.3 92.1 62.5 150.5 122.2 203.1 262.2 0 42.8 101.2 166.8 153.8 234.2 ∞ ∞ 0 58.4 124.0 111.0 191.4 ∞ ∞ ∞ 0 59.7 199.7 weight = ∞ ∞ ∞ ∞ ∞ 0 94.3 133.0 ∞∞ ∞ ∞ ∞ 0 140.0 ∞∞ ∞ ∞ ∞ ∞ 0 118.0 ∞∞∞∞ ∞ ∞ 0 ∞∞∞∞∞ ∞ ∞ and the new path matrix 12243436 12343335 12345675 12345676 path = . 12345678 12345678 12345678 12345678 58 The shortest path from the sink to the source is found by interpreting p(1, 8) = 6 and p(6, 8) = 8, which implies the path is 1 6 8. To obtain → → the path from node one to node six look at p(1, 6) = 4 and p(4, 6) = 6, which imply the path is 1 4 6. Then p(1, 4) = 4, which implies the path is 1 4. Thus the same→ results→ are found; the shortest path is 1 4 6 8 → → → → with cost 262.2. In order words the shortest route is Potchefstroom, Viljoen- skroon, Kroonstad to Bethlehem. 6.1.2 Part B If factors such as roadworks, accidents and the condition of the road are taken into consideration, the choice of a path will no longer only depend on the distance. In order to take these factors into consideration and still determine the shortest path, we formulated the following criteria: For the condition of the road we assign a mark on a scale of 1 3 with 1 good, 2 poor and 3 very − poor. For the conditions of roadworks, 1 for no roadworks, 2 for roadworks that do not affect all the lanes and 3 for stop and go. Lastly accidents 1 if there are no accidents, 2 there was an accident but it does not affect all the lanes and 3 there was an accident and the road is temporarily closed. For example From To condition of the road roadworks accident total Potchefstroom Parys 2 2 1 5 Potchefstroom Sasolburg 2 3 2 7 Potchefstroom Viljoenskroon 3 3 1 7 Parys Sasolburg 2 1 3 6 Sasolburg Heilbron 1 1 1 3 Sasolburg Kroonstad 1 2 2 5 Sasolburg Frankfort 1 2 2 5 Viljoenskroon Kroonstad 2 3 1 6 Heilbron Kroonstad 3 1 3 7 Heilbron Bethlehem 1 3 2 6 Kroonstad Bethlehem 1 1 1 3 Frankfort Bethlehem 1 1 2 4 We look at figure 6.1 and remove the part of the paths that have a total 59 greater than 6. Thus we remove the sections Potchefstroom to Salsolburg (node 1 to node 3), Potchefstroom to Viljoenskroon (node 1 to node 4) and Heilbron to Kroonstad (node 5 to node 6). Node 1 has three successors, 2, 3 and 4, but for this specific problem the only possible successor is 2. Node 5 has two successors, 6 and 8, but for this specific problem the only possible successor is 8. Therefore, the only possible path is 1 2 3 5 8, i.e. Potchefstroom Parys Sasolburg Heilbron →Bethlehem.→ → → → → → → 6.1.3 Part C Another example From To condition of the road roadworks accident total Potchefstroom Parys 2 2 1 5 Potchefstroom Sasolburg 2 3 1 6 Potchefstroom Viljoenskroon 3 3 1 7 Parys Sasolburg 2 1 3 6 Sasolburg Heilbron 1 1 1 3 Sasolburg Kroonstad 1 2 2 5 Sasolburg Frankfort 1 2 2 5 Viljoenskroon Kroonstad 2 3 1 6 Heilbron Kroonstad 3 1 2 6 Heilbron Bethlehem 2 3 2 7 Kroonstad Bethlehem 3 3 1 7 Frankfort Bethlehem 1 1 2 4 If we look at figure 6.1 and remove the part of the paths that have a total greater than 6 we will see that the branch on the right-hand side is no longer applicable. The new weight matrix will be 60 0 49.3 100 ∞ ∞ ∞∞ 0 42.8 ∞ ∞ ∞ ∞∞ 0 58.4 124 111 ∞ ∞ ∞ W = 0 94.3 ∞ ∞ ∞ ∞ ∞ 0 ∞∞ ∞ ∞ ∞ ∞ 0 118 ∞∞ ∞ ∞ ∞ 0 ∞∞ ∞ ∞ ∞∞ where Node number City 1 Potchefstroom 2 Parys 3 Sasolburg 4 Heilbron 5 Kroonstad 6 Frankfort 7 Bethlehem With the Matlab codes 7.1.1 and 7.1.2, the results will be as follows: Dijkstra’s algorithm shortest path cost = 321.1000 and path = 8 1 2 3 3 3 6. This is the shortest path, 1 2 3 6 7, with cost 321.1000. → → → → 61 Floyd-Warshall algorithm 0 49.3 92.1 150.5 216.1 203.1 321.1 0 42.8 101.2 166.8 153.8 271.8 ∞ 0 58.4 124.0 111.0 229.0 ∞ ∞ weight = 0 94.3 ∞ ∞ ∞ ∞ ∞ 0 ∞∞ ∞ ∞ ∞ ∞ 0 118.0 ∞∞∞ ∞ ∞ 0 ∞∞∞ ∞ ∞ ∞ and 1223336 1233336 1234566 path = 1234567 . 1234567 1234567 1234567 The shortest path from the sink to the source is found by interpreting p(1, 7) = 6 and p(6, 7) = 7, which implies the path is 1 6 7. To obtain the path from node one to node six look at p(1, 6) = 3 and→ p(3→, 6) = 6, which implies the path is 1 3 6. Then p(1, 3) = 2 and p(2, 3) = 3, which im- plies the path is 1 →2 →3. Thus the shortest path is 1 2 3 6 7. The cost of the shortest→ → path is 321.1000. Thus the path→ is Potchefstroom,→ → → Parys, Sasolburg, Frankfort to Bethlehem. 6.2 Problem 2 6.2.1 Part A If a forensic expert has a bloodstain with diameter, D1 = 3.5 mm, it will be classified as a low velocity droplet. For a low velocity droplet the initial 62 −1 velocity is in the interval v0 =5ms and less. This scenario using equation 3.11 is plotted in figure 3.4, where we have assumed the initial height is 2m. If we place a grid on the figure 3.4, then we obtain figure 6.2. In figure 6.2 each line represents the displacement of a droplet over time. 2.125 2.1 2.075 Distance 2.05 2.025 2 0 0.25 0.5 0.75 1 1.25 1.5 Time Figure 6.2: Distances fall over time Then for the time 0, 0.75 and 1.5 we can determine the probability of an object being present. In figure 6.2 there are 11 lines, so in order to calculate the probability we count the number of lines in a half block radius from the point. Further, assume that the probability is never 1 or 0, but 0.99 and 0.01 respectively. 63 0 0.75 1.5 pi pi ρi 0 0.75 1.5 p2 =0.99 p2 =0.01 p2 =0.01 0 0.75 1.5 p2.0125 =0.36 p2.0125 =0.01 p2.0125 =0.01 0 0.75 1.5 p2.025 =0.36 p2.025 =0.01 p2.025 =0.01 0 0.75 1.5 p2.0375 =0.01 p2.0375 =0.18 p2.0375 =0.01 0 0.75 1.5 p2.05 =0.01 p2.05 =0.36 p2.05 =0.01 0 0.75 1.5 p2.0625 =0.01 p2.0625 =0.45 p2.0625 =0.01 0 0.75 1.5 p2.075 =0.01 p2.075 =0.01 p2.075 =0.01 0 0.75 1.5 p2.0875 =0.01 p2.0875 =0.01 p2.0875 =0.45 0 0.75 1.5 p2.1 =0.01 p2.1 =0.01 p2.1 =0.36 0 0.75 1.5 p2.1125 =0.01 p2.1125 =0.01 ρ2.1125 =0.18 For each of the probabilities calculate with equation 5.2 the cost for the directed edge and the sum of each row a column.