Abstract
In this paper, we study the online unweighted knapsack problem with removal cost. The input is a sequence of items u 1,u 2,…,u n , each of which has a size and a value, where the value of each item is assumed to be equal to the size. Given the ith item u i , we either put u i into the knapsack or reject it with no cost. When u i is put into the knapsack, some items in the knapsack are removed with removal cost if the sum of the size of u i and the total size in the current knapsack exceeds the capacity of the knapsack. Here the removal cost means a cancellation charge or disposal fee. Our goal is to maximize the profit, i.e., the sum of the values of items in the last knapsack minus the total removal cost occurred.
In this paper, we consider two kinds of removal cost: unit and proportional cost. For both models, we provide their competitive ratios. Namely, we construct optimal online algorithms and prove that they are best possible.
Similar content being viewed by others
Avoid common mistakes on your manuscript.
1 Introduction
The knapsack problem is one of the most classical problems in combinatorial optimization and has a lot of applications in the real world [11]. The knapsack problem is that: given a set of items with values and sizes, we are asked to maximize the total value of selected items in the knapsack satisfying the capacity constraint.
In this paper, we study the online version of the unweighted knapsack problem with removal cost. Here, “online” means (i) the information of the input (i.e., the items) is given gradually, i.e., after a decision is made on the current item, the next item is given; (ii) the decisions we have made are irrevocable, i.e., once a decision has been made, it cannot be changed. Given the ith item u i , we either accept u i (i.e., put u i into the knapsack) or reject it with no cost. When u i is put into the knapsack, some items in the knapsack are removed with removal cost if the sum of the size of u i and the total size in the current knapsack exceeds 1, i.e., the capacity of the knapsack. Here the removal cost means a cancellation charge or disposal fee. Our goal is to maximize the profit, i.e., the sum of the values of items in the last knapsack minus the total removal cost occurred.
1.1 Related Works
The online knapsack problem (under no removal condition) was first studied on average case analysis by Marchetti-Spaccamela and Vercellis [13]. They proposed a linear time approximation algorithm such that the expected difference between the optimal profit and the one obtained by the algorithm is O(log3/2 n) under the condition that the capacity of the knapsack grows proportionally to the number of items n. Lueker [12] improved the expected difference to O(logn) under a fairly general condition on the distribution.
Iwama and Taketomi [9] studied the online knapsack problem on worst case analysis. They obtained a \(\frac{1+\sqrt{5}}{2}\approx1.618\)-competitive algorithm for the online knapsack when (a) the removable condition (without removal cost) is allowed and (b) the value of each item is equal to the size (unweighted), and showed that this is best possible by providing a lower bound 1.618 for the case. We remark that the problem has unbounded competitive ratio, if at least one of the conditions (a) and (b) is not satisfied [9, 10]. For other models such as minimum knapsack problem and knapsack problem with limited cuts, refer to papers in [7, 8, 14].
The concept of removal costs was introduced in the buyback problem [1–6]. In the problem, we observe a sequence of bids and decide whether to accept each bid at the moment it arrives, subject to constraints on accepted bids such as single item and matroid constraints. Decisions to reject bids are irrevocable, whereas decisions to accept bids may be canceled at a cost which is a fixed fraction of the bid value. Babaioff et al. [3] showed that the buyback problem with matroid constraint has \((1+2f+2\sqrt{f(1+f)} )\)-competitive ratio, where f>0 is a buyback factor. Ashwinkumar [1] extended their results and show that the buyback problem with the constraint of k matroid intersections has \(k(1+f)(1+\sqrt{1-\frac{1}{k(1+f)}})^{2}\)-competitive ratio. Babaioff et al. [3, 4] also studied the buyback problem with (weighted) knapsack constraints. They show that if the largest item is of size at most γ, where 0<γ<1/2, then the competitive ratio is \((1+2f+2\sqrt{f(1+f)})/(1-2\gamma)\).
1.2 Our Results
In this paper, we study the worst case analysis of the online unweighted knapsack problem with removal cost. We consider two kinds of models of removal cost:the proportional and the unit cost models. In the proportional cost model, the removal cost of each item u i is proportional to its value (and hence size), i.e., it is f⋅s(u i ), where s(u i ) denotes the size of u i and f>0 is a fixed constant, called buyback factor. Therefore, we can view this model as the buyback problem with knapsack constraints. In the unit cost model, the removal cost of each item is a fixed constant c>0, where we assume that every item has value at least c, since in many applications, the removal cost (i.e., cancellation charge) is not higher than its value. We remark that the problem has unbounded competitive ratio if no such assumption is satisfied (see Sect. 3).
We show that the proportional and unit cost models have competitive ratios λ(f) and μ(c) in (1) and (2), respectively, where λ(f) and μ(c) are given in Figs. 1 and 2. Namely, we construct λ(f)- and μ(c)-competitive algorithms for the models and prove that they are best possible.
where
The main ideas of our algorithms for both models are:
-
We may reject items (with no cost) many times, but in at most one round, we remove items which from the knapsack.
-
Some items are removed from the knapsack, only when the total value in the resulting knapsack gets high enough to guarantee the optimal competitive ratio.
The rest of the paper is organized as follows. In the next section, we consider the proportional cost model, and in Sect. 3, we consider the unit cost model.
2 Proportional Cost Model
In this section, we consider the proportional cost model, where each item u i has removal cost f⋅s(u i ) for some positive constant f. We first show that λ(f) is a lower bound of the competitive ratio of the problem, and then propose a λ(f)-competitive algorithm, where λ(f) is given in (1).
2.1 Lower Bound
In this subsection, we show a lower bound of the competitive ratio λ(f) for the problem.
Theorem 1
There is no online algorithm with competitive ratio less than λ(f) for the online unweighted knapsack problem with proportional removal cost.
Proof
According to the value of f, we separately consider the following two cases.
Case 1: 1/2≥f>0. Let A denote an online algorithm chosen arbitrarily. For a sufficiently small ε(>0), our adversary (see Fig. 3) requests the sequence of items whose sizes are
until A rejects some item in (4). If A rejects the item with size \(\frac{1}{2}+\varepsilon\), then the adversary stops the input sequence. On the other hand, if it rejects the item with size \(\frac{1}{2}+\frac {\varepsilon}{k}\) for some k>1, then the adversary requests an item with size \(\frac{1}{2}-\frac {\varepsilon}{k}\) and stops the input sequence.
We first note that algorithm A must take the first item, since otherwise the competitive ratio of A becomes infinite. After the first round, A always keeps exactly one item in the knapsack, since all the items in (4) have size larger than \(\frac {1}{2}\) (i.e., a half of the knapsack capacity) and for any j<k we have \((\frac{1}{2}+\frac{\varepsilon}{j})+ (\frac{1}{2}-\frac{\varepsilon }{k}) \) is larger than 1. This implies that A removes the old item from the knapsack to accept a new item. If A rejects \(\frac{1}{2}+\frac{\varepsilon}{k}\) for some k>1, the competitive ratio is at least \(1/ (\frac{1}{2}+\frac{\varepsilon }{k} )\), which approaches 2(=λ(f)) as ε→0. Finally, if A rejects no item in (4), then its profit is
while the optimal profit for the offline problem is \(\frac{1}{2}+ \varepsilon\), which completes the proof for 1/2≥f>0.
Case 2: f>1/2. Let A denote an online algorithm chosen arbitrarily, and let \(x=\frac{3+f-\sqrt{f^{2}+2f+5}}{2(1+f)}\). For a sufficiently small ε(>0), our adversary requests the following sequence of items
until A rejects some item in (6), and if A rejects the item then the adversary immediately stops the input sequence. We remark that x<1/3 for f>1/2, and the second and third items do not fit in the knapsack together.
Note that A must accept the first item x, since otherwise the competitive ratio becomes infinite. If A rejects the second item, then the competitive ratio is at least
If A takes the second item 1−x+ε (and removes the first item), the competitive ratio is at least \(\frac{1}{1-x+\varepsilon-f\cdot x}\) since the second and third items do not in the knapsack together, which approaches to \(\lambda(f)(= \frac{1}{1-x-f\cdot x})\) as ε→0, which completes the proof for f>1/2. □
2.2 Upper Bound
In this subsection, we show Algorithm 1 is λ(f)-competitive for the problem. Note that the total profit becomes small (even negative), if we remove many items from the knapsack. Intuitively, our algorithm accepts the new item if the knapsack has room to put it. If we can make the profit sufficiently high by accepting the item and removing some items from the current knapsack, then our algorithm follows this, and after this iteration, it rejects all the items. Otherwise, the algorithm simply rejects the item.
Let u i be the item given in the ith round. Define by B i−1 the set of items in the knapsack at the beginning of ith round, and by s(B i−1) the total size in B i−1.
Lemma 2
If s(B i−1)+s(u i )>1 and some \(B_{i-1}'\subseteq B_{i-1}\) satisfies \(\lambda(f)\cdot s(B_{i-1})< s(B_{i-1}')+s(u_{i})\le1\), then the sixth line of Algorithm 1 is executed in the i th round.
Proof
Since s(B i−1)+s(u i )>1 and \(\lambda(f)\cdot s(B_{i-1})< s(B_{i-1}')+s(u_{i})\), we obtain
As λ 2(f)≥1+fλ(f)+λ(f) by the definition of λ(f), we have
□
Let OPT denote an optimal solution for the offline problem whose input sequence is u 1,…,u i .
Lemma 3
If s(B i )<1/λ(f) then we have |OPT∖B i |≤1.
Proof
B i contains all the items smaller than 1/2 seen so far, since s(B i )<1/λ(f)≤1/2. Any item u∈OPT∖B i has size greater than 1−1/λ(f)≥1/2. Therefore, |OPT∖B i |≤1 holds by s(OPT)≤1. □
Theorem 4
The online Algorithm 1 is λ(f)-competitive.
Proof
Suppose that the sixth line is executed in round k. Then it holds that \(\frac{1}{\lambda(f)}+f\cdot (s(B_{k-1})-s(B_{k-1}'))< s(B_{k-1}')+s(u_{k})=s(B_{k})\). Since s(B i )=s(B k ) holds for all i≥k, we have
We next assume that the sixth line has never been executed. If s(B i )≥1/λ(f), we have the competitive ratio s(OPT)/s(B i )≤1/s(B i )≤λ(f). On the other hand, if s(B i )<1/λ(f), |OPT∖B i |=0 or 1 holds by Lemma 3. If |OPT∖B i |=0, we obtain the competitive ratio 1. Otherwise (i.e., OPT∖B i ={u l } for some l), Lemma 2 implies that \(\lambda(f)\cdot s(B_{l-1})\ge s(B_{l-1}')+s(u_{l})\) for \(B_{l-1}'=\mathrm {OPT}\cap B_{l-1}\). Therefore we obtain
□
Before concluding this section, we remark that the condition in the sixth line can be checked efficiently.
Proposition 5
We can check the condition in the sixth line in \(O(|B_{i-1}|+2^{\lambda ^{2}(f)})\) time.
Proof
Let \(x=\frac{1}{1+f} (\frac{1}{\lambda(f)}+f s(B_{i-1})-s(u_{i}) )\) and y=1−s(u i ). Our goal is to decide whether there exists \(B_{i-1}'\subseteq B_{i-1}\) such that \(x<s(B_{i-1}')\le y\) in \(O(|B_{i-1}|+2^{\lambda^{2}(f)})\) time. As s(B i−1)<1/λ(f), s(u i )≤1, and λ 2(f)≥(1+f)λ(f)+1 by the definition of λ(f), we get
Let B i−1={b 1,b 2,…,b m } satisfy s(b 1)≥…≥s(b k )≥y−x>s(b k+1)≥…≥s(b m ). Then we claim the existence of \(B_{i-1}'\) is equivalent to the existence of A⊆{b 1,b 2,…,b k } such that \(x-\sum_{i=k+1}^{m} s(b_{i})< s(A)\le y\). If such an A exists, then \(B_{i-1}'=A\cup\{b_{k+1},\dots,b_{l}\}\) satisfies the conditions, where \(l=\min\{l\ge k+1\mid s(A)+\sum_{i=k+1}^{l} s(b_{i})>x\}\). If there exists \(B_{i-1}'\) such that \(x<s(B_{i-1}')\le y\), then \(A=B_{i-1}'\setminus\{b_{k+1},\dots,b_{m}\}\) satisfies \(x-\sum_{i=k+1}^{m} s(b_{i})< s(A)\le y\).
Therefore we need to check the condition \(x-\sum_{i=k+1}^{m} s(b_{i})< s(A)\le y\) for at most \(2^{k}<2^{\lambda^{2}(f)}\) subsets, since k≤s(B i−1)/(y−x)<λ 2(f) holds by s(B i−1)<1/λ(f) and y−x>1/λ 3(f). Thus we can check the condition in the sixth line in \(O(|B_{i-1}|+2^{\lambda^{2}(f)})\). □
3 Unit Cost Model
In this section, we consider the unit cost model, where it costs us a fixed constant c>0 to remove each item from the knapsack. Recall that every item has size at least c. In this section, we show that the online unweighted knapsack problem with unit cost is μ(c)-competitive, where μ(c) is defined in (2). We note that μ(c) attains the maximum \(1+\sqrt{2}\) when \(c=1-1/\sqrt{2}\).
We remark that the problem becomes unbounded competitive ratio if items are allowed to have size arbitrarily smaller than c.
Lemma 6
For any positive number r, there is no online algorithm with competitive ratio less than r for the knapsack problem with unit removal cost without the size assumption.
Proof
Let ε denote a positive number such that ε<1/(⌈1/c⌉⋅r). For an online algorithm A chosen arbitrarily, our adversary (see Fig. 4) keeps requesting the items with size ε, until A accepts ⌈1/c⌉ items or rejects r⋅⌈1/c⌉ items. If A rejects r⋅⌈1/c⌉ items (before accepting ⌈1/c⌉ items), the adversary stops the input sequence; otherwise, it requests an item with size 1 and stops the input sequence. In the former case, the competitive ratio is at least \(\frac{ r \lceil1/c\rceil \varepsilon}{\lceil1/c\rceil\varepsilon}=r\). In the latter case, the competitive ratio becomes \(\frac{1}{\lceil1/c\rceil\cdot\varepsilon}> r\) if A rejects the last item (with size 1). Otherwise, A removes the ⌈1/c⌉ items to take the last item. This implies that the profit is 1−⌈1/c⌉⋅c≤0.
□
3.1 The Case c≥1/2
We first consider the case where c≥1/2. In this case, it is not difficult to see that the problem is 1/c(=μ(c))-competitive.
Theorem 7
If the unit removal cost c is at least 1/2, then there is no online algorithm with competitive ratio less than 1/c for the online unweighted knapsack problem.
Proof
For an online algorithm A chosen arbitrarily, our adversary first requests an item with size c. If A does not accept it, the adversary stops the input sequence. Otherwise, it next requests an item with size 1 and stops the input sequence. It is clear that A must take the first item, since otherwise the competitive ratio becomes infinite. If A rejects the second item, then we have the competitive ratio 1/c. Otherwise (i.e., A accepts the second item by removing the first item), the competitive ratio is 1/(1−c)≥1/c, since c≥1/2. □
Theorem 8
There is a 1/c-competitive algorithm for the online unweighted knapsack problem with unit removal cost.
Proof
Consider an online algorithm which takes the first item u 1 and rejects the remaining items. Since s(u 1)≥c and the optimal value of the offline problem is at most 1, the competitive ratio is at most 1/c. □
3.2 The Case c<1/2
In this section we consider the case in which c<1/2.
3.2.1 Lower Bound
For 0<c<1/2, we show that μ(c) is a lower bound of the competitive ratio for the problem by starting with several propositions needed later.
Proposition 9
For any positive integer k, we have
Proof
Note that
and
□
Definition 10
We define x k and y k as follows:
Proposition 11
η(k) and ξ(k) in (3) satisfy the following equalities.
We provide two kinds of adversaries.
Theorem 12
Assume that removal cost c satisfies \(1-\sqrt{\frac{k+1}{k+2}}\le c\le1-\sqrt{\frac{k}{k+1}}\) for a positive integer k. Then there is no online algorithm with competitive ratio less than η(k) for the online unweighted knapsack problem with unit removal cost.
Proof
Let \(x_{k}=\frac{k+2-kc-\sqrt{k^{2}(1-c)^{2}+4k}}{2}\). For an online algorithm A chosen arbitrarily, our adversary (see Fig. 5) keeps requesting the items with size x k until A accepts k items or rejects ⌈1/x k ⌉ items. If A rejects ⌈1/x k ⌉ items before accepting k items, the adversary stops the input sequence (a). Otherwise (i.e., A accepts k items), the adversary next requests an item with size 1−x k +ε where ε is a sufficiently small positive number; if A rejects it, the adversary stops the input sequence (b), and otherwise, the adversary next requests an item with size 1−x k and stops the input sequence (c). Note that all the items have size at least c, since \(1-\sqrt{\frac{k+1}{k+2}}\le c\le1-\sqrt{\frac{k}{k+1}}\) implies x k ≥c and 1−x k ≥c.
In the case of (a), we have the competitive ratio at least \(\frac{1-x_{k}}{(k-1)x_{k}} > \frac{1-x_{k}}{kx_{k}}=\eta(k), \) where the last equality follows from Proposition 11. In the case of (b), the competitive ratio is at least \(\frac{1-x_{k}+\varepsilon}{kx_{k}}> \frac{1-x_{k}}{kx_{k}} =\eta(k)\) by Proposition 11. Finally, in the case of (c), the competitive ratio is at least \(\frac{1}{1-x_{k}+\varepsilon-kc}\). Proposition 11 implies that this approaches \(\eta(k) (=\frac{1}{1-x_{k}-kc})\) as (ε→0). □
Theorem 13
Assume that removal cost c satisfies \(1-\sqrt{\frac{k}{k+1}}\le c < \frac{1}{2k}\) for a positive integer k. Then there is no online algorithm with competitive ratio less than ξ(k) for the online unweighted knapsack problem with unit removal cost.
Proof
Let A denote an online algorithm chosen arbitrarily. Then our adversary (see Fig. 6) keeps requesting items with size c until A accepts k items or rejects ⌈1/c⌉ items. If A rejects ⌈1/c⌉ items before accepting k items, the adversary stops the input sequence (a). Otherwise (i.e., A accepts k items), the adversary requests an item with size \(y_{k}=\frac{kc+\sqrt{k^{2}c^{2}+4kc}}{2}\) which is at least 1−c>c, since \(1-\sqrt{\frac{k}{k+1}}\le c < \frac{1}{2k}\); if A rejects it, the adversary stops the input sequence (b), and otherwise, the adversary requests an item with size 1−c and stops the input sequence (c).
In the case of (a), the competitive ratio is at least \(\frac {1-c}{(k-1)c}\ge\frac{1}{kc}\ge\frac{y_{k}}{kc}=\xi(k)\), where the last equality follows from Proposition 11. In the case of (b), the competitive ratio is \(\frac{y_{k}}{kc}=\xi (k)\) by Proposition 11. Finally, in the case of (c), the competitive ratio is at least \(\frac{1}{y_{k}-kc}=\xi(k)\), which again follows from Proposition 11. □
By Theorems 12 and 13, it holds that μ(c) is a lower bound of the competitive ratio for 0<c<1/2.
3.2.2 Upper Bound
In this subsection, we show that μ(c) is also an upper bound for the competitive ratio of the problem when 0<c<1/2. We start with several propositions needed later.
Proposition 14
For a positive integer k, let c satisfy \(1-\sqrt{\frac {k+1}{k+2}}\le c\le1-\sqrt{\frac{k}{k+1}}\). Then we have
Proof
We can get the results by simple calculations. □
Proposition 15
For a positive integer k, let c satisfy \(1-\sqrt{\frac {k+1}{k+2}}\le c\le1-\sqrt{\frac{k}{k+1}}\). Then we have
Proof
If \(\frac{2k-1}{2k(2k+1)}\le c\le1-\sqrt{\frac{k}{k+1}}\) then by (16), the claim is correct. Otherwise (i.e., \(c< \frac{2k-1}{2k(2k+1)}<\frac{1}{2(k+1)}\)), we also have (18) by (17). □
Proposition 16
For a positive integer k, let c satisfy \(1-\sqrt{\frac {k+1}{k+2}}\le c\le1-\sqrt{\frac{k}{k+1}}\). Then we have
Proof
The second equality holds by the definition of μ(c). Thus we only need to prove the first equality.
For α≥2, it holds that
since \(1-\sqrt{\frac{\alpha+1}{\alpha+2}}< \frac{2\alpha-1}{2\alpha(2\alpha+1)} \iff12\alpha^{2}(\alpha-2)+2\alpha(6\alpha-1)+(\alpha-2)>0\).
If k>α≥2, then it holds
by \(c\le1-\sqrt{\frac{k}{k+1}}\le1-\sqrt{\frac{\alpha+1}{\alpha+2}}< \frac{2\alpha-1}{2\alpha(2\alpha+1)}\) and Proposition 14.
Moreover when α=1, we have
for 0<c≤1/6 since \(\frac{(c+1)+\sqrt{(1-c)^{2}+4}}{2(1-c)}\le 2\iff(1-6c)(1-c)\ge0\). As \(1-\sqrt{3/4}<1/6<1-\sqrt{2/3}\), we remain to prove η(1)≤η(2) for \(1/6\le c<1-\sqrt{2/3}\). By \(c<1-\sqrt{2/3}< 1/2\),
□
Proposition 17
For a positive integer k, let c satisfy \(1-\sqrt{\frac{k+1}{k+2}}\le c\le1-\sqrt{\frac{k}{k+1}}\). Then for any positive integer α≤k and real x∈(0,1−αc), it holds that
Proof
Since \(\frac{1}{1-x-\alpha c}\) and \(\frac{1-x}{\alpha x}\) are respectively monotone increasing and decreasing in x, the first inequality holds by Proposition 11. The second inequality is obtained by Proposition 16. □
Proposition 18
For a positive integer k, let c satisfy \(1-\sqrt{\frac {k+1}{k+2}}\le c\le1-\sqrt{\frac{k}{k+1}}\). Then for any real y∈((k+1)c,1], we have
Proof
Since \(\frac{1}{y-(k+1)c}\) and \(\frac{y}{(k+1)c}\) are respectively monotone decreasing and increasing in y, the first inequality holds by Proposition 11. The second inequality follows from the definition of μ(c). □
We are now ready to prove that μ(c) is an upper bound for the competitive ratio. According to the size of c, we make use of Algorithms 2 and 3.
For \(1-\frac{1}{\sqrt{2}}\le c\le\frac{1}{2}\), we use Algorithm 2, where B i−1 denotes the set of items in the knapsack at the beginning of the ith round Let u i be the item given in the ith round. In this case, the profit of any two items is sufficiently high. Intuitively, our algorithm accepts the item if the knapsack has room to put it. If there is only one item in the knapsack and the new item has sufficiently high value, the algorithm accepts the new item and removes the item in the knapsack, and after this iteration, it rejects all the items. Otherwise, it simply rejects the item.
Theorem 19
If \(1-\frac{1}{\sqrt{2}}\le c\le\frac{1}{2}\), the online Algorithm 2 is μ(c)-competitive for the online unweighted knapsack problem with unit removal cost.
Proof
Let OPT denote an optimal solution for the offline problem whose input sequence is u 1,…,u i . If the algorithm stops at the fourth line, the competitive ratio is at most \(1/ (\frac{c+\sqrt{c^{2}+4c}}{2}-c )=\frac{c+\sqrt{c^{2}+4c}}{2c} =\mu(c)\), since s(OPT)≤1. Assume that the algorithm has never stopped at the fourth line and |B i |=1. If s(B i )≥1/2, then the competitive ratio is at most \(\frac{1}{1/2}=2\le\mu(c)\). Otherwise, the item in B i has size smaller than 1/2, while the item u j with j<i and u j ∉B i has size at least 1/2. This implies that |OPT|=1 and the competitive ratio is smaller than μ(c), since s(B i )≥c and \(s(\mathrm {OPT})< \frac{c+\sqrt{c^{2}+4c}}{2}\). If the algorithm has never stopped at the fourth line and |B i |>1, the competitive ratio is at most \(\frac{1}{2c}< \mu(c)\), since \(c\ge1-1/\sqrt{2}> 1/6\) implies \(c+\sqrt{c^{2}+4c}> 1\). □
For \(1-\sqrt{\frac{k+1}{k+2}}\le c\le1-\sqrt{\frac{k}{k+1}}\) (k=1,2,…), we use Algorithm 3. Intuitively, our algorithm accepts the new item if the knapsack has room to put it. If we can make the profit sufficiently high by accepting the item and removing some items from the current knapsack by greedy manner, then our algorithm follows this, and after this iteration, it rejects all the items. Otherwise, the algorithm simply rejects the item.
Theorem 20
If \(1-\sqrt{\frac{k+1}{k+2}}\le c\le1-\sqrt{\frac{k}{k+1}}\), the online Algorithm 3 is μ(c)-competitive for the online unweighted knapsack problem with unit removal cost.
Proof
Let OPT denote an optimal solution for the offline problem whose input sequence is u 1,…,u i . If the algorithm stops at the eleventh line in round l≤i, \(s(B_{i})=s(B_{l})=s(B_{l-1}')+s(u_{l})\) and the profit of the algorithm is \(s(B_{l-1}')+s(u_{l})-|B_{l-1}\setminus B_{l-1}'|c\). Therefore, the competitive ratio is at most \(\frac {1}{s(B_{l-1}')+s(u_{l})-|B_{l-1}\setminus B_{l-1}'|c}\le\mu(c)\), since s(OPT)≤1. Otherwise, the algorithm has never removed old items from the knapsack. If s(B i )≥1/2, then the competitive ratio is at most \(\frac{1}{1/2}=2\le\mu(c)\). On the other hand, if s(B i )<1/2, then any item in B i has size at most 1/2 while any item in OPT∖B i has size larger than 1/2. This implies |OPT∖B i |≤1 by s(OPT)≤1. If |OPT∖B i |=0, then we have OPT=B i , which implies that the competitive ratio is 1. Thus we assume that |OPT∖B i |=1. Note that |B i |≤k+1 holds, since any b∈B i satisfies \(s(b)\ge c\ge1-\sqrt{\frac {k+1}{k+2}}\ge\frac{1}{2k+4}\), where the last inequality follows from Proposition 9. Since the algorithm has never removed items, |B l |≤k+1 also holds for each l with l≤i. Let
Since \(B_{l-1}\setminus B_{l-1}'\neq\emptyset\), we have
Since s(B i )=s(B l−1)+s(B i ∖B l−1) and s(OPT)≤s(u l )+s(B l−1∩OPT)+s(B i ∖B l−1), the competitive ratio is at most
We claim that \(\frac{s(u_{l})+s(B_{l-1}\cap \mathrm {OPT})}{s(B_{l-1})} \leq\mu(c)\).
Let B l ={b 1,b 2,…,b m } satisfy s(b 1)≥s(b 2)≥…≥s(b m ). To see this claim, we separately consider the following two cases:
Case 1. Consider the case in which there exists \(b_{j}\in B_{l-1}'\) such that \(b_{h}\notin B_{l-1}'\) holds for some h>j. Let us take b j as the largest such item, i.e., \(b_{j}\in B_{l-1}'\) and \(b_{g}\notin B_{l-1}'\) for all g(<j).
In this case, we obtain the following inequalities:
Here the numerator and denominator in the left hand side of (27) respectively satisfy \(s(u_{l})+s(B_{l-1}\cap \mathrm {OPT})\le1< s(b_{h})+s(u_{l})+s(B_{l-1}')=s(b_{h})+1-x\) and \(s(B_{l-1})=s(B_{l-1}')+s(B_{l-1}\setminus B_{l-1}')\ge s(b_{h})+\alpha x\), since \(b_{h}\notin B_{l-1}'\) and s(b)>x holds for any \(b\in B_{l-1}\setminus B_{l-1}'\). Finally, we show \(\frac{1-x}{\alpha x}\le\mu(c)\), which completes the claim.
Since the algorithm has not stopped at the eleventh line and 1−x−αc>0 by (26), we have \(\frac{1}{1-x-\alpha c}=\frac{1}{s(B_{l-1}')+s(u_{l})-\alpha c}>\mu(c)\). Note that α≤|B l−1∖{b h }|≤k, since |B l−1|≤k+1. Therefore, we obtain \(\frac{1-x}{\alpha x}\le\mu(c)\) by Proposition 17.
Case 2. We next consider the case in which \(b_{j}\in B_{l-1}'\) implies \(b_{h}\in B_{l-1}'\) for all h(>j), i.e., \(B_{l-1}'\) consists of the \(|B_{l-1}'|\) smallest items of B l−1. Then we have s(b)>1−s(u l ) for any \(b \in B_{l-1} \setminus B_{l-1}'\). This implies \(B_{l-1}\cap \mathrm {OPT}\subseteq B_{l-1}'\), and \(s(B_{l-1}\setminus B_{l-1}')> \alpha x\) holds by (25).
If α≤k, thus, the competitive ratio is at most
where the last inequality follows from a similar argument to Case 1. On the other hand, if α=k+1, let \(y=s(u_{l})+s(B_{l-1}')\). Then we have
where the inequality follows from the fact that \(s(u_{l})+s(B_{l-1}\cap \mathrm {OPT})\le s(u_{l})+s(B_{l-1}')=y\) and \(s(B_{l-1})\ge s(B_{l-1}\setminus B_{l-1}')\ge(k+1)c\), since \(B_{l-1}\cap \mathrm {OPT}\subseteq B_{l-1}'\) and any item has size at least c. Finally, since y>(k+1)c and the algorithm has not stopped at the eleventh line, it holds that \(\frac{1}{y-(k+1) c}=\frac{1}{s(B_{l-1}')+s(u_{l})-(k+1) c}>\mu(c)\). This together with Proposition 18 implies \(\frac{y}{(k+1) c}\le\mu(c)\). □
References
Ashwinkumar, B.V.: Buyback problem - approximate matroid intersection with cancellation costs. In: Automata, Language and Programming. Lecture Notes in Computer Science, vol. 6755, pp. 379–390. Springer, Berlin (2011)
Ashwinkumar, B.V., Kleinberg, R.: Randomized online algorithms for the buyback problem. In: Internet and Network Economics. Lecture Notes in Computer Science, vol. 5929, pp. 529–536. Springer, Berlin (2009)
Babaioff, M., Hartline, J.D., Kleinberg, R.D.: Selling banner ads: online algorithms with buyback. In: Proceedings of the 4th Workshop on Ad Auctions (2008)
Babaioff, M., Hartline, J.D., Kleinberg, R.D.: Selling ad campaigns: online algorithms with cancellations. In: Proceedings of the 10th ACM Conference on Electronic Commerce, pp. 61–70 (2009)
Biyalogorsky, E., Carmon, Z., Fruchter, G.E., Gerstner, E.: Research note: overselling with opportunistic cancellations. Mark. Sci. 18(4), 605–610 (1999)
Constantin, F., Feldman, J., Muthukrishnan, S., Pál, M.: An online mechanism for ad slot reservations with cancellations. In: Proceedings of the Twentieth Annual ACM-SIAM Symposium on Discrete Algorithms, pp. 1265–1274 (2009)
Han, X., Makino, K.: Online minimization knapsack problem. In: Approximation and Online Algorithms. Lecture Notes in Computer Science, vol. 5893, pp. 182–193. Springer, Berlin (2010)
Han, X., Makino, K.: Online removable knapsack with limited cuts. Theor. Comput. Sci. 411, 3956–3964 (2010)
Iwama, K., Taketomi, S.: Removable online knapsack problems. In: Automata, Languages and Programming. Lecture Notes in Computer Science, vol. 2380, pp. 293–305. Springer, Berlin (2002)
Iwama, K., Zhang, G.: Optimal resource augmentations for online knapsack. In: Approximation, Randomization, and Combinatorial Optimization. Algorithms and Techniques. Lecture Notes in Computer Science, vol. 4627, pp. 180–188. Springer, Berlin (2007)
Kellerer, H., Pferschy, U., Pisinger, D.: Knapsack Problems. Springer, Berlin (2004)
Lueker, G.S.: Average-case analysis of off-line and on-line knapsack problems. J. Algorithms 29(2), 277–305 (1998)
Marchetti-Spaccamela, A., Vercellis, C.: Stochastic on-line knapsack problems. Math. Program. 68, 73–104 (1995)
Noga, J., Sarbua, V.: An online partially fractional knapsack problem. In: Proceedings of 8th International Symposium on Parallel Architectures, Algorithms and Networks, pp. 108–112 (2005)
Author information
Authors and Affiliations
Corresponding author
Additional information
X. Han partially supported by NSFC(11101065) and “the Fundamental Research Funds for the Central Universities”.
Y. Kawase partially supported by the Global COE “The Research and Training Center for New Development in Mathematics.”
K. Makino partially supported by Grant-in-Aid for Scientific Research from the Ministry of Education, Culture, Sports, Science and Technology of Japan.
Rights and permissions
About this article
Cite this article
Han, X., Kawase, Y. & Makino, K. Online Unweighted Knapsack Problem with Removal Cost. Algorithmica 70, 76–91 (2014). https://doi.org/10.1007/s00453-013-9822-z
Received:
Accepted:
Published:
Issue Date:
DOI: https://doi.org/10.1007/s00453-013-9822-z