Let us imagine that I have to fill my knapsack with items under constraints:
- Each item has an associated weight wi and profit pi
- With a maximum total weight Wmax
Knowing that:
- There are categories of items and I have to choose exactly one item from each category
- Of course, the aim is to choose items to maximise the sum of the profits
Example : Wmax=400
| Books | Books weights | Books profits | Food | Food weights | Food profits |
|---|---|---|---|---|---|
| The Bible | 500 | 25 | Cheese | 80 | 120 |
| The little prince | 150 | 5 | Banana | 250 | 200 |
Here, the best solution is (The little prince, Banana)
I have a similar problem and I'd like to find out the best way to code it but I can't figure out what version/ variation of the probleme this is, is it a known variation ?