proc GA(Fitness, theta, n, r, m)

  ; Fitness is the fitness function for ranking individuals

  ; theta is the fitness threshold, which is used to determine

  ;  when to halt

  ; n is the population size in each generation (e.g., 100)

  ; r is the fraction of the population generated by crossover (e.g., 0.6)

  ; m is the mutation rate (e.g., 0.001)


  P := generate n individuals at random

  ; initial generation is generated randomly


  while max Fitness(hi) < theta do

  i

   ; define the next generation S (also of size n)


   Reproduction step: Probabilistically select

   (1-r)n individuals of P and add them to S intact, where

   the probability of selecting individual hi is

   Prob(hi) = Fitness(hi) / SUM Fitness(hj)

    j


   Crossover step: Probabilistically select rn/2 pairs

   of individuals from P according to Prob(hi)


   foreach pair (h1, h2), produce two offspring by applying

the crossover operator and add these offspring to S

    

   Mutate step: Choose m% of S and randomly invert one

bit in each


   P := S


  end_while


  Find b such that Fitness(b) = max Fitness(hi)

  i

  return(b)


end_proc

Rakesh Kundu

Rakesh Kundu Creator

Hi, This is Rakesh Kundu, a Technology lover.

Suggested Creators

Rakesh Kundu