QUEEN, BENJAMIN NICHEOLSON (Nicholson), Cathey, N. C. Born ...
N queen
-
Upload
ahmed-yousef -
Category
Entertainment & Humor
-
view
343 -
download
1
Transcript of N queen
N-queengenetic algorithm
Empty board
G0 1 select0(0,3,1,3)
1(1,1,2,0)
2(2,3,1,1)
3(1,2,3,0)
2fitness
By counting number of attack queen for each
Queen.Basic fitness=n*(n-1)=12/2=60(0,3,1,3)1+1+0+2=4/2=2 fitness=6-2=41(1,1,2,0)1+2+1+0=4/2=2 fitness=6-2=42(2,3,1,1)1+1+1+2=5/2=2.5 fitness=6-2.5=3.5 and so on
3Selection
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)
(2,3,1,3( )0,3,1,1)
4cross 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 )
5mutation
• Select random solutionFor 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