From Biology to Computing: An Introduction to Genetic Algorithms Background Notation & Terminology Algorithm Applications Weaknesses Summary & Thoughts References & Further Reading Connect With Me!


Photo by Warren Umoh on Unsplash

When Charles Darwin developed his within the nineteenth century little did he know that this theory would have a profound impact on computational algorithms

The ideas of natural selection, survival of the fittest, mutation, and cross-overall result in the ‘best’ variants surviving and carrying the ‘best’ traits forward. John Henry Holland took these concepts and pioneered the in 1975 to unravel mathematical optimizationproblemsThis just isn’t the primary time biological processes have influenced machine learning. Perhaps probably the most notable is Frank Rosenblattdeveloping the in 1958inspired by the true neurons within the brain.

Most genetic algorithms are used to unravel problems where the is intractable on account of the sheer magnitude of permutations and combos. Example include the and problems.

When you are a Data Scientist, chances are high you’ll come across problems like these in your profession, due to this fact it’s value understanding tips on how to approach them and this post will cover among the finest and commonest methods. We’ll dive into the idea, methodology, and general uses of genetic algorithms to point out how you possibly can implement them to unravel almost any optimization problem.

Much of the terminology for genetic algorithms derive from its corresponding biological process:

  • : Mapping the issue to a conveniently numerical format for the algorithm to utilize. Common techniques include
  • A set of possible solutions.
  • A single possible solution.
  • A positional representation of 1 element within the chromosome.
  • : The worth of a Gene.
  • A rating is given to every solution to find out its ‘fitness’ to the optimization problem.

These different terms will be visually demonstrated below:

Diagram by creator.


The algorithm begins by generating an initial population for the issue. This must be adequately diverse with a variety of solutions from the possible search space with a complete number within the or ideally.


After we now have our population, we want to solutions (parents) to take forward to provide offspring for the subsequent generation. The parents are chosen based on their fitness to make sure the ‘best’ genes are passed on.

Some techniques for selection are:

  • Select a certain variety of solutions in the present population with the very best fitness function.
  • Sample from a probability distribution of the solutions (chromosomes) in the present population where each solution’s probability, , is proportional to its fitness rating, :
Equation generated by creator in LaTeX.
  • This involves choosing solutions at random and running tournaments with these subset solutions where the winner is the one with the very best fitness rating.

There are lots of other methods for the choice process and different variants of the techniques listed above. You can even mix selection procedures to generate hybrid methods as well. There isn’t any ‘one size matches all’ and it’s best to experiment with various types.


Now that we now have our parents, we want to mix their genetic material to provide offspring to generate a recent fitter population. Similarly to the choice stage, there exists sundry to perform crossover, and it is extremely depending on the style of encoding for the issue.

Let’s undergo a number of the commonest:

  • Swap the genes from a particular point on the parents’ chromosomes:
Diagram by creator.
  • Swap the genes from two chosen points on the parents’ chromosomes:
Diagram by creator.
  • Each gene is randomly chosen from the corresponding genes from the 2 parents:
Diagram by creator.

These techniques are valid for binary-encoded chromosomes and for other different encodings other operators will probably be required. There may be a terrific article linked that offers a comprehensive list of some more complex crossover operators.


The ultimate step within the algorithm is . That is analogous to where offspring can have a random alteration to its DNA. A mutation is a slight modification to the genes in an answer with a small probability. If the probability is high, then the genetic algorithm becomes a The predominant motivation behind the mutation operator is to diversify the population and reduce the possibility of .

Diagram by creator.

Lets run through some easy and simple to use mutations:

Iterate through the genes in a chromosome and with each pass randomly flip a bit with a small probability:

Diagram by creator.
  • Select two genes, with low probability, within the chromosome and swap them:
Diagram by creator.

Linked is an extra list of mutation operators.

Similarly to crossover, the above mutation operators are valid for binary-encoded problems, due to this fact is probably not appropriate for other forms of problems and encodings.


The algorithm can end on account of several reasons that are as much as the users’ discretion:

  • A certain variety of generations reached
  • A desired fitness is achieved
  • Computational resource exhausted
  • Fitness rating has plateaued

Genetic algorithms are utilized in an assorted range of fields, including but not limited to:

  • Scheduling in production planning
  • Vehicle routing problems
  • Financial markets and portfolio optimization
  • Training neural networks
  • Image processing

Some vulnerabilities of the genetic algorithm are:

  • Scalability just isn’t pretty much as good as other optimization algorithms, hence can have an extended computing time
  • Difficulty to adequately fine-tune hyperparameters similar to mutation and selection can result in non-convergence or useless results
  • Doesn’t guarantee finding the worldwide optimum, nonetheless, that is the trade-off of all meta-heuristic methods
  • An expensive and sophisticated fitness function may also result in long computation durations

The genetic algorithm derives its name from the analogous process in evolutionary biology. It’s a meta-heuristic optimization algorithm that starts from an initial population and iteratively uses the very best solutions from the population to create recent and higher solutions (offspring) through the operators of selection, crossover, and mutation. It may be utilized in many areas similar to medicine and provide chain but can suffer from long compute times depending on the evaluation metric and the hyperparameters are chosen.

(All emojis designed by OpenMoji — the open-source emoji and icon project. License: CC BY-SA 4.0)


What are your thoughts on this topic?
Let us know in the comments below.


0 0 votes
Article Rating
Newest Most Voted
Inline Feedbacks
View all comments

Share this article

Recent posts

Would love your thoughts, please comment.x