Genetic Algorithms And Evolutionary Learning .*;

N-Queens Problem Example 1

The N-Queens problem entails the placement of queens on a chess board so that none are in jeopardy. The difficulty of the problem increases with the number of queens involved.

This example also includes the option to use Position-Based Crossover. See the mating() method.

 

Example Results 1

10 queens on a 10x10 chess board. MATING_PROBABILITY = 0.7. MUTATION_RATE = 0.001. MAX_EPOCHS = 1000;

Board:
. . . . . . . Q . . 
. . . . Q . . . . . 
. Q . . . . . . . . 
. . . Q . . . . . . 
. . . . . . Q . . . 
. . . . . . . . . Q 
. . Q . . . . . . . 
. . . . . . . . Q . 
. . . . . Q . . . . 
Q . . . . . . . . . 
Completed 114 epochs.
Encountered 3 mutations in 3260 offspring.

 

Example Results 2

12 queens on a 12x12 chess board. MATING_PROBABILITY = 0.7. MUTATION_RATE = 0.01. MAX_EPOCHS = 1000;

Board:
. . . . . . Q . . . . . 
. . . . . . . . . Q . . 
. . . . . . . Q . . . . 
. Q . . . . . . . . . . 
. . . Q . . . . . . . . 
Q . . . . . . . . . . . 
. . . . . . . . Q . . . 
. . . . . . . . . . Q . 
. . . . Q . . . . . . . 
. . Q . . . . . . . . . 
. . . . . . . . . . . Q 
. . . . . Q . . . . . . 
Completed 421 epochs.
Encountered 121 mutations in 12140 offspring.


Just adding 2 to this problem increases the difficulty phenomenally. Rarely will it find a solution in less than 1000 epochs. I also had to increase the probability of mutation.

 

public void footer() {
About | Contact | Privacy Policy | Terms of Service | Site Map
Copyright© 2009-2012 John McCullock. All Rights Reserved.
}