genetic algorithms n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
GENETIC ALGORITHMS PowerPoint Presentation
Download Presentation
GENETIC ALGORITHMS

Loading in 2 Seconds...

play fullscreen
1 / 50

GENETIC ALGORITHMS - PowerPoint PPT Presentation


  • 184 Views
  • Uploaded on

GENETIC ALGORITHMS. By Prafulla S. Kota Raghavan Vangipuram. Introduction. Genetic Algorithms are a form of local search that use methods based on evolution to make small changes to a population of chromosomes in an attempt to identify an optimal solution. We discuss:

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'GENETIC ALGORITHMS' - lorand


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
genetic algorithms

GENETIC ALGORITHMS

By

Prafulla S. Kota

RaghavanVangipuram

introduction
Introduction
  • Genetic Algorithms are a form of local search that use methods based on evolution to make small changes to a population of chromosomes in an attempt to identify an optimal solution.

We discuss:

    • Representations used for genetic algorithm.
    • Idea of schemata.
    • Genetic operators, crossover and mutations.
    • Procedures used to run Genetic algorithms.
representations
Representations
  • Genetic programming can be used to evolve S-expressions, which can be used as LISP programs to solve problems.
  • A string of bits is known as a chromosome.
  • Each bit is known as a gene.
  • Chromosomes can be combined together to form creatures.
  • We will see how genetic algorithms can be used to solve mathematical problems.
the algorithm
The Algorithm
  • Generate a random population of chromosomes.
  • If the termination criteria are satisfied, stop. Else, continue with step 3.
  • Determine the fitness of each chromosome.
  • Apply crossover and mutation to selected chromosomes from the current generation, to generate a new population of chromosomes – the next generation.
  • Return to step 2.
slide5

The size of the population should be determined in advance.

  • The size of each chromosome must remain the same for crossover to be applied.
  • Fittest chromosomes are selected in each generation to produce offspring which replace the previous generation.
  • Each pair of parents produces two offspring.
fitness
Fitness

When we use traditional genetic algorithm, a metric is needed whereby the fitness of a chromosome can be objectively determined.

When we consider real creatures, fitness measure is based on the extent to which the physical form (phenotype) represented by the genetic information (genotype) met certain criteria.

crossover
Crossover
  • The crossover operator is applied to two chromosomes of the same length as follows:
    • Select a random crossover point.
    • Break each chromosome into two parts, splitting at the crossover point.
    • Recombine the broken chromosomes by combining the front of one with the back of the other, and vice versa, to produce two new chromosomes.
slide8

For example, consider the following two chromosomes:

110100110001001

010101000111101

  • A crossover point might be chosen between the sixth and seventh genes.

110100 | 110001001

010101 | 000111101

slide9

Now the chromosome parts are recombined as follows:

110100 | 000111101 => 110100000111101

010101 | 110001001 => 010101110001001

  • Single point crossover is the most commonly used form, but it is also possible to apply crossover with two or more crossover positions.
slide10

100110001

10

1100

001

011100110

01

0110

110

In two point crossover, two points are chosen that divide the chromosomes into two sections, with the outer sections considered to be joined together to turn the chromosome into a ring. The two sections are swapped with each other.

slide11

100110001

1

1

0

10

0

1

01

011100110

0

0

1

11

0

0

10

Uniform Crossover:

  • Here, a probability, p, is used to determine whether a given bit from parent 1 will be used, or from parent 2.
  • In other words, a child can receive any random bits from each of its parents.

Parent 1: 100011001

Parent 2: 001101110

mutation
Mutation
  • Similar to Hill-Climbing, which involves generating a possible solution to the problem and moving toward a better solution than the current one until a solution is found from which no better solution can be found.
  • Mutation is a unary operator (it is applied to just one argument – a single gene) that is usually applied with a low probability.
slide13

Mutation simply involves reversing the value of a bit in a chromosome.

  • For example, with a mutation rate of 0.01, it might be expected that one gene in a chromosome of 100 genes might be reversed.

010101110001001

010101110101001

termination criteria
Termination Criteria
  • There are typically two ways in which a run of a genetic algorithm is terminated.
  • Usually, a limit is put on the number of generations, after which the run is considered to have finished.
  • The run can stop when a particular solution has been reached, or when the highest fitness level in the population has reached a particular value.
  • In some cases, genetic algorithms are used to generate interesting pictures.
  • In these cases, human judgment must be used to determine when to terminate.
optimization of a mathematic function
Optimization of a Mathematic Function

Use of Genetic Algorithm to maximize value of a mathematic function.

Maximize the function:

f(x)=sin(x)

over the range of ‘x’ from 1 to 15.

‘x’ is in radians.

Each chromosome represents a possible value of ‘x’ using four bits.

slide17

We will use a population size of four chromosomes.

    • The first step is to generate a random population, which is our first generation:

c1=1001

c2=0011

c3=1010

c4=0101

    • To calculate the fitness of a chromosome, we need to first convert it to a decimal integer and then calculate f(x) for this integer.
slide18

We will assign a fitness numeric value from 0 to 100, where 0 is the least fit and 100 is the most fit.

  • f(x) generates real numbers between -1 and 1.
  • We will assign a fitness of 100 to f(x)=1 and fitness of 0 to f(x)= -1.
  • Fitness of 50 will be assigned to f(x)=0.

f’(x)= 50[f(x)+1]

= 50[Sin(x)+1]

slide19

The fitness ratio of a chromosome is that chromosome’s fitness as a percentage of the total fitness of the population.

Fitness values of First generation

slide20

Now we need to run a single step of our genetic algorithm to produce the next generation.

    • First step is to select which chromosomes will reproduce.

Roulette-wheel selection involves using the fitness ratio to randomly select chromosomes to reproduce.

roulette wheel selection
Roulette - wheel selection
  • The range of real numbers from 0 to 100 is divided up between the chromosomes proportionally to each chromosome’s fitness.
  • A random number is now generated between 0 to 100. This number will fall in the range of one of the chromosomes, and this chromosome has been selected for reproduction.
  • The next random number is used to select the chromosome’s mate.
  • Hence, fitter chromosomes will tend to produce more offspring than less fit chromosomes.
slide22

It is important that this method does not stop less fit chromosomes from reproducing at all.

  • We will now need to generate four random numbers to find the four parents that will produce the next generation.
  • We first choose 56.7, which falls in the range of c2. So, c2 is parent 1.
  • Next, 38.2 is chosen, so its mate is c1 (parent 2).
slide23

We now combine c1 and c2 to produce new offspring.

  • Select a random crossover point.

10 | 01

00 | 11

  • Crossover is applied to produce two offspring, c5 and c6:

c5=1011

c6=0001

slide24

Similarly, we calculate c7 and c8 from parents c1 and c3:

c7=1000

c8=1011

  • Observe that c4 did not get a chance to reproduce. So its genes will be lost.
  • c1 was the fittest of all chromosomes. So, it could reproduce twice, thus passing on its highly fit genes to all members of the next generation.
why genetic algorithms work
Why Genetic Algorithms Work
  • It is possible to explain genetic algorithms by comparison with natural evolution: small changes that occur on a selective basis combined with reproduction will tend to improve the fitness of the population over time.
  • John Holland invented schemata to provide an explanation for genetic algorithms that is more rigorous.
schemata
Schemata
  • Strings of numbers are used to represent input patterns in classifier systems. In these patterns, * is used to represent “any value” or “don’t care”, so that the following string:

1011*001*0

matches the following strings:

1011000100

1011000110

1011100100

1011100110

slide28

A schema is a string of bits that represents a possible chromosome, using * to represent “any value.”

  • A schema is said to match a chromosome if the bit string that represents the chromosome matches the schema in the way shown above.

*11*

This matches the following four chromosomes

0110 0111 1110 1111

slide29

A schema with n *’s will match a total of 2^n chromosomes.

Each chromosome of r bits will match 2^r different schemata.

The Defining length of a schema is defined as the distance between the first and last defined bits in the schema.

slide30

**10111*

1*0*1**

11111

1***1

*****10**1*****

The defining length for all the above schemata is 4.

dL(S)<=L(S)

slide31

Order of the schema is defined a the number of defined bits in the schema.

**10*11*

1*0*1**1

1111

1***1***1***1

1*****10***1*****

The order of all the above schemata is 4.

  • We denote the order of schema as O(S).
  • Order of the schema tells us how specific it is.
how reproduction affects schemata
How Reproduction affects Schemata
  • Consider the following population of 10 chromosomes, each of length 32.

C1=01000100101010010001010100101010

C2=10100010100100001001010111010101

C3=01010101011110101010100101010101

C4=11010101010101001101111010100101

C5=11010010101010010010100100001010

C6=00101001010100101010010101111010

C7=00101010100101010010101001010011

C8=11111010010101010100101001010101

C9=01010101010111101010001010101011

C10=11010100100101010011110010100001

slide33

Let us consider the following schema:

s0=11010*********************

This schema is matched by three chromosomes in our population: c4,c5,c10.

We say that schema s0 matches three chromosomes in generation ‘i’ and write this as follows:

m(s0,i) = 3

slide34

The fitness of a schema, S, in generation ‘i’ is written as follows:

f(S,i)

  • The fitness of a schema is defined as the average fitness of the chromosomes in the population that match the schema.
  • Hence if we define the fitness of c4, c5, and c10 as follows:

f(c4,i)=10

f(c5,i)=22

f(c10,i)=40

slide35

Hence, the fitness of the schema s0 is defined as the average of these three values:

f(s0,i)=(10+22+40)/3

= 24

  • We will now consider factors which affect the likelihood of a particular schema surviving from one generation to the next.
slide36

Let us assume that there is a chromosome that matches a schema, S, in the population at time i.

  • The number of occurrences of S in the population at time i is:

m(S,i)

  • Number of occurrences of S in the population in the subsequent generation is:

m(S,i+1)

slide37

The fitness of S in generation i is

f(S,i)

  • We will calculate the probability that a given chromosome, c, which matches the schema S at time i, will reproduce and thus its genes will be present in the population at time i+1.
  • The probability that a chromosome will reproduce is proportional to its fitness, so the expected number of offspring of chromosome c is:

m(c,i+1)=f(c,i)/a(i)

Where a(i) is the average fitness of the chromosomes in the population at time i.

slide38

Because chromosome c is an instance of schema S, we can thus deduce:

m(S, i+1)=f(c1,i)+…..f(Cn,i)/a(i)

where C1 to Cn are the chromosomes in the population at time i that match schema S.

  • Let us compare this with the definition of the fitness of schema S, f(S,i), which is defined as follows:

f(S,i)=f(c1,i)+…..f(Cn,i)/m(S,i)

slide39

By combining the above stated formulas,

m(S,i+1)=f(S,i).m(S,i)/a(i)

  • The more fit a schema is compared with the average fitness of the current population, the more likely it is that that schema will appear in a subsequent population of chromosomes.
  • There will be fewer occurrences of a given schema whose fitness is lower than the average fitness of the population and more occurrences of a given schema whose fitness is higher than average.
how mutation and crossover affect schemata
How Mutation and Crossover Affect Schemata
  • Both mutation and crossover can destroy the presence of a schema.
  • A given schema can be said to have survived crossover, if the crossover operation produces a new chromosome that matches the schema from a parent that also matches the schema.
  • For a schema to survive crossover, the crossover point must be outside the defining length.
slide41

Hence, the probability that a schema S of defining length dL(S) and of length L(S) will survive crossover is

Ps(S)=1-[dL(S)]/L(S)-1

  • This formula assumes that crossover is applied to each pair of parents that reproduce.
  • Hence, after certain modifications of the above formula:

Ps(S)>=1-(Pc)[dL(S)]/L(S)-1

slide42

Effect of Mutation:

  • Probability that mutation will be applied is Pm.
  • Hence, a schema will survive mutation if mutation is not applied to any of the defined bits. The probability of survival can be defined as:

Ps(S)=(1-Pm)^O(s)

  • Hence, a schema is more likely to survive mutation if it has lower order
slide43

We can combine all the equations we have to give one equation that defines the likelihood of a schema surviving

reproduction using crossover and mutation.

  • That equation represents the schema theorem, developed by Holland, which can be stated as:

“Short, low order schemata which are fitter than the average fitness of the population will appear with exponentially increasing regularity in subsequent generations.”

the building block hypothesis
The Building Block Hypothesis
  • The short, low order, high-fitness schemata are known as building blocks.
  • Genetic algorithms work well when a small group of genes that are close together represent a feature that contributes to the fitness of a chromosome.
  • Randomly selecting bit to represent particular features of a solution is not good enough.
  • Bits should be selected in such a way that they group naturally together into building blocks, which genetic algorithm are designed to manipulate.
deception
Deception:

Genetic Algorithms can be mislead or deceived by some building blocks into heading toward sub-optimal solutions.

One way to avoid effects of deception is to use inversion, which is a unary operator that reverses the order of a subset of the bits within a chromosome.

Another way to avoid deception is to use Messy Genetic Algorithms.

messy genetic algorithms mga s
Messy Genetic Algorithms (mGA’s)
  • Developed as an alternative to standard genetic algorithms.
  • Each bit is labeled with its position.
  • A chromosome does not have to contain a value for each position, and, a given position in a chromosome can have more than one value.
  • Each bit in a chromosome is represented by a pair of numbers: the first number represents the position within the chromosome, and the second number is the bit value.
slide47

mGA’s use the standard mutation operation. But, instead of crossover, they use splice and cut operations.

Two chromosomes can be spliced together by simply joining one to the end of other.

The cut operator splits one chromosome, into two smaller chromosomes.

evolution of strategies
Evolution of Strategies
  • The process for running this genetic algorithm is as follows:
    • Produce a random population of chromosomes. We will start with 100.
    • Determine a score for each chromosome by playing its strategy against a number of opponents.
    • Select chromosomes for the population to reproduce.
    • Replace the previous generation with new population produced by reproduction.
    • Return to step 2.
problems
Problems:
  • Most Combinatorial search problems can be successfully solved using genetic algorithms.
  • Genetic Algorithms can be applied to:
    • Travelling Salesman Problem
    • The Knight’s tour.
    • The CNF- satisfiability problem.
    • Robot Navigation.
    • Knapsack Problem
    • Time Table problem.