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 3 4 5 6 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.

Cost Cost Cost Sum c(e0 )= 4.5951 c(e0,75)=1.9956 c(e1,5)=1, 9956 c(et )= 0.6039 2,j − 2,j 2,j t 2,j − c(e0 )=0.5754 c(e0,75 )=1.9956 c(e1,5 )=1.9956 c(et )=4.5666 2.0125,j 2.0125,j 2.0125,j t 2.0125,j c(e0 )=0.5754 c(e0,75 )=1.9956 c(e1,5 )=1.9956 c(et )=4.5666 2.025,j 2.025,j 2.025,j t 2.025,j c(e0 )=1.9956 c(e0,75 )=1.5164 c(e1,5 )=1.9956 c(et )=5.5076 2.0375,j 2.0375,j 2.0375,j t 2.0375,j c(e0 )=1.9956 c(e0,75 )=0.5754 c(e1,5 )=1.9956 c(et )=4.5666 2.05,j 2.05,j 2.05,j t 2.05,j c(e0 )=1.9956 c(e0,75 )=0.2007 c(e1,5 )=1.9956 c(et )=4.1919 2.0625,j 2.0625,j 2.0625,j t 2.0625,j c(e0 )=1.9956 c(e0,75 )=1.9956 c(e1,5 )=1.9956 c(et )=5.9868 2.075,j 2.075,j 2.075,j t 2.075,j c(e0 )=1.9956 c(e0,75 )=1.9956 c(e1,5 )=0.2007 c(et )=4.1919 2.0875,j 2.0875,j 2.0875,j t 2.0875,j c(e0 )=1.9956 c(e0,75 )=1.9956 c(e1,5 )=0.5754 c(et )=4.5666 2.1,j 2.1,j 2.1,j t 2.1,j c(e0 )=1.9956 c(e0,75 )=1.9956 c(e1,5 )=1.5164 c(et )=5.5076 2.1125,j 2.1125,j 2.1125,j t 2.1125,j c(e0 )=10.5249 c(e0,75)=16.2617 c(e1,5)=16.2617 i i,j i i,j i i,j .

Using equation 5.3 the shortest path can be calculated. To determine the shortest path with the use of Dijkstra and Floyd-Warshall algorithm we need the elements of the weight matrix. We calculate the elements as follows:

t t c(ei,j) fi,j. (6.1) t,i ∈N j(i)

t To determine j∈N(i) f(i,j) assign values as follows, 0 if there is no line in the 64 area of the point, 1 if there are one or two lines in the area and 2 if there are 0 more than two lines. Then j∈N(i) f(i,j) for the following j values will have a value 0 f(2,2.0375) = 1 ∈ j N(i) 0 f(2,2.05) = 2 ∈ j N(i) 0 f(2,2.0625) = 2 ∈ j N(i) 0 f(2,2.075) = 1 ∈ j N(i) 0,75 for the rest of the j values the sum will be zero. Also for j∈N(i) f(i,j) the values will be 0.75 f(2.0375,2.0875) = 1 ∈ j N(i) 0.75 f(2.05,2.0875) = 2 ∈ j N(i) 0.75 f(2.0625,2.1) = 2 ∈ j N(i) 0.75 f(2.075,2.1125) = 1 ∈ j N(i) for the rest of the i and j values at t =0.75 this sum will be zero.

65 Then using these facts and equation 6.1 we obtain c(et ) f 0 = 4.5951 1= 4.5951 2,2.0375 (2,2.0375) − × − t=0,i ∈ j N(i) c(et ) f 0 = 4.5951 2= 9.1902 2,2.05 (2,2.05) − × − t=0,i ∈ j N(i) c(et ) f 0 = 4.5951 2= 9.1902 2,2.0625 (2,2.0625) − × − t=0,i ∈ j N(i) c(et ) f 0 = 4.5951 1= 4.5951 2,2.075 (2,2.075) − × − t=0,i ∈ j N(i) c(et ) f 0.75 = 1.5164 1=1.5164 2.0375,2.0875 (2.0375,2.0875) × t,i ∈ j N(i) c(et ) f 0.75 = 0.5754 2=1.1508 2.05,2.0875 (2.05,2.0875) × t,i ∈ j N(i) c(et ) f 0.75 = 0.2007 2=0.4014 2.0625,2.1 (2.0625,2.1) × t,i ∈ j N(i) c(et ) f 0.75 = 1.9956 1=1.9956. 2.075,2.115 (2.075,2.1125) × t,i ∈ j N(i)

If we refer back to figure 4.5 the source and the sink do not represent any position. In figure 4.5 time zero is in our case t = 0, time 1 is t = 0.75 and time 2 is t =1.5. Therefore, the weight matrix will be

01111 1 1 1 1 1 1 ∞ 0 4.5951 9.1902 9.1902 4.5951 1  ∞ ∞ ∞ − − − − ∞ ∞ ∞  0 1  ∞ ∞ ∞∞ ∞ ∞ ∞∞∞∞   0 1    ∞ ∞ ∞ ∞ ∞ ∞ ∞∞∞∞   0 1.5164 1  ∞ ∞ ∞∞ ∞ ∞ ∞ ∞ ∞   0 1.1508 1    W = ∞∞∞∞ ∞ ∞ ∞ ∞ ∞  .  0 0.4014 1  ∞∞∞∞ ∞ ∞ ∞ ∞ ∞   0 1.9956 1    ∞∞∞∞ ∞ ∞ ∞ ∞ ∞   0 1  ∞∞∞∞∞ ∞ ∞ ∞ ∞ ∞     0 1  ∞∞∞∞∞ ∞ ∞ ∞ ∞ ∞   0 1  ∞∞∞∞∞ ∞ ∞ ∞ ∞ ∞     0  ∞∞∞∞∞ ∞ ∞ ∞ ∞ ∞ ∞  66 We have constructed the weight elements from the source to all the other nodes, except the sink, unity and the weight elements from any node, except the source, to the sink also unity. The weight matrix has negative weight, therefore only the Floyd-Warshall algorithm can be used to determine the shortest path. Using Matlab code 7.1.2 we obtain the following results

Floyd-Warshall algorithm

011 1 3.6 8.2 8.2 3.6 7.0 7.8 1.6 7.2 − − − − − − − − 0 4.6 9.2 9.2 4.6 8.0 8.8 2.6 8.2  ∞ ∞ ∞ − − − − − − − −  0 1.0  ∞ ∞ ∞∞∞∞∞∞∞∞   0 1.0    ∞ ∞ ∞ ∞∞∞∞∞∞∞   0 1.5 1.0  ∞ ∞ ∞∞ ∞ ∞ ∞ ∞ ∞   0 1.2 1.0    weight = ∞∞∞∞ ∞ ∞ ∞ ∞ ∞   0 0.4 1.0  ∞∞∞∞ ∞ ∞ ∞ ∞ ∞   0 2.0 1.0    ∞∞∞∞∞ ∞ ∞ ∞ ∞   0 1.0  ∞∞∞∞∞ ∞ ∞ ∞ ∞ ∞   .   0 1 0  ∞∞∞∞∞ ∞ ∞ ∞ ∞ ∞   0 1.0  ∞∞∞∞∞ ∞ ∞ ∞ ∞ ∞     0  ∞∞∞∞∞ ∞ ∞ ∞ ∞ ∞ ∞  1234222267 8 6 1234567867 8 6   1 2 3456789101112   1 2 3456789101112     1 2 3456789101112   1 2 3456789101112   path =   . 1 2 3456789101112   1 2 3456789101112     1 2 3456789101112   1 2 3456789101112     1 2 3456789101112     1 2 3456789101112  

67 Thus for this specific problem the solution of equation 5.3 is f ∗ = 7.1902 with the path 1 2 6 12. − → → →

6.3 Results

The two problems are real world problems. The first problem illustrated the calculation of a shortest path through a network when there are no additional constraints and when there are additional constraints. The second problem is based on a blood stain problem. We have solved the problem using multi- target tracking techniques.

68