Genetic algorithms examples
For informal tutoring purposes.
MIT License
Python 3 (Anaconda)
generic GAs guideline.
-
Initialisation. Generate population of N items, each with randomly-generated chromosomes.
-
Selection.
- a. Evaluate the fitness of each element of the population.
- b. build a mating pool.
-
Reproduction.
- Repeat N times:
- a. pick two parents with probability according to relative fitness.
- b. Crossover - create a child by combining the DNA of these two parents.
- c. Mutation - mutate the child's chromosomes.
- d. Add the new child to the new population.
- Repeat N times:
-
Replacement of the old population with new population and return to Step 2.
-
Elitism. Keep the best solution and keep spawning from it.
GA Word Search example.
python main_word_search_example
tests:
python tests_word_search_ga.py
GA Symmetric Travelling Salesman Problem example.
python main_symmetric_travelling_salesman_example.py
tests:
python tests_symmetric_travelling_salesman_ga.py