Genetic Algorithms and Project ideas
This week was all about genetic algorithms (GA) and exploring the types of problems that GA would be used for. We were introduced to the “Travelling Salesman Problem” which outlines the shortest possible path between a set amount of cities. GA will create a population of agents that are initially defined as an array of random numbers each representative of a different city and calculates the total distance of travelling to those cities in that order. The fitness function is determined by the shortest distance and there are two main methods in GA for reaching that goal:
- Mutation: This is where a single agent changes its array values randomly. In this case we don’t want any duplicate numbers so instead of randomly changing one value to another, we swap 2 values with each other. Mutating [1,2,3,4,5,6,7,8] will result in a new offspring with array [1,8,3,4,5,6,7,2]
- Crossover: This is when we take two agents and combine their values by selecting a segment of one array and loading that into a new child array and surrounding the remaining values with the array values of the other parent. Crossing over [7,1,4,2,5,6,3,8] with [4,8,5,2,1,7,6,3] will result in two offspring [8,1,7,2,5,6,3,4] and [4,5,6,2,1,7,3,8]
- Each offspring is then evaluated against their parents through their fitness function and is kept if they have a better fitness and destroyed if they have a worse fitness.
This is a direct example of problem solving with GA however after learning the technical side of things I wanted to explore how it could be used in a more creative context for developing natural ecosystems of agents with inheritable DNA. This is when I came across Daniel Shiffman’s series on Genetic algorithms and was inspired by his last video in the series where he created a simplistic ecosystem of agents surviving in a 2D space.
Get Sebastian Smith’s stories in your inbox
Join Medium for free to get updates from this writer.
This is a simplistic example since it’s not using any form of fitness or evaluation to evolve the system, however these can be easily implemented by determining the success rates of reproduction between agents and producing offspring that incorporate the best features of its parents. For my project in Natural Computing, I plan to use this concept in a musical context to produce interesting and complex synthesised sounds as the program evolves visualised in an ecosystem of agents in a 2D space. This will be performed through GA and will initialise agents that are each assigned a different sound determined by its DNA with some properties being inherited by their offspring. As the system develops, new generations of agents will output sounds with more overtones and wider filter spaces to pass off the illusion of higher sound fidelity.
There are many ways to explore this idea which I plan to play with very soon such as the combination of different agents producing harmonic or inharmonic contrasts between each other as well as giving new properties based on their environment such as distortion or LFOs associated with different actions an agent may end up performing. Rather than all agents playing their sounds at once, a cleaner approach would be for each agent to play their sound at random intervals throughout their lifespan. The amount of health each agent has will directly correlate to their amplitude which can be increased by picking up food scattered throughout the space: the healthier they are, the louder their sound will be but will not affect their reproductive success rate. The more interesting an agent’s sound is, the more chance they have at producing children with other agents and this will determine their fitness as well.
The fitness function will have no end goal and also has little purpose to be evaluated since the developed sounds will be purely subjective between listeners. Instead of evaluating in a problem solving context, I could test the system against other algorithmic implementations such as DFO to see if it works better at producing more interesting and varied sounds, as well as evaluating the processing power used. This would make the system work very differently since I would have to find a way to validate the purpose of a best fly and its interaction to neighbouring flies.





