29-Oct-2022 11:19:24 knapsack_greedy_test(): MATLAB/Octave version 4.2.2 Test knapsack_greedy(). knapsack_greedy_test01(): knapsack_greedy() uses a greedy algorithm to estimate a solution of the knapsack problem. Test 1 Knapsack weight capacity is 165 Object weights: 23 31 29 44 53 38 63 85 89 82 Object values: 92 57 49 68 60 43 67 84 87 72 Object Profit Mass P/M 1 92 23 4 2 57 31 1.83871 3 49 29 1.68966 4 68 44 1.54545 5 60 53 1.13208 6 43 38 1.13158 7 67 63 1.06349 8 84 85 0.988235 9 87 89 0.977528 10 72 82 0.878049 Contents of Knapsack Object Profit Mass P/M 1 92 23 4 2 57 31 1.83871 3 49 29 1.68966 4 68 44 1.54545 6 43 38 1.13158 Number of objects chosen = 5 Total weight of chosen objects = 165 Total profit of chosen objects = 309 Test 2 Knapsack weight capacity is 26 Object weights: 12 7 11 8 9 Object values: 24 13 23 15 16 Object Profit Mass P/M 1 23 11 2.09091 2 24 12 2 3 15 8 1.875 4 13 7 1.85714 5 16 9 1.77778 Contents of Knapsack Object Profit Mass P/M 1 23 11 2.09091 2 24 12 2 Number of objects chosen = 2 Total weight of chosen objects = 23 Total profit of chosen objects = 47 Test 3 Knapsack weight capacity is 190 Object weights: 56 59 80 64 75 17 Object values: 50 50 64 46 50 5 Object Profit Mass P/M 1 50 56 0.892857 2 50 59 0.847458 3 64 80 0.8 4 46 64 0.71875 5 50 75 0.666667 6 5 17 0.294118 Contents of Knapsack Object Profit Mass P/M 1 50 56 0.892857 2 50 59 0.847458 4 46 64 0.71875 Number of objects chosen = 3 Total weight of chosen objects = 179 Total profit of chosen objects = 146 Test 4 Knapsack weight capacity is 50 Object weights: 31 10 20 19 4 3 6 Object values: 70 20 39 37 7 5 10 Object Profit Mass P/M 1 70 31 2.25806 2 20 10 2 3 39 20 1.95 4 37 19 1.94737 5 7 4 1.75 6 5 3 1.66667 7 10 6 1.66667 Contents of Knapsack Object Profit Mass P/M 1 70 31 2.25806 2 20 10 2 5 7 4 1.75 6 5 3 1.66667 Number of objects chosen = 4 Total weight of chosen objects = 48 Total profit of chosen objects = 102 Test 5 Knapsack weight capacity is 104 Object weights: 25 35 45 5 25 3 2 2 Object values: 350 400 450 20 70 8 5 5 Object Profit Mass P/M 1 350 25 14 2 400 35 11.4286 3 450 45 10 4 20 5 4 5 70 25 2.8 6 8 3 2.66667 7 5 2 2.5 8 5 2 2.5 Contents of Knapsack Object Profit Mass P/M 1 350 25 14 2 400 35 11.4286 4 20 5 4 5 70 25 2.8 6 8 3 2.66667 7 5 2 2.5 8 5 2 2.5 Number of objects chosen = 7 Total weight of chosen objects = 97 Total profit of chosen objects = 858 Test 6 Knapsack weight capacity is 67 Object weights: 23 26 20 18 32 27 29 26 30 27 Object values: 505 352 458 220 354 414 498 545 473 543 Object Profit Mass P/M 1 458 20 22.9 2 505 23 21.9565 3 545 26 20.9615 4 543 27 20.1111 5 498 29 17.1724 6 473 30 15.7667 7 414 27 15.3333 8 352 26 13.5385 9 220 18 12.2222 10 354 32 11.0625 Contents of Knapsack Object Profit Mass P/M 1 458 20 22.9 2 505 23 21.9565 9 220 18 12.2222 Number of objects chosen = 3 Total weight of chosen objects = 61 Total profit of chosen objects = 1183 knapsack_greedy_test(): Normal end of execution. 29-Oct-2022 11:19:24