0% found this document useful (0 votes)
7 views28 pages

Unit III - Genetic Algorithms and Emergent Systems

The document discusses genetic algorithms (GAs) and their inspiration from natural evolution, detailing the processes of selection, crossover, and mutation. It explains how GAs can be applied to optimization problems, such as the Traveling Salesman Problem, and highlights the concept of emergent systems in nature. Additionally, it touches on complex behaviors arising from simple interactions, exemplified by cellular automata and fractals.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views28 pages

Unit III - Genetic Algorithms and Emergent Systems

The document discusses genetic algorithms (GAs) and their inspiration from natural evolution, detailing the processes of selection, crossover, and mutation. It explains how GAs can be applied to optimization problems, such as the Traveling Salesman Problem, and highlights the concept of emergent systems in nature. Additionally, it touches on complex behaviors arising from simple interactions, exemplified by cellular automata and fractals.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 28

Unit III

1 Genetic Algorithms

1.1 Evolution in Nature

What is Life?

Why do we have different Life forms?

Is Evolution a design process?

Is Nature looking for a perfect design?

If yes, to what purpose?

1.2 What is Life?

• Creation: Life and How to Make it?


• Steve Grand profoundly observes that he has uncovered important law of nature:
“Things that persist, persist.”
“Things that don’t, don’t.”
Grand Clarifies that much of what we see persisting, like clouds on a hilltop, ripples in
a pond, or even in human bodies are in some way a persistent impression on a
constantly changing landscape.
Human Bodies are Made up of Atoms that are Entirely Different from When We are
Children.

1.3 Life Forms and Competition

• 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

• Species Evolve Continuously.

• A Species is Like the Design of a Life Form.

• Nature has Evolved a Process of Creative Adaptation.

• Sexual Reproduction Allows Inheritance of Genes From Two Parents

“It Takes Two Things to Invent Anything.

One Makes Up Combinations,

Other Chooses”

Genotypes and Phenotypes

• An organism’s genotype is the set of genes in its DNA responsible for a Particular trait.

• An organism’s phenotype is the physical expression of those genes.

• It is the physical entity that competes in the world.

An Ecosystem of Predators and Prey

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”

• A class of methods for optimization problems, more generally known as Evolutionary


Algorithms.

• Heuristic stochastic adaptive search algorithms

• Implemented on a population of candidates in the solution space.

• Inspired by the process of natural selection.

• A fitness function evaluates each candidate.

• The fittest candidates will be selected and produce.

• A genetic algorithm is a search heuristic that is inspired by Charles Darwin’s theory of


natural evolution. This algorithm reflects the process of natural selection where the
fittest individuals are selected for reproduction in order to produce offspring of the next
generation.

Notion of Natural Selection

• 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.

• Five Phases are considered in a Genetic Algorithms are:

• 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.

II. Fitness Function


• The fitness function determines how fit an individual is (the ability of an
individual to compete with other individuals). It gives a fitness score to each
individual.
• The probability that an individual will be selected for reproduction is based
on its fitness score.
III. Selection
• The idea of selection phase is to select the fittest individuals and let them
pass their genes to the next generation.
• Two pairs of individuals (parents) are selected based on their fitness scores.
Individuals with high fitness have more chance to be selected for
reproduction.

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.

Pseudocode / Algorithm Steps

• START

• Generate the initial population

• Compute fitness

• REPEAT

• Selection

• Crossover

• Mutation

• Compute fitness

• UNTIL population has converged

• STOP
Genetic Algorithm

Genetic Algorithm()

P ← Create N Candidate Solutions // Initial Population

Repeat

Compute Fitness Value for Each Member of P

S ← With Probability Proportional to Fitness Value

Randomly Select N Members from P

Offspring ← Partition S into Two Halves, Randomly Mate and Crossover


Members to Generate N Offsprings

With a Low Probability Mutate Some Offsprings

Replace k Weakest Members of P with Strongest Offsprings

Until Some Termination Criteria

Return the Best Member of P

2. SAT with 6 Clauses


F=
(𝒂 ∪ ¬𝒃 ∪ 𝒆) ∩ (¬𝒂 ∪ 𝒃 ∪ 𝒄) ∩ (¬𝒄 ∪ 𝒅 ∪ 𝒇) ∩ (𝒅 ∪ ¬𝒆 ∪ 𝒇) ∩ (¬𝒂 ∪ 𝒃 ∪ 𝒅) ∩ (𝒂 ∪ ¬𝒅 ∪ ¬𝒇)

Heuristic Function is the Number of Satisfied Clauses.

• 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

• Lets Perform Single Point Crossover

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

Iterated Hill Climbing Vs Genetic Algorithms Context

• 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 Chromosome for a Tiny Problem be a 5-Bit String

• Let the Fitness Function f(x) be a Square of the 5-Bit Binary Number

• Let the Population Contain 4 Candidates


• Let us Use the Single Point Crossover and Perform Upon the Algorithm

Initial Binary f(x) Prob Expected Actual Selection

01101 13 169 0.14 0.58 1 01101

11000 24 576 0.49 1.97 2 11000

01000 8 64 0.05 0.22 0 11000

10011 19 361 0.31 1.23 1 10011

Total 1170

Average 293

Selection

01101

11000

11000

10011

Selected Crossed-over Binary f(x) prob

01101 01100 12 144 0.08

11000 11001 25 625 0.36

11000 11011 27 729 0.42

10011 10000 16 256 0.16

Total 1754

Avg 493
Crossed-
Binary f(x) Prob Expected Actual Selection
Over

01100 12 144 0.08 0.33 0 11001

11001 25 625 0.36 1.42 2 11001

11011 27 729 0.42 1.66 2 11011

10000 16 256 0.16 0.58 0 11011

Total 1154

Average 493

Genetic Algorithms – Practicality

• Candidates are Encoded as Chromosomes.

• Genes are like Components in the Candidates.

• Genetic Algorithms Work By Inheriting Components From Two Parents.

3. GA - Travelling Salesman Problem


• Genetic Algorithms Can Be Used For The Travelling Salesman Problem (TSP) as
Follows:

• Create a Population of Candidate TSP Solutions. Let The Fitness Function Be The Cost
of The Tour. It Is A Minimization Problem.

• In The Path Representation, Tour is Represented by a Permutation of the Cities, With


The Assumption That One Returns From The Last City in The Permutation to The First.

• Selection: Clone Each Tour in Proportion to Fitness. Cheapest Tours are the Fittest.

• Crossover: Randomly Pair the Resulting Population and Perform Crossover.

• Mutation: Randomly Permute a Tour Once in a While.


Single Point Crossover

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.

Travelling Salesman Problem is NP-Hard.

A Collection of Problems from Various Sources and Problems with Known Optimal Solutions is
Available at TSPLIB.

Nearest Neighbour Heuristic


Start at Some City
Move to Nearest Neighbour
As Long as It Does Not Close the Loop Prematurely

An Example Where this Approach Will Not Work

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

The Savings Heuristic Starts With

(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

Greedy Tour Nearest Neighbour Tour Savings Tour


Optimal Tour
Solution Space: Perturbation Operators

In the Two-City Exchange the Two Shaded Cities.

Cities Exchange Their Position in the Path/Order Representation.

The New Tour Has the Dashed Edges Instead of Four Broken Ones in the Linear Order.

Two Edge Exchange

In the Two-Edge Exchange the Tour is Altered. The Two Edges Can Be Selected in nC2 Ways

Three Edge Exchange

In the Three-Edge Exchange, Three Edges are removed and Replaced by Other Edges.

This Can Be Done Four Ways.


The Three Edges Can Be Selected in nC3 Ways

4. Emergent Systems – Complex Behaviour from Simple Elements

• 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.

• The Brain is Made Up of Billions of Comparatively Simple Neurons.

• A Flock of Birds Moves in Synchrony.

• Elaborate Termite Mounds.

• Stock Market Behaviour.

• Formation of Sand Dunes.

• Hurricanes and Cyclones.

Conway’s Game Of Life


• 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.

Number of Alive
Cell State New Cell State Explanation
Neighbours

Alive >2 Dead Lonely

Alive 2 or 3 Alive Stable

Alive >3 Dead Overcrowded

Dead 3 Alive Resurrection

• From These Simple Rules – Many Stable and Persistent Emerge.

• 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.

• Fractal Patterns are Extremely Familiar, Since Nature is Full of Fractals.

• For Instance: Trees, Rivers, Coastlines, Mountains, Clouds, Seashells, Hurricanes etc.
Sierpinski Triangle

• The Sierpinski Triangle is a Fractal Described in 1915 by Waclaw Sierpinski. It is a Self


Similar Structure that Occurs at Different Levels of Iterations or Magnifications.
Human Brain - The Most Complex Object in the Known Universe
• The Brain is the Most Complex Organ in the Human Body. It Produces Our Every
Thought, Action, Memory, Feeling and Experience of the World.

• This Jelly-like Mass of Tissue, Weighing in at Around 1.4 Kilograms, Contains a


Staggering One Hundred Billion Nerve Cells, or Neurons.

• 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 Shaded Portion of the Soma is the Nucleus of the Cell.


5. Neural Network – A Computational Neuron

• The Neuron is a Simple Device That Computes Some Function of All the Inputs it
Receives from the Other Neurons.

Artificial Neural Network (ANN)

• 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.

• A Feedforward Artificial Neural Network Encapsulates a Function where the Output is a


Function of the Input.
Input Layer Hidden Layer Output Layer

Karl Sims – Evolved Creatures

• Two Simple Recursive Genotypes and Their Corresponding Phenotypes.

• The Genotype is a Directed Graph, and the Phenotype a Hierarchy 3D Parts.

You might also like