Genatic Algorithm Solving 8queen - PowerPoint PPT Presentation

1 / 5
About This Presentation
Title:

Genatic Algorithm Solving 8queen

Description:

A genetic algorithm starts with a randomly generated population of individuals, ... the current population P so that fitter' individuals are more likely to be selected ... – PowerPoint PPT presentation

Number of Views:302
Avg rating:3.0/5.0
Slides: 6
Provided by: malcol89
Category:

less

Transcript and Presenter's Notes

Title: Genatic Algorithm Solving 8queen


1
Genatic Algorithm Solving 8-queen
  • Presented by
  • Huda Younies Al_azzeh

2
Genetic algorithms
  • A genetic algorithm starts with a randomly
    generated population of individuals, with each
    individual ordinarily represented as a string of
    symbols.
  • Each (potential) individual in the population is
    rated according to a fitness function which
    measures how good an individual is with respect
    to the underlying problem.
  • For example, in the 8-queens problem
  • an individual represents a configuration of
    queens and is a string of digits from 1, 2, ,
    8 of length 8 so that the first digit details
    the location of the first queen in the first
    column, the second digit details the location of
    the second queen in the second column, and so on
  • the fitness of an individual is the number of
    pairs of non-attacking queens in the
    configuration.

3
Genetic algorithms (2)
  • Having generated an initial population at random,
    we iteratively generate a new population from the
    old one until some appropriate terminating
    condition is met, e.g., an individual in the
    population is fit enough or the number of
    iterations has hit some bound.
  • Each iteration consists of the following process
    repeated P where P is the current population
  • randomly select two individuals X and Y from the
    current population P so that fitter individuals
    are more likely to be selected
  • from X and Y, reproduce a child Z
  • with a small probability mutate the child Z by
    randomly replacing one symbol in the string with
    a randomly chosen symbol
  • add the child Z to the new population newP.
  • So, after this iteration the new population newP
    has exactly the same size as the current
    population P. The current population P is now
    replaced with the new population newP and the
    next iteration begins.
  • Reproduction and mutation are done as follows.

4
Genetic algorithms (3)
  • Reproduction of the child Z from two individuals
    X and Y is achieved through crossover.
  • The crossover of X and Y yields a child Z as
    follows
  • a random bit position in the strings X and Y is
    chosen so that both strings are partitioned into
    a prefix and a suffix
  • the suffix of Y is then concatenated onto the
    prefix of X, and the suffix of X is concatenated
    onto the prefix of Y to get two children
  • the fittest of the two children so obtained is
    taken to be the child Z.

The 8-queens problem.
X
The individual Y and the corresponding 8-queens
configuration.
The second child and the corresponding 8-queens
configuration fitness 19.
The first child is taken to be child Z.
Randomly generate a bit position.
The two interim children.
Crossover prefixes and suffixes.
The individual X and the corresponding 8-queens
configuration.
The first child and the corresponding 8-queens
configuration fitness 20.
Y
5
The genetic algorithm
  • Genetic-algorithm
  • P ? randomly generated initial population
  • repeat
  • newP ? ?
  • for i 1 to P do
  • X ? randomly chosen individual of P with
  • probability proportional to fitness
  • Y ? randomly chosen individual of P with
  • probability proportional to fitness
  • Z ? reproduced from X and Y
  • if small random probability then mutate Z
  • newP ? Z
  • until some individual is fit enough or a certain
    number of iterations have been done
  • return the fittest individual
Write a Comment
User Comments (0)
About PowerShow.com