Quadratic Knapsack Problem
   HOME

TheInfoList



OR:

The quadratic knapsack problem (QKP), first introduced in 19th century, is an extension of
knapsack problem The knapsack problem is a problem in combinatorial optimization: Given a set of items, each with a weight and a value, determine the number of each item to include in a collection so that the total weight is less than or equal to a given limit an ...
that allows for quadratic terms in the objective function: Given a set of items, each with a weight, a value, and an extra profit that can be earned if two items are selected, determine the number of items to include in a collection without exceeding capacity of the
knapsack A backpack—also called knapsack, schoolbag, rucksack, rucksac, pack, sackpack, booksack, bookbag or backsack—is, in its simplest frameless form, a fabric sack carried on one's back and secured with two straps that go over the shoulders ...
, so as to maximize the overall profit. Usually, quadratic knapsack problems come with a restriction on the number of copies of each kind of item: either 0, or 1. This special type of QKP forms the 0-1 quadratic knapsack problem, which was first discussed by Gallo et al. The 0-1 quadratic knapsack problem is a variation of knapsack problems, combining the features of unbounded knapsack problem, 0-1 knapsack problem and quadratic knapsack problem.


Definition

Specifically, the 0–1 quadratic knapsack problem has the following form: : \text \left\ : \text X\equiv\left\. Here the binary variable ''xi'' represents whether item ''i'' is included in the knapsack, p_i is the profit earned by selecting item ''i'' and P_ is the profit achieved if both item ''i'' and ''j'' are added. Informally, the problem is to maximize the sum of the values of the items in the knapsack so that the sum of the weights is less than or equal to the knapsack's capacity.


Application

As one might expect, QKP has a wide range of applications including
telecommunication Telecommunication is the transmission of information by various types of technologies over wire, radio, optical, or other electromagnetic systems. It has its origin in the desire of humans for communication over a distance greater than that fe ...
, transportation network,
computer science Computer science is the study of computation, automation, and information. Computer science spans theoretical disciplines (such as algorithms, theory of computation, information theory, and automation) to Applied science, practical discipli ...
and
economics Economics () is the social science that studies the Production (economics), production, distribution (economics), distribution, and Consumption (economics), consumption of goods and services. Economics focuses on the behaviour and intera ...
. In fact, Witzgall first discussed QKP when selecting sites for satellite stations in order to maximize the global traffic with respect to a budget constraint. Similar model applies to problems like considering the location of airports, railway stations, or freight handling terminals. Applications of QKP in the field of computer science is more common after the early days:
compiler In computing, a compiler is a computer program that translates computer code written in one programming language (the ''source'' language) into another language (the ''target'' language). The name "compiler" is primarily used for programs that ...
design problem,
clique problem In computer science, the clique problem is the computational problem of finding cliques (subsets of vertices, all adjacent to each other, also called complete subgraphs) in a graph. It has several different formulations depending on which cliq ...
,
very large scale integration Very large-scale integration (VLSI) is the process of creating an integrated circuit (IC) by combining millions or billions of MOS transistors onto a single chip. VLSI began in the 1970s when MOS integrated circuit (Metal Oxide Semiconductor) c ...
(VLSI) design. Additionally, pricing problems appear to be an application of QKP as described by Johnson et al.


Computational complexity

In general, the decision version of the knapsack problem (Can a value of at least V be achieved under a restriction of a certain capacity W?) is
NP-complete In computational complexity theory, a problem is NP-complete when: # it is a problem for which the correctness of each solution can be verified quickly (namely, in polynomial time) and a brute-force search algorithm can find a solution by tryi ...
. Thus, a given solution can be verified to in polynomial time while no algorithm can identify a solution efficiently. The optimization knapsack problem is
NP-hard In computational complexity theory, NP-hardness ( non-deterministic polynomial-time hardness) is the defining property of a class of problems that are informally "at least as hard as the hardest problems in NP". A simple example of an NP-hard pr ...
and there is no known algorithm that can solve the problem in polynomial time. As a particular variation of the knapsack problem, the 0-1 quadratic knapsack problem is also NP-hard. While no available efficient algorithm exists in the literature, there is a
pseudo-polynomial time In computational complexity theory, a numeric algorithm runs in pseudo-polynomial time if its running time is a polynomial in the ''numeric value'' of the input (the largest integer present in the input)—but not necessarily in the ''length'' of th ...
based on
dynamic programming Dynamic programming is both a mathematical optimization method and a computer programming method. The method was developed by Richard Bellman in the 1950s and has found applications in numerous fields, from aerospace engineering to economics. I ...
and other
heuristic A heuristic (; ), or heuristic technique, is any approach to problem solving or self-discovery that employs a practical method that is not guaranteed to be optimal, perfect, or rational, but is nevertheless sufficient for reaching an immediate, ...
algorithms that can always generate “good” solutions.


Solving

While the knapsack problem is one of the most commonly solved
operation research Operations research ( en-GB, operational research) (U.S. Air Force Specialty Code: Operations Analysis), often shortened to the initialism OR, is a discipline that deals with the development and application of analytical methods to improve decis ...
(OR) problems, there are limited efficient algorithms that can solve 0-1 quadratic knapsack problems. Available algorithms include but are not limited to brute force,
linearization In mathematics, linearization is finding the linear approximation to a function at a given point. The linear approximation of a function is the first order Taylor expansion around the point of interest. In the study of dynamical systems, lineariz ...
, and convex reformulation. Just like other NP-hard problems, it is usually enough to find a workable solution even if it is not necessarily optimal. Heuristic algorithms based on
greedy algorithm A greedy algorithm is any algorithm that follows the problem-solving heuristic of making the locally optimal choice at each stage. In many problems, a greedy strategy does not produce an optimal solution, but a greedy heuristic can yield locally ...
, dynamic programming can give a relatively “good” solution to the 0-1 QKP efficiently.


Brute force

The brute-force algorithm to solve this problem is to identify all possible subsets of the items without exceeding the capacity and select the one with the optimal value. The pseudo-code is provided as follows: // Input: // Profits (stored in array p) // Quadratic profits (stored in matrix P) // Weights (stored in array w) // Number of items (n) // Knapsack capacity (W) int max = 0 for all subset S do int value, weight = 0 for i from 0 to S.size-1 do: value = value + p weight = weight + w for j from i+1 to S.size-1 do: value = value + P j] if weight <= W then: if value > max then: max = value Given ''n'' items, there will be at most 2^n subsets and for each legal candidate set, the running time of computing the values earned is O(n^2). Thus, the efficiency class of brute-force algorithm is (2^n n^2 )=\lambda(2^n), being exponential.


Linearization

Problems of such form are difficult to solve directly using standard solvers and thus people try to reformulate it as a
linear program Linear programming (LP), also called linear optimization, is a method to achieve the best outcome (such as maximum profit or lowest cost) in a mathematical model whose requirements are represented by linear relationships. Linear programming is ...
using auxiliary variables and constraints so that the problem can be readily solved using commercial packages. Two well-known
linearization In mathematics, linearization is finding the linear approximation to a function at a given point. The linear approximation of a function is the first order Taylor expansion around the point of interest. In the study of dynamical systems, lineariz ...
approaches for the 0-1 QKP are the standard linearization and Glover’s linearization.


Standard linearization

The first one is the standard linearization strategy, as shown below: : LP1: maximize :\sum_^n p_i x_i + \sum_^n \left(\sum_^n (P_ + P_) z_ \right). : subject to :z_\leq x_i for all (i,j), i :z_\leq x_j for all (i,j), i :x_i+x_j-1\leq z_ for all (i,j), i :z_\geq 0 for all (i,j), i :x \in X, x binary In the formulation LP1, we have replaced the ''xixj'' term with a continuous variable ''zij''. This reformulates the QKP into a knapsack problem, which we can then solve optimally using standard solvers.


Glover's linearization

The second reformulation, which is more concise, is called Glover’s linearization. The Glover formulation is shown below, where ''Li'' and ''Ui'' are lower and upper bounds on \sum_^n P_x_j, respectively: : LP2: maximize :\sum_^n p_i x_i + \sum_^nz_i : subject to :L_ix_i\leq z_i \leq U_ix_i for i=1,\ldots, n :\sum_^nP_ x_j - U_i(1-x_i)\leq z_i\leq \sum_^nP_ x_j-L_i(1-x_i) for i=1,\ldots, n :x \in X, x binary In the formulation LP2, we have replaced the expression \sum_^n P_ x_i x_j with a continuous variable ''zi''. Similarly, we can use standard solvers to solve the linearized problem. Note that Glover’s linearization only includes n auxiliary variables with 2n constraints while standard linearization requires auxiliary variables and 3 constraints to achieve linearity.


Convex quadratic reformulation

Note that nonlinear programs are hard to solve due to the possibility of being stuck at a
local maximum In mathematical analysis, the maxima and minima (the respective plurals of maximum and minimum) of a function, known collectively as extrema (the plural of extremum), are the largest and smallest value of the function, either within a given ran ...
. However, when the program is
convex Convex or convexity may refer to: Science and technology * Convex lens, in optics Mathematics * Convex set, containing the whole line segment that joins points ** Convex polygon, a polygon which encloses a convex set of points ** Convex polytope ...
, any local maximum is the
global maximum In mathematical analysis, the maxima and minima (the respective plurals of maximum and minimum) of a function, known collectively as extrema (the plural of extremum), are the largest and smallest value of the function, either within a given ra ...
. A convex program is to maximize a
concave function In mathematics, a concave function is the negative of a convex function. A concave function is also synonymously called concave downwards, concave down, convex upwards, convex cap, or upper convex. Definition A real-valued function f on an in ...
or minimize a
convex function In mathematics, a real-valued function is called convex if the line segment between any two points on the graph of a function, graph of the function lies above the graph between the two points. Equivalently, a function is convex if its epigra ...
on a
convex set In geometry, a subset of a Euclidean space, or more generally an affine space over the reals, is convex if, given any two points in the subset, the subset contains the whole line segment that joins them. Equivalently, a convex set or a convex r ...
. A set S is convex if \forall u,v\in S, \lambda u+(1-\lambda)v\in S where \lambda \in ,1/math>. That is to say, any point between two points in the set must also be an element of the set. A function ''f'' is concave if f lambda u+(1-\lambda)vleq \lambda f(u)+(1-\lambda)f(v). A function ''f'' is convex if f lambda u+(1-\lambda)vgeq \lambda f(u)+(1-\lambda)f(v). Informally, a function is concave if the line segment connecting two points on the graph lies above or on the graph, while a function is convex if below or on the graph. Thus, by rewriting the objective function into an equivalent convex function, we can reformulate the program to be convex, which can be solved using optimization packages. The objective function can be written as c^Tx+x^TCx using linear algebra notation. We need to make ''P'' a
positive semi-definite matrix In mathematics, a symmetric matrix M with real entries is positive-definite if the real number z^\textsfMz is positive for every nonzero real column vector z, where z^\textsf is the transpose of More generally, a Hermitian matrix (that is, a co ...
in order to reformulate a convex function. In this case, we modify the objective function to be p^Tx+x^TPx+\sum_^n \left(\sum_^n, P_, \right)(x_i^2-x_i) by applying results from linear algebra, where ''P'' is a
diagonally dominant matrix In mathematics, a square matrix is said to be diagonally dominant if, for every row of the matrix, the magnitude of the diagonal entry in a row is larger than or equal to the sum of the magnitudes of all the other (non-diagonal) entries in that row ...
and thus a positive semi-definite. This reformulation can be solved using a standard commercial mixed-integer quadratic package.


Greedy heuristic algorithm

George Dantzig proposed a greedy approximation algorithm to unbounded knapsack problem which can also be used to solve the 0-1 QKP. The algorithm consists of two phrases: identify an initial solution and improve it. First compute for each item, the total objective contribution realizable by selecting it, p_i+\sum_^n P_, and sort the items in decreasing order of the potential value per unit of weight, (p_i+\sum_^nP_)/w_i. Then select the items with the maximal value-weight ratio into the knapsack until there is no space for more, which forms the initial solution. Starting with the initial solution, the improvement is conducted by pairwise exchange. For each item in the solution set, identify the items not in the set where swapping results in an improving objective. Select the pair with maximal improvement and swap. There are also possibilities that removing one from the set or adding one to the set will produce the greatest contribution. Repeat until there is no improving swapping. The complexity class of this algorithm is O(2^n) since for the worst case every possible combination of items will be identified.


Quadknap

Quadknap is an exact
branch-and-bound Branch and bound (BB, B&B, or BnB) is an algorithm design paradigm for discrete and combinatorial optimization problems, as well as mathematical optimization. A branch-and-bound algorithm consists of a systematic enumeration of candidate soluti ...
algorithm proposed by Caprara et al., where upper bounds are computed by considering a
Lagrangian relaxation In the field of mathematical optimization, Lagrangian relaxation is a relaxation method which approximates a difficult problem of constrained optimization by a simpler problem. A solution to the relaxed problem is an approximate solution to the o ...
which approximate a difficult problem by a simpler problem and penalizes violations of constraints using
Lagrange multiplier In mathematical optimization, the method of Lagrange multipliers is a strategy for finding the local maxima and minima of a function subject to equality constraints (i.e., subject to the condition that one or more equations have to be satisfied ex ...
to impost a cost on violations. Quadknap releases the integer requirement when computing the upper bounds. Suboptimal Lagrangian multipliers are derived from sub-gradient optimization and provide a convenient reformulation of the problem. This algorithm is quite efficient since Lagrangian multipliers are stable, and suitable data structures are adopted to compute a tight upper bound in linear expected time in the number of variables. This algorithm was reported to generate exact solutions of instances with up to 400 binary variables, i.e., significantly larger than those solvable by other approaches. The code was written in C and is available online.


Dynamic programming heuristic

While dynamic programming can generate optimal solutions to knapsack problems, dynamic programming approaches for QKP can only yield a relatively good quality solution, which can serve as a lower bound to the optimal objectives. While it runs in pseudo-polynomial time, it has a large memory requirement.


Dynamic programming algorithm

For simplicity, assume all weights are non-negative. The objective is to maximize total value subject to the constraint: that the total weight is less than or equal to ''W''. Then for each w\leq W, define f(m,w) to be the value of the most profitable packing of the first m items found with a total weight of ''w''. That is, let : f(m,w)=\max\left\. Then, f(m,w) is the solution to the problem. Note that by dynamic programming, the solution to a problem arises from the solution to its smaller sub-problems. In this particular case, start with the first item and try to find a better packing by considering adding items with an expected weight of 𝑤. If the weight of the item to be added exceeds ''𝑤'', then f(m,w) is the same with f(m-1,w). Given that the item has a smaller weight compared with the desired weight, f(m,w) is either the same as f(m-1,w) if adding makes no contribution, or the same as the solution for a knapsack with smaller capacity, specifically one with the capacity reduced by the weight of that chosen item, plus the value of one correct item, i.e. f(m-1,w-w_m)+p_m+\sum_^P_x_i. To conclude, we have that : f(m,w)= \begin \max f(m-1,w),f(m-1,w-w_m)+p_m+\sum_^P_x_i & \text w_m\leq w\\ f(m-1,w) & \text \end Note on efficiency class: Clearly the running time of this algorithm is O(Wn^2), based on the nested loop and the computation of the profit of new packing. This does not contradict the fact the QKP is NP-hard since ''W'' is not polynomial in the length of the input.


Revised dynamic programming algorithm

Note that the previous algorithm requires O(Wn^2) space for storing the current packing of items for all ''m,w'', which may not be able to handle large-size problems. In fact, this can be easily improved by dropping the index ''m'' from f(m,w) since all the computations depend only on the results from the preceding stage. Redefine f(w) to be the current value of the most profitable packing found by the heuristic. That is, : f(w)=\max\left\. Accordingly, by dynamic programming we have that : f(m)= \begin \max f(w),f(w-w_m)+p_m+\sum_^P_x_i & \text w_m\leq w, \\ f(w) & \text \end Note this revised algorithm still runs in O(Wn^2) while only taking up O(Wn) memory compared to the previous O(Wn^2).


Related research topics

Researchers have studied 0-1 quadratic knapsack problems for decades. One focus is to find effective algorithms or effective heuristics, especially those with an outstanding performance solving real world problems. The relationship between the decision version and the optimization version of the 0-1 QKP should not be ignored when working with either one. On one hand, if the
decision problem In computability theory and computational complexity theory, a decision problem is a computational problem that can be posed as a yes–no question of the input values. An example of a decision problem is deciding by means of an algorithm whethe ...
can be solved in polynomial time, then one can find the optimal solution by applying this algorithm iteratively. On the other hand, if there exists an algorithm that can solve the
optimization problem In mathematics, computer science and economics, an optimization problem is the problem of finding the ''best'' solution from all feasible solutions. Optimization problems can be divided into two categories, depending on whether the variables ...
efficiently, then it can be utilized in solving the decision problem by comparing the input with the optimal value. Another theme in literature is to identify what are the "hard" problems. Researchers who study the 0-1 QKP often perform computational studies to show the superiority of their strategies. Such studies can also be conducted to assess the performance of different solution methods. For the 0-1 QKP, those computational studies often rely on randomly generated data, introduced by Gallo et al. Essentially every computational study of the 0-1 QKP utilizes data that is randomly generated as follows. The weights are integers taken from a uniform distribution over the interval , 50 and the capacity constraints is an integer taken from a uniform distribution between 50 and the sum of item weights. The objective coefficients, i.e. the values are randomly chosen from ,100 It has been observed that generating instances of this form yields problems with highly variable and unpredictable difficulty. Therefore, the computational studies presented in the literature may be unsound. Thus some researches aim to develop a methodology to generate instances of the 0-1 QKP with a predictable and consistent level of difficulty.


See also

*
Knapsack problem The knapsack problem is a problem in combinatorial optimization: Given a set of items, each with a weight and a value, determine the number of each item to include in a collection so that the total weight is less than or equal to a given limit an ...
*
Combinatorial auction A combinatorial auction is a type of smart market in which participants can place bids on combinations of discrete heterogeneous items, or “packages”, rather than individual items or continuous quantities. These packages can be also called lot ...
*
Combinatorial optimization Combinatorial optimization is a subfield of mathematical optimization that consists of finding an optimal object from a finite set of objects, where the set of feasible solutions is discrete or can be reduced to a discrete set. Typical combi ...
*
Continuous knapsack problem In theoretical computer science, the continuous knapsack problem (also known as the fractional knapsack problem) is an algorithmic problem in combinatorial optimization in which the goal is to fill a container (the "knapsack") with fractional amount ...
*
List of knapsack problems The knapsack problem is one of the most studied problems in combinatorial optimization, with many real-life applications. For this reason, many special cases and generalizations have been examined. Common to all versions are a set of ''n'' items, w ...
*
Packing problem Packing problems are a class of optimization problems in mathematics that involve attempting to pack objects together into containers. The goal is to either pack a single container as densely as possible or pack all objects using as few conta ...


Notes

{{Reflist, 30em


External links


David Pisinger's Codes for different knapsack problem
Packing problems NP-complete problems Dynamic programming Combinatorial optimization Pseudo-polynomial time algorithms