Home License -- for personal use only. Not for government, academic, research, commercial, or other organizational use. 07-Oct-2025 22:12:24 knapsack_random_test(): MATLAB/Octave version 9.11.0.2358333 (R2021b) Update 7 Test knapsack_random() subset_random_test(): Test subset_random() Subsets will be of size n = 5 1: 0 0 0 0 1 13: 0 1 1 0 1 13: 0 1 1 0 1 29: 1 1 1 0 1 21: 1 0 1 0 1 4: 0 0 1 0 0 30: 1 1 1 1 0 5: 0 0 1 0 1 8: 0 1 0 0 0 13: 0 1 1 0 1 23: 1 0 1 1 1 knapsack_random_test01(): knapsack_random() randomly selects a subset of n items and considers it as a solution to a knapsack problem. Maximize profit without exceeding weight limit. Number of items is 5 Value array: 24 13 23 15 16 Weight array: 12 7 11 8 9 Weight limit is 26 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.947368 Selected items: 0 0 0 1 0 Weight 8 Value 15 Ratio 1.875000 Selected items: 0 1 0 0 1 Weight 16 Value 29 Ratio 1.812500 Selected items: 0 1 0 1 1 Weight 24 Value 44 Ratio 1.833333 Selected items: 0 1 1 0 1 Weight 27 exceeds weight limit 26 Selected items: 0 0 0 1 1 Weight 17 Value 31 Ratio 1.823529 Selected items: 1 0 0 1 1 Weight 29 exceeds weight limit 26 Selected items: 1 0 1 1 0 Weight 31 exceeds weight limit 26 Selected items: 0 1 0 0 1 Weight 16 Value 29 Ratio 1.812500 Selected items: 1 1 0 1 1 Weight 36 exceeds weight limit 26 knapsack_random_test(): Normal end of execution.