# Balancing Staff Finishing Times vs. Minimizing Total Travel Distance in Home Healthcare Scheduling
## 3 Mathematical Modeling
\(u_{j}\) represents the cumulative demand when the caretaker visits the patient node. The variable \(CMAX_{k}\) represents the calculated finishing time for caretaker \(k\) which is the time that caretaker visits and finishes their service at the last patient node on the route. We need this variable to calculate the total finishing time difference which is the sum of the absolute value of every pair of finishing times. The details of the variables are listed below. Variables:  
\(x_{ij}^{k}\)  
1 if vehicle \(k\) travels from patient node \(i\) to patient node \(j\);  
\(t_{j}\)  
Starting time at patient node \(j\);  
\(u_{j}\)  
Variable for the subtour elimination;  
\(CMAX_{k}\)  
Finishing time (Maximum completion time) for caretaker \(k\). Given a collection of patient nodes \(N=\{1,\ldots,N\}\) and a collection of caretakers \(K=\{1,2,\ldots,K\}\), the objective of the problem is to determine the optimal routes for each caregiver beginning and ending at the health center. Each caretaker must arrive at the patient node within the specified time frame. The problem can be formulated as mixed integer programming (MIP) problem with the incorporation of routing constraints and scheduling constraints (constraints related to starting time and time window). Model formulation  
\[\text{Minimize}\Bigg{\{}\sum_{k_{1},k_{2}\in K\times K,k_{1}\
eq k_{2}}|CMAX_ {k_{1}}-CMAX_{k_{2}}|,\sum_{i,j\in N,i\
eq j,k\in K}x_{ij}^{k}d_{ij}\Bigg{\}}\]  
\[\sum_{j=1}^{n}x_{0j}^{k}=1,\forall k\in K \tag{1}\]  
\[\sum_{j=1}^{n}x_{j0}^{k}=1,\forall k\in K \tag{2}\]  
\[\sum_{k=1}^{m}\sum_{i=0}^{n}x_{ij}^{k}=1,\forall j\in N\backslash\{0\} \tag{3}\]  
\[\sum_{k=1}^{m}\sum_{j=0}^{n}x_{ij}^{k}=1,\forall i\in N\backslash\{0\} \tag{4}\]  
\[\sum_{i=0}^{n}x_{ij}^{k}-\sum_{l=0}^{n}x_{ji}^{k}=0,\forall j\in N\backslash\{ 0\},\forall k\in K \tag{5}\]  
\[\sum_{i=0}^{n}x_{ij}^{k}\leq r_{jk},\forall j\in N,\forall k\in K \tag{6}\]  
\[u_{i}-u_{j}+q_{j}\leq Q\Big{(}1-x_{ij}^{k}\Big{)},\forall i,j\in N\backslash\{ 0\},i\
eq j,\forall k\in K \tag{7}\]  
\[q_{j}\leq u_{j}\leq Q,\forall j\in N\backslash\{0\} \tag{8}\]  
\[\text{Minimize}\Bigg{\{}\sum_{k_{1},k_{2}\in K\times K,k_{1}\
eq k_{2}}|CMAX_ {k_{1}}-CMAX_{k_{2}}|,\sum_{i,j\in N,i\
eq j,k\in K}x_{ij}^{k}d_{ij}\Bigg{\}}\]0\[\text{Minimize}\Bigg{\{}\sum_{k_{1},k_{2}\in K\times K,k_{1}\
eq k_{2}}|CMAX_ {k_{1}}-CMAX_{k_{2}}|,\sum_{i,j\in N,i\
eq j,k\in K}x_{ij}^{k}d_{ij}\Bigg{\}}\]1  
\[\text{Minimize}\Bigg{\{}\sum_{k_{1},k_{2}\in K\times K,k_{1}\
eq k_{2}}|CMAX_ {k_{1}}-CMAX_{k_{2}}|,\sum_{i,j\in N,i\
eq j,k\in K}x_{ij}^{k}d_{ij}\Bigg{\}}\]2  
\[\text{Minimize}\Bigg{\{}\sum_{k_{1},k_{2}\in K\times K,k_{1}\
eq k_{2}}|CMAX_ {k_{1}}-CMAX_{k_{2}}|,\sum_{i,j\in N,i\
eq j,k\in K}x_{ij}^{k}d_{ij}\Bigg{\}}\]3  
\[\text{Minimize}\Bigg{\{}\sum_{k_{1},k_{2}\in K\times K,k_{1}\
eq k_{2}}|CMAX_ {k_{1}}-CMAX_{k_{2}}|,\sum_{i,j\in N,i\
eq j,k\in K}x_{ij}^{k}d_{ij}\Bigg{\}}\]4  
The objective function is to simultaneously minimize the total finishing time difference and total distance. Constraints (1) and (2) ensure that each careaker's route begins and ends at the origin, given that the objective function is to minimize the difference in finishing times of each pair of caretakers and minimize the total distance. Constraints (3) and (4) limit the number of caretaker visits and departures per patient to one. Additionally, constraint (5) ensure that a caregiver moves on to the next patient in the sequence after providing care to the present one. The compatibility constraint (6) ensures that only a caregiver who is compatible with the patient will travel to provide care for them. Constraints (7) and (8) are subtour elimination constraints and capacity constraints, respectively. Constraint (9) becomes active when caregiver \(k\) transitions from patient \(i\) to patient \(j\) (\(x_{ij}^{k}=1\)). The completion time for patient \(i\) (starting time plus service duration plus travel time) must be less than that for patient \(j\). Constraint (10) involves time windows.