Skip to main content

Genetic Algorithms

I built an electron app that also uses react. I wanted to try experimenting with machine learning, so I started learning about genetic algorithms.
A genetic algorithm is one in which possible solutions are randomly generated, and then form a 'population'. Solutions can then 'mate' and form offspring. Additionally, solutions can 'mutate', or change slightly. The algorithm must be given a cost function in order to determine how good the solutions are (this is important, because good solutions will be more likely to 'mate' and produce more good solutions).
I chose two tasks where developing the cost function would be easy: evaluating a function (finding its zeroes) and evaluating a string against a given input (e.g. given 'I like coding.', the algorithm would eventually produce a solution of 'I like coding.'). Since the cost functions were simple, both performed well, and the 'evolution' of the solution was clear in the console.
There were two things that I enjoyed about building this project. The first was seeing how the algorithm followed the natural process of evolution to develop a solution. The second was seeing how the mating and mutation functions, as well as population size, could be adjusted to change the way that the solution developed. Mutations could occur frequently or infrequently, and they could cause small or large changes. Mating could be more or less selective (i.e. how 'good' of a solution can mate), and the number of offspring could possibly vary. A population could be larger or smaller. There could even chances of 'natural disasters' in which the bottom portion of solutions die.

Project Members: Thomas Lux