Research Article

Loop Selection for Multilevel Nested Loops Using a Genetic Algorithm

Algorithm 2

Chromosome repair.
Input:, chromosome to be repaired (), the set of all direction vectors ()
Output:repaired chromosome ()
(1)functionREPAIRCHROMOSOME()
(2)  Calculate the set of loop layers () contained in Chromosome
(3)  for eachdoCalculate the set of all direction vectors () covered by Chromosome
(4)   Calculate the set of direction vectors () covered by
(5)   
(6)  end for
(7)  Calculate the set of direction vectors () not covered by Chromosome
(8)  ifthenchromosome repair
(9)   for eachdo
(10)    Calculate the set of loop layers () that cover
(11)    Randomly select a loop layer () from and add it to the set of
(12)   end for
(13)  end if
(14)  whiledodelete redundant genes
(15)   randomly delete a loop layer () from the set of
(16)   for eachdo
(17)    Calculate the number of loop layers () in the set of that cover the direction vector of
(18)    ifthen
(19)     
(20)     break;
(21)    end if
(22)   end for
(23)  end while
(24)  Generate Chromosome that corresponds to
(25)end function