15 Comparison and Evaluation of Dynamic Programming and Genetic Algorithm for a Knapsack Problem 1040277 2004 2 25
n 2 n (Dynamic Programming : DP) (Genetic Algorithm : GA) 2 i
Abstract Comparison and Evaluation of Dynamic Programming and Genetic Algorithm for a Knapsack Problem KAKETANI Kou Knapsack problem is described as follows: there are some items with given value and volum. A knapsack has given capacity. Selected a proper subset of items to maximize the total value of selected items such that the total volume of the selected items is less than or equal to hte capacity of the knapsack. One of the easy methods for solving the problem is to investigate whole subsets of items, however, there are 2 n subsets where n is the number of items. Therefore, this brute force method is an exponentially time complexity. By this research, in order to solve a problem is two solution methods, Dynamic Programming(DP) and Genetic Algorithm(GA), are taken up, those solution methods are compared and evaluated. key words Knapsack Problem, Dynamic Programming Genetic Algorithm ii
1 1 2 3 2.1.................................. 3 2.2.................................... 3 2.3...................................... 4 3 5 3.1.............................. 5 3.2............................ 6 4 8 4.1........................... 8 4.2....................... 8 4.3........................ 10 4.3.1......................... 10 4.3.2............................. 10 4.3.3............................... 13 4.3.4.................................. 14 4.3.5................................ 17 4.3.6................................ 18 5 19 5.1............................. 19 5.1.1............................... 19 iii
5.1.2........................... 20 5.2................................. 22 6 23 25 26 iv
4.1............................ 9 4.2................................ 10 4.3 STEP1-1............................. 11 4.4 STEP1-2............................. 11 4.5 STEP1-3............................. 12 4.6 STEP2-3............................. 12 4.7 STEP2-4............................. 13 4.8................................ 13 4.9............................... 14 4.10.................................... 15 4.11................................. 15 4.12................................. 16 4.13................................. 16 4.14 2.................................... 17 4.15 2................................... 17 4.16 2................................... 18 4.17.................................... 18 v
2.1............................ 4 5.1 DP................... 20 5.2 GA................... 21 5.3.................... 22 vi
1 ( ) NP- [1] NP- [2] 2 3. 1
2
2 2.1 W p i w i n i(1 i n) J {1,2,, n} w j W p j [1] j J p j J w j j J W p j j J j J j J 2.2 3
2.3 2.3 2.3 2.1 1 12 10 2 5 3 3 2 5 4 3 1 5 8 7 10 2 5 13 1 12, 10 4 5 11 8. 4
3 3.1 (Dynamic Programming) [1] 1. 2. 3. [2] W w i 5
3.2 3.2 2.1 v[k, c](k = 1, 2, 3,, n; c = 0, 1, 2,, W ) 3.1 3.2 3.3 3.4 3.1 0 0 0 v[k, 0] = 0 (1 k n) (3.1) 3.2 1 0 p 1 v[1, c] = { 0 (0 c < w1 ) p 1 (w 1 c W ) (3.2) 3.3 3.1 3.2 v[k, c] v[k 1, c] w k v[k-1,c] w k v[k 1, c w k ] + p k v[k, c] v[v[k 1, c], v[k 1, c w k ] + p k ] 6
3.2 v[k, c] = { v[k 1, c] (c < wk ) v[v[k 1, c], v[k 1, c w k ] + p k ] (w k c) (3.3) 3.4 k 3.4 k 3.4 c w k v[k 1, c w k ] + p k = v[k, c] (3.4) w j W p j j J j J p j j J 7
4 4.1 [2] 4.2 8
4.2 No Yes 4.1 9
4.3 4.3 GA [3] 4.3.1 n l 4.2 4 7 4 0 6 2 5 1 3 0 5 2 3 1 4 6 5 6 0 3 1 4 2 3 1 5 2 0 6 4 n = 4 l = 7 4.2 4.3.2 1 2 2 1 W p i w i 10
4.3 1 1 [2310] W 8 p 0 1 p 1 5 p 2 4 p 3 2 w 0 1 w 1 3 w 2 2 w 3 5 STEP1-1 4.3 2 5 8 p 2 2 3 1 0 [p2, w2] 4.3 STEP1-1 STEP1-2 4.4 2 3 w 2 w 3 5 8 p 2 p 3 2 3 1 0 [p3, w3] 4.4 STEP1-2 STEP1-3 4.5 3 1 STEP1-2 5 w 1 10 8 1 [2310] 6 2 1 11
4.3 2 3 1 0 [p1, w1] 4.5 STEP1-3 2 1 2 [2310] 1 2 STEP2-1,2-2 1 STEP1-1,1-2 STEP2-3 4.6 3 1 STEP2-2 5 w 1 10 8 w 1 1 2 3 1 0 [p1, w1] 4.6 STEP2-3 STEP2-4 4.7 4 0 STEP2-3 5 w 0 8 8 ST EP 2 3 p 0 2 [2310] 7 12
4.3 2 3 1 0 [p0, w0] 4.7 STEP2-4 4.3.3 1 2 4.8 A 111 B 75 C 60 D 39 E 15 E 5% D 13% C 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4.3.6 4.17 Fittness( ) Generation( ) T Fittness T Generation 4.17 18
5 5.1 5.1 3. ( ) = ) ( ) (5.1) 5.1.1 5.1 20 19
5.1 5.1 DP (sec) 100 10,000 0.011 10 6 250 4,000 0.012 500 2,000 0.014 100 100,000 0.110 10 7 200 50,000 0.123 500 20,000 0.115 250 400,000 1.503 10 8 500 200,000 1.331 625 160,000 1.342 5.1.2 2 10 3 2 50 100 5,10,50 3 50 50,100,200 100 2 1 100 5 5.2 50,100,200 20 5.2 20
5.1 5.2 GA (sec) 50 100 0.20004 50 300 0.14657 50 500 0.244389 50 1,000 0.186743 50 10,000 0.244376 100 100 0.968563 100 300 0.984723 100 500 1.124372 100 1,000 1.074637 100 10,000 0.987432 200 100 3.973007 200 300 3.223305 200 500 3.352162 200 1,000 3.223874 200 10,000 3.352948 21
5.2 5.2 4 20 100,000 1,000,000 10,000,000 100,000,000 5.3 10 5, 10 6, 10 7, 10 8 20 10 5 = 2, 000 50 10 6 = 12, 500 80 10 7 = 100, 000 100 8 = 625, 000 160 5.3 10 5 10 6 10 7 10 8 (DP) 558 647 771 1,201 (GA) 556 626 748 1,081 DP (sec) 0.001 0.012 0.129 1.306 GA (sec) 0.050 0.146 0.284 0.554 22
6 20 5.1 5.1 5.1 5.2 5.3 10 8 23
24
2002 7 2004 2 25
[1] 2003. [2] : 2002. [3] GA 2002. [4] 1993. [5] T. C. R. [ 2 ] 1995. 26