Knapsack Solver
One item per line as "weight,value" - pick the knapsack type and capacity to get the highest-value combination
Knapsack type:
Capacity:
Calculation Result
Download CSV
| No. | Item | Weight | Value | Picked count |
|---|
Introduction to the tool and how to use it
The knapsack solver finds the most valuable packing that stays within capacity, in a single run. Enter one item per line in the format weight,value,
for example:
It uses classic one-dimensional dynamic programming: reverse-order roll for 0/1 knapsack, forward-order roll for unbounded knapsack, and records backtrace information to reconstruct the exact chosen set, so the combination truly reaches the optimal total value rather than a lone number. Capacity is capped at 100000 and items at 500; excess converges to the cap with a notice, so the browser never freezes.
for example:
3,54,62,35,9It uses classic one-dimensional dynamic programming: reverse-order roll for 0/1 knapsack, forward-order roll for unbounded knapsack, and records backtrace information to reconstruct the exact chosen set, so the combination truly reaches the optimal total value rather than a lone number. Capacity is capped at 100000 and items at 500; excess converges to the cap with a notice, so the browser never freezes.
How to use
- Choose the knapsack type:
· 0/1 knapsack: each item selected at most once;
· Unbounded knapsack: each item may be selected any number of times. - Enter the capacity (a positive integer; a decimal rounds with a notice).
- Click Calculate; the results table shows how many times each item was selected plus a one-line summary, and the text box gives a written summary as well.
- Results support one-click copy and CSV export.
Message board
All messages →-
No one has spoken up yet — want to go first?