Unit III
Unit III
Introduction, Evolutionary Computing, Terminologies of Evolutionary Computing, Genetic Operators, Evolutionary Algorithms: -
Genetic Algorithm, Evolution Strategies, Evolutionary Programming, Genetic Programming, Performance Measures of EA,
Evolutionary Computation versus Classical Optimization.
Evolution is an optimization process where the aim is to improve the ability of an organism, to survive in dynamically
changing and competitive environments.
• Evolution is a concept that has been hotly debated over centuries, and still causes active debates.
• for example, cosmic, chemical, stellar and planetary, organic or man-made systems of evolution.
• Attempts to define the term biological evolution still cause numerous debates, with the Lamarckian and Darwinian views
being the most popular and accepted.
– computer-based problem solving systems that use computational models of evolutionary processes, such as natural selection,
– survival of the fittest and reproduction, as the fundamental components of such computational systems.
2. Gene : A part of the chromosome that encodes a specific feature of the solution.
4. Generation : One complete cycle of the evolutionary process (evaluation, selection, reproduction).
5. Fitness Function : A measure to evaluate how good a solution (individual) is for the given problem.
6. Selection : The process of choosing individuals from the population for reproduction.
Common methods: Roulette Wheel Selection, Tournament Selection , Rank-Based Selection , Elitism
7. Crossover (Recombination) : A genetic operator that combines parts of two parents to form one or more offspring.
Types:
1) Single-point crossover
2) Two-point crossover
3) Uniform crossover
10. Elitism : A strategy to carry the best-performing individuals unchanged to the next generation.
11. Convergence : When the population stops showing significant improvement in fitness over generations.
13. Initialization : The process of generating the initial population, usually randomly.
Genetic Operators
1. Selection Operator
Definition:
Selection is the process of choosing a set of parent individuals from the current population based on their fitness scores,
which will contribute to producing the next generation.
Purpose:
To ensure that individuals with better fitness (i.e., better solutions) have a higher chance of passing their genes to the next
generation.
Drives the evolutionary pressure toward better solutions.
Common Techniques:
Roulette Wheel Selection:
o Also called fitness proportionate selection.
o Individuals are selected with a probability proportional to their fitness.
Tournament Selection:
o Randomly selects a few individuals and chooses the best among them as a parent.
o Easy to implement and widely used.
Rank-Based Selection:
o Individuals are ranked based on fitness, and selection probability is assigned according to rank, not absolute
fitness.
Elitism:
o A few best individuals (elite) are copied directly to the next generation without alteration, ensuring the best
solutions are retained.
2. Crossover (Recombination) Operator
Definition:
Crossover is a genetic operator used to combine the genetic information of two parent individuals to produce new offspring.
Purpose:
To exploit existing genetic material and create potentially better offspring by mixing traits of parents.
Mimics biological reproduction.
Types of Crossover:
Single-Point Crossover:
o A random point is selected along the length of the chromosome.
o The first part of the chromosome is taken from one parent, and the second part from the other.
Two-Point Crossover:
o Two points are chosen; the segment between them is swapped between parents.
Uniform Crossover:
o Each gene in the offspring is chosen randomly from either of the two parents.
Arithmetic Crossover (for real-number chromosomes):
o The child is created by a weighted average of the parents' gene values.
Example:
If Parent 1 = 11001 and Parent 2 = 10111,
Single-point crossover at position 3 may give:
Offspring = 11011.
3. Mutation Operator:
Mutation introduces random changes to individual genes in a chromosome to maintain genetic diversity within the population.
Purpose:
To explore new regions of the solution space.
Helps prevent premature convergence to local optima.
Maintains population diversity over generations.
Types of Mutation:
Bit Flip Mutation (for binary chromosomes):
o Randomly selects a bit and flips its value (0 → 1 or 1 → 0).
Gaussian Mutation (for real-valued genes):
o Adds small Gaussian noise to gene values.
Swap Mutation (for permutation-based chromosomes, like TSP):
o Swaps the positions of two genes in the chromosome.
Example:
Original: 11001
After bit-flip mutation at position 2: 10001
4. Replacement (Survivor Selection) Operator
Definition:
After generating new offspring using crossover and mutation, the replacement operator decides which individuals will survive into
the next generation.
Strategies:
Generational Replacement:
o Entire population is replaced by offspring.
Steady-State Replacement:
o Only a few of the least-fit individuals are replaced in each generation.
Elitism:
o Ensures that the best individuals are never lost during the replacement process.
5. Reinsertion
Definition:
Reinsertion refers to the strategy used to combine offspring and existing individuals to create the next generation’s population. It
balances exploration and exploitation.
Algorithm:-
8. end
Evolution Strategies (ES) are a family of optimization algorithms inspired by the process of natural evolution. They
belong to the broader class of Evolutionary Algorithms (EAs), which also include Genetic Algorithms (GAs) and
Genetic Programming (GP).
Core Idea:
Evolution Strategies are population-based stochastic search methods used primarily for real-valued optimization problems.
They iteratively improve a population of candidate solutions using principles of selection, mutation, and recombination.
Basic Components:
1. Population: A set of candidate solutions.
2. Selection: Choosing the best-performing individuals (according to a fitness function).
3. Mutation: Small random changes applied to individuals.
4. Recombination (optional): Combining parts of two or more parent solutions.
5. Fitness Function: Evaluates how good a solution is.
Algorithm Steps (μ, λ)-ES:
Initialize a population of μ parents.
Create λ offspring through mutation and possibly recombination.
Evaluate the fitness of all offspring.
Select the μ best individuals from:
o Only offspring → (μ, λ)-ES
o Parents + offspring → (μ+λ)-ES
Repeat for several generations.
Mutation:
Each individual is a vector of real numbers. Mutation is often done by adding Gaussian noise: x new=xold+N(0,σ2)
Where σ is the mutation strength (can be adapted over time).
Applications:
Advantages:
1) Gradient-free (doesn't need derivatives)
2) Works well in noisy or discontinuous landscapes
3) Can be easily parallelized
Disadvantages:
1) May require many evaluations (computationally expensive)
2) Convergence can be slow compared to gradient-based methods in some cases
Evolutionary Programming (EP) is a type of Evolutionary Algorithm (EA) used for optimization and machine learning tasks.
Like other EAs (e.g., Genetic Algorithms, Evolution Strategies), it mimics natural evolution to find good solutions to complex
problems.
EP focuses on the evolution of behavioral models (like finite-state machines or functions) and mainly uses mutation as its
primary operator—no crossover/recombination unlike Genetic Algorithms.
1. Initialization:
Main Operator Mutation Randomly generate a population of individuals.
Selection Stochastic (based on fitness and competition) Also, mutate the strategy parameters: σi′=σi⋅eT⋅N(0,1)
Evaluation:
Strategy parameters (e.g., mutation variance) are Evaluate each mutated individual based on a fitness
Adaptation
evolved function.
o Random noise from a normal distribution o Each individual competes with k randomly
is added to each variable. selected individuals.
Selection Mechanism
Advantages of EP
Simple to implement.
Applications of EP
Control systems
Pattern recognition
Evolutionary Programming
Feature Genetic Algorithm (GA) Evolution Strategy (ES)
(EP)
Representation Binary strings or real coded vectors Real-valued vectors Real-valued vectors
Evolutionary Programming
Feature Genetic Algorithm (GA) Evolution Strategy (ES)
(EP)
Mutation
Simple/random mutation Self-adaptive mutation strength Self-adaptive mutation strength
Strategy
Application General problem solving, combinatorial Engineering design, real-valued Function optimization, learning
Focus optimization optimization systems
Genetic Programming (GP) is a type of Evolutionary Algorithm that evolves computer programs or symbolic expressions to
solve problems.
It uses the principles of natural selection and genetic operators like selection, crossover, and mutation to evolve tree-like
structures (representing programs or mathematical expressions) over generations.
Unlike Genetic Algorithms (which evolve fixed-length strings), GP evolves variable-length computer programs, often
represented as syntax trees.
Symbolic Regression is the process of finding a mathematical expression or model that best fits a given dataset, without assuming
a fixed functional form (like linear, polynomial, etc.).
1. Initial Population: Random mathematical expressions (trees) are generated using basic operators (e.g., +, −, ×, ÷) and
terminal symbols (input variables/constants).
2. Fitness Function: Each expression is evaluated by how well it predicts or fits the data (e.g., using mean squared error).
3. Genetic Operators: Crossover and mutation are applied to evolve better expressions.
4. Best Expression: The most accurate symbolic expression (model) emerges after several generations.
Example:
Given a dataset of values for input x and output y, GP might evolve a symbolic expression like:
y=3x2+2x+1
Q. What are the key performance measures used to evaluate the effectiveness of evolutionary algorithms?
Performance Measures of EA
The effectiveness of Evolutionary Algorithms (EAs) is evaluated using several key performance measures:
1. Fitness Value:
Measures the quality of a solution based on the objective function. Higher (or lower, in case of minimization) fitness
indicates better solutions.
2. Convergence Rate:
Indicates how quickly the algorithm approaches an optimal or near-optimal solution. A fast convergence is desirable but
may risk premature convergence.
3. Success Rate:
The percentage of runs in which the EA successfully finds an acceptable or optimal solution. It reflects the reliability of
the algorithm.
4. Computational Time:
Total time taken to reach the solution. Lower time indicates better efficiency, especially important for large-scale or real-
time applications.
5. Population Diversity:
Measures the variation among individuals. High diversity prevents premature convergence and helps in exploring the
search space effectively.
6. Robustness:
The consistency of results across multiple runs with different initial conditions. Robust algorithms show low variance in
outcomes.
Handles non-linear, discrete, multi-modal, and Best suited for linear, convex, or smooth
3. Problem Handling
complex problems problems
Slower, but more robust; can avoid premature Faster in well-defined problems, but may
6. Convergence
convergence converge prematurely
Genetic Algorithms (GA), Genetic Programming Gradient Descent, Newton's Method, Linear
8. Examples
(GP), PSO, DE Programming
Goal is To guide the search process toward feasible, high-quality solutions without losing the diversity or exploratory
power of evolutionary algorithms
Types of Constraints:
2. Repair Method
3. Feasibility Preservation
Avoids constraint violation from the start but may reduce diversity.
4. Multi-Objective Approach
Example: One objective for the original fitness, another for constraint violation.
5. Stochastic Ranking
6. Decoders
Use encoded representations that always map to feasible solutions (e.g., indirect representation).
Multi-objective Optimization
Multi-objective Optimization (MOO) involves optimizing two or more conflicting objectives simultaneously, rather than a
single objective.
Instead of a single optimal solution, the goal is to find a set of trade-off solutions called the Pareto-optimal set.
Key Concepts:
1. Objective Functions:
Minimize/Maximize:f1(x),f2(x),...,fk(x)
Subject to:
2. Conflicting Objectives:
3. Pareto Dominance:
4. Pareto-optimal Set:
5. Pareto Front:
The image (plot) of the Pareto-optimal set in the objective function space. It shows the trade-offs between objectives.
Evolutionary Algorithms (EAs) are naturally suitable for MOO because they:
Algorithm Description
NSGA-II (Non-dominated Sorting Genetic Uses fast non-dominated sorting and crowding distance to maintain
Algorithm-II) diversity.
Algorithm Description
MOEA/D (Multi-objective EA based on Decomposes a multi-objective problem into several scalar sub-
Decomposition) problems.
Example:
Dynamic Environments
A dynamic environment refers to an optimization problem where the objective function, constraints, or environment
conditions change over time.
In real-world scenarios, many problems are not static—they evolve due to external or internal factors. Therefore, algorithms must
adapt to changing conditions.
Stock market prediction, Adaptive traffic control , Robotics in changing terrain, Weather modelling , Online
recommendation systems
In such cases, an algorithm must not only find a good solution once, but continuously track and adapt to changes in the
environment.
Technique Description
Memory-based Approaches Store past good solutions and reuse them when similar conditions reoccur.
Maintain population diversity to respond better to future changes (e.g., using random immigrants,
Diversity Maintenance
crowding).
Multi-population
Use multiple subpopulations to explore different areas of the search space simultaneously.
Approaches
Technique Description
Change Detection Use techniques to detect when the environment has changed, triggering re-evaluation or
Mechanisms adaptation.
Prediction Models Use machine learning or pattern recognition to anticipate future changes.
Example Scenario:
In an adaptive route planning system for delivery vehicles, traffic conditions change throughout the day. A static optimization may
fail, but a dynamic EA can adjust the routes based on real-time traffic updates.
Swarm Intelligence (SI) is a subfield of Artificial Intelligence that studies collective behavior of decentralized, self-organized
systems—such as insect colonies, bird flocks, or fish schools—to solve complex problems.
Ant Colony Optimization is a population-based, probabilistic algorithm inspired by the foraging behavior of real ants.
Ants deposit a chemical called pheromone on the ground to communicate indirectly and find the shortest path between food
sources and their colony.
2. Solution Construction: Each ant builds a solution probabilistically using pheromone and heuristic information.
4. Best Solution Selection: Select the best solution(s) from current or all iterations.
Advantages:
Limitations:
Example:
In the TSP (Travelling Salesman Problem), ants represent possible tours between cities. The more ants travel a short route, the
more pheromone it accumulates, increasing its probability of being chosen in the next iteration.
Knowledge Requirement Doesn’t require gradient or derivative Requires knowledge of gradient or function
properties
Q. Discuss the importance of selection in evolutionary algorithms and its impact on the convergence of the algorithm. [6
Marks]
Selection is a critical step in Evolutionary Algorithms (EAs) where individuals (candidate solutions) from the current population
are chosen to produce offspring for the next generation. It is based on fitness values, aiming to pass good traits to the next
generation.
Importance of Selection:
1. Drives the Search Toward Better Solutions: Fitter individuals are more likely to be selected, guiding the search process
towards promising areas of the solution space.
2. Ensures Survival of the Fittest: Helps preserve high-quality solutions by giving them a higher chance of reproduction.
3. Maintains Selective Pressure: Determines how strongly the algorithm favors fitter individuals over weaker ones.
4. Balances Exploration and Exploitation: Too much selection pressure → Premature convergence.
Method Description
Impact on Convergence:
Faster Convergence: Effective selection accelerates the convergence by quickly promoting good individuals.
Risk of Premature Convergence: Excessive focus on top individuals reduces diversity, causing the algorithm to get
stuck in local optima.
Maintains Genetic Diversity: Balanced selection strategies help avoid stagnation and improve global search ability.
Conclusion:
Selection plays a vital role in guiding the evolutionary process and determining how effectively and efficiently the algorithm
converges to optimal or near-optimal solutions. A well-designed selection mechanism ensures a good trade-off between
exploration and exploitation, crucial for the success of evolutionary algorithms.
In Evolutionary Computing (EC), a population is a group of potential solutions (called individuals or chromosomes) to a
given problem.
Each individual represents a candidate solution encoded in a particular format (e.g., binary string, real vector, or tree).
At each generation, the entire population evolves through processes like selection, crossover, and mutation to improve solution
quality.
Significance of Population in Optimization:
1. Parallel Search Space Exploration: A population allows the algorithm to explore multiple areas of the search space
simultaneously, reducing the chances of getting stuck in local optima.
2. Maintains Diversity: Diversity in the population prevents premature convergence and promotes a more robust search
for the global optimum.
3. Enables Genetic Operations: Operators like crossover require more than one individual to exchange genetic material
and produce new offspring.
o A population provides the raw material for variation and innovation.
4. Faster Convergence Over Time: A well-distributed population helps in discovering high-quality solutions faster by
propagating good traits across generations.
5. Support for Multi-objective Optimization: Populations make it possible to find and maintain a set of trade-off
solutions (Pareto front) in multi-objective problems.
6. Facilitates Elitism and Replacement Strategies: The population framework allows retaining the best individuals
from one generation to the next, improving solution quality over time.
Conclusion:
The concept of population is fundamental to evolutionary computing. It enables a robust, flexible, and parallel search process,
helping algorithms efficiently explore and exploit the solution space. A well-managed population is key to successful
optimization in EC.
Unit IV Genetic Algorithm 06 Hours
Introduction to Basic Terminologies in Genetic Algorithm: Individuals, Population, Search space, Genes, Fitness function,
Chromosome, Trait, Allele, Genotype and Phenotype.
Operators in Genetic Algorithm: Initialization, Selection, Crossover (Recombination), Mutation; fitness score, Stopping Condition,
reproduction for GA Flow, Constraints in Genetic Algorithms.
Genetic Algorithm Variants: Canonical Genetic Algorithm (Holland Classifier System), Messy Genetic Algorithms, Applications,
and benefits of Genetic Algorithms.
Basic Terminology.
Individuals: An individual is a single candidate solution in the population. It is represented as a chromosome and evaluated
using the fitness function.
Population − It is a subset of all the possible (encoded) solutions to the given problem. The population for a GA is
analogous to the population for human beings except that instead of human beings, we have Candidate Solutions
representing human beings.
Search Space: The search space consists of all possible candidate solutions for the problem.The algorithm tries to
explore this space to find the optimal solution.
Chromosomes − A chromosome is one such solution to the given problem. It is typically represented as a string of genes
(e.g., binary, real-valued, or symbols).
Trait: A trait is a specific feature of an individual, determined by one or more genes. Traits affect the performance of
a solution.
Example: In an AI robot, traits could be speed, reaction time, etc.
Gene − A gene is one element position of a chromosome. It represents a part of the solution, such as a parameter or
decision variable.
Allele − It is the value a gene takes for a particular chromosome. For example, in a binary string 1010, each digit is a
gene, and 0 or 1 are the possible alleles.
Decoding and Encoding − For simple problems, the phenotype and genotype spaces are the same. However, in most of
the cases, the phenotype and genotype spaces are different. Decoding is a process of transforming a solution from the
genotype to the phenotype space, while encoding is a process of transforming from the phenotype to genotype space.
Decoding should be fast as it is carried out repeatedly in a GA during the fitness value calculation.
For example, consider the 0/1 Knapsack Problem. The Phenotype space consists of solutions which just contain the item numbers
of the items to be picked.
However, in the genotype space it can be represented as a binary string of length n (where n is the number of items). A 0 at
position x represents that xth item is picked while a 1 represents the reverse. This is a case where genotype and phenotype spaces
Q: Explain the concept of an individual in the context of genetic algorithms and its role in the optimization process. [8
marks]
In the context of Genetic Algorithms (GAs), an individual refers to a single candidate solution to the optimization problem
being solved. It represents a point in the search space, and is encoded as a chromosome (a data structure, often a string, list, or
array).
Structure of an Individual:
2. Fitness Evaluation:
The performance or quality of each individual is measured using a fitness function. This function evaluates how well the
individual solves the problem.
4. Genetic Diversity:
A diverse set of individuals helps prevent premature convergence and allows better exploration of the search space.
An individual is the core element in a genetic algorithm. It encapsulates a single solution and plays a vital role in fitness
evaluation, selection, reproduction, and overall evolutionary improvement. Through the interaction and variation among
individuals, GAs explore and optimize complex problem spaces effectively.
Binary Representations,
Binary representation is one of the most common and simplest encoding methods used in GAs. Each individual (chromosome)
is represented as a binary string consisting of 0s and 1s, where each bit (gene) represents a feature or parameter.
For some problems when the solution space consists of Boolean decision variables yes or no, the binary representation is natural.
Take for example the 0/1 Knapsack Problem. If there are n items, we can represent a solution by a binary string of n elements,
where the xth element tells whether the item x is picked (1) or not (0).
For other problems, specifically those dealing with numbers, we can represent the numbers with their binary representation. The
problem with this kind of encoding is that different bits have different significance and therefore mutation and crossover operators
can have undesired consequences. This can be resolved to some extent by using Gray Coding, as a change in one bit does not
have a massive effect on the solution.
For problems where we want to define the genes using continuous rather than discrete variables, the real valued representation is
the most natural. The precision of these real valued or floating point numbers is however limited to the computer.
Integer Representation
For discrete valued genes, we cannot always limit the solution space to binary yes or no. For example, if we want to encode the
four distances North, South, East and West, we can encode them as {0,1,2,3}. In such cases, integer representation is desirable.
Permutation Representation
In many problems, the solution is represented by an order of elements. In such cases permutation representation is the most suited.
A classic example of this representation is the travelling salesman problem (TSP). In this the salesman has to take a tour of all the
cities, visiting each city exactly once and come back to the starting city. The total distance of the tour has to be minimized. The
solution to this TSP is naturally an ordering or permutation of all the cities and therefore using a permutation representation makes
sense for this problem.
Floating-point (also called real-valued) representation is a method where each gene in the chromosome is directly represented as
a real number (decimal value) instead of using binary encoding.
This method is particularly useful for continuous optimization problems where decision variables can take any value within a
specific range.
Structure:
Each chromosome is an array (vector) of real numbers.
Example:
Let’s say we are optimizing three variables:
Chromosome = [1.57, -3.24, 0.89]
Each number in this array represents a gene, and the entire array is one individual.
Why Use Floating-Point Representation?
Binary representations require decoding and scaling, which may reduce accuracy.
Floating-point allows direct mapping to problem variables with higher precision.
Especially suitable for engineering and scientific problems.
Advantages:
1. Higher precision in representing continuous variables.
2. Faster convergence due to smoother search landscape.
3. No decoding/encoding overhead — genes map directly to problem parameters.
4. Easier to apply gradient-based or hybrid methods.
Disadvantages:
1. Some traditional genetic operators (like single-point crossover) are less intuitive.
2. May suffer from premature convergence if diversity isn't maintained.
3. Requires specialized operators like blend crossover (BLX-α) or Gaussian mutation.
Common Operators for Floating-Point Representation:
Arithmetic crossover: Combines parents using a weighted average.
Blend crossover (BLX-α): Generates children within a defined range around parents.
Non-uniform mutation: Adds small noise to genes to maintain diversity.
Use Cases:
Engineering design optimization
Neural network weight optimization
Control parameter tuning
Continuous function minimization or maximization
Example:
Optimize the function:
f(x,y)=x2+y2 where x,y [−5,5]
Chromosome: [x, y]
Example Individual: [2.5, -1.3]
Fitness: f(2.5, -1.3) = 2.5² + (-1.3)² = 6.25 + 1.69 = 7.94
c) Write the principles of the Holland Classifier system and its application?
[5]
OR
P.T.O.
[6263]-390 2
Q5) a) Compare and contrast Word2Vec and GloVe in terms of how they
b) Explain the architecture of a Seq2Seq model and its role in neural machine
translation? [9]
OR
Transformers) work, and what are its advantages over traditional language
models? [9]
Q7) a) Explain the concept of Artificial Immune Models and their significance
OR
Q8) a) Discuss the role of antigen-presenting cells in immune activation and its