unit-5.docx
unit-5.docx
unit-5.docx
Table of Content
1) Basic concepts
2) working principle
3) procedures of GA
4) flow chart of GA
5) Genetic representations, (encoding)
6) Initialization and selection
7) Genetic operators
8) Mutation
9) Generational Cycle
10) Applications.
A genetic algorithm (GA) is an optimization and search technique based on the principles of
natural selection and genetics. It mimics the process of evolution to solve complex problems by
iteratively improving a population of candidate solutions.
Biological Background
The science that deals with the mechanisms responsible for similarities and differences in a species
is called Genetics. The word "genetics" is derived from the Greek word "genesis" meaning "to
grow" or "to become."
• Cell
Every animal/human cell is a complex of many "small" factories that work together. The center of
all this is the cell nucleus. The genetic information is contained in the cell nucleus.
• Chromosomes
All the genetic information gets stored in the chromosomes. Each chromosome is build of
deoxyribonucleic acid (DNA). In humans, chromosomes exist in pairs (23 pairs found). The
chromosomes are divided into several parts called genes. Genes code the properties of species, i.e.,
the characteristics of an individual. The possibilities of combination of the genes for one property
are called alleles, and a gene can take different alleles. For example, there is a gene for eye color,
and all the different possible alleles are black, brown, blue and green (since no one has red or violet
eyes!). The set of all possible alleles present in a particular population forms a gene pool. This gene
pool can determine all the different possible variations for the future generations. The size of the
gene pool helps in determining the diversity of the individuals in the population. The set of all the
genes of a specific species is called genome. Each and every gene has a unique position on the
genome called locus.
• Genetics
A particular individual, the entire combination of genes is called genotype. The phenotype
describes the physical aspect of decoding a genotype to produce the phenotype. Chromosomes
contain two sets of genes. These are known as diploids.
• Reproduction
1. Mitosis: In mitosis the same genetic information is copied to new offspring. There is no
exchange of information. This is a normal way of growing of multicell structures, such as organs.
2. Meiosis: Meiosis forms the basis of sexual reproduction. When meiotic division takes place, two
gametes appear in the process. When reproduction occurs, these two gametes conjugate to a zygote
which becomes the new individual.
Genetic Algorithms
Genetic Algorithms (GAs) are a type of computational optimization technique inspired by the
principles of natural selection and genetics. They are used to solve complex problems by mimicking
the process of evolution to improve a population of potential solutions iteratively. These algorithms
operate on a set of candidate solutions encoded as strings of binary digits or other data structures.
During the selection phase, individuals from the current population are evaluated based on a fitness
function, quantifying how well each solution solves the problem. The individuals with higher
fitness values are more likely to be selected for further processing, simulating the survival of the
fittest.
Crossover, or recombination, is a genetic operator where two selected individuals exchange genetic
information to create offspring. This operation is analogous to sexual reproduction, where genetic
material from both parents is combined to produce genetically diverse offspring.
Mutation introduces small random changes in the genetic information of selected individuals. This
operation helps maintain genetic diversity within the population, allowing exploration of different
regions of the solution space.
After the genetic operators are applied, a new population is created, replacing the previous
generation. This process is repeated for a fixed number of generations or until a termination
condition is met, such as reaching a desired fitness level or exceeding a specified number of
iterations.
Over the course of multiple generations, genetic algorithms explore the solution space, favoring
solutions with higher fitness values. The algorithm can converge towards an optimal or near-
optimal solution by iteratively applying selection, crossover, and mutation.
Genetic algorithms have been successfully applied to various optimization problems, including
parameter tuning, scheduling, routing, and machine learning. Their ability to explore large solution
spaces and find globally optimal or near-optimal solutions makes them particularly useful in cases
• Individuals
• Genes
Genes are the basic "instructions" for building a GA. A chromosome is a sequence of genes. Genes
may describe a possible solution to a problem, without actually being the solution. A gene is a bit
string of arbitrary lengths. The bit string is a binary representation of number of intervals from a
lower bound.
• Fitness
The fitness of an individual in a GA is the value of an objective function for its phenotype. For
calculating fitness, the chromosome has to be first decoded and the objective function has to be
evaluated. The fitness not only indicates how good the solution is, but also corresponds to how
close the chromosome is to the optimal one.
• Populations
1. Optimization problems
GAs excel at solving optimization problems, aiming to find the best solution among a large set of
possibilities. These problems include mathematical function optimization, parameter tuning,
portfolio optimization, resource allocation, and more. GAs explore the solution space by enabling
2. Combinatorial optimization
GAs effectively solve combinatorial optimization problems, which involve finding the best
arrangement or combination of elements from a finite set. Examples include the traveling salesman
problem (TSP), vehicle routing problem (VRP), job scheduling, bin packing, and DNA sequence
alignment. GAs represent potential solutions as chromosomes, and through the process of
evolution, they search for the optimal combination of elements.
3. Machine learning
GAs have applications in machine learning, particularly to optimize the configuration and
parameters of machine learning models. GAs can be used to optimize hyperparameters, such as
learning rate, regularization parameters, and network architectures in neural networks. They can
pg. 10 Faculty : Shanu Gupta(CSE Department)
VISION INSTITUTE OF TECHNOLOGY, Subject: (BCS056)
Application of Soft Computing
ALIGARH
also be employed for feature selection, where the algorithm evolves a population of feature subsets
to identify the most relevant subset for a given task.
4. Evolutionary robotics
GAs find use in evolutionary robotics, which involves evolving robot behavior and control
strategies. By representing the robot’s control parameters or policies as chromosomes, GAs can
evolve solutions that maximize performance metrics such as speed, stability, energy efficiency, or
adaptability. GAs are particularly useful when the optimal control strategies are difficult to
determine analytically.
GAs are applied in image and signal processing tasks, including image reconstruction, denoising,
feature extraction, and pattern recognition. They can optimize the parameters of reconstruction
algorithms to enhance image quality. In signal processing, they can optimize filtering parameters
for denoising signals while preserving important information. GAs can also be used for automatic
feature extraction, evolving feature extraction algorithms to identify relevant features/objects in
images or signals.
GAs have been used for design and creativity tasks, such as generating artistic designs, music
composition, and game design. By representing design elements or musical notes as genes, GAs
can evolve populations of designs or compositions and evaluate their quality using fitness functions
tailored to the specific domain. GAs have demonstrated the ability to generate novel and innovative
solutions in creative domains.
7. Financial modeling
GAs are applied in financial modeling for portfolio optimization, algorithmic trading, and risk
management tasks. GAs can optimize the allocation of assets in an investment portfolio to
maximize returns and minimize risk. They can also evolve trading strategies by adjusting trading
parameters to adapt to market conditions and maximize profits. GAs provide a flexible and adaptive
approach to modeling complex financial systems.
These applications demonstrate the versatility and effectiveness of genetic algorithms in solving
optimization and search problems across various domains. The ability of GAs to explore the
Let’s consider an example that involves optimizing a common task: finding the best route to
commute from home to work.
Imagine you want to optimize your daily commute and find the shortest route to go from your home
to your workplace. You have multiple possible routes to choose from, each with different distances,
traffic conditions, and travel times. You can use a GA to help you find the optimal route.
In this case, potential solutions can be encoded as permutations of the cities or locations along the
commute route. For example, you can represent each possible route as a string of city identifiers,
such as “A-B-C-D-E-F,” where each letter represents a location (e.g., a street, intersection, or
landmark).
2. Initialization
Start by creating an initial population of potential routes. You can randomly generate a set of routes
or use existing routes as a starting point.
3. Evaluation
Evaluate each route in the population by considering factors such as distance, traffic conditions,
travel time, and other relevant criteria. The evaluation function should quantify the quality of each
route, where lower values indicate better solutions (e.g., shorter distance, less time spent in traffic).
4. Selection
Perform a selection process to choose which routes will be part of the next generation. Selection
methods aim to favor fitter individuals, in this case, routes with lower evaluation values. Common
selection techniques include tournament selection, roulette wheel selection, or rank-based
selection.
5. Crossover
Apply crossover to create new routes by combining genetic material from two parent routes. For
instance, you can select two parent routes and exchange segments of the routes to create two new
offspring routes.
Introduce random changes in the routes through mutation. This helps explore new possibilities and
avoid getting stuck in local optima. A mutation operation could involve randomly swapping two
cities in a route, inserting a new city, or randomly changing the order of a few cities.
7. New generation
The offspring generated through crossover and mutation and a few fittest individuals from the
previous generation form the new population for the next iteration. This ensures that good solutions
are preserved and carried forward.
8. Termination
The GA continues the selection, crossover, and mutation process for a fixed number of generations
or until a termination criterion is met. Termination criteria can be a maximum number of iterations
or reaching a satisfactory solution (e.g., a route with a predefined low evaluation value).
pg. 13 Faculty : Shanu Gupta(CSE Department)
VISION INSTITUTE OF TECHNOLOGY, Subject: (BCS056)
Application of Soft Computing
ALIGARH
9. Final solution
Once the GA terminates, the best solution, typically the route with the lowest evaluation value,
represents the optimal or near-optimal route for your daily commute.
By iteratively applying selection, crossover, and mutation, GAs help explore and evolve the
population of routes, gradually converging toward the shortest and most efficient route for your
daily commute.
It’s important to note that GAs require appropriate parameter settings, such as population size,
selection strategy, crossover and mutation rates, and termination criteria, to balance exploration
and exploitation.
The basic operators include: encoding, selection, recombination and mutation operators. The
operators with their various types are explained with necessary examples.
Encoding
Encoding is a process of representing individual genes. The process can be performed using bits,
numbers, trees, arrays, lists or any other object.
Initialization
Initialization refers to the creation of the initial population of solutions. This step involves:
Selection
Selection is the process of choosing individuals for reproduction based on their fitness scores.
Techniques include:
• Roulette Wheel Selection: Probabilistic selection where fitter individuals have a higher
chance of being chosen.
• Tournament Selection: Randomly selecting a subset of individuals and choosing the best
among them.
• Elitism: Directly carrying over the best individual(s) to the next generation.
Crossover
Originally, GAs were using one point crossover which cuts two chromosomes in one point and
splices the two halves to create new ones. But with this one-point crossover, the head
Department of CSE, ICET 115 and the rail of one chromosome cannot be passed together to
the offspring. If both the head and the tail of a chromosome contain good genetic information,
none of the offspring obtained directly with one-point crossover will share the two good
Generational Cycle
1. Evaluate Fitness: Assess the fitness of each individual using a fitness function.
5. Replacement: Form a new population, typically replacing the less fit individuals.
6. Repeat: Continue the cycle until a stopping condition is met (e.g., maximum generations
or satisfactory solution).