Discrete Optimization
An effective dynamic programming algorithm for the minimum-cost maximal knapsack packing problem

https://doi.org/10.1016/j.ejor.2017.03.061Get rights and content

Highlights

  • A new and effective dynamic programming algorithm is presented.

  • We studied the two best-performing formulations and proved their equivalence.

  • An extensive computational study on instances with up to 5000 items is provided.

  • Dynamic programming outperforms the previous approaches by orders of magnitude.

  • The covering counterpart of the problem is also studied.

Abstract

Given a set of items with profits and weights and a knapsack capacity, we study the problem of finding a maximal knapsack packing that minimizes the profit of the selected items. We propose an effective dynamic programming (DP) algorithm which has a pseudo-polynomial time complexity. We demonstrate the equivalence between this problem and the problem of finding a minimal knapsack cover that maximizes the profit of the selected items. In an extensive computational study on a large and diverse set of benchmark instances, we demonstrate that the new DP algorithm outperforms a state-of-the-art commercial mixed-integer programming (MIP) solver applied to the two best performing MIP models from the literature.

Introduction

One of the most famous and most studied problems in combinatorial optimization is the classical Knapsack Problem (KP) which is defined as follows: Given a knapsack capacity C > 0 and a set I={1,,n} of items, with profits pi ≥ 0 and weights wi ≥ 0, KP asks for a maximum profit subset of items whose total weight does not exceed the capacity. The problem can be formulated using the following mixed-integer program (MIP): max{iIpixi:iIwixiC,xi{0,1},iI},where each variable xi takes value 1 if and only if item i is inserted in the knapsack. Without loss of generality, we can assume that all input parameters take integer values. In the following, we will refer to (I, p, w, C) as a knapsack instance. KP is NP-hard, but it is well-known that fairly large instances can be solved to optimality within short computing time (see, e.g., Kellerer, Pferschy, Pisinger, 2004, Martello, Pisinger, Toth, 2000, Martello, Toth, 1990, for comprehensive surveys on applications and variants of KP).

Optimization problems related to KP search for solutions satisfying one of the following two properties:

Definition 1 Maximal Knapsack Packing

Given a knapsack instance (I, p, w, C), a packing PI is a subset of items which does not exceed the capacity C, i.e., iPwiC. A packing P is called maximal if and only if P{i} is not a packing for any iP.

Definition 2 Minimal Knapsack Cover

Given a knapsack instance (I, p, w, C), a cover KI is a subset of items which exceeds or it is equal to the capacity C, i.e., cKwcC. A cover K is called minimal if and only if K{i} is not a cover for any iK.

In this article we study weighted versions of the knapsack covering and knapsack packing problems which are defined below.

Definition 3 The Minimum-Cost Maximal Knapsack Packing Problem (MCMKP)

Given a knapsack instance (I, p, w, C), the goal of MCMKP is to find a maximal knapsack packing S* ⊂ I that minimizes the profit of selected items, i.e.: S*=argminSI{iSpi|iSwiCandiSwi+wj>C,jS}.

Definition 4 The Maximum-Profit Minimal Knapsack Cover Problem (MPMKC)

Given a knapsack instance (I, p, w, C), the goal of MPMKC is to find a minimal knapsack cover S*⊆I that maximizes the profit, i.e.: S*=argmaxSI{iSpi|iSwiCandiS{j}wi<C,jS}.

In both MCMKP and MPMKC, we assume that the problem instance (I, p, w, C) is non-trivial, i.e., the corresponding optimal solution S* is a proper subset of I.

In the classical KP, one tries to pack items while maximizing their (non-negative) profits, hence, any optimal KP solution is a maximal knapsack packing. On the contrary, the objective function of MCMKP goes in the opposite direction – one searches for a subset of items to pack, while minimizing the profit of the selected items. Hence, solving the standard KP in which the profit-maximization objective is replaced by profit-minimization results in a trivial (empty) solution. This is why the maximal packing property has to be explicitly imposed when searching for an optimal MCMKP solution.

MCMKP models applications related to scheduling jobs on a single machine with common arrival times and a common deadline. The problem consists of selecting a subset of jobs to schedule (before the given deadline) and accordingly the order in which the jobs are scheduled becomes irrelevant. The set I refers to all possible jobs, job durations are given as wi and pi is the cost for executing job i, iI. The common deadline C corresponds to the capacity of the knapsack. The goal is to minimize the cost for executing scheduled jobs while at the same time ensuring that the maximal subset of jobs is scheduled (i.e., a maximal packing is preserved). Consequently, the scheduling task boils down to solving MCMKP. The problem has been called the Lazy Bureaucrat Problem (LBP) with common arrivals and deadlines (see, e.g., Gourvès, Monnot, & Pagourtzis, 2013), motivated by the special case in which pi=wi, for all iI. We deliberately refrain from using this name since in this article we study a more general setting in which no correlation is assumed to exist between the item profits and item weights.

Similarly, in case of MPMKC, the goal is to maximize the profit of scheduled jobs while ensuring that a minimal possible subset of jobs exceeding the deadline is scheduled (i.e., to preserve a minimal cover). MPMKC has been called the Greedy Boss Problem in Gourvès et al. (2013), but again, since this name is also motivated by the setting pi=wi, for all iI, we will not use this name in the remainder of the article.

MCMKP has been introduced in Arkin, Bender, Mitchell, and Skiena (2003) where it has been shown that a more general problem variant with individual arrival times and deadlines is NP-hard. Following this seminal work, the problem has been extensively studied in the Computer Science literature and results concerning the complexity of special classes of the problem and approximation algorithms have been presented (Gai, Zhang, 2008, Gourvès, Monnot, Pagourtzis, 2013, Hepner, Stein, 2002). Only the recent preliminary work (Furini, Ljubić, & Sinnl, 2015) studies the development of exact solution methods for MCMKP.

According to the definition of the coefficients pi of the objective function, the following special cases are known in the (scheduling) literature:

  • min-number-of-jobs: In this case, pi=1 for all iI and the goal is to minimize the number of scheduled jobs. By reduction from the subset-sum problem, it has been shown in Gai and Zhang (2008) that this problem variant is weakly NP-hard.

  • min-time-spent: This variant corresponds to the problem in which pi=wi for all iI. Since job profits are equal to job durations, this explains the name LBP, i.e., the goal of a “lazy employee” is to go home as early as possible, while having an excuse that there is no more time left to start a new job. This variant is also equivalent to the min-makespan variant, since all jobs have common arrival times and the goal is to minimize the time spent on executing jobs. In Gourvès et al. (2013), two greedy heuristics and an FPTAS have been proposed for the min-time-spent variant with common arrivals and deadlines.

  • min-weighted-sum: This variant considers the most general case, with no restrictions on the values of pi, and hence it covers all previous cases. We consider this variant in our article. In Furini et al. (2015), an O(n2C) dynamic programming algorithm is proposed, thus showing that MCMKP is weakly NP-hard in this general setting. In addition, three MIP formulations and their constraint programming (CP) counterparts are developed and tested, showing that the best computational performance is obtained by two of the proposed MIP models (these models are revised in Section 4).

This article aims at providing an in-depth study of exact methods (based on MIP and DP techniques) for solving MCMKP and MPMKC to provable optimality. Our contribution is as follows: First, we design a dynamic programming algorithm for MCMKP that runs in O(nC) time and O(n+C) space. It improves upon the previous DP from Furini et al. (2015) which has been shown to run in O(n2C) time and O(nC) space. Second, we compare the quality of the linear programming (LP) relaxations of the two best performing MIP models from the literature. In an extensive computational study on a large and diverse set of benchmark instances, we demonstrate that the new DP algorithm outperforms a state-of-the-art commercial MIP solver applied to these two best performing models.

Finally, we prove that MCMKP and MPMKC are two equivalent problems and that there exists a linear transformation between them. This implies that MPMKC is weakly NP-hard as well, and that there exists a DP procedure which runs in O(n(WC)) time and requires O(n+(WC)) space, where W is the sum of all item weights.

The remainder of this article is organized as follows: in the following section, we present structural properties of optimal MCMKP solutions that can be used to derive DP algorithms and MIP models. Section 3 is devoted to our new DP procedure for MCMKP. In Section 4, we present and discuss new results for two MIP models for the MCMKP. In Section 5 we prove the equivalence between MCMKP and MPMKC. Computational results are provided in Section 6 and conclusions are drawn in Section 7.

Section snippets

Solution properties for MCMKP

In this section we point out some structural properties of MCMKP solutions that will be used in the remainder of this article.

In the following, we assume that all items are sorted in nondecreasing order according to their weight, i.e., w1w2wn. For each iI, we define Ci:=Cwi, so we have C1C2Cn. We also denote by wmax:=maxiIwi(=wn). We define W:=iIwi and P:=iIpi. For a set S ⊂ I, let w(S)=iSwi and let Wi=j<iwj.

It is not difficult to see that the following property is valid, due

A new O(nC) dynamic programming algorithm for solving MCMKP

In this section we derive a new dynamic programming (DP) algorithm for MCMKP. The DP is based on the fact that, once the smallest item left out of the solution is known, MCMKP reduces to solving the knapsack problem with a lower and upper bound on its capacity (denoted by LU-KP in the following). This property can be stated as follows:

Proposition 4

The optimal MCMKP solution can be calculated as follows: OPT=miniI:iic{KP(i,C̲,C¯)+j<ipj}whereC̲=CWiwi+1 andC¯=CWi, and KP(i,C̲,C¯)=min{j>ipjyj:C̲j>iwjyj

MIP models for MCMKP

Several MIP and constraint programming (CP) formulations for MCMKP have been proposed in Furini et al. (2015) where it has been demonstrated that CP formulations are not competitive against MIP models. In the following, we present the two best performing MIP models, both of which use binary variables xi, for all iI, representing the selected items in the knapsack. The first formulation is in the natural variable space, and the second one in an extended space. We then derive new interesting

Equivalence between MCMKP and MPMKC

In this section we prove the following result:

Proposition 8

Any feasible solution S of MCMKP on an instance (I, p, w, C) corresponds to a feasible solutionS=IS of MPMKC on instance (I, p, w, C′) whereC=WC.

Before showing this result, we will discuss the critical item of MPMKC and a counterpart of the extended formulation for MPMKC. As above, we assume that items are sorted in nondecreasing order according to their weights. Observe that the index of the critical item and the corresponding weight for MPMKC

Computational study

The primary goal of this computational study is to compare the performances of the dynamic programming algorithm (DP) described in Section 3 with the MIP models discussed in Section 4. To the best of our knowledge, these models are the best performing formulations proposed so far in the literature. The computational results presented in Furini et al. (2015) allow us to conclude that both models, i.e., (Fl) and (Fe), outperform in terms of computing times the DP algorithm proposed in Furini

Conclusions and future work

Problems which impose inclusion-wise maximality of a feasible solution while at the same time minimizing a non-negative cost function, have recently received much attention from the Theoretical Computer Science community. In particular, the so-called Lazy Bureaucrat Problem has been studied from approximation and complexity points of view (see e.g., Gourvès et al., 2013 and the references therein).

In this article we studied two versions of this problem denoted by the Minimum-Cost Maximal

Acknowledgments

The authors would like to thank the two anonymous referees for their valuable comments which helped to improve the quality of the paper. The research of M. Sinnl was supported by the Austrian Research Fund (FWF, Project P 26755-N19).

References (21)

There are more references available in the full text version of this article.

Cited by (31)

  • Knapsack problems — An overview of recent advances. Part I: Single knapsack problems

    2022, Computers and Operations Research
    Citation Excerpt :

    An improved FPTAS was developed by Kovalev (2022). Furini et al. (2017) introduced the minimum-cost maximal knapsack packing problem: it consists in finding a maximal knapsack packing that minimizes the cost of the selected items. The authors proposed a DP algorithm, and showed that the problem is equivalent to a “dual” problem (the maximum-cost minimal knapsack cover).

  • Upper Dominating Set: Tight algorithms for pathwidth and sub-exponential approximation

    2022, Theoretical Computer Science
    Citation Excerpt :

    Studying Max-Min and Min-Max versions of some famous optimization problems is not a new idea, and it has recently attracted some interest in the literature: Minimum Maximal Independent Set [1–3] (also known as Minimum Independent Dominating Set), Maximum Minimal Vertex Cover [4,5], Maximum Minimal Separator [6], Maximum Minimal Cut [7], Minimum Maximal Knapsack [8–10] (also known as Lazy Bureaucrat Problem), Maximum Minimal Feedback Vertex Set [11].

  • (In)approximability of maximum minimal FVS

    2022, Journal of Computer and System Sciences
  • A novel resampling algorithm based on the knapsack problem

    2020, Signal Processing
    Citation Excerpt :

    The Greedy resampling algorithm outperforms the Stratified, MSV and Residual resampling algorithms on the same benchmark problem [31]. The knapsack problem is known to be a popular problem in the literature [33–39]. This is a constrained optimization problem which derives its name from a scenario where one can place a certain number of items inside a knapsack with a certain capacity.

View all citing articles on Scopus
View full text