Research Article
Different Transfer Functions for Binary Particle Swarm Optimization with a New Encoding Scheme for Discounted {0-1} Knapsack Problem
| Input: Solution , value vector , weight vector , index vector , and knapsack capacity . | | Output: Solution | (1) | % Repair phase | (2) | n length (x)/2 for i = 1 : do | (3) | k floor ((id (i) − 1)/3); | (4) | r mod (id (i) − 1, 3); | (5) | ifthen | (6) | | (7) | | (8) | else ifthen | (9) | x (2k + 1) 0 | (10) | x (2k + 2) 0 | (11) | ifthen | (12) | | (13) | | (14) | else ifthen | (15) | x (2k + 1) 0 | (16) | x (2k + 2) 0 | (17) | ifthen | (18) | | (19) | | (20) | else ifthen | (21) | x (2k + 1) 0 | (22) | x (2k + 2) 0 | (23) | % Optimization phase | (24) | fordo | (25) | k floor ((id (i) − 1)/3); | (26) | r mod (id (i) − 1, 3); | (27) | ifthen | (28) | | (29) | | (30) | ifthen | (31) | x (2k + 1) 0; x (2k + 2) 1 | (32) | ifthen | (33) | x (2k + 1) 1; x (2k + 2) 0 | (34) | ifthen | (35) | x (2k + 1) 1; x (2k + 2) 1 | (36) | return |
|