# The Spatial Optimization of Emergency Shelters Based on an Urban-Scale Evacuation Simulation
## 4 Materials and Methods
### The Construction of Evacuation Simulation Model
#### 4.2.2 Objective Function and Model-Building Process  
First, the correlation matrix between demand point \(O_{j}\) and shelter \(D_{i}\) is constructed as:  
\[\mathrm{O}^{T}\times D=\left[ \begin{array}{c}O_{1}\\ O_{2}\\ \vdots\\ O_{m}\end{array} \right]\times\left[D_{1}\;D_{2}\;\cdots\;D_{n}\right]=\left[ \begin{array}{cccc}O_{1}D_{1}&O_{1}D_{2}&\cdots&O_{1}D_{n}\\ O_{2}D_{1}&O_{2}D_{2}&\cdots&O_{2}D_{n}\\ \vdots&\ddots&\vdots\\ O_{m}D_{1}&O_{m}D_{2}&\cdots&O_{m}D_{n}\end{array} \right] \tag{1}\]  
where:  
\[O_{j}D_{i}=\left\{ \begin{array}{cc}1,K_{ji}\;\;\mathit{exists}\\ 0,K_{ji}\;\;\mathit{does\;not\;exist}\end{array} \right. \tag{2}\]  
If all the people at the demand point have been evacuated, i.e., when \(\lim\limits_{t\to x_{j}}p_{js}=a_{j}\), the evacuation of all routes at demand point \(O_{j}\) ends. At this point, \(t_{js}\) and \(p_{js}\) are defined as follows:  
\[t_{js}=x_{j}+r_{js}/s_{d}p_{js}=p_{js}^{x_{j}}r_{js}=1 \tag{3}\]  
Otherwise, the number of people evacuated from route \(s\) at demand point \(O_{j}\) by the \(t\)-th second is as follows:  
\[p_{js}^{t}=t\times(d_{1}/s_{d})+n_{p} \tag{4}\]Suppose \(p_{ji}^{t}\) is the number of people evacuated through route \(K_{ji}\) by the \(t\)-th second, and the matrix of the number of people evacuated by each path between demand point \(O_{j}\) and shelter \(D_{i}\) by the \(t\)-th second is as follows:  
\[P^{t}=\left[ \begin{array}{cccc}p_{11}^{t}&p_{12}^{t}&\ldots&p_{1n}^{t}\\ p_{21}&p_{22}&&p_{2n}\\ \vdots&&\ddots&\vdots\\ p_{m1}^{t}&p_{m2}^{t}&\cdots&p_{mn}^{t}\end{array} \right] \tag{5}\]  
where:  
\[p_{ji}^{t}=\left\{ \begin{array}{cccc}\text{The N. of corresponding people in the set }\text{K}_{\text{j}}&\text{is}&p_{js}^{t},K_{ji}\text{ \emph{exists}}&\text{\emph{and}}&F_{js}=0\\ \text{The N. of corresponding people in the set }\text{K}_{\text{j}}&\text{is}&p_{js},K_{ji}\text{ \emph{exists}}&\text{\emph{and}}&F_{js}=1\\ 0,K_{ji}\text{\emph{does}}&\text{\emph{not}}&\text{\emph{exist}}\end{array} \right. \tag{6}\]  
Furthermore, the number of evacuees \(A_{i}^{t}\) received by each shelter \(D_{i}\) until the \(t\)-th second is as follows:  
\[\left(\text{P}^{t}\right)^{T}\times\left[ \begin{array}{c}1\\ 1\\ \vdots\\ 1\end{array} \right]=\left[ \begin{array}{c}A_{1}^{t}\\ A_{2}^{t}\\ \vdots\\ A_{n}^{t}\end{array} \right] \tag{7}\]  
When \(\underset{t\to x_{i}}{\lim}A_{i}^{t}\approx d_{i}\), shelter \(D_{i}\) reaches the upper limit of its capacity. At this point, \(t_{js}\) and \(p_{js}\) are defined as follows:  
\[t_{js}=x_{i}+r_{js}/s_{d}p_{js}=p_{js}^{x_{i}}F_{js}=1 \tag{8}\]  
When all \(F_{js}=1\), the evacuation ends, and the time \(t\) at this point is the evacuation completion time. Then, the time \(t\) taken for all people evacuated to shelter \(D_{i}\) to complete the evacuation is the longest evacuation time among all the routes leading to \(D_{i}\). Let \(t_{ij}\) be the time it takes for all the evacuees to complete the evacuation through route \(K_{ji}\), and the following time matrix is established:  
\[T=\left[ \begin{array}{cccc}t_{11}&t_{12}&\ldots&t_{1n}\\ t_{21}&t_{22}&&\ldots&t_{2n}\\ \vdots&&\ddots&\vdots\\ t_{m1}&t_{m2}&\ldots&t_{mn}\end{array} \right]\text{,} \tag{9}\]  
where:  
\[t_{ji}=\left\{ \begin{array}{cccc}\text{The time used for the corresponding element in the set }K_{j}\text{ is }t_{js},K_{ji}\text{ \emph{exists}}\\ 0,K_{ji}\text{\emph{does}}&\text{\emph{not}}&\text{\emph{exist}}\end{array} \right. \tag{10}\]  
Suppose the set \(t_{i}=\left\{t_{1i},t_{2i},\cdots,t_{mi}\right\}\), \(T^{T}=\left[ \begin{array}{c}t_{1}\\ t_{2}\\ \vdots\\ t_{n}\end{array} \right]\); the time it takes for all the evacuees in shelter \(D_{i}\) to complete the evacuation \(T_{i}\) can then be calculated as follows:  
\[\left[ \begin{array}{c}T_{1}\\ T_{2}\\ \vdots\\ T_{n}\end{array} \right]=\left[ \begin{array}{c}Max(t_{1})\\ Max(t_{2})\\ \vdots\\ Max(t_{n})\end{array}