项目作者: Ivaskuu

项目描述 :
This is a processing java project that simulates the genetic evolution of a string of text.
高级语言: Processing
项目地址: git://github.com/Ivaskuu/evolution_of_strings.git
创建时间: 2017-07-12T01:23:00Z
项目社区:https://github.com/Ivaskuu/evolution_of_strings

开源协议:

下载


warning Work in progress warning

Evolution of strings

This is a java (processing) project that simulates the genetic evolution of a string of text.

It’s my first Machine Learning - Artificial Intelligence project, so please be gentle with me :-).

Files

The project is composed of 3 files :

  • main.pde : It creates a population based on the target, the mutation rate and the number of elements, and train it.
  • population.pde : It manages all the elements, that form the population, cioè a method to train the elements, and method to reproduce them.
  • dna.pde : It contains the genes of an element, a method to calculate it’s fitness, a method to mutate and a method to create an element from 2 parents.

main.pde

Methods

  • void setup() : Called once at the start of the program. It creates a new population, then trains it in a while loop.

population.pde

Methods

  • Population(String stringTarget, double mutationRate, int populationNum) : The constructer of the class, it creates a new population with the specified parameters.
  • void calculatePopFitness() : It calculates the fitness of all elements, and prints the median fitness, best’s genes and generation number.
  • void reproduce() : It creates a new generation of population composed of popNum elements, based on the previous best elements DNA.
  • void prepareTheMatingPool() : Puts all the elements fitness in a cumulative char array.
  • int binarySearch(double value) : Returns the position of the range of the elements. The parameter value is a random double (from 0 to the max cumulative fitness).
  • void mutate() : Calls the method mutate() for each element.

dna.pde

Methods

  • void wip() : WIP :-).
  • void wip() : WIP :-).

Mutations type and probabilities

  • One gene : One gene of the DNA is modified with a random char. Probability : 40/105.
  • Multiple genes : A random number of genes (from 0 to max) of the DNA is modified with random chars. Probability : 30/105.
  • Split & rearrange : A random point in the array is choosen, where the DNA gets splitted nad the first part goes last. Probability : 20/105.
  • Reverse genes : The DNA is reversed. Probability : 10/105.
  • All genes : All the genes of the DNA are random chars. Probability : 5/105.