Abstract
The knapsack problem is one of the classical problems in combinatorial optimization: Given a set of items, each specified by its size and profit, the goal is to find a maximum profit packing into a knapsack of bounded capacity. In the online setting, items are revealed one by one and the decision, if the current item is packed or discarded forever, must be done immediately and irrevocably upon arrival. We study the online variant in the random order model where the input sequence is a uniform random permutation of the item set. We develop a randomized (1/6.65)competitive algorithm for this problem, outperforming the current best algorithm of competitive ratio 1/8.06 (Kesselheim et al. in SIAM J Comput 47(5):1939–1964, 2018). Our algorithm is based on two new insights: We introduce a novel algorithmic approach that employs two given algorithms, optimized for restricted item classes, sequentially on the input sequence. In addition, we study and exploit the relationship of the knapsack problem to the 2secretary problem. The generalized assignment problem (GAP) includes, besides the knapsack problem, several important problems related to scheduling and matching. We show that in the same online setting, applying the proposed sequential approach yields a (1/6.99)competitive randomized algorithm for GAP. Again, our proposed algorithm outperforms the current best result of competitive ratio 1/8.06 (Kesselheim et al. in SIAM J Comput 47(5):1939–1964, 2018).
Introduction
Many realworld problems can be considered resource allocation problems. For example, consider the loading of a cargo plane with (potential) goods of different weights. Each item raises a certain profit for the airline if it is transported; however, not all goods can be loaded due to airplane weight restrictions. Clearly, the dispatcher seeks for a maximum profit packing fulfilling the capacity constraint. This example from [1] illustrates the knapsack problem: Given a set of n items, specified by a size and a profit value, and a resource (called knapsack) of fixed capacity, the goal is to find a subset of items (called packing) with maximum total profit and whose total size does not exceed the capacity. Besides being a fundamental and extensively studied problem in combinatorial optimization, knapsack problems arise in many and various practical settings. We refer the readers to textbooks [1, 2] and to the surveys of previous work in [3, 4] for further references.
The introductory example from cargo logistics can be generalized naturally to multiple airplanes of different capacities. Here, the size and the profit of an item may depend on the airplane and on the schedule, respectively. This leads to the generalized assignment problem (GAP) [2], where resources of different capacities are given, and the size and the profit of an item depend on the resource to which it is assigned. The GAP includes many prominent problems, such as the (multiple) knapsack problem [5], weighted bipartite matching [6], AdWords [7], and the display ads problem [8]. Further applications of GAP are outlined in the survey articles [9, 10].
We study online variants of the knapsack problem and GAP. Here, n items are presented sequentially, and the decision for each item must be made immediately upon arrival. This setting would arise in our logistics example if the dispatcher needs to answer customer requests immediately without knowledge of future requests. In fact, many realworld optimization problems occur as online problems, as often decisions must be made under uncertain conditions. The online knapsack problem has been studied in particular in the context of online auctions [11, 12].
Typically, the performance measure for online algorithms is the competitive ratio, which is defined as the ratio between the values of the algorithmic solution and an optimal offline solution for a worstcase input. The knapsack problem admits no randomized algorithm of bounded competitive ratio in the general online setting [12]. This holds even if only a single item can be packed, as known from the secretary problem [13, 14]. However, these hardness results are based on a worstcase input presented in adversarial order. In the random order model, the performance of an algorithm is evaluated for a worstcase input, but the adversary has no control over the input order; the input sequence is drawn uniformly at random among all permutations.
In order to define the competitive ratio of an algorithm \(\mathcal {A}\) in this model formally, let \(\mathcal {A}(\mathcal {I})\) and \({\text {OPT}}(\mathcal {I})\) denote the profits of the solutions of \(\mathcal {A}\) and an optimal offline algorithm, respectively, for input \(\mathcal {I}\). We say that \(\mathcal {A}\) is rcompetitive (or has competitive ratio r) in the random order model if
holds for all inputs \(\mathcal {I}\). Here, the expectation is over the random permutation as well as over random choices of the algorithm. The o(1)term is asymptotic with respect to the number n of items in the input.
The random order model became increasingly popular in the field of online algorithms. An early and wellknown example is the secretary problem [13, 14]. Nowadays, the matroid secretary problem [15, 16] is considered as one of the most central problems in this field. Further multiplechoice generalizations [17, 18] are part of active research as well. The model has also been successfully applied to other problem classes including scheduling [19,20,21], packing [22,23,24,25,26], graph problems [27,28,29], facility location [30], budgeted allocation [31], and submodular welfare maximization [32].
Related Work
Online Knapsack Problem
The online knapsack problem was first studied by MarchettiSpaccamela and Vercellis [33], who showed that no deterministic online algorithm for this problem can obtain a constant competitive ratio. Moreover, Chakrabarty et al. [12] demonstrated that this fact cannot be overcome by randomization.
Given such hardness results, several relaxations have been introduced and investigated. Most relevant to our work are results in the random order model. Introduced as the secretary knapsack problem [34], Babaioff et al. developed a randomized algorithm of competitive ratio \(1/(10e) < 1/27\). Kesselheim et al. [25] achieved a significant improvement by developing a (1/8.06)competitive randomized algorithm for the generalized assignment problem. Finally, Vaze [35] showed that there exists a deterministic algorithm of competitive ratio \(1/(2e) < 1/5.44\), assuming that the maximum profit of a single item is small compared to the profit of the optimal solution.
Apart from the random order model, different further relaxations have been considered. MarchettiSpaccamela and Vercellis [33] studied a stochastic model wherein item sizes and profits are drawn from a fixed distribution. Lueker [36] obtained improved bounds in this model. Chakrabarty et al. [12] studied the problem when the density (profitsize ratio) of each item is in a fixed range [L, U]. Under the further assumption that item sizes are small compared to the knapsack capacity, Chakrabarty et al. proposed an algorithm of competitive ratio \(\ln (U/L) + 1\) and provided a lower bound of \(\ln (U/L)\). Another branch of research considers removable models, where the algorithm can remove previously packed items. Removing such items can incur no cost [37, 38] or a cancellation cost (buyback model, [39,40,41]). Recently, Vaze [42] considered the problem under a (weaker) expected capacity constraint. This variant admits a competitive ratio of 1/4e.
Online GAP
Since all hardness results for online knapsack also hold for online GAP, research focuses on stochastic variants or modified online settings. Currently, the only result for the random order model is the previously mentioned (1/8.06)competitive randomized algorithm proposed by Kesselheim et al. [25]. To the best of our knowledge, the earliest paper considering online GAP is due to Feldman et al. [8]. They obtained an algorithm of competitive ratio tending to \(11/e\) in the free disposal model. In this model, the total size of items assigned to a resource might exceed its capacity; in addition, no item consumes more than a small fraction of any resource. A stochastic variant of online GAP was studied by Alaei et al. [43]. Here, the size of an item is drawn from an individual distribution that is revealed upon arrival of the item, together with its profit. However, the algorithm learns the actual item size only after the assignment. If no item consumes more than a (1/k)fraction of any resource, the algorithm proposed by Alaei et al. has competitive ratio \(1  1/\sqrt{k}\).
Online packing LPs
Packing problems where requests can consume \(d \ge 1\) different resources lead to general online packing LPs. Note that the special case of \(d=1\) is the generalized assignment problem. Buchbinder and Naor [44] initiated the study of online packing LPs in the adversarial model. The random order model admits \((1\varepsilon )\)competitive algorithms assuming large capacity ratios, i.e., the capacity of any resource is large compared to the maximum demand for it. This has been shown in a sequence of papers [22, 23, 25, 26]. Recently, Kesselheim et al. [25] gave an algorithm of competitive ratio \(1  O(\sqrt{(\log d) / B})\) where B is the capacity ratio. Consequently, their algorithm is \((1\varepsilon )\)competitive if \(B = \varOmega ((\log d) / \varepsilon ^2)\). For \(d=1\), this result matches the lower bound by Kleinberg [18].
Our Contributions
As outlined above, for online knapsack and GAP in the adversarial input model, nearly all previous works attain constant competitive ratios at the cost of either (a) imposing structural constraints on the input or (b) significantly relaxing the original online model. Therefore, we study both problems in the random order model, which is less pessimistic than the adversarial model but still considers worstcase instances without further constraints on the item properties. For the knapsack problem, our main result is the following.
Theorem 1
There exists a (1/6.65)competitive randomized algorithm for the online knapsack problem in the random order model.
One challenge in the design of knapsack algorithms is that the optimal packing can have, on a high level, at least two different structures. Either there are a few large items, constituting the majority of the packing’s profit, or there are many small such items. Previous work [25, 34] is based on splitting the input according to item sizes and then employing algorithms tailored for these restricted instances. However, the algorithms from [25, 34] choose a single item type via an initial random choice, and then pack items of that type exclusively. In contrast, our approach considers different item types in distinct time intervals, rather than discarding items of a specific type in advance. More precisely, we develop algorithms \(\mathcal {A}_L\) and \(\mathcal {A}_S\) which are combined in a novel sequential approach: While large items appearing in early rounds are packed using \(\mathcal {A}_L\), algorithm \(\mathcal {A}_S\) is applied to pack small items revealed in later rounds. We think that this approach may be helpful for other problems in similar online settings as well.
The proposed algorithm \(\mathcal {A}_L\) deals with the knapsack problem where all items consume more than 1/3 of the capacity (we call this problem 2KS). The 2KS problem is closely related to the ksecretary problem [18] for \(k=2\). We also develop a general framework that allows to employ any algorithm for the 2secretary problem to obtain an algorithm for 2KS. As a side product, we obtain a simple (1/3.08)competitive deterministic algorithm for 2KS in the random order model. For items whose size is at most 1/3 of the resource capacity, we give a simple and efficient algorithm \(\mathcal {A}_S\). Here, a challenging constraint is that \(\mathcal {A}_L\) and \(\mathcal {A}_S\) share the same resource, so we need to argue carefully that the decisions of \(\mathcal {A}_S\) are feasible, given the packing of \(\mathcal {A}_L\) from previous rounds.
Finally, we show that the proposed sequential approach also improves the current best result for GAP [25] from competitive ratio 1/8.06 to 1/6.99.
Theorem 2
There exists a (1/6.99)competitive randomized algorithm for the online generalized assignment problem in the random order model.
For this problem, we use the algorithmic building blocks \(\mathcal {A}_L\), \(\mathcal {A}_S\) developed in [25, 28]. However, we need to verify that \(\mathcal {A}_L\), an algorithm for edgeweighted bipartite matching [28], satisfies the desired properties for the sequential approach. We point out that the assignments of our algorithm differ structurally from the assignments of the algorithm proposed in [25]. In the assignments of the latter algorithm, all items are either large or small compared to the capacity of the assigned resource. In our approach, both situations can occur, because resources are managed independently.
Roadmap
We focus on the result on the knapsack problem (Theorem 1) in the first sections of this paper. For this purpose, we provide elementary definitions and facts in Sect. 2. Our main technical contribution is formally introduced in Sect. 3: Here, we describe an algorithmic framework performing two algorithms \(\mathcal {A}_L\), \(\mathcal {A}_S\) sequentially. In Sects. 4 and 5, we design and analyze the algorithms \(\mathcal {A}_L\) and \(\mathcal {A}_S\) for the knapsack problem. Finally, in Sect. 6 we describe how the sequential approach can be applied to GAP.
Preliminaries
Let \([n] := \{1,\ldots ,n\}\). Further, let \(\mathbb {Q}_{\ge 0}\) and \(\mathbb {Q}_{>0}\) denote the set of nonnegative and positive rational numbers, respectively.
Knapsack Problem
We are given a set of items \(I = [n]\), each item \(i \in I\) has size \(s_i \in \mathbb {Q}_{> 0}\) and a profit (value) \(v_i \in \mathbb {Q}_{\ge 0}\). The goal is to find a maximum profit packing into a knapsack of size \(W \in \mathbb {Q}_{> 0}\), i.e., a subset \(M \subseteq I\) such that \(\sum _{i \in M} s_i \le W\) and \(\sum _{i \in M} v_i\) is maximized. W.l.o.g. we can assume \(s_i \le W\) for all \(i \in I\). In the online variant of the problem, a single item i is revealed together with its size and profit in each round \(\ell \in [n]\). The online algorithm must decide immediately and irrevocably whether to pack i. We call an item visible in round \(\ell\) if it arrived in round \(\ell\) or earlier.
We classify items as large or small, depending on their size compared to W and a parameter \(\delta \in (0,1)\) to be determined later.
Definition 1
We say an item i is \(\delta\)large if \(s_i > \delta W\) and \(\delta\)small if \(s_i \le \delta W\). Whenever \(\delta\) is clear from the context, we say an item is large or small for short. Based on the given item set I, we define two modified item sets \(I_L\) and \(I_S\), which are obtained as follows:

\(I_L\): Replace each small item by a large item of profit 0

\(I_S\): Replace each large item by a small item of profit 0.
Therefore, \(I_L\) only contains large items and \(I_S\) only contains small items. We can assume that no algorithm packs a zeroprofit item, thus any algorithmic packing of \(I_L\) or \(I_S\) can be turned into a packing of I having the same profit. Let \({\text {OPT}}\), \({\text {OPT}}_L\), and \({\text {OPT}}_S\) be the total profits of optimal packings for I, \(I_L\), and \(I_S\), respectively. A useful upper bound for \({\text {OPT}}\) is
Bounding Sums by Integrals
In order to obtain lower or upper bounds on sums in closed form, we often make use of the following facts.
Fact 1A Let f be a nonnegative realvalued function and let \(a,b \in \mathbb {N}\). If f is monotonically decreasing, then \(\int _{a}^{b+1} f(i) ~\mathrm {d} {i}~ \le \sum _{i=a}^{b} f(i) \le \int _{a1}^{b} f(i) ~\mathrm {d} {i}~\).
Fact 1B Let f be a nonnegative realvalued function and let \(a,b \in \mathbb {N}\). If f is monotonically increasing, then \(\int _{a1}^{b} f(i) ~\mathrm {d} {i}~ \le \sum _{i=a}^{b} f(i) \le \int _{a}^{b+1} f(i) ~\mathrm {d} {i}~\).
Sequential Approach
A common approach in the design of algorithms for secretary problems is to set two phases: a sampling phase, where all items are rejected, followed by a decision phase, where some items are accepted according to a decision rule. Typically, this rule is based on the information gathered in the sampling phase. We take this concept a step further: The key idea of our sequential approach is to use a part of the sampling phase of one algorithm as decision phase of another algorithm, which itself can have a sampling phase. This way, two algorithms are performed in a sequential way, which makes better use of the entire instance. We combine this idea with using different strategies for small and large items.
Formally, let \(\mathcal {A}_L\) and \(\mathcal {A}_S\) be two online knapsack algorithms and \(I_L\) and \(I_S\) be the item sets constructed according to Definition 1. Further, let \(0<c<d<1\) be two parameters to be specified later. Our proposed algorithm samples the first cn rounds; no item is packed during this time. From round \(cn+1\) to dn, the algorithm considers large items exclusively. In this interval it follows the decisions of \(\mathcal {A}_L\). After round dn, the algorithm processes only small items and follows the decisions of \(\mathcal {A}_S\). However, it might be the case that an item accepted by \(\mathcal {A}_S\) cannot be packed because the knapsack capacity is exhausted due to the packing of \(\mathcal {A}_L\) in earlier rounds. Note that all rounds \(1,\ldots ,dn\) can be considered as the sampling phase for \(\mathcal {A}_S\). A formal description is given in Algorithm 1. Here, for a given input sequence \(\pi\) of I, let \(\pi _L\) and \(\pi _S\) denote the corresponding sequences from \(I_L\) and \(I_S\), respectively. Note that \(\pi\) is revealed sequentially and \(\pi _L\), \(\pi _S\) can be constructed online. For any input sequence \(\pi\), let \(\pi (\ell )\) denote the item at position \(\ell \in [n]\).
In the final algorithm, we set the threshold for small items to \(\delta =1/3\) and use Algorithm 1 with parameters \(c=0.42291\) and \(d=0.64570\). The choice of c and d maximizes the minimum of \({\mathbf{E}}\left[ \mathcal {A}_L\right] / {\text {OPT}}_L\) and \({\mathbf{E}}\left[ \mathcal {A}_S\right] / {\text {OPT}}_S\). For simplicity, we assume \(cn,dn \in \mathbb {N}\). If n is large enough, this assumption does not affect the competitive ratio substantially. We next give a highlevel description of the proof of Theorem 1.
Proof (of Theorem 1)
Let \(\mathcal {A}\) be Algorithm 1 and let \(\mathcal {A}_L\), \(\mathcal {A}_S\) be the algorithms developed in Sect. 4 and 5. In the next sections, we prove the following results for \(r= 1/6.65  o(1)\) (see Lemmas 6 and 11): The expected profit from \(\mathcal {A}_L\) in rounds \(cn+1,\ldots ,dn\) is at least \(r \cdot {\text {OPT}}_L\), and the expected profit from \(\mathcal {A}_S\) in rounds \(dn+1,\ldots ,n\) is at least \(r \cdot {\text {OPT}}_S\). Together with inequality (1), we obtain
\(\square\)
The order in which \(\mathcal {A}_L\) and \(\mathcal {A}_S\) are arranged in Algorithm 1 follows from two observations. Algorithm \(\mathcal {A}_S\) is powerful if it samples roughly 2n/3 rounds; a part of this long sampling phase can be used as the decision phase of \(\mathcal {A}_L\), for which a shorter sampling phase is sufficient. Moreover, the first algorithm should either pack highprofit items, or should leave the knapsack empty for the following algorithm with high probability. The algorithm \(\mathcal {A}_L\) we propose in Sect. 4 has this property (see Lemma 7), in contrast to \(\mathcal {A}_S\). If \(\mathcal {A}_S\) would precede \(\mathcal {A}_L\), the knapsack would be empty after round dn with very small probability, in which case we would not benefit from \(\mathcal {A}_L\) at all.
Finally, note that stronger algorithms for the respective subproblems can be obtained by choosing different parameters or algorithmic approaches (see Lemma 5 and [25]). However, we seek for maximizing the competitive ratio of Algorithm 1 and therefore need algorithms \(\mathcal {A}_L\) and \(\mathcal {A}_S\) that perform well within the sequential framework.
Large Items
The approach presented in this section is based on the connection between the online knapsack problem under random arrival order and the ksecretary problem [18]. In the latter problem, the algorithm can accept up to k items and the goal is to maximize the sum of their profits. Therefore, we assume that a ksecretary algorithm can observe the actual profits of the items, as opposed to the ordinal version of the problem, where an algorithm can only decide based on relative merits. This way, the ksecretary problem generalizes the classical secretary problem [13, 14] and is itself a special case of the online knapsack problem under random arrival order (if all knapsack items have size W/k).
In our setting, each large item consumes more than \(\delta =1/3\) of the knapsack capacity. We call this problem 2KS, since at most two items can be packed completely. Therefore, any 2secretary algorithm can be employed to identify two highprofit items for the knapsack packing. However, after packing the first item, the resource might be exhausted, such that the second item identified by the 2secretary algorithm cannot be packed.
Although this idea can be generalized to any ksecretary algorithm and corresponding \(\delta\)large items, the approach seems stronger for small k: While 1KS is exactly 1secretary, the characteristics of kKS and ksecretary deviate with growing k. Our results show that the problems 2secretary and 2knapsack are still close enough to benefit from such an approach.
In the following, let \(\mathcal {A}_L\) be Algorithm 2. This is an adaptation of the algorithm singleref developed for the ksecretary problem in [45]. As discussed above, 2secretary and 2KS are similar, but different problems. Therefore, in our setting it is not possible to apply the existing analysis from [45] or from any other ksecretary algorithm directly. We further note that in the approach described below, in principle any 2secretary algorithm can be employed. In Sect. 4.4, we discuss several alternative algorithms.
Assumption. For this section, we assume that all profits are distinct. This is without loss of generality, as ties can be broken by adjusting the profits slightly, using the items’ identifiers. Further, we assume \(v_1> v_2> \ldots > v_n\) and say that i is the rank of item i.
Packing Types
As outlined above, in contrast to the 2secretary problem, not all combinations of two knapsack items can be packed completely. Therefore, we analyze the probability that \(\mathcal {A}_L\) selects a feasible set of items whose profit can be bounded from below. We restrict our analysis to packings where an item \(i \in \{1,2,3,4\}\) is packed as the first item and group such packings into several packing types AM defined in the following. Although covering more packings might lead to further insights into the problem and to a stronger result, we expect the improvement to be marginal.
Let \(p_X\) be the probability that \(\mathcal {A}_L\) returns a packing of type \(X \in \{\text {A},\ldots ,\text {M}\}\). In addition, let \(p_i\) for \(i \in [n]\) be the probability that \(\mathcal {A}_L\) packs i as the first item. Finally, let \(p_{ij}\) for \(i,j \in [n]\) be the probability that \(\mathcal {A}_L\) packs i as the first item and j as the second item.
In a packing of type A, the items 1 and 2 are packed in any order. Therefore, \(p_\text {A} = p_{12} + p_{21}\). The types B and C are defined analogously using the items \(\{1,3\}\) and \(\{2,3\}\), respectively. In a packing of type D, the item 1 is accepted as the first item, together with no or any second item j. This happens with probability \(p_\text {D} = p_1\). Accordingly, we define types E, F, and G using the items 2, 3, and 4, respectively. Finally, for each item \(i \in \{1,2,3\}\), we introduce two further packing types. For \(i=1\), types H and I cover packings where the first accepted item is 1, the second accepted item j is not 2 (type H) and not 3 (type I), respectively. Therefore, we get \(p_\text {H} = p_1  p_{12}\) and \(p_\text {I} = p_1  p_{13}\). Packing types JK and LM describe analogous packings for \(i=2\) and \(i=3\), respectively. Table 1 shows all packing types AM and their probabilities expressed by \(p_i\) and \(p_{ij}\).
In Sect. 4.3, we use the packing types to describe a subset of packings whose profit can be bounded against \({\text {OPT}}_L\). For example, suppose that \({\text {OPT}}_L = v_1 + v_2\). Then, all relevant packings are of type A, H, or J. As these types are disjoint by definition, we immediately obtain \({\mathbf{E}}\left[ \mathcal {A}_L\right] \ge p_\text {A} (v_1 + v_2) + p_\text {H} v_1 + p_\text {J} v_2\).
Acceptance Probabilities of Algorithm 2
In the following, we compute the probabilities \(p_i\) and \(p_{ij}\) from Table 1 as functions of c and d. Throughout the following proofs, we denote the position of an item i in a given permutation with \({{\,\mathrm{pos}\,}}(i) \in [n]\). Further, let a be the maximum profit item from the sampling.
We think of the random permutation as being sequentially constructed. The fact given below follows from the hypergeometric distribution and becomes helpful in the proofs of Lemmas 1 and 2.
Fact 1
Suppose there are N balls in an urn from which M are blue and \(NM\) red. The probability of drawing K blue balls without replacement in a sequence of length K is \(h(N,M,K) := \left( {\begin{array}{c}M\\ K\end{array}}\right) / \left( {\begin{array}{c}N\\ K\end{array}}\right) \,.\)
In the first lemma, we provide the exact probability \(p_i\) for all \(i \in [n]\) and give lower bounds for \(p_i\) when \(i \in [4]\).
Lemma 1
The probability that item \(i \in [n]\) is accepted as the first item is
Moreover, we have the lower bound
Proof
In the first part of this proof, we analyze the probability that item i is accepted as the first item at a fixed position \(k \ge cn+1\). As a is defined as the best sampling item, \({{\,\mathrm{pos}\,}}(a) \le cn\) must hold. A permutation uniformly drawn at random satisfies \({{\,\mathrm{pos}\,}}(i)=k\) and \({{\,\mathrm{pos}\,}}(a) \le cn\) with probability \(\frac{1}{n} \frac{cn}{n1} = \frac{c}{n1}\).
Next, we draw the remaining \(k2\) items for the positions before k (see Fig. 1). Since i is packed as the first item, all previous items (except for a) must have rank greater than a. As these items are drawn from the remaining \(n2\) items (of which \(na\) have rank greater than a), the probability for this step is \(h(n2,na,k2)\) according to Fact 1. Using the law of total probability for \(k \in \{cn+1,\ldots ,dn\}\) and \(a \in \{i+1,\ldots ,n\}\), we obtain
Here, the last identity follows from \(\sum _{a=i+1}^{n} \left( {\begin{array}{c}na\\ k2\end{array}}\right) = \sum _{a=0}^{ni1} \left( {\begin{array}{c}a\\ k2\end{array}}\right) = \left( {\begin{array}{c}ni\\ k1\end{array}}\right) \,.\)
In the second part of the proof, we derive a lower bound for \(p_i\). We first consider the quotient of binomial coefficients from Eq. (2) and observe
Combining Equation (2) and inequality (3) yields
Now, the goal is to find a closed expression which bounds the last sum in inequality (4) from below. We have
and define \(f(k) = (nk)^{i1} / k\). Since f is monotonically decreasing in k and \(i1 \ge 0\), we have
where we used that Fact 1A. Let F be a function such that \(\int _{cn}^{dn} f(k) ~\mathrm {d} {k}~ = F(dn)F(cn)\). By combining inequalities (4–6) we obtain
Below we provide suitable functions F for \(i \in [4]\).
i  f(k)  F(k)  \(F(dn)  F(cn)\) 
1  \(\frac{1}{k}\)  \(\ln k\)  \(\ln \frac{d}{c}\) 
2  \(\frac{nk}{k}\)  \(n \ln k  k\)  \(n \ln \frac{d}{c} dn +cn\) 
3  \(\frac{(nk)^2}{k}\)  \(n^2 \ln k  2nk + \frac{k^2}{2}\)  \(n^2 \ln \frac{d}{c} 2n(dncn) + \frac{d^2 n^2  c^2 n^2}{2}\) 
4  \(\frac{(nk)^3}{k}\)  \(n^3 \ln k 3 n^2 k + \frac{3}{2} nk^2  \frac{k^3}{3}\)  \(n^3 \ln \frac{d}{c}  3n^3 (dc) + \frac{3}{2} n^3 (d^2c^2)  \frac{1}{3} n^3(d^3c^3)\) 
The claim follows by substituting \(F(dn)F(cn)\) in inequality (7) by the corresponding expression from the table and noting that \((i+1) \cdot \frac{(1c)^{i1}}{n} = o(1)\). \(\square\)
Next, we analyze the probabilities \(p_{ij}\) with \(i < j\) and give lower bounds for \(p_{12}\), \(p_{13}\), and \(p_{23}\).
Lemma 2
Let i and j be two items with \(i < j\). The probability that i is selected as the first item and j is selected as the second item is
Moreover, it holds that
Proof
Let i, j be two items with \(i < j\). The proof follows the same structure as the proof of Lemma 1. Again, we construct the permutation by drawing the positions for items i, j, and a first and afterwards all remaining items with position up to \({{\,\mathrm{pos}\,}}(j)\) (see Fig. 2).
Fix positions \(k={{\,\mathrm{pos}\,}}(i)\) and \(l={{\,\mathrm{pos}\,}}(j)\) . Again, \({{\,\mathrm{pos}\,}}(a) \le cn\) must hold by definition of a. The probability that a random permutation satisfies these three position constraints is \(\beta := \frac{1}{n} \frac{1}{n1} \frac{cn}{n2} = \frac{c}{n1} \cdot \frac{1}{n2}\).
All remaining items up to position l must have rank greater than a. Thus, we need to draw \(l3\) items from a set of \(n3\) remaining items, from which \(na\) have rank greater than a. This happens with probability \(h(n3,na,l3)\). Using the law of total probability for k, l with \(cn+1 \le k < l \le dn\) and \(a \in \{j+1,\ldots ,n\}\), we obtain
Again, by observing \(\sum _{a=j+1}^{n} \left( {\begin{array}{c}na\\ l3\end{array}}\right) = \sum _{a=0}^{nj1} \left( {\begin{array}{c}a\\ l3\end{array}}\right) = \left( {\begin{array}{c}nj\\ l2\end{array}}\right)\), we obtain finally
To prove the second part of the lemma, first note that Equation (8) does not depend on i, thus we have \(p_{13} = p_{23}\). It remains to find lower bounds for \(p_{12}\) and \(p_{23}\). We start with \(p_{12}\). By Equation (8) and the definition of \(\beta\), it holds that
Since \(\sum _{l=k+1}^{dn} \frac{1}{l2} = \sum _{l=k1}^{dn2} \frac{1}{l} = \left( \sum _{l=k}^{dn1} \frac{1}{l}\right) + \frac{1}{k1}  \frac{1}{dn1}\) and 1/l is monotonically decreasing, we have \(\sum _{l=k}^{dn1} \frac{1}{l} \ge \int _{k}^{dn} \frac{1}{l} ~\mathrm {d} {\ell }~ = \ln \frac{dn}{k}\) by Fact 1A. Therefore,
Similarly, using Fact 1A, we obtain
and
By combining inequalities (9) to (12), we obtain
Since \(\frac{c}{n} \cdot \left( 1  \frac{cn1}{dn1} \right) = o(1)\), this gives the claim for \(p_{12}\).
Next, we find a lower bound for \(p_{23}\). Equation (8) with \(j=3\) gives
By splitting this expression into two parts we obtain
where the inequality follows from inequality (9). Hence, using the lower bound for \(p_{12}\), the claim for \(p_{23}\) follows if we can show \(\beta \cdot \sum _{k=cn+1}^{dn1} \sum _{l=k+1}^{dn} \frac{l}{l2} \le c \cdot \left( d^2/2  cd + c^2/2 \right) + o(1)\). Since \(\frac{l}{l2}\) decreases monotonically in l, Fact 1A implies
Therefore, with \(\xi = \sum _{k=cn+1}^{dn1} \ln (k2)\), we have
Since \(\sum _{k=cn+1}^{dn1} k = \frac{(dn1) \cdot dn}{2}  \frac{cn\cdot (cn+1)}{2}\), it follows further
Using \(\beta = \frac{c}{n1} \cdot \frac{1}{n2} < \frac{c}{n^2} \cdot ( 1 + \frac{3}{n3})\), we get
where \(\eta _1 = \frac{3c}{n3} \cdot \left( \frac{d^2}{2} cd + \frac{c^2}{2} \right) = o(1)\) and
We observe that
by Fact 1B. This implies \(\eta _2 = o(1)\) and concludes the proof. \(\square\)
The remaining probabilities \(p_{21}\) and \(p_{32}\) can be obtained from the symmetry property stated in the next lemma.
Lemma 3
For any two items i and j it holds that \(p_{ij} = p_{ji}\).
Proof
Suppose i is accepted first and j is accepted as the second item in the input sequence \(\pi\). Consider the sequence \(\pi '\) obtained from \(\pi\) by swapping i with j. Since j and i are the first two elements beating the best sampling item in \(\pi '\), Algorithm 2 will select j and i on input \(\pi '\). Hence, the number of permutations must be the same for both events, which implies the claim. \(\square\)
Therefore, we can obtain all probabilities from Table 1 using Lemmas 1, 2, and 3.
Analysis
Let T be the set of items in the optimal packing of \(I_L\). This set may contain a single item, may be a twoitem subset of \(\{1,2,3\}\), or may be a twoitem subset containing an item \(j \ge 4\). In the following, we analyze the performance of Algorithm 2 for each case.
Singleitem Case
If the optimal packing contains a single item, it is the most profitable item. Let case 1 be this case. Here, we have \(T=\{1\}\) and \({\mathbf{E}}\left[ {\mathcal{A}}_L\right] \ge p_{{\text{D}}}\,{\text{OPT}}_L\).
Twoitem Cases
In cases 24, we consider packings of the form \(T = \{i,j\}\) with \(1 \le i < j \le 3\). We define cases 2, 3, and 4 as \(T = \{1,2\}\), \(T = \{1,3\}\), and \(T = \{2,3\}\), respectively. We want to consider all algorithmic packings whose profit can be bounded in terms of \({\text {OPT}}_L = v_i + v_j\). For this purpose, for each case 24 we build three groups of feasible packing types, according to whether the profit of a packing is \({\text {OPT}}_L\), at least \(v_i\), or in the interval \([v_j,v_i)\). We ensure that no packing is counted multiple times by (a) choosing appropriate packing types and (b) grouping these packing types in a disjoint way, according to their profit. Let \(\alpha _w\) be the probability that the algorithm returns the optimal packing in case \(w \in \{2,3,4\}\). It holds that \(\alpha _2 = p_\text {A}\), \(\alpha _3 = p_\text {B}\), and \(\alpha _4 = p_\text {C}\). In addition, let \(\beta _w\) be the probability that an item \(k \le i\) is packed as the first item in case \(w \in \{2,3,4\}\). We have \(\beta _2 = p_\text {H}\), \(\beta _3 = p_\text {I}\), and \(\beta _4 = p_\text {D} + p_\text {K}\). Finally, let \(\gamma _w\) be the probability that an item k with \(i < k \le j\) is packed as the first item in case \(w \in \{2,3,4\}\). It holds that \(\gamma _2 = p_\text {J}\), \(\gamma _3 = p_\text {E} + p_\text {L}\), and \(\gamma _4 = p_\text {M}\).
Finally, we define case 5 as \(T = \{i, j\}\) with \(i \ge 1\), \(j \ge 4\), and \(i < j\). In this case, note that packings of type D contain an item of value at least \(v_i\), and packings of type E, F, and G contain an item of value at least \(v_j\). Hence, we can slightly abuse the notation and set \(\alpha _5 = 0\), \(\beta _5=p_\text {D}\), and \(\gamma _5=p_\text {E}+p_\text {F}+p_\text {G}\), such that it holds that
To bound this term against \({\text {OPT}}_L = v_i + v_j\), consider the following two cases: If \(\beta _w \ge \gamma _w\), we obtain from Chebyshev’s sum inequality^{Footnote 1}
If \(\beta _w < \gamma _w\), we trivially have \(\beta _w v_i + \gamma _w v_j > \beta _w (v_i + v_j)\).
Competitive Ratio
The competitive ratio of \(\mathcal {A}_L\) is the minimum over all cases 15. Hence, setting \(\alpha _1=p_\text {D}\) and \(\beta _1 = \gamma _1 = 0\), we obtain
Clearly, inequality (15) simplifies depending on \(\beta _w \ge \gamma _w\) or \(\beta _w < \gamma _w\). The following lemma gives a sufficient condition for \(\beta _w \ge \gamma _w\).
Lemma 4
Let \(f(x)=2 \ln x 6x + 2x^2  \frac{x^3}{3}\). For parameters c, d with \(f(c) \ge f(d)\) and \(n \rightarrow \infty\), it holds that \(\beta _w \ge \gamma _w\), where \(2 \le w \le 5\).
Proof
We first show that \(f(c) \ge f(d)\) is equivalent to \(\beta _5 \ge \gamma _5\). Note that \(\beta _5 = p_\text {D} = p_1\) and \(\gamma _5 = p_\text {E} + p_\text {F} + p_\text {G} = p_2 + p_3 + p_4\). Now, using Lemma 1 and ignoring lower order terms, we have
Therefore, the claim for \(w=5\) holds by assumption. For \(2 \le w \le 4\), the claims follow immediately from \(f(c) \ge f(d)\) and the symmetry property of Lemma 3:
\(\square\)
We obtain the following two lemmas. If \(\mathcal {A}_L\) uses the entire input sequence (\(d=1\)), this algorithm is (1/3.08)competitive.
Lemma 5
With \(c = 0.23053\) and \(d = 1\) as parameters, we have \({\mathbf{E}}\left[ \mathcal {A}_L\right] \ge \left( \frac{1}{3.08} o(1) \right) {\text {OPT}}_L\).
Note that 2KS includes the secretary problem (case 1); thus, no algorithm for 2KS can have a better competitive ratio than \(1/e < 1/2.71\). In the final algorithm we set \(d<1\) to benefit from \(\mathcal {A}_S\). The next lemma has already been used to prove Theorem 1 in Sect. 3.
Lemma 6
With \(c = 0.42291\) and \(d = 0.64570\) as parameters, we have \({\mathbf{E}}\left[ \mathcal {A}_L\right] \ge \left( \frac{1}{6.65}  o(1) \right) {\text {OPT}}_L\).
Proof (of Lemmas 5 and 6)
Let f be the function defined in Lemma 4 and let \((c_1,d_1) = (0.23053,1)\) and \((c_2,d_2) = (0.42291,0.64570)\) be the two parameter pairs from Lemmas 5 and 6, respectively. It holds that
and
Hence, by Lemma 4 we have \(\beta _w \ge \gamma _w\) for any case \(w \in \{2,3,4,5\}\). Therefore, inequality (15) simplifies to \({\mathbf{E}}\left[ \mathcal {A}_L\right] \ge \min _{w=1,\ldots ,5} \left\{ \alpha _w + \frac{\beta _w + \gamma _w }{2}\right\} \cdot {\text {OPT}}_L\). Using the definitions of \(\alpha _w\), \(\beta _w\), and \(\gamma _w\) from Sect. 4.3, the definitions of \(p_X\) from Table 1, and the symmetry property of Lemma 3, we obtain after simplifying terms
Note that the algorithm attains the same competitive ratio in case 3 and 4, since \(p_{13} = p_{23}\) by Lemma 2. Table 2 shows the competitive ratios for all five cases. For the overall competitive ratio, we have
Evaluating this expression for the parameter pairs \((c_1,d_1)\) and \((c_2,d_2)\) yields \(0.32471 \ge 1/3.08\) and \(0.15039 \ge 1/6.65\) as competitive ratios, respectively. This concludes the proofs of Lemmas 5 and 6. \(\square\)
Recall that in Algorithm 1, we can only benefit from \(\mathcal {A}_S\) if \(\mathcal {A}_L\) has not filled the knapsack completely. Thus, the following property is crucial in the final analysis.
Lemma 7
With a probability of at least c/d, no item is packed by \(\mathcal {A}_L\).
Proof
Fix any set of dn items arriving in rounds \(1,\ldots ,dn\). The most profitable item \(v^*\) from this set arrives in the sampling phase with probability c/d. If this event occurs, no item in rounds \(cn+1,\ldots ,dn\) beats \(v^*\) and \(\mathcal {A}_L\) will not select any item. \(\square\)
Discussion of other 2Secretary Algorithms
As mentioned in the introduction of Sect. 4, the approach and its analysis of this section are general enough to cover all twochoice secretary algorithms. Therefore, a natural question to ask is which algorithm is a good choice within this framework. Algorithm 2 is based on the algorithm singleref developed for the ksecretary problem in [45]. In the following, we discuss several algorithms for 2secretary and related problems.
The optimistic algorithm by Babaioff et al. [34] was developed for the ksecretary problem and performs slightly better than singleref in the case \(k=2\); the competitive ratios of both algorithms are 0.4168 and 0.4119, respectively [45]. However, optimistic has a weaker threshold for accepting the first item than singleref, thus the probability considered in Lemma 7 would fall below c/d. In the present analysis of the sequential approach, we can only benefit from the second algorithm \(\mathcal {A}_S\) if \(\mathcal {A}_S\) starts with an empty knapsack (we will use this property later in Lemma 11). Hence, it is not clear if the slight gain in the expected profit compensates the drawback of an early resource consumption.
A strong algorithm for the 2secretary problem has been developed by Chan et al. [17]. The algorithm is based on a sophisticated set of decision rules, leading to a competitive ratio of 0.49. Again, the probability considered in Lemma 7 would be smaller for this algorithm. Moreover, it seems overly elaborate to find equivalents of Lemmas 1, 2, 4, and 7.
Another candidate algorithm is due to Nikolaev [46] and Tamaki [47] who proposed an algorithm for a slightly different secretary problem: Here, the objective is to maximize the probability of selecting the best two items. This algorithm depends on two parameters \(0 \le c_1 \le c_2 \le 1\). The first item is selected just as in singleref with sampling size \(c_1 n\) (select the first item beating the best sampling item). The second item must beat the first item if it arrives before round \(c_2 n\), or (merely) the best sampling item if it arrives later than this round. The success probability tends asymptotically to 0.2254 with \(c_1 = 0.2291\) and \(c_2=0.6065\), which is best possible [47]. If we use this algorithm within our framework, it turns out that the best competitive ratio is achieved for \(c_1 = c_2\). However, for \(c_1 = c_2\), this algorithm is equal to singleref in the case \(k=2\).
Therefore, we conclude that even though various algorithms for the 2secretary problem stronger than singleref exist, it is not clear if they can improve the performance of the overall algorithm within the sequential framework. On the other side, Algorithm 2 (based on singleref) is fairly easy to analyze and selects highprofit items with sufficient high probability.
Small Items
For (1/3)small items, we use solutions for the fractional problem variant and obtain an integral packing via randomized rounding. This approach has been applied successfully to packing LPs [25]; however, for the knapsack problem it is not required to solve LP relaxations in each round (as in [25]). Instead, here, we use solutions of a greedy algorithm, which is wellknown to be optimal for the fractional knapsack problem. Particularly, this algorithm is both efficient in running time and easy to analyze.
We next formalize the greedy solution for any set T of items. Let the density of an item be the ratio of its profit to its size. Consider any list L containing the items from T ordered by nonincreasing density. We define the rank \(\rho (i)\) of item i as its position in L and \(\sigma (l)\) as the item at position l in L. Thus, \(\sigma (l) = \rho ^{1}(l)\) denotes the lth densest item. Let k be such that \(\sum _{i=1}^{k1} s_{\sigma (i)} < W \le \sum _{i=1}^{k} s_{\sigma (i)}\). The fraction of item i in the greedy solution \(\alpha\) is now defined as
i.e., the \(k1\) densest items are packed integrally and the remaining space is filled by the maximum feasible fraction of the kth densest item. Let \({\text {OPT}}(T)\) and \({\text {OPT}}^*(T)\) denote the profits of optimal integral and fractional packings of T, respectively. It is easy to see that \(\alpha\) satisfies \(\sum _{i \in T} \alpha _i v_i = {\text {OPT}}^*(T) \ge {\text {OPT}}(T)\) and \(\sum _{i \in T} \alpha _i s_i = W\).
Algorithm
The algorithm \(\mathcal {A}_S\) for (1/3)small items, which is formally defined in Algorithm 3, works as follows. During the initial sampling phase of dn rounds, the algorithm rejects all items. In each round \(\ell \ge dn+1\), the algorithm computes a greedy solution \(x^{(\ell )}\) for \(I_S(\ell )\). Here, \(I_S(\ell )\) denotes the subset of \(I_S\) revealed up to round \(\ell\). The algorithm packs the current online item i with probability \(x^{(\ell )}_i\). However, generally, this can only be done if the remaining capacity of the knapsack is at least \((1/3) \cdot W \ge s_i\).
Note that in case of an integral coefficient \(x^{(\ell )}_i \in \{0,1\}\), the packing step is completely deterministic. Moreover, in any greedy solution \(x^{(\ell )}\), there is at most one item i with fractional coefficient \(x^{(\ell )}_i \in (0,1)\). Therefore, in expectation, there is only a small number of rounds where the algorithm actually requests randomness. Although this is not relevant for the proof of the competitive ratio, we provide a short proof of this observation in the following.
Observation 1
Let X denote the number of rounds where Algorithm 3 packs an item with probability \(x_i \in (0,1)\). It holds that \({\mathbf{E}}\left[ X\right] \le \ln (1/d) \le 0.44\).
Proof
Consider any round \(\ell\) and let \(x^{(\ell )}\) be the greedy knapsack solution computed by Algorithm 3. By definition of \(x^{(\ell )}\), at most one of the \(\ell\) visible items has a fractional coefficient \(x^{(\ell )}_i \in (0,1)\). The probability that this item i arrives in round \(\ell\) is \(1/\ell\) in a random permutation. Let \(X_\ell\) be an indicator variable for the event that Algorithm 3 packs an item at random in round \(\ell\). By the above argument, we have \({\mathbf{Pr}}\left[ X_\ell = 1\right] \le 1/\ell\). Since Algorithm 3 selects items starting in round \(dn+1\), we obtain
\(\square\)
Note that Algorithm 2 and the sequential approach (Algorithm 1) are deterministic algorithms. Therefore, our overall algorithm requests randomness in expectation in less than one round.
Analysis
Before we analyze the competitive ratio of \(\mathcal {A}_S\) in a sequence of lemmas, we make a few technical observations and introduce further notation.
In round \(dn+1\), the knapsack might already have been filled by \(\mathcal {A}_L\) with large items from previous rounds. For now, we assume an empty knapsack after round dn and denote this event by \(\xi\). In the final analysis, we will use the fact that \({\mathbf{Pr}}\left[ \xi \right]\) can be bounded from below, which is according to Lemma 7.
The description of Algorithm 3 is tailored to (1/3)small items, in order to complement Algorithm 2. Anyway, it is straightforward to generalize this algorithm to arbitrary maximum item size \(\delta\). In order to show similarities with the analysis from Sect. 6 later, we state the following lemmas with \(\delta\) as a parameter. For this purpose, we define \(\varDelta = \frac{1}{1\delta }\) (and obtain \(\varDelta =3/2\) in the final analysis).
Finally, let \(\alpha\) be a greedy (offline) solution for \(I_S\). By the following lemma, the probability that an item \(i \in I_S\) is packed by \(\mathcal {A}_S\) is proportional to \(\alpha _i\). By treating \(\alpha _i\) as a parameter in the next two lemmas, it is not required to analyze the profit in each round in expectation over all items. The latter approach appears in related work [28], where stochastic dependencies need to be handled carefully.
Lemma 8
Let \(i \in I_S\) and \(E_i(\ell )\) be the event that the item i is packed by \(\mathcal {A}_S\) in round \(\ell\). For \(\ell \ge dn+1\), it holds that \({\mathbf{Pr}}\left[ E_i(\ell ) \mid \xi \right] \ge \frac{1}{n} \alpha _i (1  \varDelta \ln \frac{\ell }{dn})\).
Proof
In a random permutation, item i arrives in round \(\ell\) with probability 1/n. In round \(\ell \ge dn+1\), the algorithm decides to pack i with probability \(x^{(\ell )}_i\). Note that the rank of item i in \(I_S(\ell )\) is less than or equal to its rank in \(I_S\). According to the greedy solution’s definition, this implies \(x^{(\ell )}_i \ge \alpha _i\).
Finally, the \(\delta\)small item i can be packed successfully if the current resource consumption X is at most \((1  \delta ) W\). In the following, we investigate the expectation of X to give a probability bound using Markov’s inequality at the end of this proof.
Let \(X_k\) be the resource consumption in round \(k < \ell\). By assumption, the knapsack is empty after round dn, thus \(X = \sum _{k=dn+1}^{\ell 1} X_k\). Let Q be the set of k visible items in round k. The set Q can be seen as uniformly drawn from all kitem subsets and any item \(j \in Q\) is the current online item of round k with probability 1/k. The algorithm packs any item j with probability \(x_j^{(k)}\), thus
where the last inequality holds because \(x^{(k)}\) is a feasible solution for a knapsack of size W. By the linearity of expectation and the previous inequality, the expected resource consumption up to round \(\ell\) is
Using Markov’s inequality, we obtain
which concludes the proof. \(\square\)
Using Lemma 8 we easily obtain the total probability that a specific item will be packed.
Lemma 9
Let \(i \in I_S\) and \(E_i\) be the event that the item i is packed by \(\mathcal {A}_S\). It holds that \({\mathbf{Pr}}\left[ E_i \mid \xi \right] \ge \alpha _i \left( (1d)(1+\varDelta )  \varDelta \cdot \left( 1 + \frac{1}{n} \right) \cdot \ln \frac{1}{d} \right)\).
Proof
Summing the probabilities from Lemma 8 over all rounds \(\ell \ge dn+1\) gives
By Fact 1B, we obtain
and resolving the integral yields
The claim follows by combining inequalities (16) and (17) and by rearranging terms. \(\square\)
The following lemma bounds the expected profit of the packing of \(\mathcal {A}_S\), assuming the event \(\xi\).
Lemma 10
We have \({\mathbf{E}}\left[ \mathcal {A}_S \mid \xi \right] \ge \left( (1 \! \! d) (1 \!+ \! \varDelta )  \varDelta \cdot \left( 1 \!+ \! \frac{1}{n} \right) \cdot \ln \frac{1}{d} \right) {\text {OPT}}_S\).
Proof
Let \(\beta = (1  d) (1 + \varDelta )  \varDelta \cdot \left( 1 + \frac{1}{n} \right) \cdot \ln \frac{1}{d}\). By Lemma 9, the probability that an item i is packed, assuming \(\xi\), is \({\mathbf{Pr}}\left[ E_i \mid \xi \right] \ge \alpha _i \beta\). Therefore,
\(\square\)
The conditioning on \(\xi\) can be resolved using Lemma 7. We obtain the following lemma, which is the second pillar in the proof of Theorem 1 and concludes this section.
Lemma 11
We have \({\mathbf{E}}\left[ \mathcal {A}_S\right] \ge \frac{c}{d} \left( (1  d) (1 + \varDelta )  \varDelta \cdot \left( 1 + \frac{1}{n} \right) \cdot \ln \frac{1}{d} \right) {\text {OPT}}_S\). In particular, the algorithm \(\mathcal {A}_S\) is (1/6.65)competitive with respect to \({\text {OPT}}_S\) setting \(\varDelta = 3/2\), \(c = 0.42291\), and \(d = 0.64570\).
Proof
By Lemma 7, the probability for an empty knapsack after round dn is \({\mathbf{Pr}}\left[ \xi \right] \ge \frac{c}{d}\). Thus, we obtain from Lemma 10
Setting \(\varDelta = 3/2\), which corresponds to \(\delta =1/3\), leads to
Noting that \(\frac{c}{d} \frac{3}{2n} \ln \frac{1}{d} = o(1)\), we obtain that \({\mathbf{E}}\left[ \mathcal {A}_S\right] \ge \left( \frac{1}{6.65}  o(1) \right) {\text {OPT}}_S\) for \(c = 0.42291\) and \(d = 0.64570\). \(\square\)
Extension to GAP
In this section, we show that the sequential approach introduced in Sect. 3 can be easily adapted to GAP, yielding a (1/6.99)competitive randomized algorithm. We first define the problem formally.
GAP. We are given a set of items \(I = [n]\) and a set of resources \(R = [m]\) of capacities \(W_r \in \mathbb {Q}_{> 0}\) for \(r \in R\). If item \(i \in I\) is assigned to resource \(r \in R\), this raises profit (value) \(v_{i,r} \in \mathbb {Q}_{\ge 0}\), but consumes \(s_{i,r} \in \mathbb {Q}_{> 0}\) of the resource’s capacity. The goal is to assign each item to at most one resource such that the total profit is maximized and no resource exceeds its capacity. We call the tuple \((v_{i,r}, s_{i,r})\) an option of item i and w.l.o.g. assume that options for all resources exist. This can be ensured by introducing dummy options with \(v_{i,r} = 0\). In the online version of the problem, in each round an item is revealed together with its set of options. The online algorithm must decide immediately and irrevocably, if the item is assigned. If so, it has to specify the resource according to one of its options.
Again, we construct restricted instances \(\mathcal {I}_L\) and \(\mathcal {I}_S\) according to the following definition, which generalizes Definition 1. Let \(\delta \in (0,1)\).
Definition 2
We call an option \((v_{i,r}, s_{i,r})\) \(\delta\)large if \(s_{i,r} > \delta W_r\) and \(\delta\)small if \(s_{i,r} \le \delta W_r\). Whenever \(\delta\) is clear from the context, we say an option is large or small for short. Based on a given instance \(\mathcal {I}\) for GAP, we define two modified instances \(\mathcal {I}_L\) and \(\mathcal {I}_S\) which are obtained from \(\mathcal {I}\) as follows.

\(\mathcal {I}_L\): Replace each small option \((v_{i,r}, s_{i,r})\) by the large option \((0,W_r)\).

\(\mathcal {I}_S\): Replace each large option \((v_{i,r}, s_{i,r})\) by the small option \((0, \delta W_r)\).
Thus, \(\mathcal {I}_L\) only contains large options and \(\mathcal {I}_S\) only contains small options. However, by construction no algorithm will assign an item according to a zeroprofit option. We define \({\text {OPT}}\), \({\text {OPT}}_L\), and \({\text {OPT}}_S\) accordingly. Note that the inequality \({\text {OPT}}\le {\text {OPT}}_L + {\text {OPT}}_S\) holds also for GAP.
The sequential framework of Algorithm 1 can be adapted in a straightforward manner by replacing terms like packing with assignment to resource r. Here, we set the threshold parameter to \(\delta =1/2\). In the following subsections, we specify algorithms \(\mathcal {A}_L\) and \(\mathcal {A}_S\) for (1/2)large and (1/2)small options, respectively.
Large Options
If each item consumes more than one half of a resource, no two items can be assigned to this resource. Thus, we obtain the following matching problem.
Edgeweighted bipartite matching. Given a bipartite graph \(G=(L \cup R, E)\) and a weighting function \(w :E \rightarrow \mathbb {Q}_{\ge 0}\), the goal is to find a bipartite matching \(M \subseteq E\) such that \(w(M) := \sum _{e \in M} w(e)\) is maximal. In the online version, the (offline) nodes from R and the number \(n=L\) are known in advance, whereas the nodes from L are revealed online together with their incident edges. In the case of GAP, L is the set of items, R is the set of resources, and the weight of an edge \(e=\{l,r\}\) is \(w(e)=v_{l,r}\).
Kesselheim et al. [28] developed an optimal (1/e)competitive algorithm for the online problem under random arrival order. Adapting this algorithm to the sequential approach with parameters c and d leads to the following algorithm \(\mathcal {A}_L\): During the first cn rounds, no edge is added to the matching. Then, in each round \(\ell\), the algorithm computes a maximum edgeweighted matching \(M^{(\ell )}\) for the graph revealed up to this round. Let \(l \in L\) be the online vertex of round \(\ell\). If l is matched in \(M^{(\ell )}\) to some node \(r \in R\), we call \(e^{(\ell )} = \{l,r\}\) the tentative edge of round \(\ell\). Now, if r is still unmatched and \(\ell \le dn\), the tentative edge is added to the matching.
A formal description of this algorithm is given in Algorithm 4. The proof of the approximation guarantee relies mainly on the following two lemmas; for completeness, we give the proofs from [28] here. The first lemma shows that the expected weight of any tentative edge can be bounded from below.
Lemma 12
( [28]) In any round \(\ell\), the tentative edge (if it exists) has expected weight \({\mathbf{E}}\left[ w(e^{(\ell )})\right] \ge \frac{1}{n} {\text {OPT}}_L\).
Proof
We use the fact that the random sequence of visible items in round \(\ell\) can be obtained from the following process: First, the set Q of visible items in round \(\ell\) is drawn uniformly at random from all \(\ell\)element subsets of L. Then, the online vertex of round \(\ell\) is drawn uniformly at random from Q. Note that these random experiments are independent.
After the first step, the matching \(M^{(\ell )}\) is already fixed. Let \(M^* = M^{(n)}\) be a maximum weight (offline) matching and \(M^*_Q = \{e = \{l,r\} \in M^* \mid l \in Q\}\) the matching \(M^*\) projected to visible nodes. We have \(w(M^{(\ell )}) \ge w(M^*_Q)\), since \(M^{(\ell )}\) is an optimal and \(M^*_Q\) a feasible matching for the graph revealed in round \(\ell\). As described above, each vertex \(l \in L\) has probability \(\ell /n\) to be in Q, thus
For the second step, we observe that each vertex from Q has the same probability of \(1/\ell\) to arrive in round \(\ell\). Let \(\mathcal {M}\) be the domain of the random variable \(M^{(\ell )}\). We have
Combining (19) and (18) concludes the proof. \(\square\)
However, we only gain the weight of the tentative edge \(e^{(\ell )} = \{l,r\}\) if it can be added to the matching, i.e., if r has not been matched previously. The next lemma bounds the probability for this event from below.
Lemma 13
( [28]) Let \(\xi (r,\ell )\) be the event that the offline vertex \(r \in R\) is unmatched after round \(\ell \ge cn+1\). It holds that \({\mathbf{Pr}}\left[ \xi (r,\ell )\right] \ge \frac{cn}{\ell }\).
Proof
In each round k, the vertex r can only be matched if it is incident to the tentative edge \(e^{(k)} \in M^{(k)}\) of this round, i.e., \(e^{(k)} = \{l,r\}\) where \(l \in L\) is the online vertex of round k. As l can be seen as uniformly drawn among all k visible nodes (particularly, independent of the order of the previous \(k1\) items), l has probability 1/k to arrive in round k. Consequently, r is not matched in round k with probability \(1 1/k\). This argument applies to all rounds \(cn+1,\ldots ,\ell\). Therefore,
\(\square\)
Using Lemmas 12 and 13, we can bound the competitive ratio of \(\mathcal {A}_L\) in the following lemma. Note that we obtain the optimal (1/e)competitive algorithm from [28] for \(c=1/e\) and \(d=1\).
Lemma 14
It holds that \({\mathbf{E}}\left[ \mathcal {A}_L\right] \ge \left( c \ln \frac{d}{c}  o(1) \right) {\text {OPT}}_L\).
Proof
Let \(A_\ell\) be the gain of the matching weight in round \(\ell\). As the tentative edge \(e^{(\ell )} = \{l,r\}\) can only be added if r has not been matched in a previous round, we have \({\mathbf{E}}\left[ A_\ell \right] = {\mathbf{E}}\left[ w(e^{(\ell )})\right] {\mathbf{Pr}}\left[ \xi (r,\ell )\right]\) for the event \(\xi (r,\ell )\) from Lemma 13. Therefore, from Lemmas 12 and 13, we have \({\mathbf{E}}\left[ A_\ell \right] \ge \frac{1}{n} {\text {OPT}}_L \frac{cn}{\ell } = \frac{c}{\ell } {\text {OPT}}_L\). Summing over all rounds from \(cn+1\) to dn yields
The last inequality follows from \(\sum _{\ell =cn+1}^{dn} \frac{1}{\ell } = \left( \sum _{\ell =cn}^{dn1} \frac{1}{\ell } \right)  \frac{1}{cn} + \frac{1}{dn}\) and, according to Fact 1A, \(\sum _{\ell =cn}^{dn1} \frac{1}{\ell } \ge \int _{cn}^{dn} \frac{1}{\ell } ~\mathrm {d} {\ell }~ = \ln \frac{d}{c}\). \(\square\)
Small Options
For small options, we use the LPbased algorithm from [25, Sec. 3.3] and analyze it within our algorithmic framework. In order to make this paper selfcontained, we give a linear program for fractional GAP (LP 1), the algorithm, and its corresponding proofs.
Let \(\mathcal {A}_S\) be Algorithm 5. After a sampling phase of dn rounds, in each round \(\ell\), the algorithm computes an optimal solution \(x^{(\ell )}\) of LP 1 for \(I_S(\ell )\). Here, \(I_S(\ell )\) denotes the instance of small options revealed so far. Now, the decision to which resource the current online item i is assigned, if at all, is made at random using \(x^{(\ell )}\): Resource \(r \in R\) is chosen with probability \(x^{(\ell )}_{i,r}\) and the item stays unassigned with probability \(1  \sum _{r \in R} x^{(\ell )}_{i,r}\). Note that the item can only be assigned to the chosen resource if its remaining capacity is at least \((1/2) \cdot W_r\).
To analyze Algorithm 5, we consider the gain of profit in round \(\ell \ge dn+1\), denoted by \(A_\ell\). For this purpose, let \(i^{(\ell )}\) be the item of that round and \(r^{(\ell )}\) the resource chosen by the algorithm. Now, it holds that \({\mathbf{E}}\left[ A_\ell \right] = {\mathbf{E}}\left[ v_{i^{(\ell )},r^{(\ell )}}\right] \cdot {\mathbf{Pr}}\left[ i^{(\ell )}\text { can be assigned to }r^{(\ell )}\right]\), where in the first term, the expectation is over the item arriving in round \(\ell\) and the resource chosen by the algorithm. The latter term only depends on the resource consumption of \(r^{(\ell )}\) in earlier rounds. In the next two lemmas, we give lower bounds for both terms. As in the proofs of Sect. 6.1, it is helpful to construct the random permutation of the first \(\ell\) items in two independent steps: First, the set of \(\ell\) visible items is drawn uniformly, without determining the order of items. Second, the online item arriving in round \(\ell\) is drawn uniformly from this set.
Lemma 15
( [25, Sec. 3.3]) For any round \(\ell \ge dn+1\), we have \({\mathbf{E}}\left[ v_{i^{(\ell )},r^{(\ell )}}\right] \ge \frac{1}{n} {\text {OPT}}_S\).
Proof
The proof is similar to the proof of Lemma 12. As we consider a fixed round \(\ell\), we write i and r instead of \(i^{(\ell )}\) and \(r^{(\ell )}\) for ease of presentation. Further, we write \(v(\alpha ) := \sum _{j \in I_S} \sum _{s \in R} \alpha _{j,s} v_{j,s}\) for the profit of a fractional assignment \(\alpha\).
First, the set of visible items Q in round \(\ell\) is drawn uniformly at random among all subsets of \(\ell\) items. Let \(x^{(n)}\) be an optimal (offline) solution to LP 1 and let \(x^{(n)}_Q\) denote the restriction of \(x^{(n)}\) to the items in Q, i.e., \((x^{(n)}_Q)_{j,s} = x^{(n)}_{j,s}\) if \(j \in Q\) and \((x^{(n)}_Q)_{j,s} = 0\) if \(j \notin Q\). Since \(x^{(n)}_Q\) is a feasible and \(x^{(\ell )}\) is an optimal solution for Q, we have \({\mathbf{E}}\left[ v(x^{(\ell )})\right] \ge {\mathbf{E}}\left[ v(x^{(n)}\mid _Q)\right]\).
As each item has the same probability of \(\ell /n\) to be in Q, it holds that
In the second step, the online item of round \(\ell\) is determined by choosing one item from Q uniformly at random. Let \(\mathcal {X}\) be the domain of \(x^{(\ell )}\) and \(x' \in \mathcal {X}\). We have
where we used that each item from Q arrives in round \(\ell\) with probability \(1/\ell\) and the algorithm assigns item j to resource s with probability \(x'_{j,s}\), given \(x^{(\ell )} = x'\). By the law of total expectation, it follows that \({\mathbf{E}}\left[ v_{i,r}\right] = \frac{1}{\ell } {\mathbf{E}}\left[ v(x^{(\ell )})\right]\). Combining with (20) gives the claim. \(\square\)
Hence, by the previous lemma, the expected gain of profit in each round is at least a (1/n)fraction of \({\text {OPT}}_S\), supposing the remaining resource capacity is large enough. The probability for the latter event is considered in the following lemma. Here, a crucial property is that we deal with \(\delta\)small options. As in Sect. 5.2, we define \(\varDelta =\frac{1}{1\delta }\).
Lemma 16
For any round \(\ell \ge dn+1\), it holds that
Proof
Let \(\xi\) be the event that no item is assigned to r after round dn. Note that \(\xi\) does not necessarily hold, since \(\mathcal {A}_L\) might already have assigned items to r in earlier rounds. By Lemma 13, \({\mathbf{Pr}}\left[ \xi \right] \ge \frac{c}{d}\). Therefore, it is sufficient to show \({\mathbf{Pr}}\left[ i^{(\ell )}\text { can be assigned to }r^{(\ell )} \mid \xi \right] \ge 1  \varDelta \ln \frac{\ell }{dn}\).
For this purpose, assume that \(\xi\) holds and let X denote the resource consumption of r after round \(\ell  1\). Further, let \(X_k\) be the resource consumption of r in round \(k < \ell\). We have \(X = \sum _{k=dn+1}^{\ell 1} X_k\). Let Q be the set of k visible items in round k. The set Q can be seen as uniformly drawn from all kitem subsets and any item \(j \in Q\) is the current online item of round k with probability 1/k. Now, the algorithm assigns any item j to resource r with probability \(x_{j,r}^{(k)}\), thus
where the last inequality follows from the capacity constraint for resource r in LP 1. By linearity of expectation and inequality (22), the expected resource consumption up to round \(\ell\) is thus
Now, since \(i^{(\ell )}\) is \(\delta\)small, \(X < (1\delta ) W_r\) implies \(X + s_{i^{(\ell )},r^{(\ell )}} \le W_r\), in which case the assignment is feasible. Using (23) and Markov’s inequality, we obtain
\(\square\)
The next lemma finally gives the competitive ratio of \(\mathcal {A}_S\).
Lemma 17
It holds that
Proof
We add the expected profits in single rounds using Lemmas 15 and 16.
Since \(\frac{\ell }{dn}\) is monotonically increasing in \(\ell\), we have
by Fact 1B. The integral \(\int _{dn}^{n} \ln \frac{\ell }{dn} ~\mathrm {d} {\ell }~\) evaluates to \(n \cdot \left( \ln \frac{1}{d}  1 + d \right)\), so combining the previous inequalities yields
Note that we obtain the same competitive ratio as in Lemma 11. \(\square\)
Remark
The setting of large capacities (compared to the respective resource demands) has been addressed in several papers [8, 12, 43]. For instance, such settings arise in online auctions, where the budgets are very high compared to single bids. Although the algorithm \(\mathcal {A}_S\) is not tailored for this setting, a corresponding bound can be obtained easily from Lemma 17. Setting \(c=d\) clearly maximizes the performance of \(\mathcal {A}_S\) with respect to \({\text {OPT}}_S\), thus the factor c/d vanishes. Assuming that the maximum resource demand is \(\delta \rightarrow 0\), the competitive ratio of \(\mathcal {A}_S\) tends to \(2 (1d)  \ln \frac{1}{d}\), since \(\varDelta \rightarrow 1\). This function is maximized for \(d=1/2\), yielding a competitive ratio of \(1  \ln (2) \ge 0.3068\).
Proof of Theorem 2
Finally, we prove our main theorem for GAP.
Proof (of Theorem 2)
We set the threshold between large and small options to \(\delta = 1/2\) and consider Algorithm 1 with the algorithms \(\mathcal {A}_L\) and \(\mathcal {A}_S\) as defined previously. By Lemma 14, the expected gain of profit in rounds \(cn+1,\ldots ,dn\) is \({\mathbf{E}}[ \mathcal {A}_L] \ge \left( c \ln \frac{d}{c}  o(1) \right) { {\rm OPT}}_L\). In the following rounds, we gain
according to Lemma 17 (with \(\varDelta = 2\)). Setting \(c=0.5261\) and \(d=0.6906\) gives \(c \ln \frac{d}{c} \approx \frac{c}{d} \left( 3 (1d)  2 \ln \frac{1}{d}\right)\) and thus, using \({\text {OPT}}_L + {\text {OPT}}_S \ge {\text {OPT}}\),
\(\square\)
Notes
 1.
Let \(a_1 \ge a_2 \ge \ldots \ge a_n\) and \(b_1 \ge b_2 \ge \ldots \ge b_n\). Chebyshev’s sum inequality states that \(\sum _{i=1}^{n} a_i b_i \ge (1/n) \left( \sum _{i=1}^{n} a_i\right) \left( \sum _{i=1}^{n} b_i\right)\).
References
 1.
Kellerer, H., Pferschy, U., Pisinger, D.: Knapsack Problems. Springer, Berlin (2004)
 2.
Martello, S., Toth, P.: Knapsack Problems: Algorithms and Computer Implementations. Wiley, New York (1990)
 3.
Christensen, H.I., Khan, A., Pokutta, S., Tetali, P.: Approximation and online algorithms for multidimensional bin packing: a survey. Comput. Sci. Rev. 24, 63–79 (2017)
 4.
Gálvez, W., Grandoni, F., Heydrich, S., Ingala, S., Khan, A., Wiese, A.: Approximating geometric knapsack via Lpackings. In: Proceedings of 58th IEEE annual symposium on foundations of computer science (FOCS), pp. 260–271 (2017)
 5.
Chekuri, C., Khanna, S.: A polynomial time approximation scheme for the multiple knapsack problem. SIAM J. Comput. (SICOMP) 35(3), 713–728 (2005)
 6.
Khuller, S., Mitchell, S.G., Vazirani, V.V.: Online algorithms for weighted bipartite matching and stable marriages. Theor. Comput. Sci. 127(2), 255–267 (1994)
 7.
Mehta, A., Saberi, A., Vazirani, U.V., Vazirani, V.V.: Adwords and generalized online matching. J. ACM 54(5), 22 (2007)
 8.
Feldman, J., Korula, N., Mirrokni, V.S., Muthukrishnan, S., Pál, M.: Online ad assignment with free disposal. In: Proceedings of 5th international workshop internet and network economics (WINE), pp 374–385 (2009)
 9.
Cattrysse, D.G., Wassenhove, L.N.V.: A survey of algorithms for the generalized assignment problem. Eur. J. Oper. Res. 60(3), 260–272 (1992)
 10.
Öncan, T.: A survey of the generalized assignment problem and its applications. Inf. Syst. Oper. Res. INFOR 45(3), 123–141 (2007)
 11.
Borgs, C., Chayes, J.T., Immorlica, N., Jain, K., Etesami, O., Mahdian, M.: Dynamics of bid optimization in online advertisement auctions. In: Proceedings of 16th International Conference on World Wide Web (WWW), pp 531–540 (2007)
 12.
Zhou, Y., Chakrabarty, D., Lukose, R.M.: Budget constrained bidding in keyword auctions and online knapsack problems. In: Proceedings 4th international workshop internet and network economics (WINE), pp 566–576 (2008)
 13.
Dynkin, E.B.: The optimum choice of the instant for stopping a Markov process. Sov. Math. 4, 627–629 (1963)
 14.
Lindley, D.V.: Dynamic programming and decision theory. Appl. Stat. 10, 39–51 (1961)
 15.
Babaioff, M., Immorlica, N., Kempe, D., Kleinberg, R.: Matroid secretary problems. J. ACM 65(6), 35:135:26 (2018)
 16.
Feldman, M., Svensson, O., Zenklusen, R.: A simple O(log log(rank))competitive algorithm for the matroid secretary problem. Math. Oper. Res. 43(2), 638–650 (2018)
 17.
Chan, T.H., Chen, F., Jiang, S.H.: Revealing optimal thresholds for generalized secretary problem via continuous LP: impacts on online Kitem auction and bipartite Kmatching with random arrival order. In: Proceedings of 26th annual ACMsiam symposium on discrete algorithms (SODA), pp 1169–1188 (2015)
 18.
Kleinberg, R.D.: A multiplechoice secretary algorithm with applications to online auctions. In: Proceedings of 16th Annual ACMSIAM symposium on discrete algorithms (SODA), pp 630–631 (2005)
 19.
Albers, S., Janke, M.: Scheduling in the randomorder model. In: Proceedings of 47th international colloquium on automata, languages, and programming, (ICALP) 2020, pp 68:1–68:18 (2020)
 20.
Göbel, O., Kesselheim, T., Tönnis, A.: Online appointment scheduling in the random order model. In: Proceedings 23rd annual European symposium on algorithms (ESA), pp 680–692 (2015)
 21.
Molinaro, M.: Online and randomorder load balancing simultaneously. In: P.N. Klein (ed.) Proceedings 28th annual ACMSIAM symposium on discrete algorithms (SODA). SIAM. pp 1638–1650 (2017)
 22.
Agrawal, S., Wang, Z., Ye, Y.: A dynamic nearoptimal algorithm for online linear programming. Oper. Res. 62(4), 876–890 (2014)
 23.
Feldman, J., Henzinger, M., Korula, N., Mirrokni, V.S., Stein, C.: Online stochastic packing applied to display ad allocation. In: Proceedings 18th annual european symposium on algorithms (ESA), pp 182–194 (2010)
 24.
Kenyon, C.: Bestfit binpacking with random order. In: Proceedings of 7th annual ACMSIAM symposium on discrete algorithms (SODA), pp 359–364 (1996)
 25.
Kesselheim, T., Radke, K., Tönnis, A., Vöcking, B.: Primal beats dual on online packing LPs in the randomorder model. SIAM J. Comput. 47(5), 1939–1964 (2018)
 26.
Molinaro, M., Ravi, R.: The geometry of online packing linear programs. Math. Oper. Res. 39(1), 46–59 (2014)
 27.
Bahmani, B., Mehta, A., Motwani, R.: A 1.43competitive online graph edge coloring algorithm in the random order arrival model. In: Proceedings of 21st annual ACMSIAM symposium on discrete algorithms (SODA), pp 31–39 (2010)
 28.
Kesselheim, T., Radke, K., Tönnis, A., Vöcking, B.: An optimal online algorithm for weighted bipartite matching and extensions to combinatorial auctions. In: Proceedings of 21st annual European symposium on algorithms (ESA), pp 589–600 (2013)
 29.
Mahdian, M., Yan, Q.: Online bipartite matching with random arrivals: an approach based on strongly factorrevealing lps. In: Proceedings of 43rd annual ACM symposium on theory of computing (STOC), pp 597–606 (2011)
 30.
Meyerson, A.: Online facility location. In: Proceedings of 42nd IEEE annual symposium on foundations of computer science (FOCS), pp 426–431 (2001)
 31.
Mirrokni, V.S., Gharan, S.O., Zadimoghaddam, M.: Simultaneous approximations for adversarial and stochastic online budgeted allocation. In: Proceedings of 23rd annual ACMSIAM symposium on discrete algorithms (SODA), pp 1690–1701 (2012)
 32.
Korula, N., Mirrokni, V.S., Zadimoghaddam, M.: Online submodular welfare maximization: greedy beats 1/2 in random order. SIAM J. Comput. 47(3), 1056–1086 (2018)
 33.
MarchettiSpaccamela, A., Vercellis, C.: Stochastic online knapsack problems. Math. Progr. 68, 73–104 (1995)
 34.
Babaioff, M., Immorlica, N., Kempe, D., Kleinberg, R.: A knapsack secretary problem with applications. In: Proceedings of 10th international workshop on approximation, randomization, and combinatorial optimization and 11th international workshop on randomization and computation (APPROX/RANDOM), pp 16–28 (2007)
 35.
Vaze, R.: Online knapsack problem and budgeted truthful bipartite matching. Proc. IEEE Conf. Comput. Commun. (INFOCOM) 2017, 1–9 (2017)
 36.
Lueker, G.S.: Averagecase analysis of offline and online knapsack problems. J. Algorithms 29(2), 277–305 (1998)
 37.
Han, X., Kawase, Y., Makino, K.: Randomized algorithms for online knapsack problems. Theor. Comput. Sci. 562, 395–405 (2015)
 38.
Iwama, K., Taketomi, S.: Removable online knapsack problems. In: Proceedings of 29th international colloquium on automata, languages and programming (ICALP), pp 293–305 (2002)
 39.
Babaioff, M., Hartline, J., Kleinberg, R.: Selling banner ads: online algorithms with buyback. In: Fourth workshop on ad auctions (2008)
 40.
Babaioff, M., Hartline, J.D., Kleinberg, R.D.: Selling ad campaigns: online algorithms with cancellations. In: Proceedings of 10th ACM conference on electronic commerce (EC), pp 61–70 (2009)
 41.
Han, X., Kawase, Y., Makino, K.: Online unweighted knapsack problem with removal cost. Algorithmica 70(1), 76–91 (2014)
 42.
Vaze, R.: Online knapsack problem under expected capacity constraint. Proc. IEEE Conf. Comput. Commun. (INFOCOM) 2018, 2159–2167 (2018)
 43.
Alaei, S., Hajiaghayi, M., Liaghat, V.: The online stochastic generalized assignment problem. In: Proceedings of 16th international workshop on approximation, randomization, and combinatorial optimization and 17th international workshop on randomization and computation (APPROX/RANDOM), pp 11–25 (2013)
 44.
Buchbinder, N., Naor, J.: Online primaldual algorithms for covering and packing. Math. Oper. Res. 34(2), 270–286 (2009)
 45.
Albers, S., Ladewig, L.: New results for the ksecretary problem. In: Proceedings of 30th international symposium on algorithms and computation (ISAAC), pp 18:1–18:19 (2019)
 46.
Nikolaev, M.: On a generalization of the best choice problem. Theory Probab. Appl. 22(1), 187–190 (1977)
 47.
Tamaki, M.: Recognizing both the maximum and the second maximum of a sequence. J. Appl. Prob. 16(4), 803–812 (1979)
Acknowledgements
We thank the anonymous reviewers for many valuable comments on an earlier version of this manuscript.
Funding
Open Access funding enabled and organized by Projekt DEAL.
Author information
Affiliations
Corresponding author
Additional information
Publisher's Note
Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.
Work supported by the European Research Council, Grant Agreement No. 691672. A preliminary version of this paper appeared in 22nd International Conference on Approximation Algorithms for Combinatorial Optimization Problems (APPROX 2019).
Arindam Khan: A part of this work was done when the author was at Technical University of Munich.
Rights and permissions
Open Access This article is licensed under a Creative Commons Attribution 4.0 International License, which permits use, sharing, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons licence, and indicate if changes were made. The images or other third party material in this article are included in the article's Creative Commons licence, unless indicated otherwise in a credit line to the material. If material is not included in the article's Creative Commons licence and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder. To view a copy of this licence, visit http://creativecommons.org/licenses/by/4.0/.
About this article
Cite this article
Albers, S., Khan, A. & Ladewig, L. Improved Online Algorithms for Knapsack and GAP in the Random Order Model. Algorithmica 83, 1750–1785 (2021). https://doi.org/10.1007/s00453021008012
Received:
Accepted:
Published:
Issue Date:
Keywords
 Online algorithms
 Random order model
 Packing problems