Knapsack Variants & the Van Loader
In short: every knapsack is one table with four dials you can turn: how
many of each item you may take (once, unlimited, or up to c), what a cell
means (at most, exactly or at least a capacity), how two choices combine
(max, min, or or +), and how many limits apply at once. The loop
direction decides "once" versus "unlimited" — downward reads the row before
this item touched it, upward lets the same item feed itself again. Everything
else about knapsack is naming which four settings your problem needs.

Meridian's first van of the day leaves at seven. It can carry 12 kg and its cargo bay holds 11 litres, and the morning's parcels each pay a delivery fee. A heavy little parcel of engine parts and a light but bulky roll of carpet are competing for the same van on two different limits at once. Choosing which parcels go is a knapsack problem. It isn't quite the one you have already solved, though.
You built the 0/1 knapsack table for Tunebox and squeezed it into one row by looping capacity downward. This lesson treats that table as the parent of a family. Almost every knapsack you'll meet changes one of four things, and once you can name which one, you can write the variant without memorising it.
Four dials on one table
| Dial | Choices | Example |
|---|---|---|
| How many of each item | once (0/1), unlimited, or up to c copies |
one parcel; a crate size in stock forever; five spare tyres |
| What a cell means | at most w, exactly w, at least w |
a weight limit; a calibration pallet; a ride quota |
| How cells combine | max, min, or, + |
best fee; fewest crates; is it possible; how many ways |
| How many limits | one capacity, or several | kg only; kg and litres; kg and a slot count |
Now the van loader is easy to place: once each, at most, max, and two
limits. The rest of this lesson turns each dial in turn.