ArticleslgStudy

computer science

Quadratic knapsack problem

Quadratic knapsack problem is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Quadratic knapsack problem rather than just read about it. In short: The quadratic knapsack problem (QKP), first introduced in 19th century, is an extension of knapsack problem 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, so as to maximize the overall prof…

Key takeaways

  • Quadratic knapsack problem belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Quadratic knapsack problem to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Quadratic knapsack problem from memory before moving on to harder problems.

Reference excerpt

The quadratic knapsack problem (QKP), first introduced in 19th century, is an extension of knapsack problem 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, 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 the knapsack problem, combining the features of the 0-1 knapsack problem and the quadratic knapsack problem.

Definition Specifically, the 0–1 quadratic knapsack problem has the following form:

maximize { ∑ i = 1 n p i x i + ∑ i = 1 n ∑ j = 1 , i ≠ j n P i j x i x j : x ∈ X , x binary } {\displaystyle {\text{maximize }}\left\{\sum _{i=1}^{n}p_{i}x_{i}+\sum _{i=1}^{n}\sum _{j=1,i\neq j}^{n}P_{ij}x_{i}x_{j}:x\in X,x{\text{ binary}}\right\}}

subject to X ≡ { x ∈ { 0 , 1 } n : ∑ i = 1 n w i x i ≤ W ; x i ∈ { 0 , 1 } for i = 1 , … , n } . {\displaystyle {\text{subject to }}X\equiv \left\{x\in \{0,1\}^{n}:\sum _{i=1}^{n}w_{i}x_{i}\leq W;x_{i}\in \{0,1\}{\text{ for }}i=1,\ldots ,n\right\}.}

Here the binary variable xi represents whether item i is included in the knapsack, p i {\displaystyle p_{i}} is the profit earned by selecting item i and P i j {\displaystyle P_{ij}} 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, transportation network, computer science and economics. 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 design problem, clique problem, very large scale integration (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. Thus, a given solution can be verified in polynomial time while no algorithm can identify a solution efficiently. The optimization knapsack problem is NP-hard 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 based on dynamic programming and other heuristic algorithms that can always generate “good” solutions.

Solving While the knapsack problem is one of the most commonly solved operation research (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, 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, 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:

… excerpt ends here. Continue reading the full article.

Worked examples

Example 1 — a first encounter with Quadratic knapsack problem

Start with the simplest possible case. Write down what Quadratic knapsack problem claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Quadratic knapsack problem before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Quadratic knapsack problem ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Quadratic knapsack problem

In research
Quadratic knapsack problem appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Quadratic knapsack problem in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Quadratic knapsack problem is common in secondary-school and first-year university syllabi. It links to neighbouring topics Combinatorial optimization, Dynamic programming, NP-complete problems, so understanding it makes those chapters shorter.
In everyday life
Look for Quadratic knapsack problem outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.

Affiliate

Preply — study more efficiently by working with a personal tutor. 50% off.

How to study Quadratic knapsack problem in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Quadratic knapsack problem means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Quadratic knapsack problem out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Quadratic knapsack problem in simple terms?

The quadratic knapsack problem (QKP), first introduced in 19th century, is an extension of knapsack problem 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 n…

Why does Quadratic knapsack problem matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Quadratic knapsack problem?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Quadratic knapsack problem.

Tags

  • Combinatorial optimization
  • Dynamic programming
  • NP-complete problems
  • Packing problems
  • Pseudo-polynomial time algorithms

Keep exploring