Skip to content

Latest commit

 

History

History
50 lines (42 loc) · 2.82 KB

README.md

File metadata and controls

50 lines (42 loc) · 2.82 KB

Genetic Algorithm Demos

[TOC]

This repository holds demos that use genetic algorithm.

![Screen Shot 2020-07-21 at 09.51.00](/Users/aronqi/Library/Application Support/typora-user-images/Screen Shot 2020-07-21 at 09.51.00.png)

1. Learn a word

We have a string "unicornforyou". And we want our algorithm to learn to fit this string. In other words, we want the algorithm generate a string that is the same as the given string "unicornforyou".

Here is one of the result in one simulation:

The target string we want to match is " unicornforyou "
Round  1  best fitness is  0.23076923076923078 , best gene is  cnkcqsbfgddnq
Round  2  best fitness is  0.38461538461538464 , best gene is  cngcoibfzruna
Round  3  best fitness is  0.38461538461538464 , best gene is  nngcowemzrknq
Round  4  best fitness is  0.5384615384615384 , best gene is  ukgcoscfgvkgu
Round  5  best fitness is  0.5384615384615384 , best gene is  ungcoxcfgrjgu
Round  6  best fitness is  0.5384615384615384 , best gene is  unhcoxcfgrkvu
Round  7  best fitness is  0.5384615384615384 , best gene is  ungcoxcfgrkgu
Round  8  best fitness is  0.5384615384615384 , best gene is  ungcoxcfgrkgu
Round  9  best fitness is  0.5384615384615384 , best gene is  ungcoxcfgrugu
Round  10  best fitness is  0.6153846153846154 , best gene is  ungcorcfarugu
Round  11  best fitness is  0.7692307692307693 , best gene is  ungcornfgruou
Round  12  best fitness is  0.7692307692307693 , best gene is  ungcornfaruou
Round  13  best fitness is  0.8461538461538461 , best gene is  unicornfgruou
Round  14  best fitness is  0.8461538461538461 , best gene is  unicornfgruou
Round  15  best fitness is  0.8461538461538461 , best gene is  unicornfarxou
Round  16  best fitness is  0.8461538461538461 , best gene is  unicornfgrxou
Round  17  best fitness is  0.8461538461538461 , best gene is  unicornfarxou
Round  18  best fitness is  0.8461538461538461 , best gene is  unicornfarxou
Round  19  best fitness is  0.8461538461538461 , best gene is  unicornfarxou
Round  20  best fitness is  0.8461538461538461 , best gene is  unicornfarxou
Round  21  best fitness is  0.8461538461538461 , best gene is  unicornfarxou
Round  22  best fitness is  0.9230769230769231 , best gene is  unccsrnfxrdou
Round  23  best fitness is  0.9230769230769231 , best gene is  unicornforxou
Round  24  best fitness is  0.9230769230769231 , best gene is  unicorpforxtu
Round  25  best fitness is  0.9230769230769231 , best gene is  unicornforxou
Round  26  best fitness is  0.9230769230769231 , best gene is  umicornforxou
Round  27  best fitness is  0.9230769230769231 , best gene is  unicornforxou
Round  28  best fitness is  0.9230769230769231 , best gene is  unicornforxou
Round  29  best fitness is  0.9230769230769231 , best gene is  unicornforxou
Round  30  best fitness is  1.0 , best gene is  unicornforyou
Iterated  30  times
---end---