Genetic Algorithms
The goal with a genetic algorithm is to find/create an optimal solution to a problem without anything (including training data) except a fitness function that can be used to evaluate a given solution (think of how natural selection naturally ascribes higher fitness to some individuals vs others). We call a particular solution a genome. At each generation, genomes are combined with other genomes to create new genomes. By always choosing genomes with high fitness, over time we end up with genomes that are "fit".
To get a feel for how this works, try out the following activity.
Example: String discovery problem
This activity is intended to be performed with a group of people.
- Randomly pick a 5-letter “word” from letters a-f (e.g., “dbdae”). Write it down.
- Get a fitness score below for your word (e.g., f(“dbdae”) = 0). Shout out or hold up fingers indicating your fitness.
Repeat the following steps until you feel like you've found the solution (write down each generation):
- Find another person.
- Create a new word by crossing over the first two of yours and last three of theirs (e.g., “dbdae” + “eacdf” -> “dbcdf”).
- Randomly mutate one letter (e.g., “dbcdf” -> “dbadf”). Avoid the temptation to insert any strategy or intelligence here.
- Get a score for the new word (e.g., f(“dbadf”) = 1)
- Choose whether to keep the new or the old word
Follow-up Questions
- How did you decide when to stop? (This is a hard question anytime you use GAs)
- How much did your fitness score increase over time? Was it just you, or did everyone's scores go up?
- What do you think the fitness function was? (usually you have some idea of how the fitness function works)
- When you were looking for a partner, how did you choose who to partner up with?
- How important do you think that random mutation step was? Would you have found your final solution without it?
- At the beginning everyone had different words. How important do you think diversity is in a GA?
- Did your genome change at each generation? Did your score go up at each generation? Were there streaks with no change and then sudden improvements?