N queen

ssuser20ef88 432 views 12 slides Jun 10, 2012
Slide 1
Slide 1 of 12
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12

About This Presentation

No description available for this slideshow.


Slide Content

N-queen
genetic algorithm

Empty board

G0 1select
(0(0,3,1,3

(1,1,2,0)1

(2,3,1,1)2

(1,2,3,0)3

2fitness
 By counting number of attack queen for each
Queen.
Basic fitness=n*(n-1)=12/2=6
0(0,3,1,3)1+1+0+2=4/2=2 fitness=6-2=4
1(1,1,2,0)1+2+1+0=4/2=2 fitness=6-2=4
2(2,3,1,1)1+1+1+2=5/2=2.5 fitness=6-2.5=3.5
and so on

3Selection
Select 2 generation random or high fitness
(0,3,1,3) (2,3,1,1 )
Then choose same random index for two
solution index=1
Replacement array1 from index+1 to n-1 with
array2
(1,3)< == >(1,1)
(0,3,1,1) (2,3,1,3)

(0,3,1,1) (2,3,1,3)

4cross over
2 generation random or high fitness
(0,3,1,3) (2,3,1,1 )
Then choose same random index for two
solution index=2
Replacement this element with
corresponding element on the same index
1< == > 1
(0,3,1,3) (2,3,1,1 )

5mutation
•Select random solution
For example: (0,3,1,3) select a random index
and replace this element with a random value
from(0,1,2,3)
Index =1 replacement with 2
.: solution (0,2,1,3)

When we finished this steps
if fitness==0
•Then I’ have a solution
Tags