Unit III - Genetic Algorithms and Emergent Systems
Unit III - Genetic Algorithms and Emergent Systems
1 Genetic Algorithms
What is Life?
• Procreation Makes Similar Copies Passing on the Design of Bodies Defining Species.
• Individuals in a Species Consume Resources Food for Matter and Energy
• Resources are Limited and that is Creating Competition.
• Species Compete for the Same Resources. For Example, Lion Chase for Prey
While There is Competition Between the Species There is Competition within Too.
• The Fastest, or the Wiliest, Foxes Get the Rabbits. Similarly, the Fastest or the
Cleverest Rabbits Escape i.e, Survival of the Fittest!!!
1.4 Evolution – Combination and Selection
Other Chooses”
• An organism’s genotype is the set of genes in its DNA responsible for a Particular trait.
A Small Fragment of the Vast Ecosystem. The Natural World Contains Millions of Species
Interacting with Each Other. Arrows Depict a Positive Influence of the Population of One
Species on Another.
1.5 Genetic Algorithms(GAs)
• Devised by John Holland (1975), popularized by his student David Goldberg via his
book “Genetic Algorithms”
• The process of natural selection starts with the selection of fittest individuals from a
population.
• They produce offspring which inherit the characteristics of the parents and will be
added to the next generation.
• If parents have better fitness, their offspring will be better than parents and have a
better chance at surviving.
• This process keeps on iterating and at the end, a generation with the fittest individuals
will be found.
• This notion can be applied for a search problem. We consider a set of solutions for a
problem and select the set of best ones out of them.
• Initial population
• Fitness function
• Selection
• Crossover
• Mutation
I. Initial Population
• The process begins with a set of individuals which is called a Population. Each
individual is a solution to the problem you want to solve.
• An individual is characterized by a set of parameters (variables) known as Genes. Genes
are joined into a string to form a Chromosome (solution).
• In a genetic algorithm, the set of genes of an individual is represented using a string, in
terms of an alphabet. Usually, binary values are used (string of 1s and 0s). We say that
we encode the genes in a chromosome.
IV. Crossover
Crossover is the most significant phase in a genetic algorithm. For each pair of
parents to be mated, a crossover point is chosen at random from within the genes.
For example, consider the crossover point to be 3 as shown below:
• Offspring are created by exchanging the genes of parents among themselves until the
crossover point is reached.
V. Mutation
• In certain new offspring formed, some of their genes can be subjected to a mutation
with a low random probability. This implies that some of the bits in the bit string can be
flipped.
• Mutation occurs to maintain diversity within the population and prevent premature
convergence.
• START
• Compute fitness
• REPEAT
• Selection
• Crossover
• Mutation
• Compute fitness
• STOP
Genetic Algorithm
Genetic Algorithm()
Repeat
• Assume that
• P1 = 0 1 0 1 1 0 0+1+1+1+1+0=4
• P2 = 1 1 1 0 1 0 1+1+0+0+1+1=4
C1 = 1 1 1 1 1 0 1+1+1+1+1+1=6
C2 = 0 1 0 0 1 0 0+1+1+0+1+1=4
Probability of 3SAT Being Satisfiable
• A Random Starting Point from Any of the Shaded Nodes Would Lead To the Global
Maximum.
• The Initial Population May be Randomly Distributed, But as Genetic Algorithm is Run
By Population has More Members Around the Peaks.
• The Initial Population May be Randomly Distributed, But as Genetic Algorithm is Run
By Population has More Members Around the Peaks.
Example
• Let the Fitness Function f(x) be a Square of the 5-Bit Binary Number
Total 1170
Average 293
Selection
01101
11000
11000
10011
Total 1754
Avg 493
Crossed-
Binary f(x) Prob Expected Actual Selection
Over
Total 1154
Average 493
• Create a Population of Candidate TSP Solutions. Let The Fitness Function Be The Cost
of The Tour. It Is A Minimization Problem.
• Selection: Clone Each Tour in Proportion to Fitness. Cheapest Tours are the Fittest.
Cycle Crossover
Partially Mapped Crossover (PMX)
Order Crossover
Adjacency Representation
Ordinal Representation
Given a Set of Cities and Given a Distance Measure Between Every Pair of Cities, the Task is to
Find a Hamiltonian Cycle Having Least Cost.
When the Underlying Graph is Not Completely Connected We Can Add the Missing Edges With
Very High Cost.
A Collection of Problems from Various Sources and Problems with Known Optimal Solutions is
Available at TSPLIB.
Variations:
Extend the Partial Tour at Either End
Greedy Heuristic
Sort The Edges
Add Shortest Available Edge To The Tour
As Long as It Does Not Close the Loop Prematurely
Travelling Salesman Problem(TSP) : Heuristic Way
(n-1) Tours of Length 2 Anchored on a Base Vertex and Performs (n-2) Merge Operations
to Construct the Tour
• Remove Two Edges Connected the Base Vertex From Two Loops and Add an Edge to
Connect the Two Hanging Vertices
• The Two Edges are Chosen Such that There is Maximal Savings of (Total) Cost in the
Resulting Graph
The New Tour Has the Dashed Edges Instead of Four Broken Ones in the Linear Order.
In the Two-Edge Exchange the Tour is Altered. The Two Edges Can Be Selected in nC2 Ways
In the Three-Edge Exchange, Three Edges are removed and Replaced by Other Edges.
• Emergent Systems:
Collections of Simple Entities Organize Themselves and A Larger More Sophisticated Entity
Emerges. The Behaviour of This Complex System is a Property That Emerges from Interactions
Amongst Its Components.
• An Ant Colony is Like a Living Organism That Can Find Food Very Quickly.
Number of Alive
Cell State New Cell State Explanation
Neighbours
• The Game of Life is a Cellular Automation in Which Cells are Alive or Dead. Each Cell
Obeys the Following Rules to Decide Its Fate in the Next Time Step.
Chaos and Fractals
• A Fractal is a Never-Ending Pattern. Fractals are infinitely Complex Patterns That Are
Self-Similar Across Different Scales.
• They are Created by Repeating a Simple Process Over and Over in An Ongoing Feedback
Loop. Driven by Recursion, Fractals are Images of Dynamic Systems – The Picture of
Chaos.
• For Instance: Trees, Rivers, Coastlines, Mountains, Clouds, Seashells, Hurricanes etc.
Sierpinski Triangle
• The Complexity of the Connectivity Between these Cells is Mind-Boggling. Each Neuron
Can Make Contact with Thousands or Even Tens of Thousands of Others.
• Our Brains Form a Million New Connections of Every Second of Our Lives. The Pattern
and Strength of the Connections is Constantly Changing and No Two Brains are Alike.
A Biological Neuron – Best Complex Network
• A Biological Neuron From the Brain Receives Several Inputs via Its Dendrites and Sends
a Signal Down Its Axon.
• The Axon Branches Out as Well and Connects to Dendrites of Other Neurons via
Synapses, which Transmit the Signal Chemically to the Other Neurons.
• The Neuron is a Simple Device That Computes Some Function of All the Inputs it
Receives from the Other Neurons.
• The ANN Learns the Function Through a Process of Training, in which a Large
Number of Labelled Patterns are Shown as Input, the ANN Generates an Output, and
the BackProp Algorithm Propagates the Error Back to Tune The Weights of The
Connections.