## 3 The RNN-Based Algorithm for Resource Allocation
### Task Assignment Algorithm Based on the RNN Model  
Consider a group of rescuers, \(R\), waiting at the building exits and some victims, \(V\), being trapped in hazardous areas, and assume that the initial locations of both rescuers and injured civilians are known with the support of the DBES platform. According to the work in [27], the RNN parameters can be defined as a cost, \(C(r,v)\), associated with each possible assignment of rescuer \(r\) to victim \(v\), a fail execution probability, \(L(r,v)\), representing that rescuer \(r\) is unable to rescue victim \(v\), though rescuer \(r\) has been dispatched to it, and a penalty, \(K(v)\), for not executing rescue for victim \(v\). In this case, any assignment of rescuers to victims will have an expected cost, and the objective of the algorithm is to minimize the overall expense by selecting the optimal assignments in order to increase the number of injured civilians collected. We represent the decision of dispatching rescuer \(r\) to save victim \(v\) by the probability, \(p(r,v)\), and \(p(r,v)=1\) if rescuer \(r\) is allocated to victim \(v\) and \(p(r,v)=0\), if not [27]. Hence:  
\[p(r,v)\in\{0,1\},\text{ and }\sum_{v\in V}p(r,v)=\pi(r)\in\{0,1\},\text{ }r\in R,v\in V \tag{12}\]  
where \(p(r,v)\) are either zero or one; \(\pi(r)\in\{0,1\}\) represents (a) \(\pi(r)=0\), rescuer \(r\) will not be assigned a task if the assignments related to rescuer \(r\) increases the overall cost; and (b) \(\pi(r)=1\), a rescuer cannot be re-assigned some other victims if the rescuer already has task (_i.e._, the rescuers are non-reusable). The number of victims and rescuers are denoted as \(|V|\) and \(|R|\), respectively. Based on the RNN parameters, \(C(r,v)\), \(K(v)\), \(L(r,v)\) and \(p(r,v)\), the objective function that we try to minimize can be written as [27]:  
\[\text{Minimize }C=\sum_{v\in V}\sum_{r\in R}C(r,v)p(r,v)+\sum_{v\in V}K(v) \prod_{r\in R}\{1-(1-L(r,v))p(r,v)\} \tag{13}\]  
\[\text{Subject to}:(1)\sum_{v\in V}p(r,v)=\pi(r)\in\{0,1\},\text{ }r\in R,\quad(2)p(r,v)\in\{0,1\},\text{ }r\in R,v\in V\]  
where the first term of Equation (13) is the average cost used by the rescuers, and the second term represents the accumulative average cost of failing in executing rescue for each victim. For each possible task assignment, we assume that there are only two results, success or failure, and Equation (13) takes both the cost of succeeding in rescue and the penalty of failing in the save into account. Thus, the addition of the first term and the second term indicates that the minimization of Equation (13) is to find an optimal balance between the successful execution costs and the fail rescue penalties. The first constraint ensures that we can allocate one particular rescuer to at most one victim, and the total number of allocations can be less than \(|R|\)[27]. The second one assumes that \(p(r,v)=1\) if rescuer \(r\) is allocated to victim \(v\) and \(p(r,v)=0\) if not. The expected failure probability \(\{1-(1-L(r,v))p(r,v)\}\)[27] can be rewritten in an exponential form:  
\[F = 1-(1-L(r,v))p(r,v)=1-(1-L(r,v))(p(r,v)=0\text{ }or\text{ }1)\] \[F = 1,\text{ }if\text{ }p(r,v)=0\text{ }\text{ }or\text{ }L(r,v),\text{ }if\text{ }p(r,v)=1\] \[Thus,\text{ }F = L(r,v)^{p(r,v)} \tag{14}\]  
Substitute Equation (14) into Equation (13); we obtain:  
\[Minimize\text{ }C=\sum_{v\in V}\sum_{r\in R}C(r,v)p(r,v)+\sum_{v\in V}K(v) \prod_{r\in R}L(r,v)^{p(r,v)} \tag{15}\]  
\[Subject\text{ }to:(1)\sum_{v\in V}p(r,v)=\pi(r)\in\{0,1\},\text{ }r\in R,\quad(2)p(r,v)\in\{0,1\},\text{ }r\in R,v\in V\]  
In order to find the minimum solution of Equation (15), it is possible to enumerate all possible allocations of rescuers to victims and then select the optimal result. Because of the high computational complexity, the RNN algorithm described before is used to solve Equation (15), which can provide a quick and accurate solution.