Made by: Jevan Smith, and Isaac Davidson
- Solve the knapsack problem using dynamic programming and "greedy" appoach.
- Compare and contrast with space efficient variant of dynamic programming and heap-based implementation of "greedy" approach.
- Built using python 3.7, PyCharm (Version 2018.3.5) is recommended
- time, and math
- matplotlib is required (Used Version 3.0.2)
- matplotlib.pyplot
- matplotlib.patches
❗ Note to use 'Task 3', matplotlib must be installed! Below is our programs output
============================== MENU: ============================== [1]: Task 1 and Task 2 [2]: Task 3 ============================== Option: 1 *Note: including .txt within the name Enter file name for c: p06_c.txt Enter file name for v: p06_v.txt Enter file name for w: p06_w.txt Knapsack capacity = 170 Total number of items = 7 Traditional Dynamic Programming Optimal value: 1735 Traditional Dynamic Programming Optimal subset: [2, 4, 7] Traditional Dynamic Programming Time Taken: 0.00063s Space-efficient Dynamic Programming Optimal value: 1735 Space-efficient Dynamic Programming Optimal subset: [2, 4, 7] Space-efficient Dynamic Programming Time Taken: 0.0074s Greedy Approach Optimal value: 1478 Greedy Approach Optimal subset: [1, 2, 3] Greedy Approach Time Taken: 1.2e-05s Heap-based Greedy Approach Optimal value: 1478 Heap-based Greedy Approach Optimal subset: [1, 2, 3] Heap-based Greedy Approach Time Taken: 2.3e-05s ============================== MENU: ============================== [1]: Task 1 and Task 2 [2]: Task 3 ============================== Option: 1 *Note: including .txt within the name Enter file name for c: p00_c.txt Enter file name for v: p00_v.txt Enter file name for w: p00_w.txt Knapsack capacity = 5 Total number of items = 4 Traditional Dynamic Programming Optimal value: 37 Traditional Dynamic Programming Optimal subset: [1, 2, 4] Traditional Dynamic Programming Time Taken: 2.9e-05s Space-efficient Dynamic Programming Optimal value: 37 Space-efficient Dynamic Programming Optimal subset: [1, 2, 4] Space-efficient Dynamic Programming Time Taken: 0.00016s Greedy Approach Optimal value: 25 Greedy Approach Optimal subset: [2, 4] Greedy Approach Time Taken: 9.1e-06s Heap-based Greedy Approach Optimal value: 25 Heap-based Greedy Approach Optimal subset: [2, 4] Heap-based Greedy Approach Time Taken: 1.7e-05s