Playing God with an algorithm based on evolution.
If you want to interact with the final result first, you can play with it on to PyViz examples here: https://genetic-algorithm.pyviz.demo.anaconda.com/GA
How can you maximise the number of components in a laptop, while having size, weight and price constraints? For questions like these, we often want to reach for optimisation algorithms, and one particularly fun one is Genetic Algorithm.
For the sake of a fun visualisation, let's say the optimisation is "Wherever I click on the plot is the optimimum spot to find". We're going to use a population-based approach, Genetic Algorithm, in which there is a population of individuals (each individual representing a possible solution) which evolve across generations. Each solution is just the individual's x and y coordinates.
We want to see a kind of "evolution simulator" in which we click a spot on the plot and when we begin evolving, each generation moves closer to the place we clicked.
"And God said, Let us make man in our image". First, let's create a population.
#collapse-hide import math import numpy as np import pandas as pd import random from holoviews import opts from matplotlib import pyplot as plt import holoviews as hv import panel as pn from holoviews.streams import Stream hv.extension('matplotlib', logo=False)