Research Article
Feasible Initial Population with Genetic Diversity for a Population-Based Algorithm Applied to the Vehicle Routing Problem with Time Windows
Algorithm 2
Calculation of the Hamming distance for a population of
individuals.
| (1) Initialize ind, aux, Hamming, cont, | | (2) Read_Population (InitialPopulation) | | (3) for ind = 0:ind < InitialPopulation | | (4) for aux = ind + 1:aux < InitialPopulation | | (5) Hamming = cont = 0 | | (6) for : < ChromosomesInd1 | | (7) flag = 0 | | (8) for vhInd2 = 0:vhInd2 < ChromosomesInd2 | | (9) if ==IniChromInd1 cont = 0 | | (10) end-if | | (11) if ≤ FinChromInd2 && ≤ FinChromInd1 | | (12) if gens of ind and aux are identical | | (13) flag = 1 | | (14) vhInd2 = ChromosomesInd2 | | (15) end-if | | (16) end-if | | (17) end-for | | (18) if flag == 0 | | (19) Hamming++ | | (20) end-if | | (21) cont++ | | (22) end-for | | (23) end-for | | (24) = Hamming | | (25) end-for |
|