Genetic Algorithms

intro

Right now, it’s hard to think about things other than the global pandemic that pervades our lives. It’s interesting to see how people react to the virus ranging from fear to humor. I recently saw a video of a man at the grocery store with a ruler, in effect “measuring” the distance between him and his fellow shoppers. The CDC recommends 6 feet or 2 meters of distance between people and to avoid crowded places, overall lowering the risk of infection. Currently, the number of cases is increasing and people are still congregating in masses in some locations, like parks. I thought I would explore the topic of “social distancing” and how distance between objects in p5.js could tell a story of infection. 

scenario

Describe the scenario. What is the population? What is the environment? What is the “problem” or question? What is evolving? What are the goals?

In this case, the canvas of p5.js represents a park. The population is the people within the park, represented by circles. This park is very crowded, so there are many many circles within the canvas, and the problem is that these circles are not practicing social distancing. The goal for all these circles is to be 6 feet away from another (in p5.js I would map the 6 foot criteria to a specific range). If they are less than 6 feet (or whatever the mapped distance is) both circles turn red, indicating they are too close and highlighting the increased chance of infection. I’d use this Shiffman video for how to calculate distance – https://www.youtube.com/watch?v=uAfw-ko3kB8

First, all the circles will be close to each other and through evolution, the circles will increase their distance from each other. At the end, there will be less and less circles on canvas and no colors will show. 

phenotype and genotype

What is the “thing” that is evolving? Describe its phenotype (the “expression” of its virtual DNA) and describe how you encode its genotype (the data itself) into an array or some other data structure.

In watching the Smartrockets video (https://www.youtube.com/watch?v=bGz7mv2vD6g&t=1383s), the genotype was the vectors of the rockets and phenotype was the rocket object. Similarly, my circle object would be the phenotype, and the genotype would be based on vector positions in an array. 

fitness function

What is the fitness function? How do you score each element of the population?

The fitness function would be based on distance, where the farther away the circle is from other circles, the higher the fitness.

The question is – can a circle “sense” in all directions? In this current model, there is no one static target to measure the distance from, like in Smartrockets. Should I make a static circle in the middle where the distance of all other circles would be measured from that static circle or have circles be measured against all other circles in each evolution? 

Another possible way to tackle this – would it make sense to use a repulsion force and measure the repulsion force to determine how far away circles are from each other?

mutation and crossover

Are there any special considerations to mutation and crossover to consider or would the standard approaches work?

I’m thinking about standard approaches for this assignment. However, another thing to consider for the circles is the speed at which they move. If they move faster, that could represent more social distancing, since they are trying to get away as fast as possible from one another. Because humans, or circles, are not perfect maybe there could be a mutation in the speed or distance or the circles. So, it’s a bit more realistic the time it takes for the circles to accept that they must social distance. 

Leave a comment