## 4 Solution Method
### Assign Drones to the Opened Facilities and Assign Patients to Those Drones  
The purpose of this algorithm is to assign the available drones to the opened facilities in \(S\) according to the required demand weights of their assigned patients. This is achieved using the concept of the maximum-profit knapsack problem, as proposed in [20], along with additional conditions. The idea is to prioritize facilities that have large required demand weights by assigning more drones to them and, at the same time, assigning more patients of these facilities to drones to maximize coverage. Given \(S\), which is the input list of the opened facilities from Algorithm 2, for each facility \(f\) in \(S\), in order to give priority to patients who consume lower batteries, sort the assigned patients \(i\) of \(f\), where \(i\,\in\,I\,\,\) and \(a_{if}=1\), in ascending order according to \(b_{if}\)followed by \(w_{i}\) in descending order. In other words, if two patients are equal in \(b_{if}\), the patient with the higher \(w_{i}\) will occur first in the list. Assuming \(K\) is the number of available drones and \(Total\_demand\_served\) is initialized at a value of 0, repeat the following steps \(K\) times or until all patients in \(S\) are served:  
First, select a drone \(k\) from the set of available drones \(K\). To maximize coverage, find \(MF\) facility of \(S\) that has the maximum demand weights of the patients assigned to this facility that are not yet assigned to any drone (i.e., maximum facility \(MF\) from \(S\) according to maximum \(\sum_{i\,\in\,\,l}\ w_{i}\ a_{if}\), where \(\ x_{ifk}=0\ \forall\ f\in S\) and \(\forall\ k\in K\)). In turn, assign \(k\) is assigned to \(MF\) and the demand served by drone \(k\ (Demand\_served_{k})\) to 0. Second, traverse the patients assigned to \(MF\) who are not assigned to any drone, and then check whether the value of \(b_{i\ MF}\) of the current patient \(i\) is lower than the remaining battery capacity \(B_{k}\) of drone \(k\). If this is the case, assign \(i\) to \(k\), subtract its consumed battery \(b_{i\ MF}\) from \(B_{k}\), and add \(w_{i}\) to the drone's \(Demand\_served_{k}\); otherwise, if the current patient \(i\) cannot be served by the remaining \(B_{K}\) and to maximize the coverage, try to replace patient \(i\) with patient \(z\) already assigned to \(k\), where \(w_{z}<w_{i}\), without violating the drone constraints. This is done by sorting the patients already assigned to \(k\) according to ascending demand weights \(w\), traversing them one by one, and checking whether there is a patient \(z\) for whom \(w_{z}<w_{i}\) and \(b_{z\ MF}\) + the remaining \(B_{k}\ \geq\ b_{i\ MF}\). Then, release the assigned patient \(z\) and assign the current patient \(i\) to \(k\). Also, and update \(Demand\_served_{k}\) and \(B_{k}\) according to the changes. Finally, after completing the assignments to drone \(k\), we update \(Total\_demand\_served\). After finishing all drones or serving all patients in \(S\), calculate and return \(Coverage\), which is equal to the percentage of \(Total\_demand\_served\). Algorithm 3 presents the details of the above steps. ```
1. Input: \(S\setminus\) from Algorithm 2
2. \(K\leftarrow\) number of the available drones
3. \(Total\_demand\_served\gets 0\)
4. Sort (patients in each facility \(f\) in \(S\)) \(\setminus\) by \(b_{if}\) in ascending order, followed by \(w_{i}\) in descending order
5. Repeat
6. Select (new \(k\in K\))
7. \(B\leftarrow\) battery capacity of \(k\)
8. \(MF\leftarrow\max(S)\ \setminus\) according to \(\max\sum_{i\ \in\ l}\ w_{i}\ a_{if}\) where \(\ x_{ifk}=0\ \ \forall\ f\in S\) and \(\forall\ k\in K\)
9. Assign_drone (\(k,MF\))
10. Demand_served\({}_{k}\gets 0\)
11. For each patient \(i\) assigned to \(MF\)\(\mathbf{Do}\setminus\)\(i\) is not assigned to any drone (\(x_{ifk}=0\ \ \forall\ f\in S\) and \(\forall\ k\in K\))
12. \(b_{i\ MF}\leftarrow\) battery consumed between current patient \(i\) and current facility \(MF\)
13. IF\(b_{i\ MF}\leq B\)Then
14. Assign_patient (\(i,k\))
15.