Mon Nov 18 17:44:44 2024 knapsack_random_test(): python version: 3.10.12 numpy version: 1.26.4 Test knapsack_random() subset_random_test(): Test subset_random() Subsets will be of size n = 5 6 : [0 0 1 1 0] 19 : [1 0 0 1 1] 7 : [0 0 1 1 1] 20 : [1 0 1 0 0] 5 : [0 0 1 0 1] 18 : [1 0 0 1 0] 18 : [1 0 0 1 0] 20 : [1 0 1 0 0] 13 : [0 1 1 0 1] 23 : [1 0 1 1 1] knapsack_random_test01(): knapsack_random() random selects a subset of n items and considers it as a solution to a knapsack problem. Maximize profit without exceeding weight limit. Weight limit is 26 Number of items is 5 Value array [24 13 23 15 16] Weight array [12 7 11 8 9] Selected items: [1 1 0 0 0] Weight 19 Value 37 Ratio 1.9473684210526316 Selected items: [0 1 1 1 0] Weight 26 Value 51 Ratio 1.9615384615384615 Selected items: [1 1 1 0 1] Weight 39 exceeds weight limit 26 Selected items: [1 1 0 1 1] Weight 36 exceeds weight limit 26 Selected items: [0 0 1 0 0] Weight 11 Value 23 Ratio 2.090909090909091 Selected items: [1 0 1 1 0] Weight 31 exceeds weight limit 26 Selected items: [1 1 0 0 0] Weight 19 Value 37 Ratio 1.9473684210526316 Selected items: [0 1 1 1 0] Weight 26 Value 51 Ratio 1.9615384615384615 Selected items: [0 0 0 1 1] Weight 17 Value 31 Ratio 1.8235294117647058 Selected items: [0 0 0 1 0] Weight 8 Value 15 Ratio 1.875 knapsack_random_test(): Normal end of execution. Mon Nov 18 17:44:44 2024