3

In evolutionary computation and, in particular, in the context of genetic algorithms, there is the concept of a fitness function. The better a state, the greater the value of the fitness function for that state.

What would be a good fitness function for the 8-queens problem?

nbro
  • 39,006
  • 12
  • 98
  • 176
Huma Qaseem
  • 179
  • 1
  • 3
  • 12

2 Answers2

2

Here you can find an example of how to apply genetic algorithms to solve the 8-queens problem.

The proposed fitness function is based on the chessboard arrangement, and in particular, it is inversely proportional to the number of clashes amongst attacking positions of queens; thus, a high fitness value implies a low number of clashes.

nbro
  • 39,006
  • 12
  • 98
  • 176
PieCot
  • 138
  • 3
0

This can be calculated quite easily in the context of 8-queen problem. Just start with a particular configuration. Starting from the queen in the left-most column just keep on counting the non-attacking positions (pairs) on the right with each queen. Carry on column by column towards your right until you reach the last queen. As a special case for the last queen the non-attacking pairs will be zero as their are no other queens after that.

  • This describes how to solve the problem, but it doesn't answer the question which is about formulating this as a fitness function to use in evolutionary computing. – Oliver Mason Dec 02 '19 at 11:23