Knapsack Problem solved with genetic and dynamic algorithm
Parameters can be set in MethodsBenchmark class. Example output
----- METHODS -----
Model method Dynamic
Method 1 GA: Population Size: 30 Number Of Iterations: 20 Crossover Rate: 85,00% Mutation Probability: 10,00%
Method 2 GA: Population Size: 90 Number Of Iterations: 40 Crossover Rate: 85,00% Mutation Probability: 10,00%
Method 3 GA: Population Size: 270 Number Of Iterations: 80 Crossover Rate: 85,00% Mutation Probability: 10,00%
Method 4 GA: Population Size: 810 Number Of Iterations: 160 Crossover Rate: 85,00% Mutation Probability: 10,00%
Method 5 GA: Population Size: 2430 Number Of Iterations: 320 Crossover Rate: 85,00% Mutation Probability: 10,00%
----- RESULTS ----
Number of tests: 10
Model: Found perfect solutions: 10/10 Average error: 0,00% Max error: 0,00% Average time (ms): 0,70 Max time (ms): 1
Method: 1 Found perfect solutions: 4/10 Average error: 19,88% Max error: 48,77% Average time (ms): 2,30 Max time (ms): 14
Method: 2 Found perfect solutions: 5/10 Average error: 4,84% Max error: 15,50% Average time (ms): 5,20 Max time (ms): 23
Method: 3 Found perfect solutions: 6/10 Average error: 2,16% Max error: 9,75% Average time (ms): 22,70 Max time (ms): 93
Method: 4 Found perfect solutions: 7/10 Average error: 2,00% Max error: 7,02% Average time (ms): 106,40 Max time (ms): 291
Method: 5 Found perfect solutions: 9/10 Average error: 0,12% Max error: 1,17% Average time (ms): 538,70 Max time (ms): 825