Presentation is loading. Please wait.

Presentation is loading. Please wait.

N-Queens Computer Science 301 Spring 2007 Assignment 1 Bob Presents…

Similar presentations


Presentation on theme: "N-Queens Computer Science 301 Spring 2007 Assignment 1 Bob Presents…"— Presentation transcript:

1 N-Queens Computer Science 301 Spring 2007 Assignment 1 Bob Presents…

2 Introduction  The chess queen can move and attack any distance in all 8 cardinal and ordinal directions.  On an N x N board, can N queens be placed such that no two queens can check each other? [Eiben2003], p24-p27

3 Pictorially speaking…  Queen  Checked  Safe [Eiben2003], p24-p27

4 Pictorially speaking… (cont.)  The one and only solution to the 6-Queens problem 362514 GenotypePhenotype [Eiben2003], p24-p27 Parity

5 High Level EA Pseudo-code 1.Initialize 2.While(!terminate) 1.Parent Selection 2.Recombination 3.Mutation 4.Survivor selection 3.Termination [Eiben2003], p17

6 Initialization Pseudo-code 1.For (i = 1 to population_size) 1.Create Individual at Population[i] 2.Evaluate Fitness

7 Permutation Creation 1.Create array 2.Number in-order 3.Loop i = 1 to N 1.j = random ≥ i 2.Swap(A[i], A[j]) 123456423156436125 [Skiena1997], Generating Permutations

8 Parent Selection Uniform Random  Select offspring_count number of individuals randomly from the population with repetition

9 Parent Selection Deterministic Binary Tournament 1.Select offspring_count number of individuals with repetition by repeatedly choosing two random individuals and selecting the better one

10 Recombination (“cut-and-crossfill”) 436125243156 Child 436215 [Eiben2003], p24-p27

11 Recombination (“cut-and-crossfill”) 1.Used = boolean array of all false’s 2.XPoint = random from 1 to N 3.For (i = 1 to XPoint) 1.Child[i] = ParentA[i] 2.Used[Child[i]] = true 4.j = 0 5.For (i = XPoint to N) 1.While(Used[ParentB[j]]) 1.j++ 2.Child[i] = ParentB[j]

12 Mutation  i = random from 1 to N  j = random from 1 to N  Swap(Child[i], Child[j]) Child 436215 [Eiben2003], p24-p27

13 Survival Selection Uniform Random  The surviving population is the first population_size number of individuals in a permutation of the Population and Offspring

14 Survival Selection Elitist Higher Fitness Biased Stochastic  Elitist The best individual survives  Higher Fitness Biased Better individuals are more likely to survive  Stochastic Some randomness

15 Survival Selection Sample  Each member of Offspring is compared to a random member of Population and the stronger one survives

16 Bonus  Attempt Improvement on the Genotype Parity  Smaller solution space Reproduction  Increase correlation between Parents’ fitness and Child’s fitness Speed-up  Faster EC means more solutions can be evaluated

17 Random  If you are in C++ please use the Mersenne Twister for all your random needs http://www-personal.engin.umich.edu/~wagnerr/MersenneTwister.html http://www-personal.engin.umich.edu/~wagnerr/MersenneTwister.html

18 References  [Eiben2003] A.E. Eiben and J.E. Smith. Introduction to Evolutionary Computing. Spring-Verlag, Berlin Heidelberg, 2003, ISBN 3-540-40184-9.  [Skiena1997] Steven S. Skiena. The Algorithm Design Manual. Springer- Verlag, New York, 1997. http://www2.toki.or.id/book/AlgDesignManual/ http://www2.toki.or.id/book/AlgDesignManual/


Download ppt "N-Queens Computer Science 301 Spring 2007 Assignment 1 Bob Presents…"

Similar presentations


Ads by Google