A brief introduction to Genetic Algorithms

In software engineering, genetic algorithms (GA) focus on how the evolution theory in genetics works. The structure of most GA attempt to achieve a goal by trialling and mutating over time to achieve the desired results. This is accomplished by randomly populating a bunch of subjects (in most cases they are generally named creatures or subjects) and recording how well the random subjects scored towards the desired goal.

Figure 1: A look into to create a generation with a generic class

Now that the data of our current group of subjects is recorded, we can score this iteration, or what is more commonly known as a generation, to how well the subjects did in reaching the desired goal (Kelly 2018). In programming terms, the general function that is defined here is called a fitness function. The fitness function stores the current generations progress towards the goal.

 The next step is to make a function that determines which subject in the population is the most viable choice. Since we have the subject’s fitness, ideally, we would select the best of the subjects, sometimes referred to as the elite group or the crème of the crop. The selected subjects are then paired with other members of comparable fitness. This is referred to as a crossover and makes the new generation of subjects.

Lastly, before we test the new generation, we add in a mutation modifier. Why and how this is done is the most important part to the concept of GA, as this is how the algorithm progress to coming up with the solution. If no mutation is altered and the subjects do not have the correct answer in the first generation, the ongoing generations will never gain the knowledge to find a solution or answer we are looking for, hence the need for a mutation (Marks 2002). Mutations can vary depending on the desired outcome. A good rule of thumb is to leave it as a variable that can be altered, allowing results to be adjusted at different rates with higher or lower mutations.

References:

Kelly, P 2018, Genetic Algorithms in Games (Part 1), Accessed 4 June 2020, https://gamasutra.com/blogs/PatrickKelly/20180904/325789/Genetic_Algorithms_in_Games_Part_1.php

Marks, R.E 2002, ‘Playing games with genetic algorithms’, In Evolutionary computation in economics and finance, Physica, Heidelberg, pp. 31-44.

Leave a comment