Function of a single variable
f(x)=|x|+cos(x), x in [-20,20], y in [0,25]
(also see
output
from this sample run)
...
Steps
Random population
Sort
Kill the worst half
Pair up for breeding, use 0.4 0.7 0.9 1.0
Blending
Beta=rand
x=Beta*x1+(1-Beta)*x2
x=(1-Beta)*x1+Beta*x2
x=0.5*x1+0.5*x2
x=1.5*x1-0.5*x2
x=-0.5*x1+1.5*x2
if x out of bounds then add or subtract xmax-xmin (thanks to Alex Krzepicki)
take best two
Mutation
Repeat from Sort