Haskell is a purely functional programming language.I have used Haskell to write a simple Binary Genetic Algorithm.Genetic algorithm is optimisation and search technique based on principles of genetics and natural selection.The steps I followed for Binary Genetic Algorithm are :
- Define cost function, cost, variables.
- Select GA parameters.
- Generate initial population.
- Decode chromosomes.
- Find cost for each chromosome.
- Select mates for reproduction.
- Check stopping criteria
• IF (reached max number of iterations OR
converged) THEN stop
• ELSE go to Step 4.
I have upload the Haskell Script with this post below.
The algorithm works pretty well for “Hello World”. Only last three guess is wrong. Now lets give complex target
The algorithm works well for complex combination of characters also. You can try the different target combination changing in SimpleBinaryGA.hs
Click Here to download Source Code