I'm trying to develop code (in C++) for the "Knapsack Problem". More information on this concept can be found at:
For right now, I'd like to keep it simply -- so my solution is focused on the "0-1" method (i.e., select an item or don't select an item... and I don't want to have multiple items of the same kind either).
However, instead of looking at only the "weight constraint", I also would like to include a second constraint... "volume".
I've solved the optimal answer -- maximizing "value -- in MS-Excel (using Solver). See attached XLS.
Also, I've googled for some code (for starters) and came across a potential solution in C++. I'm not exactly certain if this sample code addresses the concept (per Wiki and my XLS).
At this time, I'm using an input file (attached) and display the items (plus their value, weight, and volume) to the console. Each of these are stored in their respective arrays.
Does anyone have a recommendations how to accomplish this task?
Again, attached are:
1. Solution in MS-Excel
2. Current C++ code
3. Input.txt file (for C++ code)
4. Some sample code in C++.... not sure if it's method comes even close to the concept as described on Wikipedia and solved in MS-Excel.