Topic 4 - Evolutionary Algorithm
Topic 4 - Evolutionary Algorithm
Intelligence Algorithms
Topic 4 – Evolutionary Algorithm
Faculty of Computer & Mathematical Sciences
Universiti Teknologi MARA
A. Introduction
A. Introduction: Objectives
• To understand:
• How nature inspires evolutionary algorithm
• The foundations of evolutionary algorithm
• The differences between genetic algorithm, genetic
programming and evolutionary programming
A. Introduction: Can Evolution be Intelligent?
• Intelligence can be defined as the capability of a system to
adapt its behaviour to ever-changing environment.
• If, over successive generations an organism survives, we can say
that this organism is capable of learning to predict changes in
environment
A. Introduction: Can Evolution be Intelligent?
(cont)
• Evolutionary computation simulates evolution on a
computer.
• The result of such a simulation is a series of optimisation
algorithms, usually based on a simple set of rules.
• Optimisation iteratively improves the quality of solutions
until an optimal, or at least feasible, solution is found.
A. Introduction: Can Evolution be Intelligent?
(cont)
• The evolutionary approach is based on computational
models of natural selection and genetics.
• We call them evolutionary computation, an umbrella term
that combines genetic algorithms, evolution strategies and
genetic programming.
A. Introduction: Classifications of EA
A. Introduction: Simulation of Natural
Evolution – Survival of the Fittest
• Darwinism is based on processes of reproduction, mutation,
competition and selection.
• The power to reproduce appears to be an essential property of
life.
• The power to mutate is also guaranteed in any living organism that
reproduces itself in a continuously changing environment.
• Processes of competition and selection normally take place in the
natural world, where expanding populations of different species
are limited by a finite space.
• Evolutionary fitness – population’s ability to survive and reproduce
A. Introduction: Simulation of Natural
Evolution (cont)
• All methods of evolutionary computation simulate natural
evolution by:
• creating a population of individuals
• evaluating their fitness
• generating a new population through genetic operations
• repeating this process a number of times.
A. Introduction: EA Analogy Foundation
Genetic Algorithms
B. Genetic Algorithms
• Genetic Algorithms is a search technique used in computing
to find true or approximate solutions to optimization and
search problems based on biological evolution
• Introduced in early 1970s by John Holland, GA aims to make
computers do what nature does.
B. Genetic Algorithms
• Holland introduced algorithms that manipulate strings of
binary digits
• Each artificial “chromosomes” consists of a number of “genes”,
and each gene is represented by 0 or 1:
1 0 1 1 0 1 0 0 0 0 0 1 0 1 0 1
genes
C. Genetic Algorithms: Steps
• Step 1:
• Represent the problem variable domain as a chromosome of a
fixed length, choose the size of a chromosome population N, the
crossover probability pc and the mutation probability pm.
• Step 2:
• Define a fitness function to measure the performance, or fitness,
of an individual chromosome in the problem domain. The fitness
function establishes the basis for selecting chromosomes that will
be mated during reproduction.
C. Genetic Algorithms: Steps (cont)
• Step 3:
• Randomly generate an initial population of chromosomes of size
N:
x 1 , x 2, . . . , x N
• Step 4:
• Calculate the fitness of each individual chromosome:
f(x1), f(x2), . . . , f(xN)
C. Genetic Algorithms: Steps (cont)
• Step 5:
• Select a pair of chromosomes for mating from the current
population. Parent chromosomes are selected with a probability
related to their fitness.
• Selection Techniques
• Roulette Wheel Selection
• Rank Selection
• Tournament Selection
• etc
C. Genetic Algorithms: Steps (cont)
• Step 6:
• Create a pair of offspring chromosomes by applying the genetic
operators - crossover and mutation.
• Step 7:
• Place the created offspring chromosomes in the new population.
• Step 8:
• Repeat Step 5 until the size of the new chromosome population
becomes equal to the size of the initial population, N.
C. Genetic Algorithms: Steps (cont)
• Step 9:
• Replace the initial (parent) chromosome population with the new
(offspring) population.
• Step 10:
• Go to Step 4, and repeat the process until the termination
criterion is satisfied.
C. Genetic Algorithms: Crossover & Mutation
• Crossover and Mutation are genetic operators. There are several
techniques for these two operators
sum = 218
E. Genetic Algorithms: Case Study - Solution
• Step 5 (cont):
• select chromosomes for mating based on fitness
• E.g: spin roulette wheel where chromosomes are given slices
based on fitness ratio
• spin 6 times (same as N)
Selected:
X6 and X2
X1 and X5
X2 and X5
E. Genetic Algorithms: Case Study - Solution
• Step 6
• generate offspring by using genetic operator - crossover
• (one-point crossover) randomly choose a crossover point
where two parent chromosomes “break”
• exchanges the chromosome parts after that point
• if pair of chromosomes does not crossover, cloning takes place
E. Genetic Algorithms: Case Study - Solution
• Step 6 (cont)
• generate offspring by using genetic operator - crossover
cloning
E. Genetic Algorithms: Case Study - Solution
• Step 6 (cont)
• generate offspring by using genetic operator – mutation
• flips a randomly selected gene in a chromosome
• mutation probability is quite small in nature, and is kept low for
GAs between 0.001 and 0.01
E. Genetic Algorithms: Case Study - Solution
• Step 6 (cont)
• generate offspring by using genetic operator – mutation
E. Genetic Algorithms: Case Study - Solution
• Step 7
• place the created offspring chromosomes in the new population.
• Step 8
• continue until population size is N = 6.
E. Genetic Algorithms: Case Study - Solution
• Step 9
• replace initial (parent) population with offspring population
• Step 10
• repeat until termination criterion (typically several hundreds
generations)
X2i 0 1 0 0 1 0 X2"i
X5i 0 1 1 1
E. Genetic Algorithms: Case Study 2
• The Traveling Salesman Problem:
• Find a tour of a given set of cities so that each city is visited
only once the total distance traveled is minimized
E. Genetic Algorithms: Case Study 2 -
Individuals
• Representation is an ordered list of city numbers known as
an order-based GA.
CityList1 (3 5 7 2 1 6 4 8)
CityList2 (2 5 7 6 8 1 3 4)
… etc
E. Genetic Algorithms: Case Study 2 -
Selection
• Fitness function calculates the total distance between each
city.
CityList1 (3 5 7 2 1 6 4 8)
CityList2 (2 5 7 6 8 1 3 4)
E. Genetic Algorithms: Case Study 2 -
Crossover
• Order 1 crossover
Parent1 (3 5 7 2 1 6 4 8)
Parent2 (2 5 7 6 8 1 3 4)
Child (5 8 7 2 1 6 3 4)
E. Genetic Algorithms: Case Study 2 -
Mutation
• Swap Mutation
Before: (5 8 7 2 1 6 3 4)
After: (5 8 6 2 1 7 3 4)
E. Genetic Algorithms: Case Study 2 –TSP
Example: 30 Cities
E. Genetic Algorithms: Case Study 2 –TSP30
Example: Solution i
E. Genetic Algorithms: Case Study 2 –TSP30
Example: Solution j
E. Genetic Algorithms: Case Study 2 –TSP30
Example: Solution k
E. Genetic Algorithms: Case Study 2 –TSP30
Example: Best Solution
E. Genetic Algorithms: Case Study 2 - TSP30
Example: Overview of Performance
F. Genetic Algorithms: Benefits
• Concept is easy to understand
• Modular, separate from application
• Supports multi-objective optimization
• Good for “noisy” environments
• Always an answer; answer gets better with time
• Inherently parallel; easily distributed
F. Genetic Algorithms: Benefits (cont)
• Many ways to speed up and improve a GA-based application as
knowledge about problem domain is gained
• Easy to exploit previous or alternate solutions
• Flexible building blocks for hybrid applications
• Substantial history and range of use
G. Genetic Algorithms: When to Use?
• Alternate solutions are too slow or overly complicated
• Need an exploratory tool to examine new approaches
• Problem is similar to one that has already been successfully solved by
using a GA
• Want to hybridize with an existing solution
• Benefits of the GA technology meet key problem requirements
H. Genetic Algorithms: Some Application
Types
Domain Application Types
Control gas pipeline, pole balancing, missile evasion, pursuit
(-(*A B) C)
atoms
terminal
depth = 2
M. Genetic Programming: 1. Individual (Grow
Method )
• Starting from root, nodes are taken at random from the primitive set
(function and terminal set) until the maximum depth is reached
• Beyond that depth, only terminals can be chosen (same as full
method)
• Grow method allows for the creation of trees of more varied sizes and
shapes
M. Genetic Programming: 1. Individual (Grow
Method ) - Example
• Full tree of depth 2, when depth is < 2, choose from primitive set, else
from terminal set
• function set = {+, -, *, /}
• terminal set = {x, y, 0, 1, 2}
depth = 2
M. Genetic Programming: 1. Individual
(Ramped Half-and-Half Method)
• Combines both full and grow methods
• Produces trees of various shapes and sizes (up to maximum depth,
md)
• Population is first evenly divided into equal parts (md -1)
• Then for each parts half the trees will be generated using full method
and the other half using the grow method
• Thus a population is created with good variation
M. Genetic Programming: 1. Individual (Ramped
Half-and-Half Method) - Example
• Population is 30, maximum depth is 6
• Divide population into 6-1 = 5 parts