1 Introduction

We mainly consider the Rectangular Knapsack Problem:

Definition 1

Given \(a, b \in {\mathbb {N}}^n\) and \(\kappa \in {\mathbb {N}}\), the Rectangular Knapsack Problem (Rkp) is formulated as

$$\begin{aligned} \max \ f(x) {:=}\sum _{i = 1}^n\sum _{j=1}^n a_ib_jx_ix_j&= \left( a^\mathsf {T}x\right) \left( b^\mathsf {T}x\right) \\ \text {s.t. }\mathbf {1}^\mathsf {T}x&\le \kappa \\ x&\in \{0, 1\}^n, \end{aligned}$$

where \(\mathbf {1}\) is the all-one vector. We also define a decision version of this problem, where we are additionally given a \(\theta \in {\mathbb {N}}\), and ask whether there exists a feasible \(x\in \{0,1\}^n\) with \(f(x) \ge \theta \). \(\triangleleft \)

Fig. 1
figure 1

A graphical representation of an Rkp instance: Given a multiset of (possibly degenerated) rectangles and an integer \(\kappa \) (left), we ask for a subset of cardinality \(\kappa \) that spans the largest possible area (right). Here, we are given 9 rectangles (A,B,... I) with \(\kappa =4\)

Rkp allows a nice geometric interpretation, see Fig. 1: We are given an integer \(\kappa \in {\mathbb {N}}\) and a multiset \(R=\{ (a_i,b_i) \}_{i=1,...,n}\) of rectangles, specified by their width and height. The rectangles are allowed to be degenerated to orthogonal line segments (i.e., have width or height 0). For a subset of rectangles, we may lay them out in the plane connectedly such that the (axis-parallel) bounding-box has maximum area. Clearly, this is achieved by placing the rectangles in a linear sequence such that the bottom-left corner of a rectangle is the top-right corner of its predecessor. In Rkp we thus ask for a rectangle subset of cardinality at most \(\kappa \) that maximizes this area.

Rkp arises naturally in the study of the Cardinality-constrained Bi-objective Knapsack problem (Cbkp), as observed by Schulze et al. (2020):

Definition 2

Given \(a, b \in {\mathbb {N}}^n\) and \(\kappa \in {\mathbb {N}}\), the Cardinality-constrained Bi-objective Knapsack Problem (Cbkp) is formulated as

figure a

In this problem, we ask for the Pareto-front of two linear profit functions, subject to a cardinality constraint. As the Pareto-front can be exponential in the size of the input, Schulze et al. (2020) consider approximative methods to find a good respresentation of it; this can be achieved by iteratively solving Rkp instances. The approach has also been evaluated experimentally by Paquete et al. (2022). Schulze et al. (2020) give a 4.5-approximation for Rkp and conjecture that it is NP -hard. However, they can only show NP -hardness of two more general cases of the Rkp, namely when the a and b vectors may consist of general integer values (i.e., negative components are allowed) or when the cardinality constraint is a more general Knapsack constraint. The complexity status of the actual Rkp remained open.

Rkp is a special case of the Quadratic Knapsack Problem (Qkp) first introduced by Gallo et al. (1980); see (Pisinger 2007) for a comprehensive survey. Thereby we want to optimize a quadratic function over binary variables, i.e., \(f^q(x)=x^\mathsf {T}Q x\), subject to a knapsack constraint. Qkp is known to be strongly NP -complete even if the Knapsack constraint is a cardinality constraint, by reduction from Clique (Garey and Johnson 1979). Recall that strong NP -hardness means that the problem remains NP -hard even when all values of the numbers in the input are bounded by a polynomial in the input size; thus, such problems do not allow a pseudopolynomial algorithm unless P = NP .

Qkp with a general integral weight matrix Q does not allow a constant-factor approximation unless P = NP  (Rader and Woeginger 2002). For non-negative Q, a constant-factor approximation can currently not be ruled out, but the best known approximation guarantees only a ratio of \(\mathcal {O} \big (n^{\nicefrac 25+\varepsilon }\big )\) in \(\mathcal {O} \big (n^{\nicefrac 9\varepsilon }\big )\) time (Taylor 2016). Recall that, for a given quality requirement \(\varepsilon >0\), a (fully) polynomial-time approximation scheme, abbreviated as PTAS (FPTAS), achieves a \((1-\varepsilon )\)-approximation while its running time is bounded by a polynomial in the input size and an arbitrary (polynomial, respectively) function in \(\varepsilon ^{-1}\). A weight-matrix Q induces an n-vertex graph G that has an edge (ij) if and only if \(Q_{i,j}\ne 0\). There is an FPTAS if G has bounded tree-width and a PTAS if G is H-minor-free, for any fixed minor H (see (Pferschy and Schauer 2016) for both results). However, the problem remains strongly NP -hard even if G is guaranteed to be 3-book-embeddable (Pferschy and Schauer 2016) or vertex series-parallel (Rader and Woeginger 2002). Furthermore, an FPTAS exists for a special symmetric quadratic knapsack problem, where the knapsack constraint coefficients are dependent on the matrix Q (Kellerer and Strusevich 2010; Xu 2012).

Our contribution. Our first result is to settle NP -hardness for Rkp in Sect. 3.

Next, we show that we can use an FPTAS from the literature to construct an FPTAS for Rkp in Sect. 4, concluding that Rkp is in fact only weakly NP -hard. Interestingly, we multi-objectivize the Rkp , i.e., turn the Rkp into a multi-objective optimization problem, to apply an FPTAS from the muliobjective literature.

In Sect. 5, we describe an exact pseudopolynomial time algorithm for Rkp. Our algorithm can also be used to directly and exactly solve the original Cbkp, the starting point of the investigation of Rkp by Schulze et al. (2020). Finally, in Sect. 6 we show how to use our algorithm as a building block to develop an FPTAS for Rkp and Cbkp. We show that both our pseudopolynomial algorithm and FPTAS yield improved running times compared to the FPTAS used in Sect. 4.

2 Preliminaries

Let an Rkp instance be given by \(a, b\in {\mathbb {N}}^n\) and \(\kappa \in {\mathbb {N}}\). For \(x\in {\mathbb {N}}^n\), we have \(\left\Vert x \right\Vert _\infty {:=}\max _{i = 1, \dots , n} x_i\). Let \(\alpha {:=}\left\Vert a \right\Vert _\infty \), \(\beta {:=}\left\Vert b \right\Vert _\infty \), \(W^\uparrow {:=}\max \{\alpha ,\beta \}\), and \(W^\downarrow {:=}\min \{\alpha ,\beta \}\). W.l.o.g., we assume \(\alpha \ge \beta \) and, thus, \(W^\uparrow = \alpha \) and \(W^\downarrow = \beta \). Let N be the encoding length of the Rkp instance; we observe in particular that \(n\le N\) and \(\log \alpha \le N\). We may use these observations when showing running time bounds depending solely on the input length. Whenever we compare two vectors, e.g. \(x\le y\) for \(x,y\in {\mathbb {N}}^n\), this is understood to be component-wise.

Consider a more general version of the Cbkp: the multiobjective Knapsack problem with general knapsack constraints and an arbitrary number of objective functions.

Definition 3

Given \(C \in {\mathbb {N}}^{d\times n}\), \(w \in {\mathbb {N}}^n\), and \(\kappa \in {\mathbb {N}}\), the Multiobjective Knapsack Problem (Mokp) is formulated as

figure b

The rows \(c^1, \dots , c^d\in {\mathbb {N}} ^n\) of the objective function matrix C can be seen as individual objective functions \((c^i)^\mathsf {T}x\) meant to be maximized. A vector x dominates another vector y, if \(x \ge y\) and \(x \ne y\). Let \({Y{:=}\left\{ Cx : w^\mathsf {T}x \le \kappa , x\in \{0,1\}^n\right\} }\) be the set of value vectors of an Mokp instance. A value vector \(y\in Y\) is non-dominated if there is no other \(y'\in Y\) that dominates it. We call the set of non-dominated value vectors the non-dominated set or \(Y_N\). A solution \(x\in \{0,1\}^n\) is Pareto-optimal, if \(Cx \in Y_N\). Computing the non-dominated set for Mokp is known to be NP -hard, since it contains the single-objective knapsack problem as a special case.

An FPTAS for a multiobjective problem is an algorithm that computes, for any given quality guarantee \(\varepsilon \in (0, 1)\), a set \(S\subseteq Y\), such that for every \(y\in Y_N\), there is an \(x\in S\) with \(x \ge (1-\varepsilon ) y\) in time polynomial in the input size and \(\nicefrac {1}{\varepsilon }\). While for many multiobjective optimization problems it is known that the size of \(Y_N\) can be exponential in the input size, e.g., multiobjective versions of the shortest path, spanning tree, or knapsack problems, there also always exists a set S as above of size bounded polynomially in the input size and \(\nicefrac {1}{\varepsilon }\) (cf. Papadimitriou and Yannakakis (2000)).

3 NP -Hardness

Before we proceed with the hardness proof, we start with an initial observation. Consider an arbitrary Rkp instance and any two vectors \(x,x' \in \{0, 1\}^n\). If \(x' \le x\), we have \(f(x') \le f(x)\) since \(a, b \ge \mathbf {0}\). We can therefore deduce:

Observation 4

If there is an optimal solution (or a witness to a yes-instance) \(x'\) with \(\mathbf {1}^\mathsf {T}x' < \kappa \) for some Rkp instance, then there also exists another optimal solution (yes-witness) x with \(\mathbf {1}^\mathsf {T}x = \kappa \). It thus suffices to search for solutions with the latter property.

The next problem is known to be (weakly) NP -hard for decades (Garey and Johnson 1979). Intuitively, it asks whether we can partition the components of a vector c into two subsets of equal size such that the sum of the components of each subsets coincide.

Definition 5

(Cardinality-Constraint Partition (Ccp)) Given a vector \(c\in {\mathbb {N}}^n\), is there a vector \(x\in \{0,1\}^n\) such that \(\mathbf {1}^\mathsf {T}x = \nicefrac {n}{2}\) and \(c^\mathsf {T}x=c^\mathsf {T}(\mathbf {1}-x)\)? \(\triangleleft \)

Ccp was also used by Schulze et al. (2020) to show NP -hardness for the problem that arises from Rkp problem when ab are allowed to include negative components. However, for the true Rkp (which was tackled by the algorithmic approximation by Schulze et al. (2020)), no hardness result was shown. By massaging Ccp-instances further, we can in fact show NP -hardness for strictly non-negative (or even strictly positive) vectors ab.

Theorem 6

Rkp is NP -hard.

Proof

We reduce from Ccp to the decision variant of Rkp, establishing that the latter is NP -complete as NP membership is trivial. Let \(c\in {{\mathbb {N}}}^{n}\) be a Ccp instance. We define the sum of all c-components \(C{:=}\mathbf {1}^\mathsf {T}c\) and a sufficiently large constant \(M{:=}\left\Vert c \right\Vert _\infty \cdot \nicefrac {n}{2}\). Let \(\mathbf {C}{:=}C\cdot \mathbf {1}\) and \(\mathbf {M}{:=}M\cdot \mathbf {1}\) be the n-dimensional vectors with uniform components C and M, respectively. We construct an Rkp instance \((a,b,\kappa ,\theta )\) with

$$\begin{aligned} \kappa&\, {:=}\, \nicefrac {n}{2},\\ a&\, {:=}\, \mathbf {M}+ \kappa \cdot c,\\ b&\, {:=}\, \mathbf {M}+ \mathbf {C}- \kappa \cdot c,\\ \theta&\, {:=}\, \kappa ^2 \cdot \left( M^2 + CM + (\nicefrac {C}{2})^2\right) . \end{aligned}$$

We can assume w.l.o.g. that n and C are even numbers (as c would otherwise be a trivial no-instance for Ccp) and non-zero. Thus we have integrality for all our constructed numbers. Since \(c\in {\mathbb {N}}^n\), all constructed numbers (except for perhaps the components of b) are trivially positive and thus elements of \({\mathbb {N}}_+\). Since \(M=\kappa \left\Vert c \right\Vert _\infty \) is at least as large as any component of \(\kappa \cdot c\), also every component of b is in fact positive and thus from \({\mathbb {N}}_+\). The tuple \((a,b,\kappa ,\theta )\) is hence a legal Rkp instance.

We now show that \((a,b,\kappa ,\theta )\) is an Rkp yes-instance if and only if the original \(c\in {\mathbb {N}}^{n}\) is a Ccp yes-instance by proving the equivalence directly. Assume \((a,b,\kappa ,\theta )\) is a yes-instance for Rkp, and consider a solution vector \(\bar{x}\in \{0,1\}^n\). By Observation 4, we can assume w.l.o.g. that \(\mathbf {1}^\mathsf {T}\bar{x}=\kappa \) and thus \(\mathbf {M}^\mathsf {T}\bar{x}=\kappa M\) and \(\mathbf {C}^\mathsf {T}\bar{x} = \kappa C = \kappa \cdot c^\mathsf {T}\mathbf {1}\). We examine the objective \(f(\bar{x})\):

$$\begin{aligned} f(\bar{x})&= a^\mathsf {T}\bar{x} \cdot b^\mathsf {T}\bar{x}\\&= (\mathbf {M}+ \kappa \cdot c)^\mathsf {T}\bar{x} \cdot (\mathbf {M}+ \mathbf {C}- \kappa \cdot c)^\mathsf {T}\bar{x}\\&= (\mathbf {M}^\mathsf {T}\bar{x} + \kappa \cdot c^\mathsf {T}\bar{x} )\cdot (\mathbf {M}^\mathsf {T}\bar{x} + \mathbf {C}^\mathsf {T}\bar{x} - \kappa \cdot c^\mathsf {T}\bar{x})\\&= (\kappa M + \kappa \cdot c^\mathsf {T}\bar{x} )\cdot (\kappa M + \kappa \cdot c^\mathsf {T}(\mathbf {1}-\bar{x}))\\&= \kappa ^2 \cdot \left( M^2 + M\cdot c^\mathsf {T}\bar{x} + M\cdot c^\mathsf {T}(\mathbf {1}-\bar{x}) + (c^\mathsf {T}\bar{x})\big (c^\mathsf {T}(\mathbf {1}-\bar{x})\big )\right) \\&= \kappa ^2 \cdot \left( M^2 + MC + (c^\mathsf {T}\bar{x})\big (c^\mathsf {T}(\mathbf {1}-\bar{x})\big )\right) \end{aligned}$$

Therefore, \(f(\bar{x}) \ge \theta \) reduces to \(\left( c^\mathsf {T}\bar{x}\right) \left( c^\mathsf {T}(\mathbf {1}-\bar{x})\right) \ge (\nicefrac {C}{2})^2\). This inequality holds if and only if \(c^\mathsf {T}\bar{x} = c^\mathsf {T}(\mathbf {1}-\bar{x}) = \nicefrac {C}{2}\). Thus \((a,b,\kappa ,\theta )\) is a yes-instance for Rkp if and only if c is a yes-instance for Ccp (both witnessed by the identical solution vector \(\bar{x}\)). \(\square \)

Ccp remains NP -hard even if all components of c are positive (in contrast to only being non-negative) and distinct (Garey and Johnson 1979). By the above construction we naturally obtain:

Observation 7

Rkp remains NP -hard even if all components of a and all components of b are positive and distinct.

4 An FPTAS via MOKP

The Mokp admits an FPTAS proposed by Erlebach et al. (2002). To apply this FPTAS, we first establish a connection between Rkp and Mokp. To this end, we define for a given Rkp instance with \(a, b\in {\mathbb {N}}^n\) and \(\kappa \in {\mathbb {N}}\) a Cbkp instance and thus a Mokp instance of the following form:

$$\begin{aligned} \max \&a^\mathsf {T}x\\ \max \&b^\mathsf {T}x\\ \text {s.t. }\mathbf {1}^\mathsf {T}x&\le \kappa \\ x&\in \{0, 1\}^n. \end{aligned}$$

Lemma 8

Any optimal solution to Rkp is a Pareto-optimal solution to the respective Mokp instance.

Proof

Let \(\hat{x}\) be an optimal solution to Rkp and assume its value vector is dominated in the Mokp instance by some other value vector. Let x be a solution corresponding to the latter. Clearly, \(f(x) = \left( a^\mathsf {T}x\right) \left( b^\mathsf {T}x\right) > \left( a^\mathsf {T}\hat{x}\right) \left( b^\mathsf {T}\hat{x}\right) = f(\hat{x})\). As both solutions are feasible w.r.t. the cardinality constraint, \(\hat{x}\) cannot be an optimal solution to Rkp. \(\square \)

Algorithm 1

Given an Rkp instance \((a,b,\kappa )\) and \(\varepsilon > 0\), we solve it as an Mokp instance using the FPTAS by Erlebach et al. (2002). The latter algorithm is thereby started with a quality requirement \(\varepsilon ' {:=}\nicefrac {\varepsilon }{2}\) to compute an approximate solution set S. Our Rkp solution is an \(x\in S\) with maximum \(\left( a^\mathsf {T}x\right) \left( b^\mathsf {T}x\right) \).\(\triangleleft \)

Theorem 9

Algorithm 1 is an FPTAS for Rkp with running time bounded by \({\mathcal {O}}(\varepsilon ^{-2}n^3\log ( n\alpha )\log ( n\beta )) \subseteq \mathcal {O} (\varepsilon ^{-2}n^3\log (nW^\uparrow )^2) \subseteq {\mathcal {O}}(\varepsilon ^{-2} N^5)\).

Proof

We first prove the approximation ratio. Let \(\hat{x}\) be an optimal solution to Rkp. We also know that \((a,b)^\mathsf {T}\hat{x}\) is a non-dominated point to the Mokp instance by Lemma 8. Thus, the FPTAS computes at least one solution \(\mathring{x}\) with \(a^\mathsf {T}\mathring{x} \ge (1-\varepsilon ') a^\mathsf {T}\hat{x}\) and \(b^\mathsf {T}\mathring{x} \ge (1-\varepsilon ') b^\mathsf {T}\hat{x}\). The chosen solution \(\bar{x} \in S\) has maximum \(\left( a^\mathsf {T}\bar{x}\right) \left( b^\mathsf {T}\bar{x}\right) \) and thus we have

$$\begin{aligned} f(\bar{x})&= \left( a^\mathsf {T}\bar{x}\right) \left( b^\mathsf {T}\bar{x}\right) \ge \left( a^\mathsf {T}\mathring{x}\right) \left( b^\mathsf {T}\mathring{x}\right) \\&\ge \left( 1-\varepsilon '\right) ^2 \left( a^\mathsf {T}\hat{x}\right) \left( b^\mathsf {T}\hat{x}\right) \ge \left( 1 - \varepsilon \right) \left( a^\mathsf {T}\hat{x}\right) \left( b^\mathsf {T}\hat{x}\right) = (1-\varepsilon )f(\hat{x}). \end{aligned}$$

The running time of the FPTAS by Erlebach et al. (2002) is in \(\Theta \Big (\varepsilon ^{-d}n^{d+1} (\log U_1)\cdots (\log U_d)\Big )\), where \(U_i\) is an upper bound on the respective objective function values. Since \(\nicefrac {\varepsilon }{2} \in \Theta (\varepsilon )\), we can bound the running time in the above algorithm by \({\mathcal {O}}\Big (\varepsilon ^{-2}n^3(\log n\alpha )(\log n\beta )\Big )\). \(\square \)

Corollary 10

Algorithm 1 is an FPTAS for Cbkp with running time bounded by \({\mathcal {O}}(\varepsilon ^{-2}n^3\log (n\alpha )\log (n\beta )) \subseteq \mathcal {O} (\varepsilon ^{-2}n^3\log (nW^\uparrow )^2)\subseteq {\mathcal {O}}(\varepsilon ^{-2} N^5)\).

While these results, based on using the FPTAS from the literature as a black box, already improve on the known 4.5-approximation for Rkp, we show below that we can further improve the results in terms of running time by attacking the problem more directly.

5 Exact pseudopolynomial algorithm

We describe an exact pseudopolynomial algorithm for Rkp. It is also based on a multi-objective optimization decomposition. Given a solution \(x\in \{0,1\}^n\), we map it to its evaluation tuple via

$$\begin{aligned} x \mapsto \left\langle a^\mathsf {T}x, b^\mathsf {T}x, \mathbf {1}^\mathsf {T}x \right\rangle . \end{aligned}$$

These tuples form the corner stone of our enumeration procedure below. Observe that multiple solutions may attain the same evaluation tuple. A tuple \(t=\left\langle t_1,t_2,t_3 \right\rangle \) dominates a tuple \(t'=\left\langle t'_1,t'_2,t'_3 \right\rangle \) if \(t_1\ge t'_1\), \(t_2\ge t'_2\), \(t_3 \le t'_3\), and \(t\ne t'\). Recall that we can assume w.l.o.g. that \(\beta \le \alpha \).

Algorithm 2

We maintain a set of tuples T. It is initialized with \(T = \{\left\langle 0, 0, 0 \right\rangle \}\), the corresponding solution would be the n-dimensional all-zeros vector. The algorithm now runs in n iterations. In iteration i, we consider every current tuple \(t=\left\langle t_1,t_2,t_3 \right\rangle \in T\) and obtain a new tuple \(t'=\left\langle t'_1,t'_2,t'_3 \right\rangle {:=}\left\langle t_1+a_i,t_2+b_i,t_3+1 \right\rangle \). In solution space, this corresponds to setting the i-th component of the associated solution to 1. We discard \(t'\) if \(t'_3>\kappa \), or there is another tuple \(\left\langle s,t'_2,t'_3 \right\rangle \in T\) with \(s \ge t'_1\). We denote these pruning strategies by P1 and P2, respectively.

After all n iterations, we attain the optimal objective value as \({\max _{\left\langle t_1,t_2,t_3 \right\rangle \in T}\{t_1\cdot t_2\}}\).

\(\triangleleft \)

If we are also interested in optimal solutions, we can use standard techniques to keep track of one solution per tuple. This incurs an additional factor of \(\Theta (n)\) in the running time later.

We observe that the computed solution is feasible. Moreover, the final set T contains every possible non-dominated tuple—and possibly some more:

Lemma 11

Algorithm 2 finds all non-dominated evaluation tuples of a given instance.

Proof

The algorithm is essentially a brute-force enumeration, computing all possible evaluation tuples. However, the algorithm uses two pruning strategies.

Pruning P1 is correct since the algorithm never decreases the number of non-zero components in any considered solution. Pruning P2 only deletes (some) dominated evaluation tuples: The tuples in iteration i correspond to subsolutions only considering the first i components. It is well-known, see e.g. (Nemhauser and Ullmann 1969), that any non-dominated solution x cannot contain any dominated subsolutions. If it contained a dominated subsolution \(x'\), let \(y'\) denote the subsolution dominating \(x'\); we could substitute \(x'\) by \(y'\) in x to achieve a new solution that then dominates x. \(\square \)

We now establish how the non-dominated tuples given by Algorithm 2 help us in solving Rkp. We have to be a bit more careful than in the proof of Lemma 8.

Lemma 12

The evaluation tuple of any optimal solution to Rkp is non-dominated.

Proof

Let \(\hat{x}\) be an optimal solution to Rkp and assume its evaluation tuple is dominated by some other evaluation tuple. Let x be a solution corresponding to the latter. Then \(a^\mathsf {T}x \ge a^\mathsf {T}\hat{x}\), \(b^\mathsf {T}x \ge b^\mathsf {T}\hat{x}\), and \(\mathbf {1}^\mathsf {T}x\le \mathbf {1}^\mathsf {T}\hat{x}\), with at least one of these inequalities being strict. If one of the first two is strict, x attains a better objective value than \(\hat{x}\)—a contradiction. If only the thirds is strict, we have \(\mathbf {1}^\mathsf {T}x<\kappa \) and could set a further component in x to 1, obtaining a yet better objective value—again a contradiction. \(\square \)

Theorem 13

Algorithm 2 is a pseudopolynomial exact algorithm for Rkp. Its running time is bounded by \(\mathcal {O} (n^3 \beta ) = \mathcal {O} (n^3 W^\downarrow )\).

Proof

The fact that Algorithm 2 computes all non-dominated evaluation tuples together with Lemma 12 establishes correctness, and it remains to discuss the running time. We can encode T as a two-dimensional array A with \(\kappa \beta \) rows and \(\kappa \) columns. A tuple \(\left\langle t_1, t_2, t_3 \right\rangle \) is stored as \(A[t_2, t_3] = t_1\); we have \(A[t'_2,t'_3]=-\infty \) if there is no tuple \(\left\langle \cdot ,t'_2,t'_3 \right\rangle \in T\). Thus each pruning test can be trivially performed in constant time. For later reference, let \(\tau \) denote the maximum number of tuples ever in T. We have \(\tau \le \kappa ^2 \beta \le n^2 \beta \). Over the n iterations this yields a running time of \(\mathcal {O} (n \tau ) \subseteq \mathcal {O} (n^3 \beta )\). \(\square \)

Corollary 14

Algorithm 2 yields a pseudopolynomial exact algorithm for Cbkp. Its running time is bounded by \(\mathcal {O} (n^3 \beta )= \mathcal {O} (n^3 W^\downarrow )\).

6 FPTAS

Algorithm 3

For a given \(\varepsilon \in (0,1)\), let

$$\begin{aligned} \delta {:=}\root n \of {\nicefrac {1}{(1 - \varepsilon )}} > 1 \end{aligned}$$

and for \(y\in {\mathbb {N}}\) let

$$\begin{aligned} \Delta (y) {:=}{\left\{ \begin{array}{ll}\left\lceil \log _{\delta } y \right\rceil &{} \text {if } y \ge 1\\ -1&{} \text {else.}\end{array}\right. } \end{aligned}$$

Given a solution \(x\in \{0,1\}^n\), we map it to its scaled evaluation tuple via

$$\begin{aligned} x \mapsto \left\langle a^\mathsf {T}x, \Delta \left( b^\mathsf {T}x\right) , \mathbf {1}^\mathsf {T}x \right\rangle . \end{aligned}$$

We reuse Algorithm 2 but modify it slightly: Instead of working on evaluation tuples, we let Algorithm 2 now work on scaled tuples. Observe that we thus initialize T with the tuple \(\left\langle 0,-1,0 \right\rangle \) that corresponds to \(x=\mathbf {0}\).

The only algorithmic part we need to change is the computation of new scaled evaluation tuples from a predecessor. In Algorithm 2, we were able to deduce a new candidate tuple \(t'\) using only the predecessor tuple \(t\in T\) and not an actual solution x, since only linear functions were involved. To also achieve the same running time in the new algorithm, we also shall not store a full solution for each tuple. Instead, for each scaled tuple \(t\in T\), we additionally store a single value B(t): Let x be a solution that yields tuple t; we want \(B(t){:=}b^\mathsf {T}x\) to be the value we would store as the second entry in an unscaled evaluation tuple of x. The initial tuple has \(B(\left\langle 0,-1,0 \right\rangle )=0\). For a scaled evaluation tuple \(t=\left\langle t_1,t_2,t_3 \right\rangle \in T\) in iteration i, we can then efficiently generate a new tuple \(t'{:=}\left\langle t_1+a_i,\Delta (B(t)+b_i),t_3+1 \right\rangle \) with \(B(t') {:=}B(t)+b_i\). Tuple \(t'\) is added to T subject to the same pruning strategies as described in Algorithm 2, working purely on the scaled evaluation tuples.

The final objective value is naturally computed as \(\max _{t=\left\langle t_1,t_2,t_3 \right\rangle \in T}t_1\cdot B(t)\).\(\triangleleft \)

Lemma 15

The running time of Algorithm 3 is bounded by \(\mathcal {O} (\varepsilon ^{-1}\, n^3\log (n\beta ))\subseteq \mathcal {O} (\varepsilon ^{-1}\, n^3\log (nW^\downarrow ))\subseteq \mathcal {O} (\varepsilon ^{-1} N^4)\).

Proof

The second entry in any scaled evaluation tuple is comprised by the \(\Delta \) function that can attain at most \(\lceil \log _{\delta } \kappa \beta \rceil + 2\) different values. Thus, we can let our array A have \(\lceil \log _{\delta } \kappa \beta \rceil + 2\) rows and \(\kappa \) columns. Again, let \(\tau \) denote the size of A. We have:

$$\begin{aligned} \tau \le \kappa (2 + \lceil \log _\delta \kappa \beta \rceil ) \le n (3 + \log _\delta n\beta ) \in \mathcal {O} \Bigg (\frac{n\log n\beta }{\log \delta }\Bigg ) = \mathcal {O} \Bigg (\frac{n^2\log n\beta }{\log \nicefrac {1}{(1 - \varepsilon )}}\Bigg ). \end{aligned}$$

The B(t) values can be perceived as an additional entry in every cell of A and thus contributing as a constant factor to the size of A. Considering \(\nicefrac 1\varepsilon \rightarrow \infty \), we have

$$\begin{aligned} \frac{1}{\log \nicefrac {1}{(1 - \varepsilon )}} = \frac{-1}{\log (1 - \varepsilon )} = \frac{1}{\varepsilon + \nicefrac {\varepsilon ^2}{2} + \nicefrac {\varepsilon ^3}{3} + \dots } \in \Theta \bigg (\frac{1}{\varepsilon }\bigg ) \end{aligned}$$

by Taylor expansion. Thus, \(\tau \in \mathcal {O} (\varepsilon ^{-1} n^2 \log n\beta )\). The algorithm’s overall running time is thus understood to be bounded by \(\mathcal {O} (n\tau )=\mathcal {O} (\varepsilon ^{-1} n^3 \log n\beta )\). \(\square \)

Theorem 16

Algorithm 3 is an FPTAS for Rkp.

Proof

Consider an Rkp instance \((a,b,\kappa )\) with an optimal solution \(\hat{x}\). Lemma 15 settles the running time requirement. It remains to show that for every \(\varepsilon >0\), Algorithm 3 finds a feasible solution \(\mathring{x}\) with \(f(\mathring{x}) \ge (1-\varepsilon )f(\hat{x})\).

Let \(X_i\) be a set of solutions corresponding to T after iteration \(i\in \{1, \dots n\}\), and \(X_0=\{ \mathbf {0}\}\). Recall that in any solution \(x\in X_i\), only the first i components of x may be non-zero. At any point in the algorithm, we may consider a final best solution \(\check{x}\) that we could still hope to find; initially set \(\check{x}{:=}\hat{x}\).

If the algorithm finds an optimal solution, the claim is true. Suppose an optimal solution is not found; let \(\ell \) be the smallest iteration index, such that there is no solution in \(X_\ell \) that has the same first \(\ell \) components as \(\check{x}\). We define \(\check{x}^\ell \in \{0,1\}^n\) such that \(\check{x}^\ell _i {:=}\check{x}_i\) for \(1\le i \le \ell \) and \(\check{x}^\ell _i {:=}0\) for \(\ell < i \le n\). That is, \(\check{x}^\ell \) is equal to \(\check{x}\) on the first \(\ell \) components and 0 in all further components. Since \(\check{x}^\ell \not \in X_\ell \), there must be some solution \(\bar{x}^\ell \in X_\ell \) that dominates \(\check{x}^{\ell }\).

Since \(\bar{x}^\ell \) dominates \(\check{x} ^\ell \) we have

$$\begin{aligned} a^\mathsf {T}\bar{x}^\ell&\ge a^\mathsf {T}\check{x}^\ell ,\\ \Delta \Big ( b^\mathsf {T} \bar{x}^\ell \Big )&\ge \Delta \Big (b^\mathsf {T} \check{x}^\ell \Big )\text {, and}\\ 1^T \bar{x}^\ell&\le 1^T \check{x}^\ell . \end{aligned}$$

Focusing on the second inequality, if \(\Delta \big (b^\mathsf {T} \bar{x}^\ell \big ) = -1\), we have \(b^\mathsf {T}\bar{x}^\ell = b^\mathsf {T}\check{x}^\ell = 0\). Otherwise, if \(\Delta \big (b^\mathsf {T} \check{x}^\ell \big ) = -1\), clearly \(b^\mathsf {T}\bar{x}^\ell \ge b^\mathsf {T}\check{x}^\ell \). If neither \(\Delta \)-evaluation yields \(-1\), we have for \(\nu {:=}\log _{\delta } b^\mathsf {T}\bar{x}^\ell \text { and } \mu {:=}\log _{\delta } b^\mathsf {T}\check{x}^\ell ,\) that \(\nu \ge \mu - 1\) and thus

$$\begin{aligned} b^\mathsf {T}\bar{x}^\ell = \delta ^\nu \ge \delta ^{\mu -1} = \nicefrac {1}{\delta } \cdot b^\mathsf {T}\check{x}^\ell . \end{aligned}$$

Consequently, in all cases the inequality

$$\begin{aligned} b^\mathsf {T}\bar{x}^\ell \ge \nicefrac 1\delta \cdot b^\mathsf {T}\check{x}^\ell \end{aligned}$$

holds.

We now define \(\check{x}^r {:=}\check{x} - \check{x}^\ell \), i.e., \(\check{x}^r\) matches \(\check{x}\) on the last \(n-\ell \) components and is 0 on the first \(\ell \) components. Let \(\tilde{x} {:=}\bar{x} ^\ell + \check{x} ^r\). We see that

$$\begin{aligned} a^\mathsf {T}\tilde{x} = a^\mathsf {T}\bar{x} ^\ell + a^\mathsf {T}\check{x}^r&\ \ge \ a^\mathsf {T}\check{x} ^\ell + a^\mathsf {T}\check{x}^r = a^\mathsf {T}\check{x},\\ b^\mathsf {T}\tilde{x} = b^\mathsf {T}\bar{x}^\ell + b^\mathsf {T}\check{x}^r&\ \ge \ \nicefrac {1}{\delta }\cdot b^\mathsf {T}\check{x}^\ell + b^\mathsf {T}\check{x}_i \ge \nicefrac {1}{\delta }\cdot b^\mathsf {T}\check{x}, \text { and }\\ 1^\mathsf {T}\tilde{x} = 1^\mathsf {T}\bar{x}^\ell + 1^\mathsf {T}\check{x}^r&\ \le \ 1^\mathsf {T}\check{x}^\ell + 1^ \mathsf {T}\check{x}^r = 1^\mathsf {T}\check{x}. \end{aligned}$$

Intuitively, while \(\check{x}\) is no longer attainable after iteration \(\ell \), solution \(\tilde{x}\) is still attainable as it can arise from \(\bar{x}\). At the same time, \(\tilde{x}\) is a solution with an objective value that is at most a factor of \(\nicefrac {1}{\delta }\) worse than \(\check{x}\) in the second component.

We can iterate the above consideration with \(\tilde{x}\) assuming the role of \(\check{x}\). We again look for an iteration index \(\ell \), such that the new \(\check{x}\) does not agree with some solution in \(X_\ell \) on its first \(\ell \) components. If such an index is not present then the new \(\check{x}\) is actually computed by the algorithm. If such an index is present, this new index \(\ell \) is now strictly larger than the index considered before. As there are only n possible indices, we repeat this argument at most n times. For each repetition, we lose a factor of at most \(\nicefrac {1}{\delta }\) in the second component.

Let \(\mathring{x}\) be the final solution by the algorithm. We conclude that \(b^\mathsf {T}\mathring{x} \ge \nicefrac {1}{\delta ^n} \cdot b^\mathsf {T}\hat{x} = (1-\varepsilon ) b^\mathsf {T}\hat{x}\), while \(a^\mathsf {T}\mathring{x} \ge a^\mathsf {T}\hat{x}\) and \(1^\mathsf {T}\mathring{x}\le 1^\mathsf {T}\hat{x} \le \kappa \). Consequently, \(\mathring{x}\) is feasible and \(f(\mathring{x}) = \left( a^\mathsf {T}\mathring{x}\right) \left( b^\mathsf {T}\mathring{x}\right) \ge \left( a^\mathsf {T}\hat{x}\right) (1-\varepsilon )\left( b^\mathsf {T}\hat{x}\right) = (1-\varepsilon ) f(\hat{x})\). \(\square \)

Corollary 17

Algorithm 3 yields an FPTAS for Cbkp with running time in \(\mathcal {O} (\varepsilon ^{-1}\, n^3\log n\beta )\subseteq \mathcal {O} (\varepsilon ^{-1}\, n^3\log (nW^\downarrow ))\subseteq \mathcal {O} (\varepsilon ^{-1} N^4)\).

7 Conclusion

We answered all open questions from Schulze et al. (2020) regarding the complexity and approximability of Rkp: while the problem is indeed NP -hard, it allows not only a pseudopolynomial exact algorithm, but also an FPTAS—the theoretically strongest kind of approximation algorithm. Furthermore, our techniques in fact also allow us to directly tackle the Cbkp, achieving the equivalent algorithmic results.

Comparing Algorithms 1 and 3, our approach achieves a better running time in all cases: \(\mathcal {O} (\varepsilon ^{-2}n^3\log ( n W^\downarrow )\log ( n W^\uparrow )) \subseteq \mathcal {O} (\varepsilon ^{-2} N^5)\) vs. \(\mathcal {O} (\varepsilon ^{-1}\, n^3\log \left( nW^\downarrow \right) )\subseteq \mathcal {O} (\varepsilon ^{-1} N^4)\). Especially, our pseudopolynomial algorithm shows that Rkp can be solved in polynomial time even if only \(W^\downarrow \) (but not \(W^\uparrow \)) is bounded by a polynomial in the input size.

Furthermore, it should be understood that our algorithms (and proofs) can trivially be extended to any fixed arbitrary number of objective functions.