The Online Pause and Resume Problem: Optimal Algorithms and An Application to Carbon-Aware Load Shifting

Adam Lechowicz, Nicolas Christianson, Jinhang Zuo, Noman Bashir, Mohammad Hajiesmaili, Adam Wierman, Prashant Shenoy

Introduction

This paper introduces and studies the online pause and resume problem (OPR), considering both minimization (OPR-min) and maximization (OPR-max) variants. In OPR-min, a player is presented with time-varying prices in a sequential manner and decides whether or not to purchase one unit of an item at the current price. The player must purchase kk units of the item over a time horizon of TT and they incur a switching cost whenever their decision changes in consecutive time steps, i.e., whenever they pause or resume purchasing. The goal of the player is to minimize their total cost, which consists of the aggregate price of purchasing kk units and the aggregate switching cost incurred over TT slots. In OPR-max, the setting is exactly the same, but the goal of the player is to maximize their total profit, and any switching cost they incur is subtracted. In both cases, the price values are revealed to the player one by one in an online manner, and the player has to make a decision without knowing the future values.

Our primary motivation for introducing OPR is the emerging importance of carbon-aware computing and, more specifically, carbon-aware temporal workload shifting, which has seen significant attention in recent years [RKS+22, ALK+23, BGH+21, WBS+21]. In carbon-aware temporal workload shifting, an interruptible and deferrable workload may be paused during periods of high carbon intensity and resumed during periods of low carbon intensity. The workload needs to be running for kk units of time to complete and must be finished before its deadline TT. However, pausing and resuming the workload typically comes with overheads such as storing the state in memory and checkpointing; hence frequent pausing and resuming is undesirable. The objective of temporal workload shifting is to minimize the total carbon footprint of running the workload, which includes both the original compute demand and the overhead due to pausing and resuming (a.k.a., the switching cost). The carbon intensity of the electric grid is time-varying due to the intermittency of renewable energy, and thus finding the best pause and resume strategy is challenging due to the unknown future fluctuations of carbon intensity. Note that OPR can also capture other potentially interesting applications where pricing changes over time and switching frequently is undesirable. One example is renting spot virtual machines from a cloud service provider in the setting where pricing is set according to supply-demand dynamics [ZLW17, ABI+20, SRI16].

On the theory front, the OPR problem has strong connections to various existing problems in the literature on online optimization. We extensively review the prior literature in Section 7 and focus on the most relevant theoretical problems below. The OPR problem is strongly connected to the kk-search problem [LPS08, LSLH22], which belongs to the broader class of online conversion problems [SLH+21], a.k.a, time series search and one-way trading [EYFKT01]. In the minimization variant of the kk-search problem, an online decision-maker aims to buy kk units of an item for the least cost over a sequence of time-varying cost values. At each step, a cost value is observed, and the decision is whether or not to buy one unit at the current observed cost without knowing the future values. In contrast to kk-search, the OPR problem introduces the additional component of managing the switching cost, which poses a significant additional challenge in algorithm design.

The existence of the switching cost in OPR connects it to the well-studied problem of smoothed online convex optimization (SOCO) [LLWA12], also known as convex function chasing (CFC) [FL93], and its generalizations including metrical task systems (MTS) [BLS92]. In SOCO, a learner is faced with a sequence of cost functions ftf_{t} that are revealed online, and must choose an action xtx_{t} after observing ftf_{t}. Based on that decision, the learner incurs a hitting cost, ft(xt)f_{t}(x_{t}) as well as a switching cost, ∥xt−xt−1∥\|x_{t}-x_{t-1}\|, which captures the cost associated with changing the decision between rounds. In contrast to SOCO, OPR includes the long-term constraint of satisfying the demand of kk units over the horizon TT, which poses a significant challenge not present in SOCO-like problems.

The coexistence of these differentiating factors, namely the switching cost and the long-term deadline constraint, make OPR uniquely challenging, and means that prior algorithms and analyses for related problems such as kk-search and SOCO cannot be directly adapted.

Contributions. We introduce online algorithms for the minimization and maximization variants of OPR and show that our algorithms achieve the best possible competitive ratios. We also evaluate the empirical performance of the proposed algorithms on a case study of carbon-aware load shifting. The details of our contributions are outlined below.

To tackle OPR, we focus our efforts on online threshold-based algorithms (OTA), the prominent design paradigm for classic problems such as kk-search [LPS08, LSLH22], one-way trading [EYFKT01, SLH+21], and online knapsack problems [ZCL08, SYH+22, YZH+21]. In the kk-min search problem, for example, a threshold-based algorithm specifies kk threshold values and chooses to trade the ii-th item only if the current price is less than or equal to the value suggested by the ii-th threshold value.

Direct application of prior OTA algorithms to OPR results in undesirable behavior (such as frequently changing decisions) since their threshold function design is oblivious to the switching cost present in OPR. To address this challenge, we seek an algorithm that can simultaneously achieve the following behaviors: (1) when the player is in “trading mode,” they should not impulsively switch away from trading in response to a price that is only slightly worse, since this will result in a switching penalty; and (2) the player should not switch to “trading mode” unless prices are sufficiently good to warrant the switching cost. These two ideas motivate an algorithm design that uses two distinct threshold functions, each of which captures one of the above two cases. We present our algorithms DTPR-min and DTPR-max for OPR-min and OPR-max, respectively, in Section 3, which build upon this high-level idea of a double-threshold.

Main results

While OTA algorithms are intuitive and simple to describe, it is highly challenging to design threshold functions that lead the corresponding algorithms to be competitive against the offline optimum. The addition of switching cost in OPR further exacerbates the technical challenge of designing optimal threshold functions. The key result which enables our double-threshold approach is a technical observation (see Observation 3), which shows that the difference between the functions guiding the algorithm’s decisions should be a factor of β\beta, where β\beta represents the fixed switching cost incurred by changing the decision in OPR.

Identifying this relationship between the two threshold functions significantly facilitates the competitive analysis of both DTPR-min and DTPR-max, enabling our derivation of a closed form of each threshold. Using this idea, we characterize the competitive ratios of DTPR-min and DTPR-max as a function of problem parameters, including an explicit dependence on the magnitude of the switching cost β\beta (see Theorems 4 and 5). Furthermore, we derive lower bounds for the competitive ratio of any deterministic online algorithm, showing that our proposed algorithms are optimal for this problem (formal statements in Theorems 8 and 9). The competitive ratios we derive for both DTPR-min and DTPR-max exactly recover the best prior competitive results for the kk-search problem [LPS08], which corresponds to the case of β=0\beta=0 in OPR, i.e., no switching cost. Formal statements and a more detailed discussion of our main results are presented in Section 4.

Case study.

Finally, in Section 6, we illustrate the performance of our proposed algorithm by conducting an experimental case study simulating the carbon-aware load shifting problem. We utilize real-world carbon traces from Electricity Maps [Map20], which contain carbon intensity values for grid-sourced electricity across the world. Our experiments simulate different strategies for scheduling a deferrable and interruptible workload in the face of uncertain future carbon intensity values. We show that our algorithm’s performance significantly improves upon existing baseline methods and adapted forms of algorithms for related problems such as kk-min search.

Problem Formulation and Preliminaries

We begin by formally introducing the OPR problem and providing background on the online threshold-based algorithm design paradigm, which is used in the design of our proposed algorithms. Table 1 summarizes the core notations for OPR. Recall that this formulation is motivated by the setting of carbon-aware temporal workload shifting, as described in the introduction.

There are two variants of the online pause and resume problem (OPR).We use OPR whenever the context is applicable to both minimization (OPR-min) and maximization (OPR-max) variants of the problem, otherwise, we refer to the specific variant. The same policy applies to DTPR, our proposed algorithm for OPR. In OPR-min (OPR-max) a player must buy (sell) k≥1k\geq 1 units of some asset (one unit at each time step) with the goal of minimizing (maximizing) their total cost (profit) within a time horizon of length TT. At each time step 1≤t≤T1\leq t\leq T, the player is presented with a price ctc_{t}, and must immediately decide whether to accept this price (xt=1x_{t}=1) or reject it (xt=0x_{t}=0). The player is required to complete this transaction for all kk units by some point in time TT. Both kk and TT are known in advance. Thus, the requirement of kk transactions is a hard constraint, i.e., ∑t=1Txt=k\sum_{t=1}^{T}x_{t}=k, and if at time T−iT-i the player still has ii units remaining to buy/sell, they must accept the prices in the subsequent ii slots to accomplish kk transactions.

Additionally, in both variants of OPR, the player incurs a fixed switching cost β>0\beta>0 whenever they decide to change decisions between two adjacent time steps (i.e., when ∥xt−1−xt∥=1\lVert x_{t-1}-x_{t}\rVert=1). We assume that x0=0x_{0}=0 and xT+1=0x_{T+1}=0, implying that any player must incur a minimum switching cost of 2β2\beta, once for switching “on” and once for switching “off”. While the player incurs at least a switching cost of 2β2\beta, note that the total switching cost incurred by the player is bounded by the size of the asset kk since the switching cost cannot be larger than k2βk2\beta.

In summary, the offline version of OPR-min can be summarized as follows:

Of course, our focus is the online version of OPR, where the player must make irrevocable decisions at each time step without the knowledge of future inputs. More specifically, in both variants of OPR the sequence of prices {ct}t∈[1,T]\{c_{t}\}_{t\in[1,T]} is revealed sequentially – future prices are unknown to an online algorithm, and each decision xtx_{t} is irrevocable.

Our goal is to design an online algorithm that maintains a small competitive ratio [BLS92], i.e., performs nearly as well as the offline optimal solution. For an online algorithm ALG and an offline optimal solution OPT, the competitive ratio for a minimization problem is defined as: CR(ALG)=max⁡σ∈ΩALG(σ)/OPT(σ),\textnormal{CR}(\texttt{ALG})=\max_{\sigma\in\Omega}\texttt{ALG}(\sigma)/\texttt{OPT}(\sigma), where σ\sigma denotes a valid input sequence for the problem and Ω\Omega is the set of all feasible input instances. Further, OPT(σ)\texttt{OPT}(\sigma) is the optimal cost given this input, and ALG(σ)\texttt{ALG}(\sigma) is the cost of the solution obtained by running the online algorithm over this input. Conversely, for a problem with a maximization objective, the competitive ratio is defined as max⁡σ∈ΩOPT(σ)/ALG(σ)\max_{\sigma\in\Omega}\texttt{OPT}(\sigma)/\texttt{ALG}(\sigma). With these definitions, the competitive ratio for both minimization and maximization problems is always greater than or equal to one, and the lower the better.

Assumptions and additional notations.

We make no assumptions on the underlying distribution of the prices other than the assumption that the set of prices arriving online {ct}t∈[1,T]\{c_{t}\}_{t\in[1,T]} has bounded support, i.e., ct∈[L,U]∀t∈[1, T]c_{t}\in[L,U]\forall t\in[1,~{}T], where LL and UU are known to the player. We also define θ=U/L\theta=U/L as the price fluctuation. These are standard assumptions in the literature for many online problems, including one-way trading, online search, and online knapsack; and without them the competitive ratio of any algorithm is unbounded. We use cmin⁡(σ)=min⁡t∈[1,T]ctc_{\min}(\sigma)=\min_{t\in[1,T]}c_{t} and cmax⁡(σ)=max⁡t∈[1,T]ctc_{\max}(\sigma)=\max_{t\in[1,T]}c_{t} to denote the minimum and maximum encountered prices for any valid OPR sequence σ\sigma.

2 Background: Online Threshold-Based Algorithms (OTA)

Online threshold-based algorithms (OTA) are a family of algorithms for online optimization in which a carefully designed threshold function is used to specify the decisions made at each time step. At a high level, the threshold function defines the “minimum acceptable quality” that an arriving input/price must satisfy in order to be accepted by the algorithm. The threshold is chosen specifically so that an agent greedily accepting prices meeting the threshold at each step will be ensured a competitive guarantee. This algorithmic framework has seen success in the online search and one-way trading problems [LSLH22, SLH+21, LPS08, EYFKT01] as well as the related online knapsack problem [ZCL08, SYH+22, YZH+21]. In these works, the derived threshold functions are optimal in the sense that the competitive ratios of the resulting threshold-based algorithms match information-theoretic lower bounds of the corresponding online problems. As discussed in the introduction, the framework does not apply directly to the OPR setting, but we make use of ideas and techniques from this literature. We briefly detail the most relevant highlights from the prior results before discussing how these related problems generalize to OPR in the next section.

In the online 1-min/1-max search problem, a player attempts to find the single lowest (respectively, highest) price in a sequence, which is revealed sequentially. The player’s objective is to either minimize their cost or maximize their profit. When each price arrives, the player must decide immediately whether to accept the price, and the player is forced to accept exactly one price before the end of the sequence. For this problem, El-Yaniv et al. [EYFKT01] presents a deterministic threshold-based algorithm. The algorithm assumes a finite price interval, i.e., the price is bounded by the interval [L,U][L,U], where LL and UU are known. Then, it sets a constant threshold Φ=LU\Phi=\sqrt{LU}, and the algorithm simply selects the first price that is less than or equal to Φ\Phi (for the maximization version, it accepts the first price greater than or equal to Φ\Phi). This algorithm achieves a competitive ratio of U/L=θ\sqrt{U/L}=\sqrt{\theta}, which matches the lower bound; hence, it is optimal [EYFKT01].

k𝑘k-min/k𝑘k-max search.

The online kk-min/kk-max search problem extends the 1-min/1-max search problem – a player attempts to find the kk lowest (conversely, highest) prices in a sequence of prices revealed sequentially. The player’s objective is identical to the 1-min/1-max problem, and the player must accept at least kk prices by the end of the sequence. Several works have developed a known optimal deterministic threshold-based algorithm for this problem, including [LPS08, EYFKT01]. Leveraging the same assumption of a finite price interval [L,U][L,U], the threshold function is a sequence of kk thresholds {Φi}i∈[1,k]\{\Phi_{i}\}_{i\in[1,k]}, which is also called the reservation price policy. At each step, the algorithm accepts the first price, which is less than or equal to Φi\Phi_{i}, where i−1i-1 is the number of prices that have been accepted thus far (for the maximization version, it accepts the first price which is ≥Φi\geq\Phi_{i}). In the kk-min setting, this algorithm is α\alpha-competitive, where α\alpha is the unique solution of

For the kk-max variant, this algorithm is ω\omega-competitive, where ω\omega is the unique solution of

The sequence of thresholds {Φi}i∈[1,k]\{\Phi_{i}\}_{i\in[1,k]} for both variants of the problem are constructed by analyzing possible input cases, “hedging” against the risk that future (unknown) prices will jump to the worst possible value, i.e., UU for kk-min search, LL for kk-max search. These potential cases can be enumerated for different values of ii, where 0≤i≤k0\leq i\leq k denotes the number of prices accepted so far. By simultaneously balancing the competitive ratios for each of these cases (setting each ratio equal to the others), the optimal threshold values and the optimal competitive ratios are derived. We refer to this technique as the balancing rule and a rigorous proof of this approach, with corresponding lower bounds, can be found in [LPS08]. The lower bounds highlight that the α\alpha and ω\omega which solve the expressions for the competitive ratios above are optimal for any deterministic kk-min and kk-max search algorithms, respectively. Further, α\alpha and ω\omega provide insight into a fundamental difference between the minimization and maximization settings of kk-search. As discussed in [LPS08], for large θ\theta, the best algorithm for kk-max search is roughly O(kθk)O(k\sqrt[k]{\theta})-competitive, while the best algorithm for kk-min search is at best O(θ)O(\sqrt{\theta})-competitive. Similarly, for fixed θ\theta and large kk, the optimal competitive ratio for kk-max search is roughly O(ln⁡θ)O\left(\ln\theta\right), while the optimal competitive ratio for kk-min search converges to O(θ)O(\sqrt{\theta}).

Double Threshold Pause and Resume (DTPR) Algorithm

A fundamental challenge in algorithm design for OPR is how to characterize threshold functions that incorporate the presence of switching costs in their design. Our key algorithmic insight is to incorporate the switching cost into the threshold function by defining two distinct threshold functions, where the function to be used for price admittance changes based on the current state (i.e., whether or not the previous price was accepted by the algorithm).

To provide intuition for the state-dependence of the threshold function, consider the setting of OPR-min. At a high level, if the player has not accepted the previous price, they should wait to accept anything until prices are sufficiently low to justify incurring a cost to switch decisions. On the other hand, if the player has accepted the previous price, they might be willing to accept a slightly higher price – if they do not accept this price, they will incur a cost to switch decisions. While this high-level idea is intuitive, characterizing the form of threshold functions such that the resulting algorithms are competitive is challenging.

where α\alpha is the competitive ratio of DTPR-min defined in Equation (9).

The DTPR-max algorithm

where ω\omega is the competitive ratio of DTPR-max defined in Equation (10).

Designing the Double Threshold Values

A key component of the DTPR algorithms for both variants are the thresholds in Equations (5) and (6). The key idea is to design the thresholds by incorporating the switching cost into the balancing rules as a hedge against possible worst-case scenarios. To accomplish this, we enumerate three difficult cases that DTPR may encounter. (CASE-1): Consider an input sequence where DTPR does not accept any prices before it is forced to accept the last kk prices. Here, the enforced prices in the worst-case sequence will be UU for OPR-min and LL for OPR-max. This sequence occurs only if no price in the sequence meets the first threshold for acceptance. On the other hand, in the case that DTPR does accept prices before the end of the sequence, we can further divide the possible sequences into two extreme cases for the switching cost it incurs. (CASE-2): In one extreme, the algorithm incurs only the minimum switching cost of 2β2\beta, meaning that kk contiguous prices are accepted by DTPR. (CASE-3): In the other extreme, DTPR incurs the maximum switching cost of k2βk2\beta, meaning that kk non-contiguous prices are accepted. Intuitively, in order for DTPR to be competitive in either of these extreme cases, the prices accepted in the latter case should be sufficiently “good” to absorb the extra switching cost of (k−1)2β(k-1)2\beta.

Given the insight from these cases, we use can use the balancing rule (see Section 2.2) to derive the two threshold families. Let σ\sigma be any arbitrary sequence for OPR. Given these extreme input sequences, we now concretely show how to write the balancing rule equations. We consider the cases of DTPR-min and DTPR-max separately below.

Balancing equations for DTPR-max

The same idea extends to balance between possible inputs for OPR-max. Consider the following examples for a few values of cmax⁡(σ)c_{\max}(\sigma). If cmax⁡(σ)<uic_{\max}(\sigma)<u_{i}, we know that OPT cannot do better than kui−2βku_{i}-2\beta. Suppose that ω\omega is the target competitive ratio, and we balance between these and other potential cases:

Solving for the threshold values

Main Results

We now present competitive results of DTPR for both variants of OPR and discuss the significance of the results in relation to other algorithms for related problems. Our results for the competitive ratios of DTPR-min and DTPR-max are summarized in Theorems 4 and 5. We also state the lower bound results for any deterministic online algorithms for OPR-min and OPR-max in Theorems 8 and 9. Proofs of the results for DTPR-min and DTPR-max are deferred to Section 5 and Appendix B, respectively. Formal proofs of lower bound theorems are given in Appendix D, and a sketch is shown in Section 5.2. Note that in the competitive results, W(x)W(x) denotes the Lambert WW function, i.e., the inverse of f(x)=xexf(x)=xe^{x}. It is well-known that W(x)W(x) behaves like ln⁡(x)\ln(x) [HH08, Ste09]. We start by presenting our competitive bounds on DTPR-min and DTPR-max.

DTPR-min is an α\alpha-competitive deterministic algorithm for OPR-min, where α\alpha is the unique positive solution of

DTPR-max is an ω\omega-competitive deterministic algorithm for OPR-max, where ω\omega is the unique positive solution of

These theorems present upper bounds on the competitive ratios, showing their dependence on the problem parameters. To investigate the behavior of these competitive ratios, in Figures 4 and 4, we show the competitive ratios of both algorithms as problem parameters are varied. More specifically, in Figure 4, we visualize α\alpha as a function of β\beta and LL, where kk and UU are fixed. The color (shown as an annotated color bar on the right-hand side of the plot) represents the order of α\alpha. If β>0\beta>0 and L→0L\rightarrow 0, Figure 4 shows that α\alpha is roughly O(k)O\left(k\right), which we discuss further in Corollary 6(a). In Figure 4, we visualize ω\omega as a function of β\beta and LL, where kk and UU are fixed. The color represents the order of ω\omega. In the dark blue region of the plot, Figure 4 shows that ω→∞\omega\rightarrow\infty when b→kb\rightarrow k, which provides insight into the extreme case for switching cost when β≳kL2\beta\gtrsim\frac{kL}{2}.

To obtain additional insight into the form of the competitive ratios in Theorems 4 and 5, we present the following corollaries for two asymptotic regimes of interest: REGIME-1 captures the order of the competitive ratio when kk is fixed and α\alpha or ω\omega are sufficiently large, and REGIME-2 captures the order of the competitive ratio when k→∞k\rightarrow\infty.

(a) For REGIME-1, with fixed k≥1k\geq 1 and β∈(0,U−L2)\beta\in(0,\frac{U-L}{2}), the competitive ratio of DTPR-min is

(b) Furthermore, for REGIME-2, with k→∞k\rightarrow\infty and c=2βU,c∈(0,U−LU)c=\frac{2\beta}{U},c\in(0,\frac{U-L}{U}), the competitive ratio of DTPR-min is

(a) For REGIME-1, with fixed k≥1k\geq 1 and b=2βL,b∈(0,k)b=\frac{2\beta}{L},b\in(0,k), the competitive ratio of DTPR-max is

and (b) for REGIME-2, with k→∞k\rightarrow\infty and b=2βL,b∈(0,k)b=\frac{2\beta}{L},b\in(0,k), the competitive ratio of DTPR-max is

Corollary 6(a) contextualizes the behavior of α\alpha (the competitive ratio of DTPR-min) in the most relevant OPR-min setting (when β∈(0,U−L2)\beta\in(0,\frac{U-L}{2})). Let us also briefly discuss the other cases for the switching cost β\beta, and why this interval makes sense. When β>U−L2\beta>\frac{U-L}{2}, the switching cost is large enough such that OPT only incurs a switching cost of 2β2\beta. In this regime, α\alpha does not fully capture the competitive ratio of DTPR-min, since every value in the threshold family {ui}i∈[1,k]\{u_{i}\}_{i\in[1,k]} is at least UU; in other words, whenever the algorithm begins accepting prices, it will accept kk prices in a single continuous segment, incurring minimal switching cost of 2β2\beta. As β→∞\beta\rightarrow\infty, the competitive ratio of DTPR-min approaches 11.

Conversely, Corollary 7(a) contextualizes the behavior of ω\omega in the most relevant OPR-max setting (when β∈(0,kL2)\beta\in(0,\frac{kL}{2})), but we also discuss the other cases for the switching cost β\beta, and why this interval makes sense. When β≥kL2\beta\geq\frac{kL}{2}, the switching cost is too large, and the competitive ratio may become unbounded. Note that this is shown explicitly in Figure 4. Consider an adversarial sequence which forces any OPR-max algorithm to accept kk prices with value LL at the end of the sequence. On such a sequence, even a player which incurs the minimum switching cost of 2β2\beta achieves zero or negative profit of kL−2β≤0kL-2\beta\leq 0, and this is not well-defined.

Next, to begin to investigate the tightness of Theorems 4 and 5, it is interesting to consider special cases that correspond to models studied in previous work. In particular, when β=0\beta=0, i.e., there is no switching cost, OPR degenerates to the kk-search problem [LPS08]. For fixed k≥1k\geq 1 and θ→∞\theta\rightarrow\infty, the optimal competitive ratios shown by [LPS08] are θ/2\sqrt{\theta/2} for kk-min, and kkθk+1\sqrt[k+1]{k^{k}\theta} for kk-max (see Section 2.2). Both versions of DTPR exactly recover the optimal kk-search algorithms [LPS08].To see this, note that by eliminating all β\beta terms from Equations (9) and (10), we exactly recover Equations (3) and (4), which are the definitions of the kk-search algorithms. When θ→∞\theta\rightarrow\infty as L→0L\rightarrow 0, DTPR-min and DTPR-max match each kk-search result exactly when β=0\beta=0. In Corollaries 6(b) and 7(b), DTPR-min and DTPR-max also match each kk search result exactly when k→∞k\rightarrow\infty and β=0\beta=0. (See Sec. 2.2) Figure 4 shows that if β=0\beta=0 and L→0L\rightarrow 0, then α→∞\alpha\rightarrow\infty, which matches the kk-min result of θ/2∼∞\sqrt{\theta/2}\thicksim\infty. Similarly, Figure 4 shows that if β=0\beta=0 and L→0L\rightarrow 0, then ω→∞\omega\rightarrow\infty, which matches the kk-max result of kkθk+1∼∞\sqrt[k+1]{k^{k}\theta}\thicksim\infty.

More generally, one can ask if the competitive ratios of DTPR can be improved upon by other online algorithms outside of the special case of kk-search. Our next set of results highlights that no improvement is possible, i.e., that DTPR-min and DTPR-max maintain the optimal competitive ratios possible for any deterministic online algorithm for OPR.

Let k≥1k\geq 1, θ≥1\theta\geq 1, and β∈(0,U−L2)\beta\in(0,\frac{U-L}{2}). Then α\alpha given by Equation (9) is the best competitive ratio that a deterministic online algorithm for OPR-min can achieve.

Let k≥1k\geq 1, θ≥1\theta\geq 1, and β∈(0,kL2)\beta\in(0,\frac{kL}{2}). Then ω\omega given by Equation (10) is the best competitive ratio that a deterministic online algorithm for OPR-max can achieve.

By combining Theorems 4 and 5 with Theorems 8 and 9, these results imply that the competitive ratios of DTPR-min and DTPR-max are optimal for OPR-min and OPR-max.

Finally, it is interesting to contrast the upper and lower bounds for OPR with those for kk-search, since the contrast highlights the impact of switching costs. In OPR-min with β>0\beta>0, DTPR-min improves on existing optimal results for kk-min search, particularly in the case where LL approaches (i.e., θ→∞\theta\rightarrow\infty). Since Theorem 8 implies that DTPR-min is optimal, this shows that the addition of switching cost in OPR-min enables an online algorithm to achieve a better competitive ratio compared to kk-min search, which is a surprising result. In contrast, for OPR-max with β>0\beta>0, DTPR-max’s competitive bounds are worse than existing results for kk-max search, particularly for large β\beta. Since Theorem 9 implies that DTPR-max is optimal, this suggests that OPR-max is fundamentally a more difficult problem compared to kk-max search.

Proofs

We now prove the results described in the previous section. In Section 5.1, we prove the DTPR-min results presented in Theorem 4 and Corollary 6. In Section 5.2, we provide a proof sketch for the lower bound results in Theorems 8 and 9, and defer the formal proofs to Appendix D. The competitive results for DTPR-max in Theorem 5 and Corollary 7 are deferred to Appendix B.

We begin by proving Theorem 4 and Corollary 6. The key novelty in the proof of the main competitive results (Theorems 4 and 5) lies in our effort to derive two threshold functions and balance the competitive ratio in several worst-case instances with respect to these thresholds, as outlined in Section 3.

Observe that as ϵ→0\epsilon\rightarrow 0, σj\sigma_{j} and ρj\rho_{j} are sequences yielding the worst-case ratios in Sj\mathcal{S}_{j}, as DTPR-min is forced to accept (k−j)(k-j) worst-case UU values at the end of the sequence, and each accepted value is exactly equal to the corresponding threshold.

Before proceeding to the next step, we use an intermediate result stated in the following lemma with a proof given in Appendix C.

For ϵ→0\epsilon\rightarrow 0, the competitive ratio DTPR-min/OPT\texttt{DTPR-min}/\texttt{OPT} is exactly α\alpha:

and thus for any sequence s∈Ss\in\mathcal{S},

Since OPT(s)≥kcmin⁡(s)+2β\texttt{OPT}(s)\geq kc_{\min}(s)+2\beta for any sequence ss, this implies that DTPR-min is α\alpha-competitive. ∎

To show part (a) for REGIME-1, with fixed k≥1k\geq 1, observe that we can expand the right-hand side of Equation (9) using the binomial theorem to obtain the following:

Next, observe that α⋆\alpha^{\star} solving the following expression satisfies α⋆≥α    ∀k:k≥1\alpha^{\star}\geq\alpha\;\;\forall k:k\geq 1, (i.e. α⋆\alpha^{\star} is an upper bound of α\alpha):

By solving the above for α⋆\alpha^{\star}, we obtain

Last, note that as L→0L\rightarrow 0, we obtain the following result: α∼k2+kU2β+1+k24≈O(k)\alpha\thicksim\frac{k}{2}+\sqrt{\frac{kU}{2\beta}+1+\frac{k^{2}}{4}}\approx O\left(k\right).

To show part (b) for REGIME-2, we first observe that the right-hand side of Equation 9 can be approximated as (1+1kα)k ≈ e1/α\left(1+\frac{1}{k\alpha}\right)^{k}~{}\approx~{}e^{1/\alpha} when k→∞k\rightarrow\infty. Then by taking limits on both sides, we obtain the following:

For simplification purposes, let β=cU/2\beta=cU/2, where cc is a small constant on the interval (0,U−LU)\left(0,\frac{U-L}{U}\right). We then obtain the following:

By definition of Lambert WW function, solving this equation for α\alpha obtains the result in Corollary 6(b). ∎

2 Lower Bound Analysis: Proof Sketch for Theorems 8 and 9

Here we present a proof sketch for the lower bound construction that is used to prove both Theorems 8 and 9. We show how to formalize it in the case of Theorem 8 in Appendix D.1, and in the case of Theorem 9 in Appendix D.2.

Suppose that ALG is a deterministic online algorithm for OPR. The lower bound proofs for both OPR-min and OPR-max leverage the same instance, where ALG plays against an adaptive adversary.

To describe the instance, we first need some preliminaries. Define a sequence of prices T1,…,Tk\mathcal{T}_{1},\dots,\mathcal{T}_{k}, which are the prices the adversary will present to ALG. The “worst-case value” that ALG can encounter is defined based on the problem variant. Since we assume that prices are bounded on the interval [L,U][L,U], these values are UU for OPR-min, and LL for OPR-max.

The adversary begins by presenting T1\mathcal{T}_{1} to ALG, at most kk times or until ALG accepts it. If ALG never accepts T1\mathcal{T}_{1}, the adversary presents the worst-case value at least kk times for the remainder of the sequence. In the formal proof, we show that this case causes ALG to achieve a competitive ratio of at least α\alpha for OPR-min, or at least ω\omega for OPR-max.

If ALG does accept T1\mathcal{T}_{1}, the adversary continues the sequence by presenting the worst-case value to ALG, at most kk times or until ALG switches to reject it. This essentially forces ALG to switch immediately after accepting T1\mathcal{T}_{1}. In the formal proof, we show that any algorithm which does not switch away immediately achieves a competitive ratio worse than α\alpha and ω\omega for OPR-min and OPR-max.

After ALG has switched away, the adversary continues the sequence by presenting T2\mathcal{T}_{2} to ALG at most kk times or until ALG accepts it. Again, if ALG never accepts T2\mathcal{T}_{2}, the adversary presents the worst-case value at least kk times for the remainder, and ALG cannot do better than α\alpha or ω\omega.

The adversary continues in this fashion, presenting each Ti\mathcal{T}_{i} at most kk times (or until ALG accepts it and the adversary forces ALG to switch away immediately afterward). Whenever ALG does not accept some Ti\mathcal{T}_{i} after it is presented kk times, the adversary sends the price to the worst-case value for the remainder of the sequence. If ALG accepts kk prices before the end of the sequence, the adversary concludes by presenting the best-case value (LL for OPR-min, UU for OPR-max) at least kk times.

In the formal proofs presented in Appendix D, we show that any deterministic strategy that ALG uses to accept prices on this sequence achieves a competitive ratio of at least α\alpha for OPR-min, and at least ω\omega for OPR-max.

Case Study: Carbon-Aware Temporal Workload Shifting

We now present experimental results for the DTPR algorithms in the context of the carbon-aware temporal workload shifting problem. We evaluate DTPR-min (and DTPR-max in Appendix A) as compared to existing algorithms from the literature that have been adapted for OPR.

We consider a carbon-aware load shifting system that operates on a hypothetical data center. An algorithm is given a deferrable and interruptible job that takes kk time slots to complete, along with a deadline T≥kT\geq k, such that the job must be completed at most TT slots after its arrival. The objective is to selectively run units of the job such that the total carbon emissions are minimized while still completing the job before its deadline.

For the minimization variant (OPR-min) of the experiments, we consider carbon emissions intensities, as the price values. At each time step tt, the electricity supply has a carbon intensity ctc_{t}, i.e., if the job is being processed during the time step tt (xt=1x_{t}=1), the data center’s carbon emissions during that time step are proportional to ctc_{t}. If the job is not being processed during the time step tt (xt=0x_{t}=0), we assume for simplicity that carbon emissions in the idle state are negligible and essentially . To model the combined computational overhead of interrupting, checkpointing, and restarting the job, the algorithm incurs a fixed switching cost of β\beta whenever xt−1≠xtx_{t-1}\not=x_{t}, whose values are selected relative to the price values.

We use real-world carbon traces from Electricity Maps [Map20], which provide time-series information about the average carbon emissions intensity of the electric grid. We use traces from three different regions: the Pacific Northwest of the U.S., New Zealand, and Ontario, Canada. The data is provided at an hourly granularity and includes the current average carbon emissions intensity in grams of CO2 equivalent per kilowatt-hour (gCO2eq/kWh), and the percentage of electricity being supplied from carbon-free sources. In Figure 9 (in Appendix A), we plot three representative actual traces for carbon intensity over time for a 96-hour period in each region.

Parameter settings

We test for time horizons (TT) of 48 hours, 72 hours, and 96 hours. The chosen time horizon represents the time at which the job with length kk must be completed. As is given in the carbon trace data, we consider time slots of one hour.

The online algorithms we use in experiments take LL and UU as parameters for their threshold functions. To set these parameters, we examine the entire carbon trace for the current location. For the Pacific NW trace and the Ontario trace, these values represent lower and upper bounds of the carbon intensity values for a full year. For the New Zealand trace, these values are a lower and upper bound for the values during a month of data, which is reflected by a smaller fluctuation ratio. We set LL and UU to be the minimum and maximum observed carbon intensity over the entire trace.

To generate each input sequence, a contiguous segment of size TT is randomly sampled from the given carbon trace. In a few experiments, we simulate greater volatility over time by “scaling up” each price’s deviation from the mean. First, we compute the average value over the entire sequence. Next, we compute the difference between each price and this average. Each of these differences is scaled by a noise factor of m≥1m\geq 1. Finally, new carbon values are computed by summing each scaled difference with the average. If m=1m=1, we recover the same sequence, and if m>1m>1, any deviation from the mean is proportionately amplified. Any values which become negative after applying this transformation are truncated to . This technique allows us to evaluate algorithms under different levels of volatility. Performance in the presence of greater carbon volatility is important, as on-site renewable generation is seeing greater adoption as a supplementary power source for data centers [RKS+22, ALK+23].

Benchmark algorithms

To evaluate the performance of DTPR, we use a dynamic programming approach to calculate the offline optimal solution for each given sequence and objective, which allows us to report the empirical competitive ratio for each tested algorithm. We compare DTPR against two categories of benchmark algorithms, which are summarized in Table 3.

The first category of benchmark algorithms is carbon-agnostic algorithms, which run the jobs during the first kk time slots in order, i.e., accepting prices c1,…,ckc_{1},\dots,c_{k}. This approach incurs the minimal switching cost of 2β2\beta, because it does not interrupt the job while it is being processed. The carbon-agnostic approach simulates the behavior of a scheduler that runs the job to completion as soon as it is submitted, without any focus on reducing carbon emissions. Note that the performance of this approach significantly varies based on the randomly selected sequence, since it will perform well if low-carbon electricity is available in the first few slots, and will perform poorly if the first few slots are high-carbon.

We also compare DTPR against switching-cost-agnostic algorithms, which only consider carbon cost. We have two algorithms of this type, each drawing from existing online search methods in the literature. Although they do not consider the switching cost in their design, they still incur a switching cost whenever their decision in adjacent time slots differs.

The first such algorithm is a constant threshold algorithm, which uses the UL\sqrt{UL} threshold value first presented for online search in [EYFKT01]. In our minimization experiments, this algorithm runs the workload during the first kk time slots where the carbon intensity is at most UL\sqrt{UL}.

The other switching-cost-agnostic algorithm tested is the kk-search algorithm shown by [LPS08] and described in Section 2.2. The kk-min search algorithm chooses to run the iith hour of the job during the first time slot where the carbon intensity is at most Φi\Phi_{i}.

2 Experimental Results

We now present our experimental results. Our focus is on the empirical competitive ratio (a lower competitive ratio is better). We report the performance of all algorithms for each experimental setting, in each tested region. Throughout the minimization experiments, we observe that DTPR-min outperforms the benchmark algorithms. The 95th percentile worst-case empirical competitive ratio achieved by DTPR-min is a 48.248.2% improvement on the carbon-agnostic method, a 15.615.6% improvement on the kk-min search algorithm, and a 14.414.4% improvement on the constant threshold algorithm.

In Figure 5, we show results for three different values of time horizon TT in each carbon trace, with fixed β\beta, fixed k=⌈T/6⌉k=\lceil T/6\rceil, and no added volatility. Although our experiments test three distinct values for TT, we later observe that the ratio between kk and TT is the primary factor which changes the observed performance of the algorithms we test; in this figure, DTPR and the benchmark algorithms compare very similarly on the same carbon trace for different TT values. As such, we set T=48T=48 in the rest of the experiments in this section for brevity. This represents a slack value of 4848 hours.

In the first experiment, we test all algorithms for different job lengths kk in the range from 44 hours to T/2T/2 (2424 hours). The switching cost β\beta is non-zero and fixed, and no volatility is added to the carbon trace. By testing different values for kk, this experiment tests different ratios between the workload length and the slack provided to the algorithm. In Figures 6(a), 7(a), and 8(a), we show that the observed competitive ratio of DTPR-min outperforms the benchmark algorithms, and it compares particularly favorably for short job lengths. Averaging over all regions and job lengths, the competitive ratio achieved by DTPR-min is a 11.411.4% improvement on the carbon-agnostic method, a 14.014.0% improvement on the kk-min search algorithm, and a 5.55.5% improvement on the constant threshold algorithm.

In the second experiment, we test all algorithms for different switching costs β\beta in the range from to U/5U/5. The job length kk is set to 1010 hours, and no volatility is added to the carbon trace. By testing different values for β\beta, this experiment tests how an increasing switching cost impacts the performance of DTPR-min with respect to other algorithms which do not explicitly consider the switching cost. In Figures 6(b), 7(b), and 8(b), we show that the observed competitive ratio of DTPR-min outperforms the benchmark algorithms for most values of β\beta in all regions. Unsurprisingly, the carbon-agnostic technique (which incurs minimal switching cost) performs better as β\beta grows. While the constant threshold algorithm has relatively consistent performance, the kk-min search algorithm performs noticeably worse as β\beta grows. Averaging over all regions and switching cost values, the competitive ratio achieved by DTPR-min is a 18.218.2% improvement on the carbon-agnostic method, a 8.98.9% improvement on the kk-min search algorithm, and a 4.14.1% improvement on the constant threshold algorithm.

In the final experiment, we test all algorithms on sequences with different volatility. The job length kk and switching cost β\beta are both fixed. We add volatility by setting a noise factor from the range 1.01.0 to 3.03.0. By testing different values for this volatility, this experiment tests how each algorithm handles larger fluctuations in the carbon intensity of consecutive time steps. In Figures 6(c), 7(c), and 8(c), we show that the observed competitive ratio of DTPR-min outperforms the benchmark algorithms for all noise factors in all regions. Intuitively, higher volatility values cause the online algorithms to perform worse in general. Averaging over all regions and noise factors, the competitive ratio achieved by DTPR-min is a 53.653.6% improvement on the carbon-agnostic method, a 13.513.5% improvement on the kk-min search algorithm, and a 14.314.3% improvement on the constant threshold algorithm.

By averaging over all experiments for a given region, we obtain the cumulative distribution function plot for each algorithm’s competitive ratio in Figures 6(d), 7(d), and 8(d). Compared to the carbon-agnostic, constant threshold, and kk-min search algorithms, DTPR-min achieves a lower average empirical competitive ratio distribution for all tested regions. Across all regions at the 95th percentile, DTPR-min achieves a worst-case empirical competitive ratio of 1.401.40. This represents a 48.248.2% improvement over the carbon-agnostic algorithm, and improvements of 15.615.6% and 14.414.4% over the kk-min search and constant threshold switching-cost-agnostic algorithms, respectively.

Related Work

This paper contributes to three lines of work: (i) work on online search and related problems, e.g., kk-search, one-way trading, and online knapsack; (ii) work on online optimization problems with switching costs, e.g., metrical task systems and convex function chasing; and (iii) work on carbon-aware load shifting. We describe the relationship to each below.

The OPR problem is closely related to the online kk-search problem [LSLH22, LPS08], as discussed in the introduction and Section 2.2. It also has several similar counterparts, including online conversion problems such as one-way trading [EYFKT01, MAS14, SLH+21, DHT07] and online knapsack problems [ZCL08, SYH+22, YZH+21], with practical applications to stock trading [LPS08], cloud pricing [ZLW17], electric vehicle charging [SZL+20], etc. The kk-search problem can be viewed as an integral version of the online conversion problem, while the general online conversion problem allows continuous one-way trading. The basic online knapsack problem studies how to pack arriving items of different sizes and values into a knapsack with limited capacity, while its extensions to item departures [ZLW17, SYH+22] and multidimensional capacity [YZH+21] have also been studied recently. Another line of research leverages machine learning predictions of unknown future inputs to design learning-augmented online algorithms for online kk-search [LSLH22] and online conversion [SYH+22]. However, to the best of our knowledge, none of these works consider the switching cost of changing decisions. Thus, this work is the first to incorporate switching costs to the kk-search framework.

Metrical Task Systems.

The metrical task systems (MTS) problem was introduced by Borodin et al. in [BLS92]. Several decades of progress on upper and lower bounds on the competitive ratio of MTS recently culminated with a tight bound of Θ(log⁡2n)\Theta(\log^{2}n) for the competitive ratio of MTS on an arbitrary nn-point metric space, with Θ(log⁡n)\Theta(\log n) being possible on certain metric spaces such as trees [BCLL21, BCR22]. Several modified forms of MTS have also seen significant attention in the literature, such as smoothed online convex optimization (SOCO) and convex function chasing (CFC), in which the decision space is an nn-dimensional normed vector space and cost functions are restricted to be convex [FL93, LLWA12]. The best known upper and lower bounds on the competitive ratio of CFC are O(n)O(n) and Ω(n)\Omega(\sqrt{n}), respectively, in nn-dimensional Euclidean spaces [BKL+19, Sel20]. However, algorithms with competitive ratios independent of dimension can be obtained for certain special classes of functions, such as α\alpha-polyhedral functions [CGW18]. A number of recent works have also investigated the design of learning-augmented algorithms for various cases of CFC/SOCO and MTS which exploit the performance of machine-learned predictions of the optimal decisions [ACE+20, CHW22, CSW23, LYR22, RCMW22]. The key characteristic distinguishing OPR from MTS and its variants is the presence of a terminal deadline constraint. None of the algorithms for MTS-like problems are designed to handle such long-term constraints while maintaining any sort of competitive guarantee.

Carbon-Aware Temporal Workload Shifting.

The goal of shifting workloads in time to allow more sustainable operations of data centers has been of interest for more than a decade, e.g., [GSS19, LLW+11, LCB+12, LWAT12]. Traditionally, such papers have used models that build on one of convex function chasing, kk-search, or online knapsack to design algorithms; however such models do not capture both the switching costs and long-term deadlines that are crucial to practical deployment. In recent years, the load shifting literature has focused specifically on reducing the carbon footprint of operations, e.g., [RKS+22, ALK+23, BGH+21, WBS+21]. Perhaps most related to this paper is [WBS+21], which explores the problem of carbon-aware temporal workload shifting and proposes a threshold-based algorithm that suspends the job when the carbon intensity is higher than a threshold value and resumes it when it drops below the threshold. However, it does not consider switching nor does it provide any deadline guarantees. Other recent work on carbon-aware temporal shifting seeks to address the resultant increase in job completion times. In [SBM+23], authors leverage the pause and resume approach to reduce the carbon footprint of ML training and high-performance computing applications such as BLAST [fBI22]. However, instead of resuming at normal speed (1×1\times) during the low carbon intensity periods, their applications resume operation at a faster speed (m×m\times), where the scale factor mm depends on the application characteristics. It uses a threshold-based approach to determine the low carbon intensity periods but does not consider switching costs or provide any deadline guarantees. An interesting future direction is to extend the DTPR algorithms to consider the ability to scale up speed after resuming jobs.

Conclusion

Motivated by carbon-aware load shifting, we introduce and study the online pause and resume problem (OPR), which bridges gaps between several related problems in online optimization. To our knowledge, it is the first online optimization problem that includes both long-term constraints and switching costs. Our main results provide optimal online algorithms for the minimization and maximization variants of this problem, as well as lower bounds for the competitive ratio of any deterministic online algorithm. Notably, our proposed algorithms match existing optimal results for the related kk-search problem when the switching cost is , and improve on the kk-min search competitive bounds for non-zero switching cost. The key to our results is a novel double threshold algorithm that we expect to be applicable in other online problems with switching costs.

There are a number of interesting directions in which to continue the study of OPR. We have highlighted the application of OPR to carbon-aware load shifting, but OPR also applies to many other problems where pricing changes over time and frequent switching is undesirable. Pursuing these applications is important. Theoretically, there are several interesting open questions. First, considering the target application of carbon-aware load shifting, some workloads are highly parallelizable [SBM+23], which adds another dimension of scaling to the problem (i.e., instead of choosing to run 1 unit of the job in each time slot, the online player must decide how many units to allocate at each time slot). This makes the theoretical problem more challenging, and is an important consideration for future work. Additionally, very recent work has incorporated machine-learned advice to achieve better performance on related online problems, including kk-search [LSLH22, SLH+21], CFC/SOCO [CHW22, LYR22], and MTS [ACE+20, CSW23, RCMW22]. Designing learning-augmented algorithms for OPR is a very promising line of future work, particularly considering applications such as carbon-aware load shifting, where predictions can significantly improve the algorithm’s understanding of the future in the best case.

References

Appendix A Case Study Results for DTPR-max Algorithm

This section presents and discusses the deferred experimental results for the DTPR-max algorithm (pseudocode summarized in Algorithm 2) in the carbon-aware temporal workload shifting case study. We evaluate DTPR-max against the same benchmark algorithms described in Section 6.1.

For the maximization metric, we consider the percentage of carbon-free electricity powering the grid. At each time step tt, the electricity supply has a carbon-free percentage ctc_{t}, i.e., if the job is being processed during time slot tt (xt=1x_{t}=1), the electricity powering the data center’s is ct%c_{t}\% carbon-free, and the objective is to maximize this percentage over all kk slots of the active running of the workload.

In these maximization experiments, the switching-cost-agnostic kk-max-search algorithm chooses to run the iith hour of the job during the first time slot where the carbon-free supply is at least Φi\Phi_{i}. Similarly, the constant threshold algorithm chooses to run the job whenever the carbon-free supply is at least UL\sqrt{UL}. We set LL and UU to be the minimum and maximum carbon-free supply percentages over the entire trace being studied.

As in Section 6.2, our focus is on the competitive ratio (lower competitive ratio is better). We report the performance of all algorithms for each experiment setting, in each tested region.

In the first experiment, we test all algorithms for different job lengths kk in the range from 44 hours to T/2(24)T/2(24). The switching cost β\beta is non-zero and fixed, and no volatility is added to the carbon trace. By testing different values for kk, this experiment tests different ratios between the workload length and the slack provided to the algorithm. In Figures 10(a), 11(a), and 12(a), we show that the observed average competitive ratio of DTPR-max narrowly outperforms the benchmark algorithms for all values of kk in all regions, and it compares particularly favorably for short job lengths. Averaging over all regions and job lengths, the competitive ratio achieved by DTPR-max is a 4.94.9% improvement on the carbon-agnostic method, a 8.48.4% improvement on the kk-max search algorithm, and a 2.12.1% improvement on the constant threshold algorithm.

In the second experiment, we test all algorithms for different switching costs β\beta in the range from to U/5U/5. The job length kk is set to 1010 hours, and no volatility is added to the carbon trace. By testing different values for β\beta, this experiment tests how an increasing switching cost impacts the performance of DTPR-max with respect to other algorithms which do not explicitly consider the switching cost. In Figures 10(b), 11(b), and 12(b), we show that the average competitive ratio of DTPR-max notably outperforms the other algorithms for a wide range of β\beta values in all regions. Unsurprisingly, the carbon-agnostic technique (which only incurs a switching cost of 2β2\beta) is more competitive as β\beta grows. The kk-max search algorithm performs noticeably worse as β\beta grows. While the constant threshold algorithm has relatively consistent performance, the kk-max search algorithm performs noticeably worse as β\beta grows. Averaging over all regions and switching cost values, the competitive ratio achieved by DTPR-max is a 2.52.5% improvement on the carbon-agnostic method, a 6.46.4% improvement on the kk-max search algorithm, and a 0.10.1% improvement on the constant threshold algorithm.

In the final experiment, we test all algorithms on sequences with different volatility. The job length kk and switching cost β\beta are both fixed. We add volatility by setting a noise factor from the range 1.01.0 to 3.03.0. By testing different values for this volatility, this experiment tests how each algorithm handles larger fluctuations in the carbon intensity of consecutive time steps. In Figures 10(c), 11(c), and 12(c), we show that the observed average competitive ratio of DTPR-max outperforms the other algorithms for most noise factors in all regions, with a slight degradation in the Pacific Northwest region. Intuitively, higher volatility values cause the online algorithms to perform worse in general. Averaging over all regions and noise factors, the competitive ratio achieved by DTPR-max is a 13.013.0% improvement on the carbon-agnostic method, a 11.211.2% improvement on the kk-max search algorithm, and a 2.12.1% improvement on the constant threshold algorithm.

By averaging over all experiments for a given region, we obtain the cumulative distribution function plot for each algorithm’s competitive ratio in Figures 10(d), 11(d), and 12(d). Compared to the carbon-agnostic, constant threshold, and kk-max search algorithms, DTPR-max generally exhibits a lower average empirical competitive ratio over the tested regions. Notably, all of the algorithms are nearly 1-competitive in our experiments. Compared to our minimization experiments, DTPR-max outperforms the baseline algorithms by a smaller margin. Across all regions at the 95th percentile, DTPR-max achieves a worst-case empirical competitive ratio of 1.081.08. This represents a 16.116.1% improvement over the carbon-agnostic algorithm, and improvements of 11.411.4% and 2.192.19% over the kk-max search and constant threshold switching-cost-agnostic algorithms, respectively.

We conjecture that one dynamic contributing to this is the relatively low values of θ\theta observed for the carbon-free supply percentage in these real-world carbon traces.

Appendix B Competitive Analysis of DTPR-max: Proof of Theorem 5

Here we prove the DTPR-max results presented in Theorem 5 and Corollary 7.

For 0≤j≤k0\leq j\leq k, let Sj⊆S\mathcal{S}_{j}\subseteq\mathcal{S} be the sets of OPR-max price sequences for which DTPR-max accepts exactly jj prices (excluding the k−jk-j prices it is forced to accept at the end of the sequence). Then all of the possible price sequences for OPR-max are represented by S=⋃j=0kSj\mathcal{S}=\bigcup_{j=0}^{k}\mathcal{S}_{j}. By definition, uk+1=Uu_{k+1}=U. Let ϵ>0\epsilon>0 be fixed, and define the following two price sequences σj\sigma_{j} and ρj\rho_{j}:

We have two special cases for j=0j=0 and j=1j=1. For j=0j=0, we have that σ0=ρ0\sigma_{0}=\rho_{0}, and this sequence simply consists of u1−ϵu_{1}-\epsilon repeated kk times, followed by LL repeated kk times. For j=1j=1, we also have that σ1=ρ1\sigma_{1}=\rho_{1}, and this sequence consists of one price with value u1u_{1} and one price with value LL, followed by u2−ϵu_{2}-\epsilon repeated kk times and LL repeated kk times.

Observe that as ϵ→0\epsilon\rightarrow 0, σj\sigma_{j} and ρj\rho_{j} are sequences yielding the worst-case ratios in Sj\mathcal{S}_{j}, as DTPR-max is forced to accept (k−j)(k-j) worst-case LL values at the end of the sequence, and each accepted value is exactly equal to the corresponding threshold.

Observe that OPT(σj)/DTPR-max(σj)=OPT(ρj)/DTPR-max(ρj)\texttt{OPT}(\sigma_{j})/\texttt{DTPR-max}(\sigma_{j})=\texttt{OPT}(\rho_{j})/\texttt{DTPR-max}(\rho_{j}). First, the optimal solution for both sequences is exactly the same: kcmax⁡(σj)−2β=kcmax⁡(ρj)−2βkc_{\max}(\sigma_{j})-2\beta=kc_{\max}(\rho_{j})-2\beta. For any sequence ss in Sj\mathcal{S}_{j}, we also know that cmax⁡(s)<uj+1c_{\max}(s)<u_{j+1}, so OPT(ρj)=OPT(σj)≤kuj+1−2β\texttt{OPT}(\rho_{j})=\texttt{OPT}(\sigma_{j})\leq ku_{j+1}-2\beta.

Note that whenever j<2j<2, we have that σ0=ρ0\sigma_{0}=\rho_{0}, and σ1=ρ1\sigma_{1}=\rho_{1}. Thus, DTPR-min(ρj)=DTPR-min(σj)\texttt{DTPR-min}(\rho_{j})=\texttt{DTPR-min}(\sigma_{j}) holds for any value of jj.

For ϵ→0\epsilon\rightarrow 0, the competitive ratio OPT/DTPR-max\texttt{OPT}/\texttt{DTPR-max} is exactly ω\omega:

and thus for any sequence s∈Ss\in\mathcal{S},

Since OPT(s)≤kcmax⁡(s)−2β\texttt{OPT}(s)\leq kc_{\max}(s)-2\beta for any sequence ss, this implies that DTPR-max is ω\omega-competitive.∎

For simplification purposes, let β=bL/2\beta=bL/2, where bb is a real constant on the interval (0,k)\left(0,k\right). To show part (a) for REGIME-1, with fixed k≥1k\geq 1, observe that for sufficiently large ω\omega, we have the following:

Let ω+=kk⋅kθk−bk+1\omega_{+}=\sqrt[k+1]{k^{k}\cdot\frac{k\theta}{k-b}}. Then, for sufficiently large ω\omega, we have the following:

Furthermore, let ε>0\varepsilon>0 and set ω−=(1−ε)kk⋅kθk−bk+1\omega_{-}=(1-\varepsilon)\sqrt[k+1]{k^{k}\cdot\frac{k\theta}{k-b}}. A similar calculation as above shows that for sufficiently large θ\theta we have:

Thus, ω=O(kkkθk−bk+1)\omega=O\left(\sqrt[k+1]{k^{k}\frac{k\theta}{k-b}}\right) satisfies (10) for sufficiently large ω\omega, fixed k≥1k\geq 1, and β=bL2 s.t. b∈(1,k)\beta=\frac{bL}{2}\text{ s.t. }b\in(1,k).

To show part (b) for REGIME-2, observe that the right-hand side of (10) can be approximated as (1+ωk)k ≈ eω\left(1+\frac{\omega}{k}\right)^{k}~{}\approx~{}e^{\omega} when k→∞k\rightarrow\infty. Then by taking limits on both sides, we obtain the following:

Let β=bL/2\beta=bL/2 as outlined above. We then obtain the following:

By definition of the Lambert WW function, solving this equation for ω\omega obtains part (2). ∎

Appendix C Proofs of Lemmas 10 and 11

In this section, we give the deferred proofs of Lemmas 10 and 11, which are used in the proofs of Theorem 4 and Theorem 5, respectively.

We show that the following holds for any j∈[0,k]j\in[0,k], by Definition 1:

By substituting Def. 1 into ∑i=1jui\sum_{i=1}^{j}u_{i}, the above can be simplified exactly to the closed form for uj+1u_{j+1}:

and the claim follows by the definition of uj+1u_{j+1}. ∎

We show that the following holds for any j∈[0,k]j\in[0,k], by Definition 2:

Appendix D Proofs of Lower Bound Results

This section formally proves the lower bound results for both OPR-min and OPR-max, building on the proof sketch provided in Section 5.2.

Since any arbitrary deterministic online algorithm ALG cannot achieve a competitive ratio better than α\alpha playing against this adaptive adversary, our proposed algorithm DTPR-min is optimal. ∎

D.2 Proof of Theorem 9 (OPR-max Lower Bound)

Let ALG be a deterministic online algorithm for OPR-max, and suppose that the adversary uses the price sequence u1,…,uku_{1},\dots,u_{k}, which is exactly the sequence defined by (6). u1u_{1} is presented to ALG, at most kk times or until ALG accepts it. If ALG never accepts u1u_{1}, the remainder of the sequence is all LL, and ALG achieves a competitive ratio of ku1−2βkL−2β=ω\frac{ku_{1}-2\beta}{kL-2\beta}=\omega, as defined in (8).

If ALG accepts u1u_{1}, the next price presented is LL, repeated at most kk times or until ALG switches to reject LL. After ALG has switched, u2u_{2} is presented to ALG, at most kk times or until ALG accepts it. Again, if ALG never accepts u2u_{2}, the remainder of the sequence is all LL, and ALG achieves a competitive ratio of at least ku2−2βu1+(k−1)L−4β=ω\frac{ku_{2}-2\beta}{u_{1}+(k-1)L-4\beta}=\omega, as defined in (8).

As the sequence continues, whenever ALG does not accept some uiu_{i} after it is presented kk times, the adversary drops the price to LL for the remainder of the sequence. Otherwise, if ALG accepts kk prices before the end of the sequence, the adversary concludes by presenting UU at least kk times.

Observe that any ALG which does not immediately reject the first LL presented to it after accepting some uiu_{i} obtains a competitive ratio strictly worse than ω\omega. To illustrate this, suppose ALG has just accepted u1u_{1}, achieving a profit of u1−βu_{1}-\beta so far. The adversary begins to present LL prices, and ALG accepts y≤(k−1)y\leq(k-1) of these LL prices before switching away. If y=(k−1)y=(k-1), ALG will accept kk prices before the end of the sequence and achieve a competitive ratio of kU−2βu1+(k−1)L−2β>ω\frac{kU-2\beta}{u_{1}+(k-1)L-2\beta}>\omega. Otherwise, if y<(k−1)y<(k-1), the profit achieved by ALG so far is at most u1−2β+yLu_{1}-2\beta+yL, while the profit achieved by ALG if it had immediately switched away (y=0y=0) would be u1−2βu_{1}-2\beta – since any price which might be accepted by ALG in the future should be ≥L\geq L, the latter case strictly improves the competitive ratio of ALG.

Assuming that ALG does immediately reject any LL presented to it, and that ALG accepts some prices before the end of the sequence, the competitive ratio attained by ALG is at least kuj+1−2β∑i=1jui−(j+1)2β+(k−j)L=ω\frac{ku_{j+1}-2\beta}{\sum_{i=1}^{j}u_{i}-(j+1)2\beta+(k-j)L}=\omega, as defined in (8).

Similarly, if ALG accepts kk prices before the end of the sequence, the competitive ratio attained by ALG is at least kU−2β∑i=1kui−k2β=ω\frac{kU-2\beta}{\sum_{i=1}^{k}u_{i}-k2\beta}=\omega, as defined in (8).

Since any arbitrary deterministic online algorithm ALG cannot achieve a competitive ratio better than ω\omega playing against this adaptive adversary, our proposed algorithm DTPR-max is optimal. ∎