Genetic Algorithm in Machine Learning
A genetic algorithm is an adaptive heuristic search algorithm inspired by "Darwin's
theory of evolution in Nature." It is used to solve optimization problems in machine
learning. It is one of the important algorithms as it helps solve complex problems that
would take a long time to solve.
Genetic Algorithms are being widely used in different real-world applications, for
example, Designing electronic circuits, code-breaking, image processing, and artificial
creativity.
** Population: Population is the subset of all possible or probable solutions, which can
solve the given problem.
○ Chromosomes: A chromosome is one of the solutions in the population for the
given problem, and the collection of gene generate a chromosome.
○ Gene: A chromosome is divided into a different gene, or it is an element of the
chromosome.
○ Allele: Allele is the value provided to the gene within a particular chromosome.
○ Fitness Function: The fitness function is used to determine the individual's
fitness level in the population. It means the ability of an individual to compete
with other individuals. In every iteration, individuals are evaluated based on
their fitness function.
○ Genetic Operators: In a genetic algorithm, the best individual mate to
regenerate offspring better than parents. Here genetic operators play a role in
changing the genetic composition of the next generation.
○ Selection
After calculating the fitness of every existent in the population, a selection process is
used to determine which of the individualities in the population will get to reproduce and
produce the seed that will form the coming generation.
Types of selection styles available
○ Roulette wheel selection
○ Event selection
○ Rank- grounded selection
How Genetic Algorithm Work?
The genetic algorithm works on the evolutionary generational cycle to generate high-
quality solutions. These algorithms use different operations that either enhance or
replace the population to give an improved fit solution.
It basically involves five phases to solve the complex optimization problems, which are
given as below:
○ Initialization Fitness Assignment Selection Reproduction Termination
***********{EXTRA}***********
1. Initialization
The process of a genetic algorithm starts by generating the set of individuals, which is
called population. Here each individual is the solution for the given problem. An
individual contains or is characterized by a set of parameters called Genes. Genes are
combined into a string and generate chromosomes, which is the solution to the problem.
One of the most popular techniques for initialization is the use of random binary strings.
2. Fitness Assignment
Fitness function is used to determine how fit an individual is? It means the ability of an
individual to compete with other individuals. In every iteration, individuals are evaluated
based on their fitness function. The fitness function provides a fitness score to each
individual. This score further determines the probability of being selected for
reproduction. The high the fitness score, the more chances of getting selected for
reproduction.
3. Selection
The selection phase involves the selection of individuals for the reproduction of
offspring. All the selected individuals are then arranged in a pair of two to increase
reproduction. Then these individuals transfer their genes to the next generation.
There are three types of Selection methods available, which are:
○ Roulette wheel selection
○ Tournament selection
○ Rank-based selection
4. Reproduction
After the selection process, the creation of a child occurs in the reproduction step. In
this step, the genetic algorithm uses two variation operators that are applied to the
parent population. The two operators involved in the reproduction phase are given
below:
○ Crossover: The crossover plays a most significant role in the reproduction
phase of the genetic algorithm. In this process, a crossover point is selected at
random within the genes. Then the crossover operator swaps genetic
information of two parents from the current generation to produce a new
individual representing the offspring.
○ The genes of parents are exchanged among themselves until the crossover
point is met. These newly generated offspring are added to the population. This
process is also called or crossover. Types of crossover styles available:
○ One point crossover
○ Two-point crossover
○ Livery crossover
○ Inheritable Algorithms crossover
○ Mutation
The mutation operator inserts random genes in the offspring (new child) to
maintain the diversity in the population. It can be done by flipping some bits in
the chromosomes.
Mutation helps in solving the issue of premature convergence and enhances
diversification. The below image shows the mutation process:
Types of mutation styles available,
○ Flip bit mutation
○ Gaussian mutation
○ Exchange/Swap mutation
5. Termination
After the reproduction phase, a stopping criterion is applied as a base for termination.
The algorithm terminates after the threshold fitness solution is reached. It will identify
the final solution as the best solution in the population.
Advantages of Genetic Algorithm
○ The parallel capabilities of genetic algorithms are best.
○ It helps in optimizing various problems such as discrete functions, multi-
objective problems, and continuous functions.
○ It provides a solution for a problem that improves over time.
○ A genetic algorithm does not need derivative information.
Limitations of Genetic Algorithms
○ Genetic algorithms are not efficient algorithms for solving simple problems.
○ It does not guarantee the quality of the final solution to a problem.
○ Repetitive calculation of fitness values may generate some computational
challenges.
Difference between Genetic Algorithms and Traditional
Algorithms
○ A search space is the set of all possible solutions to the problem. In the
traditional algorithm, only one set of solutions is maintained, whereas, in a
genetic algorithm, several sets of solutions in search space can be used.
○ Traditional algorithms need more information in order to perform a search,
whereas genetic algorithms need only one objective function to calculate the
fitness of an individual.
○ Traditional Algorithms cannot work parallelly, whereas genetic Algorithms can
work parallelly (calculating the fitness of the individualities are independent).
○ One big difference in genetic Algorithms is that rather of operating directly on
seeker results, inheritable algorithms operate on their representations (or
rendering), frequently appertained to as chromosomes.
○ One of the big differences between traditional algorithm and genetic algorithm
is that it does not directly operate on candidate solutions.
○ Traditional Algorithms can only generate one result in the end, whereas Genetic
Algorithms can generate multiple optimal results from different generations.
○ The traditional algorithm is not more likely to generate optimal results, whereas
Genetic algorithms do not guarantee to generate optimal global results, but also
there is a great possibility of getting the optimal result for a problem as it uses
genetic operators such as Crossover and Mutation.
○ Traditional algorithms are deterministic in nature, whereas Genetic algorithms
are probabilistic and stochastic in nature.
Tabu search Flowchart
(LINK: https://www.youtube.com/watch?app=desktop&v=A7cTp1Fhg9o
What is Neural-Network based Optimization?
The process of minimizing (or maximizing) any mathematical
expression is called optimization. Optimizers are algorithms or
methods used to change the attributes of the neural network such as
weights and learning rate to reduce the losses. Optimizers are used to
solve optimization problems by minimizing the function.
Methods (Link: https://towardsdatascience.com/optimizers-for-training-
neural-network-59450d71caf6)
● Gradient Descent.
● Stochastic Gradient Descent (SGD)
● Mini Batch Stochastic Gradient Descent (MB-SGD)
● SGD with momentum.
● Nesterov Accelerated Gradient (NAG)
● Adaptive Gradient (AdaGrad)
● AdaDelta.
● RMSprop
Describe Fuzzy optimization techniques in brief.
Fuzzy optimization is a well-known optimization problem in artificial intelligence,
manufacturing and management, so establishing general and operable fuzzy
optimization methods are important in both theory and application.
Fuzzy optimization is distinguished from possibilistic optimization by both
semantics and optimization procedures. As will be seen below, fuzzy optimization
optimizes over sets of real numbers while possibilistic optimization optimizes over
sets of (possibility) distributions.
The precise quantification of many system performance criteria and parameter and
decision variables is not always possible, nor is it always necessary. When the
values of variables cannot be precisely specified, they are said to be uncertain or
fuzzy. If the values are uncertain, probability distributions may be used to quantify
them. Alternatively, if they are best described by qualitative adjectives, such as dry
or wet, hot or cold, clean or dirty, and high or low, fuzzy membership functions
can be used to quantify them. Both probability distributions and fuzzy membership
functions of these uncertain or qualitative variables can be included in quantitative
optimization models
Large, small, pure, polluted, satisfactory, unsatisfactory, sufficient, insufficient,
excellent, good, fair, poor and so on are words often used to describe various
attributes or performance measures of water resources systems. These descriptors
do not have ‘crisp’, well-defined boundaries that separate them from others. A
particular mix of economic and environmental impacts may be more acceptable to
some and less acceptable to others. Plan A is better than Plan B. The water quality
and temperature is good for swimming. These qualitative, or ‘fuzzy’, statements
convey information despite the imprecision of the italicized adjectives. This
chapter illustrates how fuzzy descriptors can be incorporated into optimization
models of water resources systems. Before this can be done some definitions are
needed.
Sequential Linear Programming
Successive Linear Programming (SLP), also known as Sequential Linear Programming, is
an optimization technique for approximately solving nonlinear optimization problems.
It is related to, but distinct from, quasi-Newton methods.
Starting at some estimate of the optimal solution, the method is based on solving a sequence of first-
order approximations (i.e. linearization) of the model. The linearization are linear programming
problems, which can be solved efficiently. As the linearization need not be bounded, trust regions or
similar techniques are needed to ensure convergence in theory.
SLP has been used widely in the petrochemical industry since the 1970s.
Sequential quadratic programming
Sequential quadratic programming (SQP) is an iterative method for constrained nonlinear
optimization which may be considered a quasi-Newton method. SQP methods are used
on mathematical problems for which the objective function and the constraints are twice continuously
differentiable.
SQP methods solve a sequence of optimization sub problems, each of which optimizes a quadratic
model of the objective subject to a linearization of the constraints. If the problem is unconstrained,
then the method reduces to Newton's method for finding a point where the gradient of the objective
vanishes. If the problem has only equality constraints, then the method is equivalent to
applying Newton's method to the first-order optimality conditions, or Karush–Kuhn–Tucker
conditions, of the problem.