3
$\begingroup$

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?

$\endgroup$
0

2 Answers 2

2
$\begingroup$

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.

$\endgroup$
0
$\begingroup$

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.

$\endgroup$
1
  • $\begingroup$ 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. $\endgroup$ Commented Dec 2, 2019 at 11:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .