0% found this document useful (0 votes)
13 views57 pages

Class 20 21 Unlocked

Genetic algorithms (GAs), proposed by Holland in 1975, are search techniques inspired by biological evolution that aim to optimize solutions through processes like selection, crossover, and mutation. They operate by generating a population of potential solutions, evaluating their fitness, and iteratively improving them over generations. GAs are applicable in various domains, including control systems, design, game playing, and robotics, and are known for their ability to find satisfactory solutions over time.
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)
13 views57 pages

Class 20 21 Unlocked

Genetic algorithms (GAs), proposed by Holland in 1975, are search techniques inspired by biological evolution that aim to optimize solutions through processes like selection, crossover, and mutation. They operate by generating a population of potential solutions, evaluating their fitness, and iteratively improving them over generations. GAs are applicable in various domains, including control systems, design, game playing, and robotics, and are known for their ability to find satisfactory solutions over time.
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/ 57

GENETIC ALGORITHM

•GA’s first proposed by Holland [1975].


•Part of evolutionary computing, which
is a rapidly growing area of artificial
intelligence.
•Based on analogies with the processes
of Biological Evolution.
•GA seeks to improve the fitness of the
population generation after generation .
What is GA
• A genetic algorithm (or GA) is a search technique
used in computing to find true or approximate
solutions to optimization and search problems.
• (GA)s are categorized as global search heuristics.
• (GA)s are a particular class of evolutionary
algorithms that use techniques inspired by
evolutionary biology such as inheritance,
mutation, selection, and crossover (also called
recombination).
Biological Background
“Natural selection”
• The origin of species: “Preservation of favourable variations and rejection of
unfavourable variations.”
• There are more individuals born than can survive, so there is a continuous struggle
for life.
• Individuals with an advantage have a greater chance for survive: so survival of the
fittest.
•Mathematical expresses as fitness: success in life

Natural Selection Charles Darwin (1809-1882)


Controversial and very influential book (1859)
Goldberg (1996) “....the metaphor underlying genetic algorithm is that of natural
evolution. In evolution, the problem each species faces is one of searching for
beneficial adaptations to a complicated and changing environment. The “knowledge”
that each species has gained is embodied in the makeup of the chromosomes of its
members.”
Biological Background
“The cell”
• Genetic information is stored in the chromosomes
• Each chromosome is build of DNA
• Chromosomes in humans form pairs.
• There are 23 pairs.
• The chromosome is divided in parts: genes
• Genes code for properties
• Every gene has an unique
position on the chromosome:
locus
Research on genetic
algorithms:

• If very little background knowledge is available and the problem environment provides
a natural measure for the quality of outcomes, it is appropriate to view the problem of
learning as a search for high-performance structures ... [Grefenstette]

• Genetic algorithms search by allocating effort to regions of the search space based on an
estimate of the relative performance of competing regions. [In complex domains] one
expects perpetual novelty to be a characteristic feature ... In these cases, traditional
search techniques ... are likely to be misled [and] genetic algorithms may be the search
technique of choice for machine learning systems ... [Fitzpatrick and Grefenstette]
GA Terminology
Outline of the Basic Genetic Algorithm
• [Start] Generate random population of n chromosomes (suitable solutions for the
problem)
• [Fitness] Evaluate the fitness f(x) of each chromosome x in the population
• [New population] Create a new population by repeating following steps until the
new population is complete
– [Selection] Select two parent chromosomes from a population according to
their fitness (the better fitness, the bigger chance to be selected)
– [Crossover] With a crossover probability cross over the parents to form a new
offspring (children). If no crossover was performed, offspring is an exact copy
of parents.
– [Mutation] With a mutation probability mutate new offspring at each locus
(position in chromosome).
– [Accepting] Place new offspring in a new population
• [Replace] Use new generated population for a further run of algorithm
• [Test] If the end condition is satisfied, stop, and return the best solution in current
population
• [Loop] Go to step 2
Basic Genetic Algorithm
• Start with a large “population” of randomly generated
“attempted solutions” to a problem
• Repeatedly do the following:
– Evaluate each of the attempted solutions
– Keep a subset of these solutions (the “best” ones)
– Use these solutions to generate a new population
• Quit when you have a satisfactory solution (or you
run out of time)
GA Operators

• Methods of representation.
• Methods of selection.
• Methods of Reproduction.
GA Operators

• Methods of representation.
• Methods of selection.
• Methods of Reproduction.
Coding
• Encode solutions as binary strings: sequences of 1's
and 0's, where the digit at each position represents the
value of some aspect of the solution.
(A)

(B)

(C)

Sen and Stoffa, (1991)


Outline of the Basic Genetic Algorithm
• [Start] Generate random population of n chromosomes (suitable solutions for the
problem)
• [Fitness] Evaluate the fitness f(x) of each chromosome x in the population
• [New population] Create a new population by repeating following steps until the
new population is complete
– [Selection] Select two parent chromosomes from a population according to
their fitness (the better fitness, the bigger chance to be selected)
– [Crossover] With a crossover probability cross over the parents to form a new
offspring (children). If no crossover was performed, offspring is an exact copy
of parents.
– [Mutation] With a mutation probability mutate new offspring at each locus
(position in chromosome).
– [Accepting] Place new offspring in a new population
• [Replace] Use new generated population for a further run of algorithm
• [Test] If the end condition is satisfied, stop, and return the best solution in current
population
• [Loop] Go to step 2
Methods of Selection
• Selection is the process of selecting two or more parents
from the population for crossing.

• This selection pressure drives the GA to improve the


population fitness over the successive generations.

“the best ones survive to create new offspring”

• There are many different techniques which a genetic


algorithm can use to select the individuals to be copied
over into the next generation.
Methods of Selection
There exist at least three methods of selection:

• Roulette-wheel selection: the fitter is the


solution with the most chances to be chosen

HOW IT WORKS ?
Roulette wheel selection (Fitness-Proportionate
selection)
• Conceptually, this can be represented as a game of roulette -
each individual gets a slice of the wheel, but more fit ones get
larger slices than less fit ones.

Plotting of fitness function


2.Rank Selection
Each individual in the population is assigned a numerical rank based on fitness, and selection is
based on this ranking. Situation before ranking (graph of fitnesses)

Situation after ranking (graph of order numbers)


SLOWER
CONVERG
ENCE
The rank of the model may range from 0 (for the best model) to n-1 (for the worst model)

The selection is done such a way that the best model in the population contributes a number
of copies that is an integral (the number is predetermined) number of copies that the worst
model receives.
3.Tournament Selection
• Random pairs are selected from a population of,
say n, individuals and their fitness values are
computed.
• The fitness is compared and one of the two
models is accepted based on a probability “Ps”,
called the tournament selection number which is
an adjustable parameter.

• Process is repeated until there are n models in the


offspring population.
Elitism
• It is a method where first copies the
best chromosome (or a few best) to
new population.

• It prevents losing the best found


solution and therefore increases the
performance of GA. [see the
example]
Outline of the Basic Genetic Algorithm
• [Start] Generate random population of n chromosomes (suitable solutions for the
problem)
• [Fitness] Evaluate the fitness f(x) of each chromosome x in the population
• [New population] Create a new population by repeating following steps until the
new population is complete
– [Selection] Select two parent chromosomes from a population according to
their fitness (the better fitness, the bigger chance to be selected)
– [Crossover] With a crossover probability cross over the parents to form a new
offspring (children). If no crossover was performed, offspring is an exact copy
of parents.
– [Mutation] With a mutation probability mutate new offspring at each locus
(position in chromosome).
– [Accepting] Place new offspring in a new population
• [Replace] Use new generated population for a further run of algorithm
• [Test] If the end condition is satisfied, stop, and return the best solution in current
population
• [Loop] Go to step 2
Cross-over
It depends upon the encoding scheme used for the problem.
Single point crossover - one crossover point is selected, binary string from beginning
of chromosome to the crossover point is copied from one parent, the rest is copied from
the second parent

11001011+11011111 = 11001111
Two point crossover - two crossover point are selected, binary string from beginning of
chromosome to the first crossover point is copied from one parent, the part from the first to the
second crossover point is copied from the second parent and the rest is copied from the first
parent

11001011 + 11011111 = 11011111


Cross-over
Uniform crossover - bits are randomly copied from the first or from the second parent

11001011 + 11011101 = 11011111

Mutation
The last genetic operator is mutation. It is the random alteration of a bit. It can
be carried out during the crossover process.[see the example in next slide]

It is used to maintain genetic diversity from one generation of a population of


chromosomes to the next.
Mutation
• It helps to prevent the search falling into a local
optimum of the state space.

• It helps to prevent the population from stagnating at


any local optima.

11001001 => 10001001

In the above diagram the selected bits are inverted


Mutation contd….
Basic Genetic Algorithm
• Start with a large “population” of randomly generated
“attempted solutions” to a problem
• Repeatedly do the following:
– Evaluate each of the attempted solutions
– Keep a subset of these solutions (the “best” ones)
– Use these solutions to generate a new population
• Quit when you have a satisfactory solution (or you
run out of time)
Figure: Convergence for the
minimization of a function using both
GA and Monte Carlo algorithm
Benefits of Genetic Algorithms
• Concept is easy to understand
• Modular, separate from application
• Supports multi-objective optimization
• Always an answer; answer gets better with time.
• Easy to exploit previous or alternate solutions
• Flexible building blocks for hybrid applications.
GA Applications
Domain Application Type

Control Gas pipeline, missile evasion

Design Aircraft design, keyboard configuration, communication networks

Game playing Poker, checkers

Security Encryption and Decryption

Robotics Trajectory planning


Neural Network
• Artificial intelligence (AI) is a bigger concept to create intelligent machines
that can simulate human thinking capability and behavior, whereas,
machine learning is an application or subset of AI that allows machines to
learn from data without being programmed explicitly.

• AI is a technology using which we can create intelligent systems that can


simulate human intelligence.

• Machine learning is a subfield of artificial intelligence, which enables


machines to learn from past data or experiences without being explicitly
programmed.

• Machine learning enables a computer system to make predictions or take


some decisions using historical data without being explicitly programmed.
Machine learning uses a massive amount of structured and semi-structured
data so that a machine learning model can generate accurate result or give
predictions based on that data.
Biological Neural Nets
• Pigeons as art experts (Watanabe et al. 1995)

– Experiment:
• Pigeon in Skinner box
• Present paintings of two different artists (e.g. Chagall /
Van Gogh)
• Pigeons were able to discriminate between two
pictures with 95% accuracy (when presented with
pictures they had been trained on)

• Discrimination still 85% successful for previously


unseen paintings of the artists

• Pigeons do not simply memorise the pictures


• They can extract and recognise patterns (the ‘style’)
• They generalise from the already seen to make
predictions

• This is what neural networks (biological and


artificial) are good at (unlike conventional computer)
Neural Networks
Neural Networks
• We are born with about 100 billion neurons.

• A neuron may connect to as many as 100,000


other neurons.
Neural Networks
• Signals “move” via electrochemical signals.

• The synapses release a chemical transmitter –


the sum of which can cause a threshold to be
reached – causing the neuron to “fire”

• Synapses can be inhibitory or excitatory.


The First Neural Neural Networks

McCulloch and Pitts produced the first neural


network in 1943.

Many of the principles can still be seen in


neural networks of today.
Neural Network
An artificial neural network (ANN), usually called "neural network"
(NN), is a mathematical model or computational model that tries to
simulate the structure and/or functional aspects of biological neural
networks.

It consists of an interconnected group of artificial neurons and processes


information using a connectionist approach to computation.

In most cases an ANN is an adaptive system that changes its structure


based on external or internal information that flows through the network
during the learning phase.

Neural networks are non-linear statistical data modeling tools. They can
be used to model complex relationships between inputs and outputs or to
find patterns in data.
What are Neural Networks?
• Models of the brain and nervous system
• Highly parallel
– Process information much more like the brain than a
serial computer
• Learning

• Very simple principles


• Very complex behaviours

• Applications
– As powerful problem solvers
– As biological models
• Neurone vs. Node
Node
• The sigmoid function, also called the
sigmoidal curve (von Seggern 2007, p. 148) or
logistic function, is the function

1
y= −x
1+ e
Artificial Neuron

w1j
x1

w2j n
x2 s j = ∑ wij xi y j = f (s j )
i =0
yj

1
−s
wnj 1+ e j

xn

bj
Artificial Neuron

w1j
x1

w2j n
x2 s j = ∑ wij xi y j = f (s j )
i =0
yj

1
−s
wnj 1+ e j

xn

bj
ANNs – The basics
An artificial network consists of a pool of simple processing units which
communicate by sending signals to each other over a large number of weighted
connections.

• ANNs incorporate the two fundamental components of


biological neural nets:

1. Neurones (nodes)
2. Synapses (weights)
In traditional feed-forward neural networks, a hidden
layer neuron is a neuron whose output is connected to
the inputs of other neurons and is therefore not visible
as a network output (hence the term hidden layer).
• Feeding data through the net:

(1 × 0.25) + (0.5 × (-1.5)) = 0.25 + (-0.75) = - 0.5

Squashing:
1
= 0.3775
1+ e 0.5
ANNs – The basics

Basically, the first hidden layer detects pixels


of light and dark, they are not very useful for
face recognition, but they are extremely useful
to identify edges and simple shapes on the
second hidden layer.

The third hidden layer knows how to comprise


more complex objects from edges and simple
shapes.

Finally, at the end, the output layer will be able


to recognize a human face with some
confidence.
Neural Networks

Each unit performs a relatively simple job: receive


input from neighbors or external sources and use this
to compute an output signal which is propagated to
other units (Test stage).
Apart from this processing, there is the task of the
adjustment of the weights (Learning stage).
The system is inherently parallel in the sense that
many units can carry out their computations at the
same time.
Neural Networks

1. Learning stage

Your knowledge
is useless !!

2. Test stage
(working stage)
Neural Networks
The two most important steps in applying neural networks to recognition problems are the
selection and learning stages, since these directly influence the overall performance and thus
the results obtained.

Three reasons can cause a bad performance (Romeo, 1994): an inadequate network
configuration, the training algorithm being trapped in a local minimum, or an unsuitable
learning set.

Finally, problems can occur with the selected training set.


Your knowledge
The two most frequent problems are overtraining and a bad, i.e., unrepresentative, learning set.
is useless !!
In the latter case, either too many bad patterns are selected (i.e., patterns attributed to the wrong
class) or the training set does not allow for a good generalization. For instance, the sample
space may be incomplete, i.e., samples needed for an adequate training of the network are
simply missing. Overtraining of the learning set may also pose a problem. Overtraining means
the selected training set is memorized such that performance is only excellent on this set but not
on other data. To circumvent this problem, the selected set of examples is often split into a
training and a validation set.

Weights are optimized using the training set. However, cross validation with the second set
ensures an overall good performance.
Classification (Learning)

We can categorize the learning situations in three


distinct sorts. These are:
Classification (Learning)

• Supervised learning in which the network is trained


by providing it with input and matching output
patterns. These input-output pairs are usually
provided by an external teacher.
Classification (Learning)

• Unsupervised learning in which an (output) unit is trained to


respond to clusters of pattern within the input. In this paradigm
the system is supposed to discover statistically salient features
of the input population. Unlike the supervised learning
paradigm, there is no a priori set of categories into which the
patterns are to be classified; rather the system must develop its
own representation of the input stimuli.
The data have no target attribute.

We want to explore the data to find some intrinsic structures in them.

Unsupervised learning is used to find patterns or hidden structures in


datasets that have not been categorized or labeled
Reinforcement Learning
Reinforcement learning is learning what to do—how to map
situations to actions—so as to maximize a numerical reward
signal. The learner is not told which actions to take, but instead
must discover which actions yield the most reward by trying them.

RL works with data from a dynamic environment. And the goal is not to cluster data
or label data, but to find the best sequence of actions that will generate
the optimal outcome.

The way reinforcement learning solves this problem is by allowing a piece of software
called an agent to explore, interact with, and learn from the environment.

Some real-life applications are-

• Game Playing
• Robot Navigation
Reinforcement Learning
One of the challenges that arise in reinforcement learning, and not in other kinds of
learning, is the trade-of between exploration and exploitation. To obtain a lot of
reward, a reinforcement learning agent must prefer actions that it has tried in the past
and found to be effective in producing reward. But to discover such actions, it has to
try actions that it has not selected before. The agent has to exploit what it already
knows in order to obtain reward, but it also has to explore in order to make better
action selections in the future. The dilemma is that neither exploration nor exploitation
can be pursued exclusively without failing at the task. The agent must try a variety of
actions and progressively favor those that appear to be best.

Some real-life applications are-

• Game Playing
• Robot Navigation

You might also like