# Balanced Assignments of Periodic Tasks

Héloïse Gachet, Frédéric Meunier

► To cite this version:

Héloïse Gachet, Frédéric Meunier. Balanced Assignments of Periodic Tasks. 24th Symposium on Algorithmic Approaches for Transportation Modelling, Optimization, and Systems (ATMOS 2024), Sep 2024, Egham, United Kingdom. pp.5:1-5:12, 10.4230/OASIcs.ATMOS.2024.5 . hal-05450831

HAL Id: hal-05450831

https://hal.science/hal-05450831v1

Submitted on 9 Jan 2026

HAL is a multi-disciplinary open access
archive for the deposit and dissemination of sci-
entific research documents, whether they are pub-
lished or not. The documents may come from
teaching and research institutions in France or
abroad, or from public or private research centers.

L'archive ouverte pluridisciplinaire HAL, est
destinée au dépôt et à la diffusion de documents
scientifiques de niveau recherche, publiés ou non,
émanant des établissements d'enseignement et de
recherche français ou étrangers, des laboratoires
publics ou privés.

<figure><img src="image_1.png" /></figure>

Distributed under a Creative Commons CC BY 4.0 - Attribution - International License
# Balanced Assignments of Periodic Tasks

Héloïse Gachet ☑
École nationale des ponts et chaussées, Champs-sur-Marne, France

SNCF, DTIPG, Saint-Denis, France

Frédéric Meunier ☑ID
École nationale des ponts et chaussées, Champs-sur-Marne, France

## Abstract

This work deals with a problem of assigning periodic tasks to employees in such a way that each employee performs each task with the same frequency in the long term. The motivation comes from a collaboration with the main French railway company, the SNCF. An almost complete solution is provided under the form of a necessary and sufficient condition that can be checked in polynomial time. A complementary discussion about possible extensions is also proposed.

**2012 ACM Subject Classification** Mathematics of computing → Graph algorithms; Applied computing → Transportation

**Keywords and phrases** Fair schedule, Eulerian digraph, Markov chain, interval graph

**Digital Object Identifier** 10.4230/OASICS.ATMOS.2024.5

**Funding** This research was partially supported by the SNCF as part of a CIFRE PhD.

**Acknowledgements** The authors are also grateful to Jean-François Delmas for pointing out the situation of “normal numbers,” whose existence status shares some similarity with that of balanced feasible assignments; see Section 4.1.

# 1 Introduction

## 1.1 Context

The problem studied in this paper was suggested to the authors through a collaboration with the SNCF, the main French railway company. The schedules of their freight train drivers are always periodic: a collection of round trips is repeated every week, with each round trip performed at the same time within the week. Such schedules are often termed “cyclic rosters” in the literature. One motivation for this periodicity is that such schedules are easily understood and memorized by the employees. Another motivation is that these schedules balance experience: in the long term, each round trip is performed the same number of times by each employee. This ensures fairness and also maintains a similar level of proficiency among the employees.

More generally, in the transport sector, periodicity is an important requirement, to which a full body of research is devoted; see, e.g., [5, 7, 8]. Based on the authors’ experience and the literature, the concern of balancing experience among employees, given tasks that must be performed periodically, is not only present at the SNCF but also in many other companies. For instance, in an article by Breugem, Dollevoet, and Huisman [2], the same motivations as described in the previous paragraph apply, justifying the use of cyclic rosters among teams of employees (grouped by characteristics) for the Netherlands Railways. Another example, this time for bus drivers, is studied in an article by Xie and Suhl [10].

This raises a natural mathematical question: given tasks that need to be repeated every week and a group of employees, under what conditions is it possible to create (not necessarily periodic) schedules ensuring that in the long term each task is performed the same number of times by each employee?

<figure><img src="image_2.png" /></figure>

© Héloïse Gachet and Frédéric Meunier;
licensed under Creative Commons License CC-BY 4.0

24th Symposium on Algorithmic Approaches for Transportation Modelling, Optimization, and Systems (ATMOS 2024).

Editors: Paul C. Bouman and Spyros C. Kontogiannis; Article No. 5; pp. 5:1–5:12

<figure><img src="image_3.png" /></figure>

OpenAccess Series in Informatics
OASICS Schloss Dagstuhl – Leibniz-Zentrum für Informatik, Dagstuhl Publishing, Germany
## 5:2 Balanced Assignments of Periodic Tasks

In this paper, we propose an almost complete solution to this problem. To the authors' knowledge, this problem has not been addressed in the literature. Nevertheless, problems with almost the same input but where the “balancedness” criterion is replaced by a more standard optimization criterion, such as minimizing the number of employees, have been studied in various papers. As an example, Korst, Aarts, Lenstra, and Wessels [4] consider the problem of assigning periodic operations, with fixed starting times and different periods, to a minimal number of processors.

### 1.2 Problem formulation

Consider a collection of tasks that have to be performed periodically (typically every week in an industrial setting), and a group of indistinguishable employees who will perform them. Formally, we are given

- a collection of $n$ intervals $[a_i, b_i) \subset (-1, 1)$, with $b_i \in (0, 1]$ and $b_i - a_i \le 1$.

- a positive integer $q$.

Each interval of this collection represents a task: the $r$th occurrence of task $i$ ($r \in \mathbb{Z}_{>0}$) takes place over the time interval $[a_i + r, b_i + r)$. The number $q$ corresponds to the number of employees, whom we identify from now on with the set $[q]$. Every occurrence of each task has to be assigned to an employee. Such an assignment is feasible if no employee is assigned two occurrences overlapping within $\mathbb{R}_{>0}$. Such an assignment is balanced if each task is performed by each employee every $q$ periods in the long term average.

In symbols, consider an assignment $f: [n] \times \mathbb{Z}_{>0} \to [q]$, where $f(i, r) = j$ means that the $r$th occurrence of task $i$ is assigned to employee $j$. It is feasible if

$$[a_i + r, b_i + r) \cap [a_{i'} + r', b_{i'} + r') \neq \emptyset \quad \Rightarrow \quad f(i, r) \neq f(i', r') \quad (1)$$

for all $i \neq i'$ and all $r, r'$. (Remark that the left-hand side holds only if $|r - r'| \le 1$.) It is balanced if

$$\lim_{t \to +\infty} \frac{1}{t} |\{r \in [t]: f(i, r) = j\}| = \frac{1}{q}, \quad (2)$$

for all $i \in [n]$ and all $j \in [q]$. An illustration is given in Figure 1.

We aim at identifying conditions under which there exists a balanced feasible assignment and at studying the related algorithmic question.

A few comments are in order. First, remark that there exists a feasible assignment if and only if there is no point in $\mathbb{R}$ contained in more than $q$ intervals $[a_i + r, b_i + r)$. (This has also been noted by Korst, Aarts, Lenstra, and Wessels [4, Theorem 2.3], in a more general setting.) This means that for our problem, feasibility is not the challenge. Second, when there is a point of $[0, 1)$ contained in no interval $[a_i + r, b_i + r)$, then the construction of a balanced feasible assignment is trivial: without loss of generality, this point is 0, and any feasible assignment $f$ and any cyclic permutation $\pi$ of $[q]$ provides a balanced feasible assignment $g$, periodic with period $q$, defined by $g(i, r) := (\pi^r \circ f)(i, 1)$ for $i \in [n]$ and $r \in \mathbb{Z}_{>0}$. Finally, there are feasible assignments for which the limit in (2) is not well-defined. By definition, if the limit is not well-defined, then the assignment is not balanced.

### 1.3 Main results

Clearly, a necessary condition for the existence of a balanced feasible assignment is that there is a feasible assignment in which an employee performs each task at least once. Our first main result states the following surprising fact: this condition is actually sufficient.
**► Theorem 1.** There exists a balanced feasible assignment if and only if there exists a feasible assignment with an employee performing each task at least once. Moreover, if there exists a balanced feasible assignment, then there exists such an assignment that is periodic.

An assignment $f$ is *periodic* if there exists $h \in \mathbb{Z}_{>0}$ such that $f(i, r + h) = f(i, r)$ for all $i \in [n]$ and $r \in \mathbb{Z}_{>0}$. The proof will actually make clear that, in case of the existence of a balanced feasible assignment, it is always possible to get a period $h$ upper-bounded by $q^2 \times q!$.

The necessary and sufficient condition of Theorem 1 is simple enough to obtain an algorithmic counterpart. This is the second main result of the paper.

**► Theorem 2.** Deciding whether there exists a balanced feasible assignment can be done in polynomial time. Moreover, if the number of employees is constant, then such an assignment can be computed in polynomial time when it exists.

The proofs of these two theorems can be found in Section 3.2. They essentially consist in reducing the question of existence of a balanced feasible assignment to a problem of pebbles on an arc-colored Eulerian directed graph. The latter problem is dealt with in Section 2, which can be read independently of the rest of the paper. Section 3.1 introduces preliminary results and tools, such as a graph $D^F$ built from a well-chosen set $\mathcal{F}$ of feasible assignments and that plays an important role in the proofs. This graph $D^F$ is a particular arc-colored Eulerian directed graph on which we apply the results of Section 2.

## 2 A problem of pebbles on an arc-colored Eulerian directed graph

This section introduces a problem of pebbles moving on an Eulerian directed graph, which we believe to be interesting for its own sake. The proof of Theorem 1 will essentially consist in reducing the problem of existence of a balanced feasible assignment to this pebble problem. This pebble problem will also be useful for algorithmic discussions, as in the proof of Theorem 2. From now on, this section does not refer anymore to the question of assignments and periodic tasks.

Consider an arc-colored Eulerian directed multi-graph $D = (V, A)$ such that each vertex is the head of exactly one arc of every color, and also the tail of exactly one arc of every color. (In other words, each color is a collection of vertex disjoint directed cycles covering the vertex set.) Assume we have a pebble on each vertex. We denote by $P$ the set of pebbles, and we have thus $|P| = |V|$.

Now, we explain how a sequence of colors induces a sequence of moves for the pebbles. Given a sequence $c_1, c_2, \dots$ of colors, each pebble is first moved along the unique arc of color $c_1$ leaving the vertex on which it is originally located; then it is moved along the unique arc of color $c_2$ leaving the vertex it has reached after the first move; and so on. Remark that each move sends each pebble on a distinct vertex and so after each move, there is again a pebble on each vertex.

We might ask under which condition there exists an infinite sequence of colors such that the arc visits are "balanced," i.e., each pebble visits each arc with the same frequency. Not only such a sequence always exists but such a sequence can be chosen to be periodic.

**► Proposition 3.** There always exists a periodic sequence of colors making each pebble visit each arc with the same frequency.

The proof shows a bit more: each pebble actually follows a periodic walk on $D$ which has the same period as the sequence of colors, and the latter is upper bounded by $|A|(|V| - 1)!$.
5:4 Balanced Assignments of Periodic Tasks

<figure><img src="image_4.png" /><figcaption>(a) An instance with three tasks (n = 3). The first three occurrences of each task are represented. The tasks 2 and 3 are in the set {i ∈ [3]: a_i ≤ 0} and their fourth occurrence is represented in lighter color.</figcaption></figure>

<figure><img src="image_5.png" /><figcaption>(b) A feasible assignment f for three employees (q = 3). Assuming that this pattern is repeated along the horizontal axis, each line represents an employee and the rth occurrence of the task i is on the line of employee j when f(i,r) = j. This assignment is not balanced: employee 2 works 72% of the time, employee 3 works 56% of the time, employee 1 does not perform task 3, and employee 3 performs 75% of the occurrences of task 3.</figcaption></figure>

<figure><img src="image_6.png" /><figcaption>(c) A feasible assignment g for three employees (q = 3). Assuming that this pattern is repeated along the horizontal axis, the assignment g is feasible and balanced: task 1 is performed equally by employees 1, 2, and 3, and so are tasks 2 and 3. The assignment g is periodic with period h = 3.</figcaption></figure>

Figure 1 Example of an instance, with two feasible assignments.

The proof of this proposition relies on a larger graph $\tilde{D} = (\tilde{V}, \tilde{A})$ built as follows. The vertex set $\tilde{V}$ is the set of bijections from $P$ to $V$. For every color $c$, define the permutation $\sigma^c$ of $V$ by setting $\sigma^c(i) = i'$ whenever there is an arc of color $c$ from $i$ to $i'$ in $D$. The set $\tilde{A}$ is built as follows: for each bijection $\eta: P \to V$ and each color $c$, introduce an arc $(\eta, \sigma^c \circ \eta)$, and color this arc with color $c$. The indegree and outdegree of every vertex in $\tilde{V}$ are equal to the number of colors.

For each pebble $j$, we introduce a function $p_j: \tilde{A} \to A$. Given an arc $\tilde{a} = (\eta, \eta')$ of $\tilde{A}$ with color $c$, we define $p_j(\tilde{a})$ as the arc $(\eta(j), \eta'(j))$ of $A$ with color $c$.

The graph $\tilde{D}$ is an encoding of all possible distributions of the pebbles on $V$ and all possible transitions between these distributions. More precisely consider any initial distribution $\eta$ of the pebbles on $V$ and a sequence of colors $c_1, c_2, \dots$. The moves induced by the sequence of colors translate into a walk on $\tilde{D}$. The corresponding sequence of vertices of $\tilde{D}$ is the sequence of distributions of the pebbles on $V$ induced by the sequence of colors.

**Lemma 4.** Let $j \in P$, $a \in A$, and $\tilde{K}$ be a connected component of $\tilde{D}$ (note that weakly and strongly connected components of $\tilde{D}$ are identical by equality of the in- and outdegrees). Denoting by $\kappa$ the number of connected components of $\tilde{D}$, we have

$$|p_j^{-1}(a) \cap A(\tilde{K})| = \frac{(|V|-1)!}{\kappa}.$$

In particular, the left-hand term is independent of $j$, $a$, and $\tilde{K}$.
**Proof.** Denote by $c$ the color of $a$.

We prove first that every connected component $\tilde{K}$ of $\tilde{D}$ contains at least one arc from $p_j^{-1}(a)$. Let $\eta$ be a vertex of such a connected component $\tilde{K}$. Consider any walk $W$ in $D$ from $\eta(j)$ to the tail of $a$, and then traversing $a$. Such a walk exists because $D$ is strongly connected. With $c_1, c_2, \dots, c$ being the sequence of colors of the arcs traversed by the walk, the sequence

$$ \eta, \sigma^{c_1} \circ \eta, \sigma^{c_2} \circ \sigma^{c_1} \circ \eta, \dots, \sigma^c \circ \dots \circ \sigma^{c_2} \circ \sigma^{c_1} \circ \eta $$

forms a walk in $\tilde{K}$ starting from $\eta$, whose image by $p_j$ is $W$. Hence, $\tilde{K}$ contains at least one arc from $p_j^{-1}(a)$.

Second, given two components $\tilde{K}_1$ and $\tilde{K}_2$ of $\tilde{D}$, we build an injective map $\psi: A(\tilde{K}_1) \to A(\tilde{K}_2)$ as follows (actually, it is a bijection but this property is not explicitly used). Pick $\tilde{a}_1 \in p_j^{-1}(a) \cap A(\tilde{K}_1)$ and $\tilde{a}_2 \in p_j^{-1}(a) \cap A(\tilde{K}_2)$. According to what we have just proved, these two arcs exist. Write $\tilde{a}_1 = (\eta_1, \sigma^c \circ \eta_1)$ and $\tilde{a}_2 = (\eta_2, \sigma^c \circ \eta_2)$. Then, for an arc $\tilde{a} \in A(\tilde{K}_1)$ with tail vertex $\eta$ and color $d$, set $\psi(\tilde{a})$ as the arc $(\eta \circ \eta_1^{-1} \circ \eta_2, \sigma^d \circ \eta \circ \eta_1^{-1} \circ \eta_2)$ with color $d$ (this arc is unique). Checking that $\psi$ is injective is immediate.

Third, we check that $\psi$ maps elements from $p_j^{-1}(a) \cap A(\tilde{K}_1)$ to $p_j^{-1}(a) \cap A(\tilde{K}_2)$. Let $\tilde{a}$ be an arc in $p_j^{-1}(a) \cap A(\tilde{K}_1)$. It is of the form $(\eta, \sigma^c \circ \eta)$. Its image by $\psi$ is the arc $(\eta \circ \eta_1^{-1} \circ \eta_2, \sigma^c \circ \eta \circ \eta_1^{-1} \circ \eta_2)$ with color $c$. Denoting $i$ the tail of $a$, we have $\eta(j) = \eta_1(j) = \eta_2(j) = i$, which implies immediately that $p_j(\psi(\tilde{a}))$ has the same endpoints as $a$. Since it has also the same color $c$, we have $p_j(\psi(\tilde{a})) = a$.

From the previous two paragraphs, we see that for any two components $\tilde{K}_1$ and $\tilde{K}_2$ of $\tilde{D}$, we have $|p_j^{-1}(a) \cap A(\tilde{K}_1)| \le |p_j^{-1}(a) \cap A(\tilde{K}_2)|$. Since the choices of $\tilde{K}_1$ and $\tilde{K}_2$ can be arbitrary, we have actually

$$ |p_j^{-1}(a) \cap A(\tilde{K}_1)| = |p_j^{-1}(a) \cap A(\tilde{K}_2)|. \qquad (3) $$

Finally, an arc $\tilde{a} = (\eta, \eta')$ is mapped to $a$ by $p_j$ precisely when $\tilde{a}$ is colored with color $c$, we have $\eta' = \sigma^c \circ \eta$, and $\eta(j) = i$ (where $i$ is the tail of $a$). The number of bijections $\eta$ from $P$ to $V$ with $\eta(j) = i$ is $(|V| - 1)!$. Hence, $|p_j^{-1}(a)| = (|V| - 1)!$. Combining this with equality (3), we get the desired conclusion. $\blacksquare$

**Proof of Proposition 3.** Choose any connected component $\tilde{K}$ of $\tilde{D}$. It is Eulerian, since each vertex of $\tilde{D}$ has equal in- and outdegrees. Consider an arbitrary Eulerian cycle, and denote by $c_1, c_2, \dots$ the sequence of colors of the arcs of this cycle. According to Lemma 4, every pebble $j$ moved according to this sequence of colors follows a closed walk on $D$ visiting each arc $\frac{|V|-1)!}{\kappa}$ times. Repeating infinitely many times this sequence of colors provides the desired periodic sequence. $\blacksquare$

# 3 Proofs of the main results

## 3.1 Preliminaries

This section introduces preliminary results and a few tools that will be crucial for the proofs of Theorems 1 and 2 given in Section 3.2. In particular, we show how to introduce fictitious tasks in a way that will simplify some discussions, we explain how to build a new feasible assignment from a sequence of feasible assignments, and finally we define a graph $D^F$ built from a set of feasible assignments, which will be useful to cast the problem of existence of balanced feasible assignments as the pure graph problem of Section 2.
### 3.1.1 Making the number of employees and the number of tasks overlapping 0 equal

Denote by $U$ the set $\{i \in [n]: a_i \le 0\}$. In other words $U$ is the set of tasks that are overlapping the left endpoint of the interval $[0, 1]$. We can get $|U| = q$ by adding fictitious tasks $i$ whose intervals are of the form $[0, \varepsilon)$ for an $\varepsilon > 0$ small enough. Just after the proof of the following lemma, the relevance of this transformation will be highlighted.

**Lemma 5.** *The number $\varepsilon$ can be chosen so that the following holds: There exists a feasible assignment for the original instance if and only if there exists a feasible assignment for the instance with the fictitious tasks.*

**Proof.** Let $\varepsilon := \min(\{a_i: a_i > 0\} \cup \{a_i + 1: a_i \le 0\})$. Obviously, if there exists a feasible assignment with the fictitious tasks, then the restriction of this assignment to the original tasks is feasible. Conversely, suppose there exists a feasible assignment $f$ for the original instance. We extend it on the fictitious tasks as follows: for each integer time, the assignment $f$ leaves a number of idle employees equal to the number of fictitious tasks; extending $f$ arbitrarily on the $r$th occurrence of these tasks with these employees leads to a feasible assignment for the instance with the fictitious tasks. (The number $\varepsilon$ has been chosen so that this does not create any conflict.) $\blacksquare$

Since a balanced feasible assignment for the instance with the fictitious tasks is obviously balanced and feasible when restricted to the original instance, the assumption $|U| = q$ is made throughout Section 3. For every feasible assignment $f$ and every $r \in \mathbb{Z}_{>0}$, we introduce the map $\varphi_{f,r}: i \in U \mapsto f(i,r) \in [q]$. The assumption $|U| = q$ makes $\varphi_{f,r}$ a bijection, which will turn out to be useful, already in the next paragraph.

### 3.1.2 Building a new feasible assignment from a sequence of feasible assignments

In the proofs, we will build new feasible assignments from sequences of feasible assignments. Let $f_1, f_2, \dots$ be an infinite sequence of feasible assignments. Define inductively the permutations $\pi_r$ of $[q]$ by the equation $\pi_{r+1} = \pi_r \circ \varphi_{f_r, 2} \circ \varphi_{f_{r+1}, 1}^{-1}$, where $\pi_1$ is an arbitrary permutation of $[q]$. This implies in particular

$$ (\pi_{r+1} \circ f_{r+1})(\cdot, 1) = (\pi_r \circ f_r)(\cdot, 2). \qquad (4) $$

Notice that if the $f_r$ are periodic, then so are the $\pi_r$. Note also that the period of the $\pi_r$ can be much larger than that of the $f_r$. (Similar constructions have been used in the work of Eisenbeis, Lelait, and Marmol [3].)

**Lemma 6.** *The map $(i, r) \mapsto (\pi_r \circ f_r)(i, 1)$ is a feasible assignment.*

**Proof.** Let us show that $g: (i, r) \mapsto (\pi_r \circ f_r)(i, 1)$ is a feasible assignment by checking the contrapositive of (1). Consider $i, i' \in [n]$ with $i \ne i'$ and $r, r' \in \mathbb{Z}_{>0}$. Suppose $g(i, r) = g(i', r')$, i.e., $(\pi_r \circ f_r)(i, 1) = (\pi_{r'} \circ f_{r'})(i', 1)$. Without loss of generality, suppose that $r \le r'$. Consider first the case when $r = r'$. Since $\pi_r$ is a permutation, we have $f_r(i, 1) = f_r(i', 1)$. Since $f_r$ is feasible, then the contrapositive holds for $f_r$, namely, $[a_i + 1, b_i + 1) \cap [a_{i'} + 1, b_{i'} + 1) = \emptyset$, which is equivalent to $[a_i + r, b_i + r) \cap [a_{i'} + r', b_{i'} + r') = \emptyset$, as desired.

Consider now the case when $r + 1 = r'$. Note first that if $i' \notin U$, then $b_i + r < a_{i'} + r + 1$ and so $[a_i + r, b_i + r) \cap [a_{i'} + r', b_{i'} + r') = \emptyset$. Suppose now that $i' \in U$. Using the definition of $\pi_{r+1}$, we have $\pi_r(f_r(i, 1)) = \pi_r(f_r(i', 2))$. Since $\pi_r$ is a permutation, then $f_r(i, 1) = f_r(i', 2)$. The contrapositive holds for the feasible assignment $f_r$, so $[a_i + r, b_i + r) \cap [a_{i'} + r', b_{i'} + r') = \emptyset$.

Finally, if $r + 2 \le r'$, then $[a_i + r, b_i + r) \cap [a_{i'} + r', b_{i'} + r')$ is necessarily empty. Therefore, $g$ is a feasible assignment. $\blacksquare$
### 3.1.3 Definition of $D^F$

For each $i, i' \in U$, pick a feasible assignment $f_{ii'}$ such that $f_{ii'}(i, 1) = f_{ii'}(i', 2)$ if it exists. Let $\mathcal{F}$ be the set of all these feasible assignments (some $f_{ii'}$ might be equal but only one representative is kept). The proofs rely on a directed multi-graph $D^F = (U, A^F)$, with vertex set $U$ and whose arcs are defined from the set $\mathcal{F}$. The arc set $A^F$ is obtained by introducing $q$ arcs for each $f \in \mathcal{F}$: an arc from $i \in U$ to $i' \in U$ whenever $f(i, 1) = f(i', 2)$ – repetitions are allowed –; such an arc is labeled with $f$.

Note the following properties:

- The $q$ arcs labeled with the same feasible assignment $f$ form a collection of vertex-disjoint directed cycles: each vertex is by construction the head of exactly one arc and the tail of exactly one arc.

- The number of arcs in $A^F$ is $q|\mathcal{F}|$.

- When $D^F$ is weakly connected – i.e., the underlying undirected graph is connected – it is also strongly connected and Eulerian.

Lemma 6 will be used to retrieve a feasible assignment from a walk on $D^F$. The next lemma will be useful in that regard.

**► Lemma 7.** *The directed graph $D^F$ is Eulerian if and only if there exists a feasible assignment with an employee performing each task at least once.*

**Proof.** Suppose there exists a feasible assignment $f$ with an employee $j^*$ performing each task at least once. For every $r$ such that $f(i, r) = j^*$ and $f(i', r+1) = j^*$ there is an arc $(i, i')$ in $A^F$ because we can build a feasible assignment from $f$ in which the first occurrence of $i$ and the second occurrence of $i'$ are both assigned to employee $j^*$. Thus the sequence of tasks in $U$ performed by employee $j^*$ induces in $D^F$ a walk visiting all vertices. This implies that the graph $D^F$ is weakly connected and as noted above this implies that $D^F$ is Eulerian.

Suppose now that $D^F$ is Eulerian. Let $a_1, a_2, \dots$ be the sequence of arcs of an Eulerian cycle of $D^F$, visited infinitely many times, and consider the sequence $f_1, f_2, \dots$ of assignments labeling this arc sequence. Denote by $i_r$ the tail of the arc $a_r$. Let $\pi_r$ be the permutations defined by equation (4), for this sequence of assignments, with $\pi_1$ being arbitrary. Let then $g$ be the feasible assignment as in Lemma 6. Let $i \in [n]$. Define then $i' := \varphi_{f_1, 1}^{-1}(f_1(i, 1))$. In particular, we have $f_1(i, 1) = f_1(i', 1)$. In other words, $i'$ is the task in $U$ performed before the first occurrence of $i$ in the assignment $f_1$. Let $\bar{r}$ be such that $a_{\bar{r}}$ leaves the vertex $i'$ with label $f_1$, which means that $i' = i_{\bar{r}}$ and $f_{\bar{r}} = f_1$. Such $\bar{r}$ exists because an Eulerian cycle visits all arcs and because from every vertex, there is an outgoing arc labeled with $f_1$ by construction of $D^F$. Thus, we have

$$g(i, \bar{r}) = \pi_{\bar{r}}(f_{\bar{r}}(i, 1)) = \pi_{\bar{r}}(f_1(i, 1)) = \pi_{\bar{r}}(f_1(i_{\bar{r}}, 1)) = \pi_{\bar{r}}(f_{\bar{r}}(i_{\bar{r}}, 1)).$$

We have $f_r(i_r, 1) = f_r(i_{r+1}, 2)$ for all $r \in \mathbb{Z}_{>0}$ because the arc $a_r$ is labeled with $f_r$ and $a_r$ goes from $i_r$ to $i_{r+1}$. Then, combining this equality alternatively with the equation (4), we get

$$\pi_{\bar{r}}(f_{\bar{r}}(i_{\bar{r}}, 1)) = \pi_{\bar{r}-1}(f_{\bar{r}-1}(i_{\bar{r}}, 2)) = \pi_{\bar{r}-1}(f_{\bar{r}-1}(i_{\bar{r}-1}, 1)) = \dots = \pi_1(f_1(i_1, 1)) = g(i_1, 1).$$

Therefore $g(i, \bar{r}) = g(i_1, 1)$. Since $i$ was chosen arbitrarily, this means the employee $g(i_1, 1)$ performs each task at least once. ▼

<figure><img src="image_7.png" /></figure>
## 3.2 Proof of Theorems 1 and 2

This section deals with the proofs of our two main results.

**Proof of Theorem 1.** As already mentioned, one direction is immediate: if there exists a balanced feasible assignment, then this assignment is such that every employee performs each task at least once. We prove now the opposite direction.

Suppose there exists a feasible assignment with an employee performing each task at least once. By Lemma 7, $D^F$ is Eulerian. Locate one pebble on each vertex of $D^F$. Applying Proposition 3 on $D^F$, with each feasible assignment in $\mathcal{F}$ identified with a color, we get a periodic sequence $f_1, f_2, \dots$ of feasible assignments. Denote by $g$ the resulting periodic feasible assignment given by Lemma 6 for this sequence, with $\pi_1$ being an arbitrary permutation.

Number $j = g(i, 1)$ the pebble initially located on vertex $i \in U$. This makes sure that each pebble gets a distinct number in $[q]$ (by the bijectivity of $\varphi_{g,1}$). We establish now the following claim: For every $i \in U$ and every $j \in [q]$, pebble $j$ is on vertex $i$ after its $(r-1)\text{th}$ move if and only if $g(i, r) = j$.

Let us proceed by induction on $r \in \mathbb{Z}_{>0}$. This is true for $r = 1$ by the definition of the numbering of the pebbles. Suppose now that the claim if true for some $r \in \mathbb{Z}_{>0}$. Consider pebble $j$ and assume it is located on $i$ after its $r$th move. This means that the pebble $j$ was on vertex $i'$ after its $(r-1)\text{th}$ move then moved along the arc from $i'$ to $i$ labeled with $f_r$. Then, using equation (4) and the fact that $f_r(i, 2) = f_r(i', 1)$ by definition of $D^F$,

$$g(i, r+1) = \pi_{r+1}(f_{r+1}(i, 1)) = \pi_r(f_r(i, 2)) = \pi_r(f_r(i', 1)) = g(i', r) = j, \quad (5)$$

as desired. Conversely, assume that $g(i, r+1) = j$. Denote by $i'$ the tail of the arc of head $i$ and label $f_r$. Then equation (5) holds as well, meaning that $g(i', r) = j$. By induction, the pebble $j$ was located on vertex $i'$ after its $(r-1)\text{th}$ move. It then moves along the arc from $i'$ to $i$ with label $f_r$, which concludes the proof of the claim.

We check that $g$ is balanced. According to Proposition 3, for every $i \in U$, every $j \in [q]$, and every $f \in \mathcal{F}$, we have

$$\lim_{t \to +\infty} \frac{1}{t} \left| \{r \in [t]: \text{pebble } j \text{ leaves } i \text{ along arc labeled } f \text{ for its } (r-1)\text{th move}\} \right| = \frac{1}{|A^F|}.$$

With the claim, this equality becomes

$$\lim_{t \to +\infty} \frac{1}{t} \left| \{r \in [t]: f_r = f \text{ and } g(i, r) = j\} \right| = \frac{1}{|A^F|}.$$

This equality is actually also true when $U$ is replaced by the larger set $[n]$. Indeed, given $i \in [n]$ and $f \in \mathcal{F}$, the bijectivity of $\varphi_{f,r}$ ensures that there exists a unique $u(i, f)$ in $U$ such that $f(u(i, f), r) = f(i, r)$ and we have $g(i, r) = g(u(i, f_r), r) = j$ for every $r \in \mathbb{Z}_{>0}$, by definition of $g$ and $u(i, f_r)$. Therefore, for all $i \in [n]$

$$\lim_{t \to +\infty} \frac{1}{t} \left| \{r \in [t]: g(i, r) = j\} \right| = \sum_{f \in \mathcal{F}} \lim_{t \to +\infty} \frac{1}{t} \left| \{r \in [t]: f_r = f \text{ and } g(i, r) = j\} \right| = \frac{|\mathcal{F}|}{|A^F|} = \frac{1}{q},$$

as desired.

<figure><img src="image_8.png" /></figure>

The proof actually shows that the period of the periodic balanced feasible assignment $g$ built within the proof is upper bounded by $q^2 \times q!$. Indeed, with the comment following Proposition 3, each vertex $i$ is visited by each pebble every $h$ moves (with $h$ the period of the $f_r$), where $h$ is bounded by $|A^F|(q-1)! \le q^2 \times q!$. Using the claim in the proof of Theorem 1,
for each $i \in U$ and $r \in \mathbb{Z}_{>0}$, we have $g(i,r) = g(i,r+h)$. Extending this relation to all $i \in [n]$ as in the proof of Theorem 1 (since the sequence of the $f_r$ also has period $h$), the period of $g$ is bounded by $q^2 \times q!$.

The proof of Theorem 2 combines this remark, Theorem 1, Lemma 7, and the following lemma.

**Lemma 8.** Let $i, i'$ be two tasks of $U$. Deciding whether there exists a feasible assignment $f$ such that $f(i, 1) = f(i', 2)$ and building such an assignment if it exists can be done in polynomial time.

**Proof.** Let $G$ be the interval graph built from all the intervals $[a_k, b_k)$ for $k \in [n]$ together with the intervals $[a_k+1, b_k+1)$ for $k \in U$. Deciding whether there exists a feasible assignment $f$ such that $f(i, 1) = f(i', 2)$ is equivalent to deciding whether there is a proper $q$-coloring of $G$ with the intervals $[a_i, b_i)$ and $[a_{i'}+1, b_{i'}+1)$ colored the same color. (Indeed, such a feasible assignment translates into a proper $q$-coloring of $G$ with the desired property and conversely such a $q$-coloring provides a “partial” feasible assignment which can be extended into a feasible one easily.) This is equivalent in turn to the problem of deciding the $q$-colorability of $G$ with $[a_i, b_i)$ and all intervals intersecting $[a_{i'}+1, b_{i'}+1)$ (the latter interval excluded) colored with pairwise distinct colors. Here, we use the fact that $|U| = q$, i.e., there are $q-1$ intervals intersecting $[a_{i'}+1, b_{i'}+1)$. The problem of deciding whether a partial coloring of an interval graph can be extended to a proper $q$-coloring can be done in polynomial time when the partial coloring contains at most one occurrence of each color (this is a result by Biró, Hujter, and Tuza [1]). If such a partial coloring extension exists, then it can be built in polynomial time as well. ◀

**Proof of Theorem 2.** According to Lemma 8, the graph $D^F$ can be built in polynomial time (since $|F| \le q^2$). Deciding whether a graph is strongly connected can be done in polynomial time, and $D^F$ being strongly connected means it is Eulerian. Therefore, using Theorem 1 along with Lemma 7, deciding whether there exists a balanced feasible assignment can be done in polynomial time.

Moreover, Theorem 1 provides a construction of a periodic balanced feasible assignment $g$ (if it exists). By expliciting the arguments, the construction consists first in building the graph $\tilde{D}$ of Lemma 4, and then in computing an Eulerian cycle in an arbitrary connected component of this graph (as done in the proof of Proposition 3), which provides a periodic sequence of feasible assignments $f_1, f_2, \dots$. The size of $\tilde{D}$ and the period of this sequence are both polynomial when $q$ is fixed. In other words, the sequence can be described in polynomial time when $q$ is fixed. This allows a polynomial description of $g$ when $q$ is fixed according to the comment following the proof of Theorem 1. ◀

# 4 Concluding remarks

## 4.1 All feasible assignments are balanced (Almost)

If we are just interested in the existence of a balanced feasible assignment, and not on the periodicity of such an assignment or its computability, we can replace Proposition 3 by the following lemma in the proof of Theorem 1. We keep the same setting of an arc-colored Eulerian directed multi-graph $D = (V, A)$ with a distribution of pebbles on its vertices, as in the beginning of Section 3.2.

**Lemma 9.** Consider an infinite sequence of independent random colors drawn uniformly. Then, almost surely, this sequence makes each pebble visit each arc with the same frequency.
5:10 Balanced Assignments of Periodic Tasks

In particular there are infinitely many color sequences making each pebble visit each arc with the same frequency. The proof relies on basic properties of Markov chains. (A standard reference on Markov chains is the book by Norris [6].) The proof does not show how to construct such a sequence of colors. It is not even clear that the proof could be modified in that regard. So the proof shows that almost all color sequences have the desired property, but does not explain how to construct a single such sequence. Although this might sound surprising, this phenomenon is quite common. Normal numbers form an example: (almost) all numbers are normal but not a single one has been described explicitly [9].

The proof of Proposition 3 actually provides an alternative proof of the existence of sequences of colors making each pebble visit each arc with the same frequency, with an explicit construction. However, the latter proof does not show that almost all sequences are actually like that. (In counterpart, it shows that such a sequence can be chosen to be periodic.)

**Proof of Lemma 9.** Any realization of this random sequence of colors defines a sequence of moves for the pebbles, as described above. Consider an arbitrary pebble. The random sequence of colors translates thus into a random walk of the pebble on the graph $D$. Denote by $X_k$ the arc along which the pebble performs its $k$th move. The $X_k$'s form a finite Markov chain. Since the graph is Eulerian, this Markov chain is irreducible, and hence there exists a unique invariant distribution $\lambda$ such that $\lambda^\top = \lambda^\top M$, where $M$ is the transition matrix of the Markov chain.

We claim that $\lambda$ is actually the vector $\frac{1}{|A|}e$, where $e$ is the all-one vector. By the uniqueness of the invariant distribution, it is enough to check that $e$ is a left eigenvector of $M$ with eigenvalue equal to 1. The entry $M_{a,a'}$ of the transition matrix (row $a$, column $a'$), which corresponds to the probability of moving along $a'$ just after moving along $a$, is equal to $1/\alpha$ if the head of $a$ is the tail of $a'$, and 0 otherwise. The indegree of each vertex being $\alpha$, we have

$$ \sum_{a \in A} M_{a,a'} = \alpha \frac{1}{\alpha} = 1, $$

and therefore $e^\top M = e^\top$.

According to the ergodic theorem, for almost all realizations of the random sequence of colors, the pebble visits any arc $a$ with a frequency equal to the corresponding entry in $\lambda$, which is equal to $\frac{1}{|A|}$ for all arcs since it is a probability distribution proportional to the all-one vector. The previous discussion does not depend on the considered pebble, which implies the desired result: for almost all realizations of the random sequence of colors, every pebble visits every arc with a frequency equal to $\frac{1}{|A|}$. ◀

Similarly to the proof of Theorem 1, using a much larger set of feasible assignments $F'$ (typically one for each feasible “pattern” on $[1, 2]$), Lemma 9 could translate into the following statement: *If there is at least one balanced feasible assignment, then almost all feasible assignments are balanced.*

## 4.2 Tasks with different periods

Suppose now that each task $i \in [n]$ comes with a period $\tau_i \ge b_i - a_i$: the $r$th occurrence of task $i$ takes place over the time interval $[a_i + r\tau_i, b_i + r\tau_i)$. In this more general setting, it is not clear under which extra condition Theorem 1 and Theorem 2 are verified. When some periods are irrational, the equivalence stated by Theorem 1 does not necessarily hold. Figure 2 provides an example where there exists a feasible assignment with one employee performing all the tasks at least once but no feasible assignment is balanced.
<figure><img src="image_9.png" /><figcaption>(a) An instance with three tasks ($n = 3$). The task 3 has interval $[1 - \pi, 1)$ and period $\pi$, the task 2 has interval $[1 - e, 1)$ and period $e$ and the task 1 has interval $[e - 3, e - 2)$ and period 1.</figcaption></figure>

<figure><img src="image_10.png" /><figcaption>(b) A feasible assignment $f$ for three employees ($q = 3$). Assuming that this pattern is extended along the horizontal axis, the employee 3 performs each task at least once.</figcaption></figure>

■ **Figure 2** Example of an instance with irrational periods, for $q = 3$, with a feasible assignment where an employee performs each task at least once but with no balanced feasible assignment: after time $1 + e$, there is no possible swap of the tasks between the employees.

However, the authors do not know what happens when all the periods are rational. In the latter case, there is a natural way to associate to the original instance a new instance, with all tasks of period 1 and with the same number of employees. This goes as follows. Write the $\tau_i$ as fractions of integers with the same denominator, and denote by $p_i$ the numerator. Let $p$ be a common multiplier of the $p_i$. For every $i \in [n]$ interpret the $p/p_i$ first occurrences of tasks $i$ as the first occurrence of $p/p_i$ new tasks that replace the original task $i$. Then, scale the time with a factor $1/p$ so as to get a common period of 1. Clearly, a balanced assignment for this new instance translates into a balanced one for the original instance, but it is not clear whether things go the other way around. Moreover, the construction described above is not polynomial and extending Theorem 2 along these lines seems even more elusive.

## 4.3 When the number of employees is part of the instance

Theorem 2 states that when the number of employees $q$ is constant, a balanced feasible assignment (if it exists) can be built in polynomial time. However, the proof exhibits a period bounded by $q^2 \times q!$ for this balanced feasible assignment. Therefore, when $q$ is part of the instance, it is not clear whether the construction of a balanced feasible assignment (under condition of existence) is polynomial.

► **Question.** When the number $q$ of employees is part of the instance, what is the complexity status of the construction of a balanced feasible assignment (if it exists)?
5:12 Balanced Assignments of Periodic Tasks

References

1 Miklós Biró, Mihály Hujter, and Zsolt Tuza. Precoloring extension. I. Interval graphs. *Discrete Mathematics*, 100(1-3):267–279, 1992.

2 Thomas Breugem, Twan Dollevoet, and Dennis Huisman. Analyzing a family of formulations for cyclic crew rostering. In Dennis Huisman and Christos D Zaroliagis, editors, *ATMOS 2020*, volume 85, pages 7:1–7:16, 2020.

3 Christine Eisenbeis, Sylvain Lelait, and Bruno Marmol. Circular-arc graph coloring and unrolling, February 1998.

4 Jan Korst, Emile Aarts, Jan Karel Lenstra, and Jaap Wessels. Periodic assignment and graph colouring. *Discrete Applied Mathematics*, 51(3):291–305, 1994.

5 Christian Liebchen and Rolf Möhring. The modeling power of the periodic event scheduling problem: Railway timetables – and beyond. In *Computer-aided Systems in Public Transport*, volume 600, pages 117–150. Springer Berlin Heidelberg, January 2008.

6 James R Norris. *Markov chains*. Cambridge university press, 1998.

7 Philine Schiewe and Anita Schöbel. Periodic timetabling with integrated routing: Toward applicable approaches. *Transportation Science*, 54(6):1714–1731, 2020.

8 Paolo Serafini and Walter Ukovich. A mathematical model for periodic scheduling problems. *SIAM Journal on Discrete Mathematics*, 2(4):550–581, 1989.

9 Wikipedia. Normal number, 2024. [Online; accessed 1-July-2024]. URL: https://en.wikipedia.org/wiki/Normal_number.

10 Lin Xie and Leena Suhl. Cyclic and non-cyclic crew rostering problems in public bus transit. *OR Spectrum*, 37:99–136, 2015.