## 4 The Cloud-Enabled Emergency Navigation System
### Coordinated Emergency Navigation
```
1:while an evacuee reaches a landmark do
2: Collect in situ hazard information with smart phone's built-in camera
3: Sense other smart phones in the near-field communication range
4:if the neighbouring smart phones has changed then
5: Reset the RNN structure in the AHCPN-based energy management module
6: Set \(RNN_{new}\gets true\)
7:endif
8: /* Emit \(N_{m}\) SPs to search energy-efficient communication routes */
9:while\(N_{c}<N_{m}\)do
10:while\(H_{c}<H_{m}\)do
11: Generate a random value \(R\) between 0 and 1
12:if\(R>V_{Drift}\)\(\&\)\(-RNN_{new}\)then
13: Choose the neighbour associated with the most excited neuron as the next hop
14:else
15: Choose a random neighbour as the next hop
16:endif
17: /* When a SP reaches a new smart phone */
18:if\(P_{Bluetooth+3G}^{i}\geqslant P_{3G}^{i}\)then
19: Stop searching and transmit the SP to the cloud access point via 3G
20:else
21: Check the current discovered route in the cognitive map of the SP
22:if all of the neighbours of the current smart phone have been visited then
23: Stop searching and convey the SP to the cloud access point via 3G
24:else
25: Add the current smart phone to the cognitive map of the SP
26:endif
27:endif
28:endwhile
29: Generate an ACK to bring back gathered delay and energy information
30:endwhile
31: Choose the top ranked path \(P\) in the routing list to send the snapshot
32: Cloud severs employ image processing algorithms to identify the location of the evacuee and the hazard intensity
33: Update the related hazard situation in the building graph
34: Generate a random value \(R\) between 0 and 1
35:if\(R>V_{SPN}\)then
36: Choose the decision made by the CPN-based algorithm
37:else
38: Choose the decision made by the SPN-based algorithm
39:endif
40: Send the decision back to the evacuee through the reverse of path \(P\)
41:endwhile
```  
**Pseudocode 1 The initial SPF algorithm [51] consists of global control forces and local control forces. The global control forces coordinate the individuals and determine the distribution of the individuals, while the local control forces dominate the personal behaviours. In our treatment, we replace the local control forces with the CPN-based algorithm to control the individual behaviour of evacuees and use the global forces to regulate the intra-group behaviours. Details of the CPN-based emergency evacuation algorithm can be seen in [44] and [45]. The force between two evacuees can be calculated from the following equation:  
\[f(r)=-\frac{c_{1}}{r^{\sigma_{1}}}+\frac{c_{2}}{r^{\sigma_{2}}} \tag{1}\]  
where \(c_{1}\), \(c_{2}\), \(\sigma_{1}\) and \(\sigma_{2}\) are dynamic parameters and \(r\) represents the physical distance between two civilians. Term \(-\frac{c_{1}}{r^{\sigma_{1}}}\) represents the repulsive force, while \(\frac{c_{2}}{r^{\sigma_{2}}}\) depicts the attractive force. We assume that each civilian can only be affected by other civilians within 20 meters. If the distance between two civilians is smaller than seven meters, a repulsive force will be generated; otherwise, an attractive force will be produced. To achieve this, we set \(c_{1}\) to 20, \(c_{2}\) to 15, \(\sigma_{1}\) to 0.9478 and \(\sigma_{2}\) to 0.8, respectively. This ensures that the civilians will evacuate in loose groups without increasing the level of congestion. To combine SPF and the CPN-based algorithm, various schemes can be employed. For instance, the resultant direction can be calculated by the weighted sum model in which the two elements are assigned with different weights. Another simple scheme is to randomly choose either the decision of SPF or CPN as the next decision at a time. The latter scheme is employed in this system: when an SPF-related decision is chosen, we adopt the associated neighbour node that has the most matched direction with the resultant force as the next hop.