The arrival process at EDs is usually characterized by a strong intra-day variation both in the arrival rate and interarrival times: typically, experimental data show rapid changes in the number of arrivals during the night hours, as opposed to a smoother profile at daytime. As we already mentioned in the Introduction, for this reason, the ED arrival process is usually modeled as an NHPP.
Statistical model
We describe the statistical model of the ED patient arrivals we propose. As opposed to Kim and Whitt (2014a), we do not assume any analytical model for the arrival rate \(\lambda (t)\), and therefore a suitable representation of the unknown function is needed. A realistic representation can be obtained by averaging the number of arrivals observed in experimental data on suitable intervals over the 24 h of the day, not necessarily equally spaced.
Let \(\{T_i\}\) denote a partition P of the observation period \(T = [0,24]\) (h) in N intervals, and let \(\{\lambda _i\}\) be the corresponding sample average rates. Then a piecewise constant approximation of \(\lambda (t)\) can be written
$$\begin{aligned} \lambda _D(t)= \sum _{i=1}^N \lambda _i\,{\mathbf{1}} _{T_i}(t), \quad t\in T, \end{aligned}$$
(1)
where \({\mathbf{1}} _{T_i}(t)\) is 1 for \(t\in T_i\) and 0 otherwise (the indicator function of set \(T_i\)). Any partition P gives rise to a different approximation \(\lambda _D(t)\), depending on the number of intervals and their lengths. Therefore a criterion is needed to select the best partition \(P^\star\) with some desirable features.
First of all, we need to ensure that there is no overdispersion in the arrivals data. We refer to the commonly used dispersion test proposed in Kathirgamatamby (1953) and reported in Kim and Whitt (2014a). If it is satisfied, then it is possible to combine arrivals for the same day of the week over different weeks. To this aim, for any partition P, let \(\{k_i^r\}\) denote the number of arrivals in the i-th partition interval \(T_i\) in the r-th week, \(r=1,\ldots , m\). Consider the statistics
$$\begin{aligned} Ds_i = \displaystyle \frac{1}{\mu _i}\displaystyle \sum _{r=1}^m \left( k_i^r - \mu _i\right) ^2, \quad i=1,\ldots ,N, \end{aligned}$$
where \(\mu _i = \frac{1}{m}\sum _{r=1}^m k_i^r\) is the average number of arrivals in the given interval for the same day of the week over the considered m weeks. Under the null hypothesis that the counts \(\{k_i^r\}\) are a sample of m independent Poisson random variables with the same mean count \(\mu _i\) (no overdispersion), then \(Ds_i\) is distributed as \(\chi ^2_{m-1}\), the chi-squared distribution with \(m-1\) degrees of freedom. Therefore the null hypothesis is not rejected with \(1-\alpha\) confidence level if
$$\begin{aligned} Ds_i \le \chi ^2_{m-1,\alpha }, \quad i=1,\ldots ,N, \end{aligned}$$
(2)
where \(\chi ^2_{m-1,\alpha }\) is, of course, the \(\alpha\) level critical value of the \(\chi ^2_{m-1}\) distribution.
Furthermore, the partition is feasible if data are consistent with NHPP. Namely, if we denote by \(k_i\) the number of arrivals in each interval \(T_i=[a_i, b_i)\) obtained by considering data of the same weekday, in the same interval, over m weeks, i.e. \(k_i=\sum _{r=1}^m k_i^r\), \(i=1,\ldots ,N\), the partition is feasible if each \(k_i\) has a Poisson distribution with a rate \(\lambda _i\) obtained as \(\mu _i/(b_i-a_i)\). To check the validity of the Poisson hypothesis, the CU KS test can be performed (see Brown et al. (2005), Kim and Whitt (2014a)). We prefer to use CU KS rather than the Lewis KS test since this latter is highly sensitive to rounding of the numerical values and the CU KS test has more power against alternative hypotheses involving exponential interarrival times (see Kim and Whitt (2014b) for a detailed comparison between the effectiveness of the two tests).
To perform CU KS test, for any interval \(T_i=[a_i, b_i)\), let \(t_{ij}\), \(j=1, \ldots ,k_i,\) be the arrival times within the i-th interval obtained as the union over the m weeks of the arrival times in each \(T_i\). Now consider the rescaled arrival times defined by \(\tau _{ij} =\displaystyle \frac{t_{ij}-a_i}{b_i-a_i}\). The rescaled arrival times, conditionally to the value \(k_i\), are a collection of i.i.d. random variables uniformly distributed over [0, 1]. Hence, in any interval, we compare the theoretical cumulative distribution function (cdf) \(F(t) = t\) with the empirical cdf
$$\begin{aligned} F_i(t) = \frac{1}{k_i}\sum _{j=1}^{k_i} {\mathbf{1}} _{\{\tau _{ij} \le t\}}, \qquad 0 \le t \le 1. \end{aligned}$$
The test statistics is defined as follows
$$\begin{aligned} D_i = \sup _{0 \le t \le 1}(\vert F_i(t)-t\vert ). \end{aligned}$$
(3)
The critical value for this test is denoted as \(T(k_i,\alpha )\) and its values can be found on the KS test critical values table. Accordingly, the Poisson hypothesis is not rejected if
$$\begin{aligned} D_i \le T(k_i,\alpha ), \quad i=1, \ldots , N. \end{aligned}$$
(4)
This test has to be satisfied on each interval \(T_i\) to qualify the partition P given by \(\{T_i\}\) as feasible, in the sense that the CU KS test is satisfied, too.
A further restriction is imposed on the feasible partitions. Given the experimental data, realistic partitions can not have a granularity too fine to avoid that some \(k_i\) being too small may unduly determine the rejection of the CU KS test. To this aim, a suited lower threshold value for the interval length must be chosen, taking into account the specific case study considered.
Now let us evaluate the feasible partitions also in terms of the characteristics of the function \(\lambda _D(t)\). It would be amenable to define a fit error for \(\lambda (t)\), which unfortunately is unknown. The problem can be resolved by considering a piecewise constant approximation \(\lambda _F(t)\) over a very fine partition \({P}_F\) of T. A set of 96 equally spaced intervals of 15 minutes was considered and the corresponding average rates \(\lambda _i^F\) were estimated from data.
The function \(\lambda _F(t)\) can be considered as an empirical arrival rate model. Note that partition \({P}_F\) need not be feasible since it only serves to define the finest piecewise constant approximation of \(\lambda (t)\). Therefore the following fit error can be defined
$$\begin{aligned} E(P)= \sum _{i=1}^N \sum _{j=1}^{N_j} (\lambda _j-\lambda _{i_j}^F)^2, \end{aligned}$$
(5)
where \(N_j\) is the number of intervals of 15 minutes contained in \(T_j\), and identified by the set of indexes \(\{i_j\}\subset \{1,\ldots ,96\}\).
Finally, it is also advisable to characterize the “smoothness” of any approximation \(\lambda _D(t)\) to avoid very gross partitions with high jumps between adjacent intervals using the mean squared error
$$\begin{aligned} S(P) = \sum _{j=2}^N (\lambda _j-\lambda _{j-1})^2. \end{aligned}$$
(6)
In the following Sect. 2.2 the model features illustrated above are organized in a proper optimization procedure that provides the selection of the best partition according to conflicting goals.
The approach we propose enables us to well address the major two issues raised in Kim and Whitt (2014a) (and reported in the Introduction) when dealing with modelling ED patient arrivals, namely the choice of the intervals and the overdispersion. Concerning the third issue, the data rounding, the arrival times in the data we collected are rounded to seconds (format hh:mm:ss), and occurrences of simultaneous arrivals which would cause zero interarrival times are not present. Therefore, we do not need any unrounding procedure. Anyhow, as already pointed out above, the CU KS test we use is not very sensitive to data rounding.
Statement of the optimization problem
Any partition \(P=\{T_i\}\) of \(T = [0,24]\) is characterized by the boundary points \(\{x_i\}\) of its intervals and by their number N. Let us introduce a vector of variables \(x\in {{\mathbb {Z}}}^{25}\) such that
$$\begin{aligned} T_i=[x_i, x_{i+1}), \end{aligned}$$
\(i=1, \ldots ,24\), with \(x_1=0\) and \(x_{25}=24\).
Functions in (5) and (6) are indeed functions of x, and therefore will be denoted by E(x) and S(x), respectively. Therefore, the objective function that constitutes the selection criterion is given by
$$\begin{aligned} f(x) = E(x) + w S(x), \end{aligned}$$
(7)
where \(w>0\) is a parameter that controls the weight of the smoothness penalty term compared to the fit error: the larger w, the smaller the difference between average arrival rates in adjacent intervals; this, in turn, implies that on a steep section of \(\lambda _F(t)\) an increased number of shorter intervals is adopted to fill the gap with relatively small jumps.
The set \({\mathcal {P}}\) of feasible partitions is defined as follows:
$$\begin{aligned} \begin{array}{l} {{\mathcal {P}}}=\Bigl \{x\in {{\mathbb {Z}}}^{25} ~ | ~ x_1 = 0, \quad x_{25}=24, \quad x_{i+1}-x_i\ge \ell _i, \quad g_i(x)\le 0, \bigr . \\ \ \\ \bigl . h_i(x)\le 0, \quad i=1, \ldots , N \Bigr \} \end{array} \end{aligned}$$
(8)
where
$$\begin{aligned} \ell _i= & {} {\left\{ \begin{array}{ll} 0 \quad \hbox {if} \quad x_i=x_{i+1},\\ \ell \quad \hbox {otherwise},\\ \end{array}\right. } \end{aligned}$$
(9)
$$\begin{aligned} g_i(x)= & {} {\left\{ \begin{array}{ll} 0 \quad \hbox {if} \quad x_i=x_{i+1},\\ D_i - T(k_i,\alpha ) \quad \hbox {otherwise},\\ \end{array}\right. } \end{aligned}$$
(10)
$$\begin{aligned} h_i(x)= & {} {\left\{ \begin{array}{ll} 0 \quad \hbox {if} \quad x_i=x_{i+1},\\ Ds_i - \chi ^2_{m-1,\alpha } \quad \hbox {otherwise},\\ \end{array}\right. } \end{aligned}$$
(11)
\(i=1, \ldots , N\). The value \(\ell\) in (9) denotes the minimum interval length allowed and we assume \(\ell \ge 1/4\). Of course, constraints \(g_i(x)\le 0\) represent the satisfaction of the CU KS test in (4), while constraints \(h_i(x)\le 0\) concern the dispersion test in (2). Therefore, the best piecewise constant approximation \(\lambda _D^\star (t)\) of the time-varying arrival rate \(\lambda (t)\) is obtained by solving the following black-box optimization problem:
$$\begin{aligned} \begin{aligned} \max ~~&f(x) \\ s.t. ~~&x\in {{\mathcal {P}}}. \\ \end{aligned} \end{aligned}$$
(12)
We highlight that the idea of using as constraints of the optimization problem a test to validate the underlying statistical hypothesis on data along with a dispersion test is completely novel in the framework of modeling the ED patient arrivals process. The only proposal which uses a similar approach is in our previous paper (De Santis et al. 2020).
It is important to note that in (7) the objective function has no analytical structure in terms of the independent variables and it can only be computed by a data-driven procedure once the \(x_i\)’s values are given. The same is true for the constraints \(g_i(x)\) and \(h_i(x)\) in (8). Therefore the problem at hand is an integer nonlinear constrained black-box problem, and both the objective function and the constraints are relatively expensive to compute and this makes it difficult to efficiently solve. Consequently, classical optimization methods either can not be applied (since based on the analytic knowledge of the functions involved) or they are not efficient especially when evaluating the functions at a given point is very computationally expensive. Therefore to tackle the problem (12) we turned our attention to the class of Derivative-Free Optimization and black-box methods (see, e.g., Audet and Hare (2017), Conn et al. (2009), Larson et al. (2019)). Specifically, we adopt the algorithmic framework recently proposed in Liuzzi et al. (2020). It represents a novel strategy for solving black-box problems with integer variables and it is based on the use of suited search directions and a non-monotone line search procedure. Moreover, it can handle generally-constrained problems by using a penalty approach. We refer to Liuzzi et al. (2020) for a detailed description and we only highlight that the results reported in Liuzzi et al. (2020) clearly show that this algorithm framework is particularly efficient in tackling black-box problems like the one in (12). In particular, the effectiveness of the adopted exploration strategy concerning the state-of-the-art methods for black-box is shown. This is because the approach proposed in Liuzzi et al. (2020) combines computational efficiency with a high level of reliability.