Knapsack Problem
Updated 2026-07-28
Summary
The knapsack problem is an NP-complete problem in combinatorial optimization. It can be described as: given a set of items, each with its own weight and value, how should we choose items to maximize the total value within a limited total weight? The name of the problem comes from how to choose the most suitable items to place in a given knapsack, where the space is limited but we need to maximize the value of the items contained.
Definition
The knapsack problem is an NP-complete problem in combinatorial optimization. It can be described as: given a set of items, each with its own weight and value, how should we choose items to maximize the total value within a limited total weight? The name of the problem comes from how to choose the most suitable items to place in a given knapsack, where the space is limited but we need to maximize the value of the items contained. The knapsack problem often arises in resource allocation where decision makers must choose from a set of indivisible projects or tasks, subject to time or budget constraints. The knapsack problem has a long history, dating back to 1897. The term "knapsack problem" first appeared in the early work of mathematician Tobias Dantzig, who studied the problem of how to pack luggage, aiming to maximize the value of selected luggage without overloading.
Introduction
How to use
The knapsack problem is an NP-complete problem in combinatorial optimization. It can be described as: given a set of items, each with its own weight and value, how should we choose items to maximize the total value within a limited total weight? The name of the problem comes from how to choose the most suitable items to place in a given knapsack, where the space is limited but we need to maximize the value of the items contained.
Mechanism
Under capacity constraints, select items to maximize total value; it is an NP-complete problem in combinatorial optimization. The optimal solution requires enumerating (or dynamic programming) all feasible combinations, which leads to computational explosion for large scales, so approximate or heuristic solutions are often used.
Practice
In progress 0/3Practice this model in one real situation:
Cases
- Time management: selecting high-value tasks within 24 hours; investment portfolio: allocating weights within risk budget; luggage weight limit trade-offs.
Common pitfalls
- Blind greediness (only taking the highest unit value) misses the optimal combination; pursuing global optimum ignores computational cost; ignoring non-linear constraints.
Sources
Source support: Explicit
References currently contain only Wikipedia links; primary sources still need review.
- zh.wikipedia.orghttps://zh.wikipedia.org/wiki/%E8%83%8C%E5%8C%85%E9%97%AE%E9%A2%98verified
account_treeGenealogyexpand_more
PRIVATE NOTES · Only visible to you
SAVED Q&A
ENTRY Q&A · Private saving available
Ask with a clear boundary
thinkingmodels answers from published entry context only.
Your question is sent to thinkingmodels. The answer uses public entry context only.
RELATED MODELS