Pseudocode for GA from http://www.willamette.edu/~levenick/cs448/lectures/L15_GAdetails.html
create initial population
while (!done) {
evaluate fitness for each individual
select mating pool
apply genetic operators to mating pool to create new individuals
replace worst individuals with new individuals
}
report results
Pseudocode for select mating pool (probalistically on the basis of fitness)
given a list of individuals, each with a fitness, and a runningSum variable
sum=0;
for each individual {
sum += fitness
runningSum = sum
}
iterate p times (p is the number of individuals in the mating pool) {
r = random number between 0 and sum-1
start with first individual on list
while runningSum < r
go to next individual
add current individual to mating pool
}
Pseudo for Genetic Programming from http://216.239.37.100/search?q=cache:PdDGrBurg9wJ:www.evalife.dk/publications/RKU_CEC2002_smooth_operators.pdf+pseudocode+for+Genetic+Programming&hl=en&ie=UTF-8
Main
initialise population P(0)
evaluate P(0)
t=0
while (t t=t+1
Recombine P(t-1) --> P(t)
Mutate P(t) --> P(t)
Evaluate P(t)
Tournament selection P(t) --> P(t)
}
create initial population
while (!done) {
evaluate fitness for each individual
select mating pool
apply genetic operators to mating pool to create new individuals
replace worst individuals with new individuals
}
report results
Pseudocode for select mating pool (probalistically on the basis of fitness)
given a list of individuals, each with a fitness, and a runningSum variable
sum=0;
for each individual {
sum += fitness
runningSum = sum
}
iterate p times (p is the number of individuals in the mating pool) {
r = random number between 0 and sum-1
start with first individual on list
while runningSum < r
go to next individual
add current individual to mating pool
}
Pseudo for Genetic Programming from http://216.239.37.100/search?q=cache:PdDGrBurg9wJ:www.evalife.dk/publications/RKU_CEC2002_smooth_operators.pdf+pseudocode+for+Genetic+Programming&hl=en&ie=UTF-8
Main
initialise population P(0)
evaluate P(0)
t=0
while (t
Recombine P(t-1) --> P(t)
Mutate P(t) --> P(t)
Evaluate P(t)
Tournament selection P(t) --> P(t)
}
<< Home