# Hybrid Harmony Search for Stochastic Scheduling of Chemotherapy Outpatient Appointments
## 2 Problem Statement
Six distinct sources of uncertainty characterize the problem under investigation: (i) the medical consultation time \(Dc_{p}^{\omega}\); (ii) the drug preparation time \(Dt_{p}^{\omega}\); (iii) the batch transportation time \(TD_{p}^{\omega}\); (iv) the set-up time \(Ds_{p}^{\omega}\); (v) the treatment time \(Di_{p}^{\omega}\); (vi) the deferral probability \(\lambda\)\({}_{p}^{\omega}\), i.e., a patient \(p\) at scenario \(\omega\) is deferred. In particular, \(\lambda\)\({}_{p}^{\omega}\) is derived from \(U\)\([0,\)\(1]\). If \(\lambda\)\({}_{p}^{\omega}\) is lower than or equal to \(\overline{\lambda}\),  
research contributions also demonstrated that the evolutionary mechanism of HS is faster than genetic algorithms [41; 42]. A harmony solution consists of an n-dimensional real-coded vector. Let us suppose a single harmony is denoted as \(x{=}\left(x_{1},\ldots,x_{j},\ldots,x_{n}\right)\) such that each variable is defined in the domain \([LB_{j},UB_{j}]\in\mathbb{R}\) and \(f(x)\) is the related objective function value. Since the healthcare scheduling problem under investigation can be classified as a combinatorial issue, each real-coded solution has to be converted into a sequence of patients. To this end, we employed a well-known mechanism based on the smallest position value (SPV) rule [43], which allows for converting any real-valued harmony vector into a discrete job permutation. In brief, such a rule, which works by employing a sorting procedure, enables the algorithm to switch from a conventional scheme to a discrete one. For example, Table 2 shows a generic real-encoded harmony \(x\) corresponding to the permutation solution \(\pi\) = {7-6-2-1-8-4-3-5} after the SPV conversion is executed. The computational procedure of HS is explicated by the pseudo-code in Algorithm 1. A preliminary initialization phase is needed to set the initial values of three control parameters, i.e., the harmony memory consideration rate (_HMCR_), the pitch adjustment (_PAR_) and the bandwidth (_BW_). Then, a set of randomly generated solutions (harmonies) are stored in the Harmony Memory (_HM_). The number of the harmony solutions contained in _HM_ is denoted as harmony memory size (_HMS_). The generation of the initial population (i.e., the initial _HM_) may assume a strategic role in the searchability of an evolutionary algorithm. To enhance the quality of the initial HM, two harmonies are replaced by two well-known heuristics, namely Short Processing Time (SPT) and Long Processing Time (LPT), which consider only the treatment times. ```
1:Step 1: Initialization and setting of control parameters, namely HMS, HMCR,
2:PAR, BW, \((LB_{j},UB_{j})\)\(\forall\)\(j=1,\)\(\ldots,\)\(n\); iter = 0;
3:Step 2: Generate the initial population, i.e., the \(HM\), and calculate the objective
4:function of each harmony vector. 5:Step 3: Improve \(a\) new harmony \(x^{new}\) as follows:
6:for\(i=1\): HMS
7:for\(j=1\): \(n\)
8:if\(rand\) < HMCR
9:\(x_{ij}^{new}=x_{aj}\) where \(a\in(1,\)\(\ldots,\)\(HMS\))
10:if\(rand\) < PAR
11:\(x_{ij}^{new}=x_{ij}^{new}\pm\)\(rand\) - BW
12:end
13:else
14:\(x_{ij}^{new}\)= \(LB_{j}\)+\(rand\) - \((UB_{j}-LB_{j})\)
15:end
16:end
17:end
18:Step 4: Compute the objective function \(fx^{new}\)). Update _evals_ and _iter_. 19:Step 5: Update HM by \(x^{new}\) \(\leftarrow\)\(x^{new}\) if \(f(x^{new})\) < \(fx^{new}\)
20:Step 6:if the exit criterion is satisfied
21: Stop the algorithm; Return \(x^{best}\) and \(f(x^{best})\)
22:else
23: Goto Step 3
24:end
```  
**Algorithm 1** Harmony Search  
After the initial _HM_ is created, the decoding procedure is employed by the Harmony Search for evaluating the _HM_ (see Section 3.3). A variable _evals_ is updated to record the \begin{table}
\begin{tabular}{c c c c c c c c c} \hline \(\pi\) & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 \\ \hline \(x\) & 0.14 & \(-\)0.74 & 1.11 & 0.98 & 2.32 & \(-\)1.54 & \(-\)2.24 & 0.78 \\ \hline \end{tabular}
\end{table} 
Table 2: Illustrative example of encoded solution \(x\) and permutation solution \(\pi\).