Minimizing Waiting Time Given Lists of Resources

Given a list of resources that each agent needs, I describe an algorithm to minimize the total time agents must wait between using resources.

Finding the optimal schedule of resources such that the total time agents must wait between using the resources is minimized turns out to be a linear programming problem that uses elements of graph theory. In this article, I describe agents as students and resources as classes that they must take, but the model can be generalized to include many other situations.

Model

There are kk courses, c1,,ckc_1, \ldots, c_k, and nn students at a school. The set of all courses is denoted C={c1,,ck}C=\left\{c_1, \ldots, c_k\right\}. The school is open for tR+t \in \mathbb{R}_{+} time.

Each student i=1,,ni=1, \ldots, n has a set of courses that they would like to take, denoted as KiK_i. The number of courses that each student can take is less than kk. Hence, the set KiK_i is a strict subset of CC, i.e. KiCK_i \subset C. The duration of each course cic_i is tiR+t_i \in \mathbb{R}_{+} time.

The school manager chooses the starting xi[0,t)x_i \in[0, t) and ending yi(0,t]y_i \in(0, t] times of each course ciCc_i \in C such that yixi=tiy_i-x_i=t_i. Let the starting and ending times of each course be ordered by the sequence of intervals J:=([xi,yi])i=1kJ:=\left(\left[x_i, y_i\right]\right)_{i=1}^k.

Definition. Concurrent Courses\textbf{Definition. Concurrent Courses}

Suppose QQ is the set of students that are taking a course ciCc_i \in C. A course cic_i can occur at the same time as another course cjcic_j \neq c_i if no student in QQ is taking cjc_j, i.e. cjiQKic_j \notin \bigcup_{i \in Q} K_i.

Let μ\mu be defined to be the Lebesgue measure. For each student ii, set of courses KiK_i, and the starting and ending times of each course ordered by the sequence of intervals, JJ, define the time interval that the student spends in class as the union of disjoint time intervals Ji(Ki,J):=cqKiJq\mathcal{J}_i\left(K_i, J\right):=\bigcup_{c_q \in K_i} J_q. Let the total time student ii spends at school be the interval Li(Ki,J):=[min(Ji(Ki,J)),max(Ji(Ki,J))]L_i\left(K_i, J\right):=\left[\min \left(\mathcal{J}_i\left(K_i, J\right)\right), \max \left(\mathcal{J}_i\left(K_i, J\right)\right)\right]. For each student ii, the time lost function is the length of the complement of the time interval that the student spends in class defined as

Φi(Ki,J):=μ({xLi(KiJ)xJi(Ki,J)}). \Phi_i\left(K_i, J\right):=\mu\left(\left\{x \in L_i\left(K_i J\right) \mid x \notin \mathcal{J}_i\left(K_i, J\right)\right\}\right).

Definition. Optimality\textbf{Definition. Optimality}

Starting and ending times of courses JJ^* is optimal if

cqKiJq=(1) \bigcap_{c_q \in K_i} J_q^*=\emptyset \tag{1}

for every student i=1,,ni=1, \ldots, n (the sequence of time intervals is feasible) and

i=1nΦi(Ki,J)i=1nΦi(Ki,J)(2) \sum_{i=1}^n \Phi_i\left(K_i, J^*\right) \leq \sum_{i=1}^n \Phi_i\left(K_i, J^{\prime}\right) \tag{2}

for any J{([xi,yi])i=1ki,xiR0J^{\prime} \in\left\{\left(\left[x_i, y_i\right]\right)_{i=1}^k \mid \forall i, x_i \in \mathbb{R}_{\geq 0}\right. and yixi=tiy_i-x_i=t_i and cqKiJq=}\left.\bigcap_{c_q \in K_i} J_q^{\prime}=\emptyset\right\} (no feasible alternative sequence of time intervals is strictly less than the optimal schedule).

An Algorithm to Find the Optimal Schedule

I now describe an algorithm to find the optimal schedule, if it exists. The optimal schedule may not exist depending on how long the school is open, tt, and the duration of each course tit_i. As you will see, the solution depends on a linear programming problem, which may or may not have a solution.

First, I provide some important definitions that the algorithm will use. Most of these definitions can be found in graph theory textbooks such as (Balakrishnan & Ranganathan, 2012).

Definition. Intersection Graphs\textbf{Definition. Intersection Graphs}

Let F:={S1,,Sp}\mathcal{F}:=\left\{S_1, \ldots, S_p\right\} be a family of sets. The intersection graph of F\mathcal{F} consists of vertices viv_i for each set SiS_i and a set of edges {{vi,vj}ij,SiSj}\left\{\left\{v_i, v_j\right\} \mid i \neq j, S_i \cap S_j \neq \emptyset\right\}. If SiS_i is an interval, then the intersection graph is called an interval graph.

Definition. Subgraph\textbf{Definition. Subgraph}

A graph H=(W,F)H=(W, F) is a subgraph of a graph G=(V,E)G=(V, E) if WVW \subseteq V and FEF \subseteq E. A subgraph HH of a graph G=(V,E)G=(V, E) is generated if F={{x,y}Ex,yW}F=\{\{x, y\} \in E \mid x, y \in W\} (i.e. HH includes all edges in EE whose vertices are in WW).

Definition. Clique\textbf{Definition. Clique}

A graph is complete if, for any two vertices, there is an edge. A clique in a graph G=(V,E)G=(V, E) is a complete subgraph. A clique is dominant if it is not contained in any larger clique. An ordering of dominant cliques (ω1,,ωn)\left(\omega_1, \ldots, \omega_n\right) is called consecutive if for any three indices α,β,γ\alpha, \beta, \gamma such that α<β<γ\alpha<\beta<\gamma, if a vertex aVa \in V belongs to both ωα\omega_\alpha and ωγ\omega_\gamma, then aa belongs to ωβ\omega_\beta.

Consider the algorithm as follows.

  1. Create an undirected graph denoted by G:=(C,E)G:=(C, E) which consists of CC, a set of vertices representing courses, and EE, a set of edges such that an edge connects course cic_i with cjc_j if and only if course cic_i can occur at the same time as another course cjc_j.

  2. For each generated subgraph of GG that is an interval graph, SS, and ordering of dominant cliques ω1,,ωu\omega_1, \ldots, \omega_u of SS that is consecutive, let a length of time of ωi\omega_i be denoted as DiD_i and let JJ be constructed using DiD_i and the ordering of dominant cliques. Then solve the linear program by selecting Di0D_i \geq 0 to minimizei=1nΦi(Ki,J)\operatorname{minimize} \sum_{i=1}^n \Phi_i\left(K_i, J\right) such that i=1uDit\sum_{i=1}^u D_i \leq t and the time of each course cic_i is tit_i in JJ.

Note that for step 2, there are theorems that simplify the search space. For example, a graph is an interval graph if and only if it is a rigid circuit graph and it has no asteroidal triple, see (Lekkeikerker & Boland, 1962).

If the number of courses, kk, is large, the second step of the algorithm may not be feasible. In such a case, a solution might be to first use the algorithm above to generate optimal starting and ending times of courses (given example lists of courses that are small and kk is small) and then create a neural network to learn the underlying pattern to predict optimal schedules for larger kk. This might be a potential path to research further.

An Application of the Algorithm

Suppose that there are six courses and five students. The list of courses that each student would like to take is K1={c1,c3,c4},K2={c1,c2},K3={c1,c4},K4={c2,c5}K_1=\left\{c_1, c_3, c_4\right\}, K_2=\left\{c_1, c_2\right\}, K_3=\left\{c_1, c_4\right\}, K_4=\left\{c_2, c_5\right\}, and K5={c4,c5,c6}K_5=\left\{c_4, c_5, c_6\right\}. Suppose the school is open for t=t= 3 hours, and each course requires one hour.

An iteration of the algorithm might result in the following computation. First, the undirected graph (C,E)(C, E) is constructed as follows.

Next, a generated subgraph that is an interval graph might remove the edge connecting c1c_1 to c6c_6. An ordering of dominant cliques ω1,,ω4\omega_1, \ldots, \omega_4 of the generated subgraph that is consecutive is ω1={c1,c5},ω2={c5,c3},ω3={c3,c6,c2}\omega_1=\left\{c_1, c_5\right\}, \omega_2=\left\{c_5, c_3\right\}, \omega_3=\left\{c_3, c_6, c_2\right\}, and ω4={c2,c4}\omega_4=\left\{c_2, c_4\right\}. The linear programming problem is then constructed as

minimize2D2+D3 \operatorname{minimize} 2 D_2+D_3

such that D1+D2+D3+D43,D11,D1+D21,D2+D31,D31,D3+D41D_1+D_2+D_3+D_4 \leq 3, D_1 \geq 1, D_1+D_2 \geq 1, D_2+D_3 \geq 1, D_3 \geq 1, D_3+D_4 \geq 1, and D41D_4 \geq 1 and Di0D_i \geq 0 for all i=1,,4i=1, \ldots, 4. The solution to the minimization problem for this generated subgraph is D1=1,D2=0,D3=1D_1=1, D_2=0, D_3=1, and D4=1D_4=1. The interval graph representing the starting and ending times of each course would be as follows.

Under this schedule, the only person who must wait is student 3, who would like to take c1c_1 and c4c_4.

References

  1. Balakrishnan, R., & Ranganathan, K. (2012). A textbook of graph theory. Springer Science & Business Media.
  2. Lekkeikerker, C., & Boland, J. (1962). Representation of a finite graph by a set of intervals on the real line. Fundamenta Mathematicae, 51(1), 45–64.