SlowGuess/NeurIPS_2023_OCR huggingface dataset:
Ziyad Benomar  
CREST, ENSAE, Ecole polytechnique  
ziyad.benomar@ensae.fr
Vianney Perchet  
CREST, ENSAE and Criteo AI LAB  
vianney.perchet@normalesup.org
Several problems have been extensively studied in the learning-augmented setting, where the algorithm has access to some, possibly incorrect, predictions. However, it is assumed in most works that the predictions are provided to the algorithm as input, with no constraint on their size. In this paper, we consider algorithms with access to a limited number of predictions, that they can request at any time during their execution. We study three classical problems in competitive analysis, theski rental problem, the secretary problem, and the non-clairvoyant job scheduling. We address the question of when to query predictions and how to use them.
With the rise of data science and the huge emphasis on research in machine learning and artificial intelligence, powerful predictive tools have emerged. This gave birth to learning-augmented algorithms, which use these predictions to go beyond the standard long-standing worst-case limitations. The design of such algorithms requires establishing good tradeoffs between consistency and robustness, i.e. having improved performance when the predictions are accurate, and not behaving poorly compared to the case without predictions if they are erroneous. This was formalized by Lykouris and Vassilvitskii [41] for the caching problem, and Purohit et al. [47] for the ski- rental and scheduling problems. Since then, the learning-augmented setting had many applications in implementing data structures [36, 23, 39] and in the design of algorithms [15, 7, 6, 11, 30, 5, 1, 4, 10, 40].
Several questions and research directions have been explored, such as exhibiting optimal robustness-consistency tradeoffs [48], incorporating predictions from multiple experts [3, 19], or customizing learning approaches to make predictions for such algorithms [49, 21, 18, 34, 2]. In most papers, those predictions are assumed to be given as inputs, which is unfortunately not realistic, practical or applicable to real-life scenarios. Indeed, many problems such as scheduling, paging, or set cover, require some arbitrarily large number of predictions (roughly speaking one per request or job). We claim that, on the contrary, algorithms might have only access to a finite budget of predictions as each one of them is costly to compute. Therefore, the main question rather becomes deciding how and when to spend the assigned budget, by requesting new predictions. Such a setting was considered for example in [31] for the caching problem. Moreover, it also happens that the quality of the predictions improves with time, as more data are collected, more knowledge of the problem is gathered, or delaying the computation of prediction allows to allocate more computational power to them, hence enhancing their precision, for instance with more powerful forecasting models. The question of planning the prediction requests is thus quite crucial.
The problems we mentioned fall into the category of online algorithms, operating under uncertainty, and gaining more information about the input of the problem through time, eventually depending on their past decisions. The performance of such algorithms is measured by their competitive ratio [14], which is the worst-case ratio between their output and that of the optimal offline algorithm, having full knowledge of the inputs and parameters of the problem. To illustrate our claims, we shall focus
on three well-established and fundamental problems in competitive analysis: ski rental, secretary, and job scheduling problems.
Ski-rental In the ski-rental problem, the decision maker faces each day the choice of either renting a ski for a unit cost, or buying it at a cost of  $b$  and skiing for free after that. The only decision to be made by the algorithm is therefore when to buy. The unknown parameter is the length  $x$  of the ski season, and the objective is to minimize the total cost of renting and buying. The optimal offline algorithm has a cost  $\min \{x, b\}$ , the deterministic online break-even algorithm, which consists in renting for the first  $b - 1$  days and then buying, results in a competitive ratio of 2 [32], and the optimal randomized algorithm introduced by Karlin et al. [33] yields a competitive ratio of  $\frac{e}{e - 1}$ .
Secretary problem The second problem we study is the secretary problem. Consider having  $N$  applicants observed sequentially in a uniformly random order. Immediately after a candidate is observed, the algorithm has to either select them and stop, or refuse them irrevocably. The objective is to maximize the probability of selecting the best applicant overall. The particularity of this problem is that a single incorrect decision at any point leads to failure and zero gain. Consequently, the cost of making a wrong decision is significantly high. The optimal offline algorithm has access to all values and thus can choose the maximum with probability 1. The optimal online strategy is to reject the first  $N / \mathrm{e}$  applicants, then stop at the first applicant who is better than all of them [17, 25]. This is often referred to as the  $1 / \mathrm{e}$  rule, and it gives a success probability of  $1 / \mathrm{e} \approx 0.368$ .
Job scheduling The third problem we consider is the preemptive non-clairvoyant job scheduling. The input is a set of jobs with unknown sizes, that the algorithm needs to schedule on a single machine, with the possibility of halting a job during its execution and resuming it later. The goal is to minimize the sum of their completion times, i.e. finish as many jobs as possible rapidly. The only observations made during the run of an algorithm are the completion times of the jobs. These observations, along with the times at which they are received, depend on both the input instance and the algorithm's past decisions. The cost of early incorrect decisions is more significant than that of later incorrect decisions. Take for example the instance of job sizes  $\{x_{1} = 1, x_{2} = 100\}$ , running  $x_{1}$  then  $x_{2}$  gives an output  $1 + 101 = 102$ , while running them in the inverse order gives  $100 + 101 = 201$ . The optimal offline algorithm is to schedule the jobs in increasing order of size, and a deterministic online algorithm called round-robin, gives a competitive ratio of 2, which is optimal for an arbitrarily large number of jobs [46].
1.1 Organization and contributions
In Section 2, we consider the ski rental problem, where we assume that an oracle provides binary predictions on how the snow season length  $x$  compares to the purchasing cost  $b$ , and that these predictions are accurate with a probability that is a function of time, known to the algorithm and denoted as  $p_t$ . This assumption accurately reflects and models what is practically occurring. As the snow season begins, there is significant uncertainty about how long it will last. However, over time, the accuracy of predictions increases as more weather observations are made, the direction of snowstorms becomes clearer, and additional data is collected. The algorithm is permitted to request only one prediction during its execution, at a time of its choice. Depending on the function  $p_t$  and on how the prediction is used once queried, it can be more advantageous to rent for a period of time  $t$  before requesting it, i.e. paying a cost for making a better decision in the future. We consider that once the prediction is queried, we use either the deterministic or the randomized algorithm presented in [47] for the ski rental problem. We show how to optimally choose  $t$ , and how the knowledge of  $p_t$  allows us to tune the parameter  $\lambda$ , regulating the levels of consistency and robustness in both algorithms.
Secondly, we consider in Section 3 the secretary problem with access to an oracle, accurate with a probability  $p$ , telling if there are better applicants in the future. In practice, this would correspond to the following scenario: consider a decision-maker with an imperfect interviewing process, and thus can only compare the applicants with each other, i.e. observe their relative ranks, but lacks access to their true value. On the other hand, an expert who, due to extensive experience, knows how to better interview the applicants and extract their true value, and also knows the distribution of their values (as in a prophet setting with i.i.d variables). The decision-maker can ask the expert to interview some applicants for a cost. After that, the expert does not disclose the precise value of the applicant - that is irrelevant to the decision maker-, but they provide a recommendation (accept or reject) and
accompany it with a confidence level, which is the probability that this recommendation is accurate. Assuming that the decision-maker has enough budget to ask for the expert's advice  $B$  times, we give an algorithm whose success probability depends on  $p$  and  $B$ , converges to 1 as  $p$  goes to 1 and  $B$  grows, and that is always lower bounded by  $1 / \mathrm{e}$ . Our algorithm easily adapts to the case where the accuracy of the oracle is time-dependent.
Section 4 is dedicated to the preemptive non-clairvoyant job scheduling, where we assume that the algorithm can request access to the sizes of  $B$  chosen jobs. In contrast with the two previous problems, there is no advantage in waiting before querying the hints, and since the jobs play identical roles, the algorithm can only request the sizes of  $B$  randomly chosen ones. We show first that the competitive ratio 2 cannot be improved unless  $B = \Omega(N)$ , where  $N$  is the number of jobs. Then we present an algorithm that chooses randomly  $B$  jobs and requests their sizes, then runs concurrently the optimal offline algorithms on those jobs and round-robin on the others, with time-dependent processing rates. We prove a generic expression for the output of this algorithm that depends on the chosen processing rate, and then we give a particular processing rate that yields a competitive ratio of  $2 - (B / N)^2$ , therefore interpolating the competitive ratios 2 and 1 met respectively when no hint is given, and when all the job sizes are known.
Finally, we run simulations of our algorithms in Section 5. We show that the performance of the algorithm we introduced for the secretary problem matches our theoretical lower bound, and we compare it to another heuristic version that we did not study theoretically. Then, by exhaustively testing the algorithm we designed for the scheduling problem with access  $B$  job sizes on various benchmark instances, we observe that it has a better performance in practice than the theoretical upper bound  $2 - (B / N)^{2}$ .
The ski-rental and scheduling problems have received extensive attention in the realm of learning-augmented algorithms [47, 48, 3, 19, 18, 37, 9]. They serve respectively as notable examples for problems requiring a single prediction and multiple predictions. Moreover, they both have numerous applications and variants, as [32, 12, 24, 44] for the ski rental and [42, 16, 38] for the scheduling problem. The secretary problem was also among the first problems studied with the advice model. Dütting et al. [22] consider that a binary prediction is received with each applicant, indicating whether it is the best overall or not. Assuming that these predictions are accurate each with a probability  $p$  independently, they design algorithms that improve upon the  $1/e$  success probability. While this model closely aligns with ours, we consider a scenario where the algorithm has a limited budget of predictions and must carefully determine when to query them. Antoniadis et al. [7] studied a variant of the problem where the objective is to maximize the value of the selected applicant. They consider that the algorithm is provided with a prediction of the value of the best applicant.
For both the ski- rental and the secretary problems, we consider predictions that are accurate with a known probability. A similar assumption was made in [28], where the oracle is assumed to deliver a prediction that is accurate with a probability of at least  $\epsilon$ , and that can be arbitrarily inaccurate with the remaining probability. The authors give improved competitive ratios depending on  $\epsilon$  for some online problems including caching, online set cover, and facility location.
The aspect of having a limited prediction budget is relatively underexplored in the literature. The question was initially examined in the context of the online linear optimization problem with hints, where Bhaskara et al. [13] demonstrated that a sublinear number of hints is sufficient to achieve regret bounds similar to those in the full hints setting when the timing of requesting hints is well chosen. Im et al. [31] also investigated this question for the caching problem, presenting an algorithm that strategically utilizes the assigned prediction budget to improve the competitive ratio as the budget increases. In a very recent paper, the ski-rental and the Bahncard problems were explored in a setting with costly predictions [20], where the cost of predictions is added to the total cost paid by the algorithm. This can be seen as a penalized version of querying predictions under budget constraints. Other works have also investigated the reduction of the prediction size rather than the number of predictions. Specifically, they consider binary predictions encoded on a single bit and explore how the competitive ratio can be enhanced compared to other types of predictions [22, 45, 8].
Another important question we cover thanks to the ski-rental problem is how to optimally balance robustness vs consistency with respect to predictions [47]. This tradeoff is usually done by adding
some extra-parameter  $\lambda \in [0,1]$  that reflects how much the decision-maker is willing to trust blindly the prediction, and which appears naturally in the bounds of the competitive ratio. Roughly speaking, for  $\lambda = 1$ , the decision maker focuses solely on the performances of their algorithms when predictions are incorrect (hence predictions are actually disregarded), while for  $\lambda = 0$ , they naively consider that predictions are correct. Intermediate values of  $\lambda$  correspond to less extreme behaviors, and the final competitive ratio strongly depends on the value of this parameter and the total "amount" of errors (measured with respect to some problem-dependent metric) in predictions. Setting a value for this parameter requires having some knowledge about the quality of the prediction. Khodak et al. [34] shows how to learn to set  $\lambda$ 's value in an online learning setting, where the algorithm runs repeatedly on different instances, and learns to predict unknown parameters based on features on the new instances. After many runs, the value of  $\lambda$  can be increased since the predictions become more and more accurate. In our case, we have binary predictions that are correct with a known probability, which is a natural assumption for binary predictions [45, 22], and we show that this allows us to optimally choose the value of  $\lambda$ .
2 Ski-rental with time-dependent guarantees on the prediction
We consider that the cost of renting a ski for one day is 1, while the cost of buying is  $b > 1$ , and we denote  $x$  the duration of the ski season, which is unknown. For all the algorithms we present, if the ski season is over then the algorithm stops and no further cost is paid. In the learning-augmented setting, we assume that the algorithm possesses a prediction  $y$  for  $x$ . Many variants of this scenario have also been explored in previous research papers [47, 35, 27, 48]. We restrain ourselves to the case of binary predictions, comparing the number of snow days to the budget. More precisely, we assume the existence of an oracle, that can be called at any time  $t$ , predicting whether  $x - t > b$  or not, where  $x - t$  is the number of remaining snow days. Furthermore, we assume that the accuracy of the oracle improves over time. If queried at time  $t$ , then the prediction is correct with a probability  $p_t$ , known to the algorithm, that is independent of the problem's history and increases over time. We assume that, due to budget limitations, the algorithm can access the oracle only once during its execution, and thus it must carefully choose the time of asking for the prediction.
Let  $\mathsf{ALG}$  be an algorithm such that, with a prediction accurate with probability  $p$ , it has a competitive ratio  $C(\mathsf{ALG}, p)$ . We define the algorithm  $\mathsf{ALG}_t$  that rents for the first  $t$  days, then queries a prediction  $\mathcal{Q}_t$  of  $\mathbb{1}(x - t \geq b)$  at the start of day  $t + 1$ , and then acts like  $\mathsf{ALG}$ . We have the following result.
Lemma 2.1.  $ALG_{t}$  has a competitive ratio of at most  $\frac{t}{b} + C(ALG, p_t)$ .
The term  $t / b$  represents the additional cost due to renting the first  $t$  days, in order to have a better accuracy  $p_t$  which decreases the second term. The optimal time for querying a prediction is  $t^\star$  minimizing the function  $t / b + C(\mathsf{ALG}, p_t)$ . Although this requires knowing all the sequence  $(p_t)_{t \geq 0}$  in advance, we can design simple online heuristics for being close to a local minimum, where the accuracy of the oracle at some step  $t$  is only revealed when that step is reached. We can for example access the oracle at the first time  $t$  when  $t / b + C(\mathsf{ALG}, p_t)$  increases.
In the following, we show how Lemma 2.1 can be applied with explicit algorithms ALG that are given a binary prediction as input. We consider the algorithms 1 and 2, which were first introduced in [47]. In both algorithms, the parameter  $\lambda$  indicates how much the prediction is trusted. Assuming that the input prediction is accurate with a probability  $p = \mathbf{P}(\mathcal{Q} = \mathbb{1}(x\geq b))$ , we show how to tune  $\lambda$  in both algorithms to minimize their costs, and we upper bound their competitive ratios.
Algorithm 1: Deterministic algorithm with input binary prediction [47]
Input: cost  $b$  for buying, a prediction  $\mathcal{Q}$  for  $\mathbb{1}(x\geq b)$
1 if  $Q = 1$  then buy on the start of day  $[\lambda b]$ ;
2 else buy on the start of day  $\lceil b / \lambda \rceil$
Lemma 2.2. If the oracle  $\mathcal{Q}$  delivers an accurate prediction with probability  $p \geq 0.5$ , then by choosing  $\lambda = \sqrt{\frac{1 - p}{p}}$ , the algorithm achieves a competitive ratio of at most  $1 + 2\sqrt{p(1 - p)}$ .
The optimal choice of  $\lambda$  gives therefore a competitive ratio that is always upper bounded by 2, which is the optimal competitive ratio without prediction, and decreases to 1 when the accuracy of the oracle
Figure 1: Competitive ratios of Algorithms 1 and 2 with the optimal choice of  $\lambda$ , for  $p \in (0.5, 1)$  and  $b = 5, 10, 100$
Figure 2: Competitive ratio obtained by renting  $t$  days before querying a prediction, with  $p_t = 0.95 - 0.4\exp (-t / 5)$  and  $b = 50,100$
is better. While Algorithm 1 is deterministic, the next algorithm we study is randomized, where the day of buying is a random variable, drawn from a probability distribution that depends on the prediction  $\mathcal{Q}$ . We show again an optimal choice of  $\lambda$  for minimizing the competitive ratio.
Algorithm 2: Randomized algorithm with input binary prediction [47]
Input: cost b for buying, a prediction Q for 1(x ≥ b)
1 if Q = 1 then buy on the start of day d ∈ {1,..., [λb]}, with probability ∝ (1 - 1/b) [λb]−d;
2 else buy on the start of day d ∈ {1,..., [b/λ]} , with probability ∝ (1 - 1/b) [b/λ]−d;
Lemma 2.3. If the oracle  $\mathcal{Q}$  delivers an accurate prediction with probability  $p \geq 0.5$ , then with  $\lambda = \min \left\{1, \frac{1}{b} + \sqrt{(e - 1)(1/p - 1)}\right\}$ , Algorithm 2 has a competitive ratio of at most
$$
\left\{ \begin{array}{l l} \frac {1}{e - 1} + 2 \sqrt {\frac {p (1 - p)}{e - 1}} + \left(1 - \frac {1 - 1 / b}{e - 1}\right) p & \text {i f} p \geq \left(1 + \frac {(1 - 1 / b) ^ {2}}{e - 1}\right) ^ {- 1}, \\ \frac {e}{e - 1} + \frac {1 - p}{b - 1} & \text {o t h e r w i s e}. \end{array} \right.
$$
Figure 1 shows the competitive ratios of both algorithms depending on  $p$  when  $\lambda$  is chosen optimally. The upper bound shown in Lemma 2.3 depends on  $b$ , this is why we test it with different values of  $b$ . As expected, the randomized algorithm yields better guarantees than the deterministic one. However, when  $p$  is very close to 1, Algorithm 1 is slightly better, because the randomized algorithm requires having  $\lambda \geq 1 / b$ , and therefore in the limit where  $p = 1$ , the optimal choice is  $\lambda = 1 / b$ , giving the upper bound  $1 + 1 / b$  instead of 1 on the competitive ratio.
Now, assuming that the oracle is accurate with a known time-dependent probability  $p_t$ , the previous lemmas allow to optimally choose the time of querying the prediction when one of the two algorithms we presented is used after the prediction is obtained. We only state the result for the case where Algorithm 1 is used. The proof is immediate using Lemmas 2.1 and 2.2, and a similar result can be shown using Lemmas 2.1 and 2.3 when Algorithm 2 is used instead.
Theorem 2.4. If the predictions delivered by the oracle are accurate with a probability  $p_t$  that only depends on the time, then renting until time  $t$ , then querying a prediction  $\mathcal{Q}_t$  and running Algorithm 1 with parameter  $\lambda = \sqrt{\frac{1 - p_t}{p_t}}$ , yields a competitive ratio of at most  $1 + t / b + 2\sqrt{p_t(1 - p_t)}$ .
We consider in Figure 2 an example where  $p_t = 0.95 - 0.4 \exp(-t / 5)$ , thus  $p_0 = 0.55$  and  $\lim_{t \to \infty} p_t = 0.95$ . The figure shows the competitive ratio of renting  $t$  days then using one of the Algorithms 1 or 2, with  $b = 50, 100$ . We observe that this strategy can significantly improve the competitive ratio if  $t$  is chosen correctly. Of course, this depends strongly on  $p_t$  and  $b$ . In particular, for the randomized algorithm, it is better to query the prediction at  $t = 0$  when  $b = 50$ .
3 Secretary problem with  $B$  predictions
Assume that  $N$  applicants are observed sequentially in a uniformly random order  $(x_{1},\ldots ,x_{N})$ , all having distinct values. After an applicant is interviewed, the decision-maker has to either accept them
and halt the process, or refuse them irrevocably. We consider a setting where, when an applicant  $x_{t}$  is observed, and the budget is still not exhausted, the algorithm can request a binary prediction  $\mathcal{Q}(x_{t})$  indicating if there are better applicants coming in the future. We assume a maximal budget of  $B$  predictions, where  $B$  is a constant independent of  $N$ . We assume first that the predictions are error-free, and we give theoretical guarantees on Algorithm 3 in that case, and after that, we show how it can be adapted to handle predictions that are accurate only with a probability  $p$ . In this section, we say that an algorithm succeeded if the selected applicant is the best overall.
We consider first Algorithm 3, which rejects the first  $\lceil r_B N \rceil$  applicants, where  $r_B \in (0,1)$  is a threshold depending on  $B$ , and then queries a prediction for the first applicant  $x_t$  better than all of them. If the oracle predicts that there is a better candidate in the future ( $\mathcal{Q}(x_t) = 1$ ) then the algorithm is restarted with the inputs  $(x_{t+1}, \ldots, x_N)$  and budget  $B - 1$ .
Algorithm 3: ADATHRESH Adaptive Threshold
Input: Budget  $B$  , sequence of applicants  $(x_{1},\ldots ,x_{N})$  1 Reject the first  $\lceil r_B N\rceil$  applicants;   
2 for  $t = \lceil r_B N\rceil +1,\dots ,N$  do   
3 if  $x_{t} > \max \{x_{1},\dots ,x_{t - 1}\}$  then   
4 if  $B > 0$  then   
5 query a prediction  $\mathcal{Q}(x_t)$  .   
6 if  $\mathcal{Q}(x_t) = 0$  then Return: t;   
7 else Return ADATHRESH(  $B - 1,(x_{t + 1},\dots ,x_N))$  .   
8 else Return: t;
Theorem 3.1. Let  $(q_{B})_{B\geq -1},(r_{B})_{B\geq 0}$  the sequences defined by  $q_{-1} = 0$  and for  $B\geq 0$