4.2.1. Algorithm Description

The whole algorithm is divided into two procedures. The first procedure will allocate an optimal exit to each evacuation group (all evacuation groups passing through the same exit belong to the same evacuation zone), and the second will compute the departure time of each evacuation group in the same zone. Their pseudo code is as follows.

Input: indoor road network model, exits, escape speed ( *V*), group size (uniform or random) and the number of groups (*n*).

Output: Total evacuation time ( *T*), the departure time (*t i d*) and the evacuation path for each group.

Notes about Procedure 1: Line 5 adds all evacuation groups in the network into an array *N*. Line 6 adds all exits in the network into an array *E.* Line 7 initializes the number of evacuees evacuated by each exit to 0. While *N* is not empty, namely there are any evacuation groups in *N* that aren't allocated to any exits, Lines 9 to14 compare the number of evacuees passing through each exit to find the exit *minE* with the fewest evacuees. Lines 15 to 16 take *minE* as the starting point, run Dijkstra algorithm to expand a new shortest path. The group located at the end node of the new path is *minG.* Then let *minG* evacuate through *minE*. Next, update the number of evacuees passing through *minE* (Line 19) and remove *minG* from *N* (Line 20). Thus, an evacuation group is allocated to one exit by one loop. When all evacuation groups are allocated to an exit (that is, until *N* is empty), the loop ends.


In brief, during the implementation of Procedure 1, there is a Dijkstra algorithm at each exit, but only the Dijkstra algorithm on the exit with the least number of evacuees runs at each time, and the Dijkstra algorithm only expands one shortest path at a time (that is, to find an evacuation group). Then the number of evacuees allocated to each evacuation exit is compared with each other to determine which exit to run Dijkstra algorithm until all evacuation groups are allocated.

Notes about Procedure 2: Lines 3 adds all evacuation groups in the network into an array *N* with the array length of *n*. Line 4 sorts all evacuation groups in *N* according to their shortest route length. Then an outer loop (Line 5) is used to process each zone, namely, each exit. There are two inner loops in the outer loop. The first inner loop (Lines 6 to 10) is used to extract all each evacuation groups passing through the same exit from *N*, then adds them into *M* by order. Line 11 makes group 1 in *M* depart immediately once an emergency occurs, and *a* = 1, where *a* is the evacuation sequence number of the first group in each evacuation combination that successively passes through the emergency exit. Then the second inner loop (Lines 12 to 17) is executed to compute the departure time of *Gi* in *M*, where *i* is from 2 to *m* that is the number of groups in the same zone. The departure time of *Gi* is calculated as follows: *tid* = *tap* + *tae* + ... + *ti*−<sup>1</sup> *e* − *tip*. If *tid* > 0, the delayed time of *Gi* is *tid*. Otherwise, *Gi* evacuates immediately without any delay once an emergency occurs, and let *a* = *i*. Execute the inner loop until all evacuation groups in *M* ge<sup>t</sup> their departure time, then return to Line 5. When the outer loop finishes and the procedure ends.

Procedure 2 (Calculate the departure time of each group in each zone):


#### 4.2.2. Time Complexity Analysis

In Procedure 1, the while loop runs n times, and the for loop runs ne times. In addition, when running Dijkstra algorithm to expand each node, the path length of all nodes in the network needs to compare n times. So, the time complexity of Procedure 1 is *<sup>O</sup>*(*n*(*n* + *ne*)). For *ne* - *n*, the final time complexity is *<sup>O</sup>n*<sup>2</sup>.

In Procedure 2, the outer for loop runs *ne* times, the first inner for loop runs *n* times, the second for loop runs *m* times. So, the time complexity of Procedure 2 is *<sup>O</sup>*(*ne*(*n* + *<sup>m</sup>*)). For *m* ≤ *n*, the final time complexity is *<sup>O</sup>*(*n* ∗ *ne*). Of course, this process also includes a sorting process with the time complexity *<sup>O</sup>n*<sup>2</sup> or *<sup>O</sup>n* log2 *n* .

Once the PSEP algorithm completes partition, each zone is equivalent to a single-exit evacuation network. For a zone, the time complexity of calculating the departure time of each evacuation group is *<sup>O</sup>*(*m*), while the time complexity of completing the calculation by the algorithm in [25] is *<sup>O</sup>m*2*k*, where *m* is the number of groups in the zone, *k* is the number of arcs of all evacuation path and *k* is the arithmetic mean of *k*.
