Genetic Algorithm Choices & Applications
By: Gautam Singhal
Tags: Genetic Algorithm, Optimization

Author Names

Gautam Singhal: Data Scientist (Gautam Singhal)

Rick Sarkar: Lead Data Scientist(Rick Sarkar)

Date: 13th December 2020

Introduction

Gregor Johann Mendel, through his works on pea plants, was instrumental in discovering the law of inheritance, further extended to the defined Genes which are essentially the structural and functional units of every living cells, as many scientists define. Centuries have passed and new ways were decoded to use genetic studies to a different field of apparently incoherent fields of studies apart from biological sciences. And wallah! The success was enormous. So much so that it changed the way we look in the world of matter and memory.

Today we are going to discuss the fascinating story of Genetic Algorithms and how they impacted data sciences.

Let us start by understanding how Genetic Algorithms (GA) are perceived and defined by different experts and also the users and developers around the world.

According to Wilfried Roetzel, Dezhen Chen et al., in Design and Operation of Heat Exchangers and their Networks, 2020 says “Genetic algorithms are randomized search algorithms that have been developed to imitate the mechanics of natural selection and natural genetics. Genetic algorithms operate on string structures, like biological structures, which are evolving in time according to the rule of survival of the fittest by using a randomized yet structured information exchange. Thus, in every generation, a new set of strings is created, using parts of the fittest members of the old set.”

Sourabh Katoch & Sumit Singh Chauhan & Vijay Kumar in their article “A review on the genetic algorithm: past, present, and future” in October 2020 opine “Genetic algorithm (GA) is an optimization algorithm that is inspired from the natural selection. It is a population-based search algorithm, which utilizes the concept of survival of the fittest. The new populations are produced by the iterative use of genetic operators on individuals present in the population. The chromosome representation, selection, crossover, mutation, and fitness function computation are the key elements of GA.”

GA is believed to be derived from the Evolutionary algorithm and Charles Darwin’s theory of natural selection. It is an optimization technique used to obtain an optimal result.

According to natural selection, the fittest individuals have better genes as compared to other individuals from their population and have a higher probability to survive, “Survival of the fittest”. The fittest individuals pass their genes to their offspring after mating and create the next generation. The genes passed to the offspring are also mutated randomly to some degree. After mutation, the offspring might receive some new trait which may help it to become the fittest in its generation.

With every new generation, the genes of the individuals will improve consistently making them more fit for any problem. These fittest individuals can be used as the optimal solution for a given problem.

Common Terms

• Gene — Possible value for a variable of the given problem

• Chromosome/Individual — Possible solution to the given problem. Made from the list of genes for all the variables

• Population — List of possible solutions made from the list of individuals/chromosomes.

• Search space — Region where all the feasible solutions can exist

How GA is different?

Unlike traditional optimization algorithms (TA), GA is faster and more efficient and is used to solve more complex problems. They can also be applied in AI. TA follows a finite step by step method to find the optimal solution for a given problem and uses fully deterministic rules while GA is based on natural selection and uses probabilistic rules. In GA, the optimal solution can be found in a population of individual values. On the other hand, TA gives a single value as the optimal solution.

GA can be applied on discrete and continuous functions and the results improve with new generation similar to the law of evolution. GA can be used on problems that cannot provide the derivative information and are perfect for problems with large search space and many constraints.

GA is highly dependent on the fitness evaluation, individual selection, and the convergence test. The fitness of all the individuals is calculated for in the populations of all the generations and any mistake can lead to select bad individuals and discard the fit individuals for the given problem. Hence, the algorithm will never converge.

If the convergence criteria are not kept ideally, then the algorithm will continuously try to find the optimal solution and this will be computationally expensive.

Stopping Condition/ Convergence Test

• Obtained the desired solution which is greater than the minimum threshold.

• Solution from the next generation is almost as fit as the solution from the previous generation.

• Set limitations on constraints such as fixed number of generations, computation time, computation power, etc.

GA Flowchart

a. Initial population also known as the first generation is generated from randomly generated individuals from the data provided for a given problem.

b. Fitness is evaluated for the individuals from the population-based on criteria.

c. Stopping condition checks if all constraints are true. For example, the solution is optimal, if the generation has reached its limit, etc.

d. If the stopping condition is true, then the process will end.

e. Else, the process will iterate for the creation of next-generation (f to i).

f. Individuals with the highest fitness scores are selected as the parent.

g. Crossover between the selected parents generates one or more offspring.

h. Each offspring is mutated which adds a random characteristic to it which may or may not be present in the previous generation.

i. Offspring population also known as next-generation undergoes fitness evaluation (back to b).

Example

Find the optimal parameters to maximize the following equation:

-2x1 + 3x2 + 2x3–3x4

Where, x1, x2, x3 and x4 belongs to {0, 1}

GA Steps:

1. Encoding

Encoding is a process in which the variable information is mapped in the form of bits to represent the chromosome, such that each bit represents a single gene. There are many ways of encoding such as binary encoding, permutation encoding, value encoding, etc.

2. Fitness Evaluation

For the given problem, the following can be the individuals

3. Crossover

Crossover leads to create new individuals. Mating of fit individuals has a better probability to pass fit genes to their offspring and making it a more optimal solution. There are various techniques for the crossover, some have been described below:

3.1. Single Point Crossover

A single point is selected in the individuals and divides into two parts to create an offspring.

3.2. Two Point Crossover

Two points are selected in the individuals and divide into three parts to create an offspring.

3.3. Multi-point Crossover

Multiple points are selected in the individuals and divide to create an offspring.

4. Mutation

Mutation helps an offspring to attain new traits that were not present in the parents. If the mutation probability is kept high, then the offspring will become more random and will have higher chances to lose the genes received from its parents. If it is kept low, then the offspring will have more parent’s genes and will have lower chances to attain new traits. There are various techniques to mutate an offspring, one has been shown below.

In the below example, if the gene in mutation probability has 1, we flipped the gene in the offspring. Else keep it the same.

Genetic Operators:

Major Genetic operators are four, viz. encoding, selection, crossover, and selection. The diagram below depicts these:

Genetic Algorithms and their Variants:

GA is broadly classified into some categories, viz. real and binary coded, multi objective, parallel, chaotic, and hybrid. The word cloud below lists some variants of GA:

Applications of GA:

Authors Note:

This blog intends to provide an overview of GA and how it is perceived in common literature. Furthermore, we aimed at providing a one-stop reference for coders and researchers to find and understand the different variants of GA and where they can be applied.