# A Genetic Algorithm Based Approach for Solving the Minimum Dominating Set of Queens Problem

Authors: Saad Alharbi; Ibrahim Venkat
Journal: Journal of Optimization
 (2017)

---

## Abstract

In the field of computing, combinatorics, and related areas, researchers have formulated several techniques for the Minimum Dominating Set of Queens Problem (MDSQP) pertaining to the typical chessboard based puzzles. However, literature shows that limited research has been carried out to solve the MDSQP using bioinspired algorithms. To fill this gap, this paper proposes a simple and effective solution based on genetic algorithms to solve this classical problem. We report results which demonstrate that near optimal solutions have been determined by the GA for different board sizes ranging from 8 × 8 to 11 × 11.


---

## Body

## 1. Introduction

The MDSQP which is otherwise known as the chess covering problem is one of the well-known chessboard problems which has been receiving continued interests by researchers including the computational intelligence domain. In the field of graph theory, specifically the study of dominating sets had addressed this problem even in the early 1970s. Inn×n chessboard, cells are organized as n rows and n columns. In chess layman terms, a queen (say Q) placed on a square will dominate all squares associated with the row, column, and two diagonals with reference to Q. The idea behind this problem is to find the minimum number of queens required to dominate the whole chessboard. Domination here refers to the coverage of all the possible squares being attacked by those queens including the square dominated by the respective queens. Previous researches have been trying to find the domination number γ(Qn) for the n-queens problem using mathematical and combinatorial approaches [1–8]. Many formulations have been derived and presented in these approaches. It has been observed that limited efforts have been carried out to employ evolutionary algorithms to address the MDSQP. In fact, most of the studies in the literature were devoted to address the original n-queens problem which is called a nonattacking problem. The results of such studies have demonstrated that evolutionary algorithms are capable of outperforming other principled approaches such as backtracking to solve such problems. However, these studies have focused only on the nonattacking n-queens problem, whereas, to the best of our knowledge, the MDSQP has been least considered using bioinspired evolutionary algorithms.Evolutionary algorithms have been proved to be successful for solving and optimizing a wide range of complex problems including combinatorial ones, such as the one studied here, within reasonable computing time [9]. Generally speaking, evolutionary algorithms can be classified into two main categories which are swarm intelligence based approaches and classical evolutionary approaches. Swarm intelligence (SI) approaches are inspired from the social natural behavior such as animals group behavior when searching for food or avoiding certain threat [10]. Several SI approaches with reference to the literature include Particle Swarm Optimization (PSO) and Ant Colony Optimization (ACO). ACO have been proved to efficiently solve several optimization problems [11]. PSO has also demonstrated good results in optimizing various complex problems such as the supply chain management (e.g., [12]) and shortest path problems [13, 14].The classical evolutionary algorithms, on the other hand, including genetic algorithms, were successfully adopted in a wide range of optimization problems. Genetic algorithm is one of the most commonly used evolutionary algorithms in the literature which was first proposed in the 1970s [15]. GA was inspired from the natural process of searching and selection process which leads to the survival of the fittest individuals [15]. Researchers in the literature have demonstrated the efficiency of adopting GA in solving various optimization problems such as data mining [16] and network traffic control [17]. In fact, GA have been adopted in the literature solely to solve some problems such as [17, 18] and were hybridized with other approaches for more enhanced results. Commonly, GA is hybridized with local and heuristic search approaches such as Cuckoo search [19] and Tabu search [20]. Furthermore, various researchers hybridized it with other evolutionary approaches like dynamic programming as in [21].Therefore, this paper intends to fill these gaps and present a bioinspired genetic algorithm (GA) to solve the MDSQP problem by considering board sizes gradually from the typical8×8 chessboard up to a 11×11 board. The proposed approach gradually increments the number of queens placed on the board from just below the lower bounds suggested in the literature until an optimal solution has been determined (i.e., all the squares of the chessboard get dominated). The remaining paper is organized as follows: Section 2 discusses related work; Section 3 formulates the problem; Section 4 presents the evolutionary mechanism of the proposed technique; results are discussed in Section 5 and the paper is finally concluded with insights for future work in Section 6.


## 2. Related Work

Vast amount of efforts have been devoted to investigate chessboard problems. Problems related to chessboard can mainly be classified to the originaln-queen problem and the dominating set (i.e., the covering problem). The original n-queen problem can be defined as placing n queens on n×n chessboard in an optimal way such as none of the queens should attack each other [22, 23]. It was first introduced in 1850 [24]. Numerous researches have been performed to solve this problem using different approaches; most of them adopted mathematical approaches and graph theory such as [25–27]. The study of such a problem may benefit in the understanding of various applications such as traffic control, deadlock prevention, and parallel memory storage [28]. The complexity of the n-queen problem is known as exponential where it gets more complex with large n values. Various approaches were adopted to solve this problem such as backtracking [29], neural networks [30–32], and evolutionary and optimization algorithms [33–42].The domination set problem on the other hand has received less attention by computer science researchers. In fact, various researches have been devoted to investigate such a problem but were mainly adopting mathematical models. Burger and Mynhardt pointed out that the queens dominating problem is one of the most difficult chessboard problems [43]. It is commonly defined as finding the minimum numbers of queens required to cover all the squares of n×n chessboard. This number is termed as the domination number and referred by the notation γQn. Researchers have arrived at upper and lower bounds since early 1970s [3]. Many formulations and values were derived and found especially for small values of n [3, 43–45]. Table 1 shows some of these values. Figure 1 shows a brief taxonomy of typical chessboard problems. For instance, several studies were conducted to find the domination number of the normal domination [8]. In these studies, it is required to find the minimum queens to be optimally placed on n×n chessboard that will cover all squares in the board. However, many researchers considered the domination set problems under several variations. For instance, many studies were conducted to investigate the independent domination number which can be defined as the number of queens which do not attack each other and cover the entire n×n chessboard [3]. Various values and formulations were derived and proved in a mathematical context. Furthermore, the “diagonal queens domination problem” was frequently stated in the literature. In such a problem, it is required to find the number of minimum queens placed in the main diagonal and cover the entire n×n chessboard [3, 4]. Cockayne has also tried to find the domination number of the queens placed on a single column [3]. Furthermore, many researchers carried out studies to solve the problem of the domination set on a toroidal chessboard [1]. In such studies, it is required to find out the minimum number of queens that would cover the entire squares in the torus. Bozóki et al., on the other hand, shed the light on a different problem called “domination of the rectangular queens graph” where it is required to find the domination number of queens in a rectangular chessboard (n×m) in which the number of squares in column and rows are different [46]. They derived lower bounds for small values of n and m particularly 4≤m≤n≤18.Table 1
Domination number for somen values pertaining to the MDSQP.
n
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
γ
(
Q
n
)
1
1
1
3
3
4
4
5
5
5
5
7
7
≤8
≤9
≤9
9
9Figure 1
Basic taxonomy of chessboard problems.As seen above, the queens domination set problem has been enormously studied especially using mathematical methods. However, literature still lacks the adoption of computational models particularly optimization approaches to solve this problem. Limited articles were found technically considering the problem. For instance, Fernau tried to analyze the complexity of this problem using backtracking, dynamic programming on subsets, and dynamic programming on path decomposition [47]. He indicated that the complexity of the dominating queen problem is a challenging problem. On the other hand, Mohabbati-Kalejahi et al. (2012) presented a hybrid Imperialist Competitive Algorithm (ICA) with a local search algorithm in order to solve the nonattacking queens based domination problems [48]. The proposed hybrid algorithm was compared with the basic ICA in the two problems and the results indicated an improved performance in terms of average runtime and average fitness value. The solution was formulated for the nonattacking n queens problem. However, for the domination problem less details and information have been provided pertaining to the implementation details of the proposed algorithm. For example, crucial components of an evolutionary algorithm such as the formulation of a fitness function have not been presented in detail. Therefore, this work is intended to fill this gap in the literature by adopting a typical bioinspired genetic algorithm (GA) to solve theMinimum Dominating Set of Queens Problem(MDSQP). The proposed algorithm is described in the following sections.


## 3. Problem Formulation

In order to solve the problem and present it programmatically we firstly labelled all squares in the chessboard by sequencing numbers starting gradually from 1 ton×n starting from the top most left square to the bottom right most square. Figure 2 shows an example of the proposed labelling schema with reference to the commonly used 8×8 chessboard. In addition, all squares in the board have a location (analogous to the norms of the analytical geometry) in the (x,y) coordinate form, where x denotes the row number and y denotes the column number. For example, the location of the square 28 in Figure 2 is (4, 4). This location can be used to determine the dominated squares for a queen placed in a particular square. Let G be a set of chessboard squares G={p1,p2,…,pn×n} and let Sq be the set of dominated squares by queen q for the case of i number of queens. Then it follows that (1)Sqi=p1,p2,…,pn×n.Defining a fitness function for this problem firstly requires defining a method to identify dominated squares for all queens on the board. For a queen placed on the location (x,y), a square n will be n∈Sq if at least one of the following conditions holds:(2)x=xj∀j1,2,…,n,(3)y=yj∀j1,2,…,n,(4)xj=x-j,y=y-j∀j1,2,…,x-1,(5)xj=x+j,yj=y-j∀j1,2,…,y-1,(6)xj=x-j,yj=y+j∀j1,2,…,x-1,(7)xj=x+j,yj=y+j∀j1,2,…,n-1.Equations (2) and (3) represent the dominated squares in terms of rows and columns, respectively. The rest of the equations from (4) to (7) represent the squares dominated by a queen placed in (x,y) for the diagonal directions. Specifically the dominated squares of the two diagonals pertaining to the four sides (upper left, lower left, upper right, and lower right). For example, squares 19, 10, and 1 in Figure 2 are instances of dominated squares by the queen placed on the square 28 and this case has been modeled using a logical algebraic expression using (4). The main objective is to maximize the number of dominated squares in a chessboard by k queens and finding optimal locations of these k queens is quite challenging owing to the complexity of permutations and combinations involved. Therefore, this is measured by the following fitness function: (8)fx=SG,where(9)S=sq1∪sq2∪⋯∪sqk.The value of this function approaches 1 when all the squares of the chessboard get dominated at least once. In other words, a fitness value <1 could cohesively indicate that there are some squares or at least 1 square which has not been dominated by any ith queen (sqi).Figure 2
The proposed labelling scheme of a typical8×8 chessboard.


## 4. Formulation of the Problem Using Genetic Algorithms

The proposed GA formulation has been modeled to solve then×n chessboard. The overall structure of the proposed GA can be described in Figure 3.Figure 3
A typical example showing the proposed coding scheme.


### 4.1. Coding

Individuals have been coded in a matrix of orderk×m. Intuitively k×m, the product of the columns and rows, represents the population size (number of possible candidate solutions). The elements of the matrix represent m bit binary encodings of the labels (each square has been labelled as discussed before) of the queens being placed on the chessboard. The following matrices show typical examples for the case of few possible candidate solutions(10)A=1100110001101001011001100010.Furthermore, the dominated square set has also been coded in a matrix S as shown below; the total number of unique dominated squares is represented by the number of rows. (11)S=11100100000001.The above matrix shows an example instance of a dominated set containing two squares in the chessboard. Furthermore, let us assume that we would like to encode only one candidate solution in a 4×4 chessboard. Figure 3 shows that two queens are placed in the squares labelled 6 and 16. By converting the decimal values of these squares into 8-digit binary code and taking into consideration having two queens, therefore, we get a 1×2 matrix which is shown below:(12)A=0000011000010000.Furthermore, to identify the dominated squares by the two queens placed in the chessboard, (2) to (7) must be applied. Accordingly, Figure 3 shows that all squares in the chessboard except label 3 are dominated by the two queens. Therefore, the dominated set S is as follows:(13)S=1,2,4,5,6,7,8,9,10,11,12,13,14,15,16.By converting the elements of S into 8-digit binary code we will get the following dominated set matrix S:(14)S=000000010000001000000011⋮⋮00010000.Illustration of typical crossover operations is as follows:15a1100100⟹11011100011110001010015b0011111⟹000100011000001111110.


### 4.2. Initial Population and Fitness Evaluation

A random population consisting of 100 individuals (possible candidate solutions) is generated at the initialization stage of the GA making sure that queens are placed in different squares in the board. The domination rate of the queens is computed using the fitness function as modeled in Section2. The selection criteria of our proposed techniques are as follows. Individuals are sorted based on their fitness value and the top 50% of the population (candidates with the potential fitness capability) will be allowed to survive and will be considered into the next generation. Candidates whose fitness capability is below 50% will be discarded (they will not be allowed to survive). Subsequent to this selection process, the classical roulette-wheel selection method has been adopted for selecting individuals that will be mated for reproduction.


### 4.3. Crossover and Offspring Generation

The new generation is produced by implementing the one-point crossover between two parents. The steps involved in the proposed crossover operator can be described as follows:(i)
Two individuals are selected according to the selection operator.(ii)
Generate a random crossover point in the two parents.(iii)
Exchange genetic materials after the crossover point.(iv)
Validate new individuals so that the individuals are retained within the boundaries of the chessboard.(v)
If an offspring’s location happens to be to zero owing to stochastics, generate a random adjustment point.(vi)
Change the value of the adjustment position to 1.(vii)
If an offspring’s location is larger thann×n, based on the chessboard size change the value of the digits of the chromosome causing this issue to 0.Equation 15a shows an example of a crossover operation between two parents to produce two children (offspring); 15b shows an example of a crossover operation to illustrate the validation and adjustment process.Furthermore, we have also implemented mutation with the probability of 0.05. In mutation, we simply select two random positions for the selected individuals and substitute the values of these positions to their complements (i.e., change zero to one and vice versa). In order to avoid the production of individuals outside the boundaries of the chessboard, the same crossover validation and adjustment mechanism have been found to be efficient.


## 4.1. Coding

Individuals have been coded in a matrix of orderk×m. Intuitively k×m, the product of the columns and rows, represents the population size (number of possible candidate solutions). The elements of the matrix represent m bit binary encodings of the labels (each square has been labelled as discussed before) of the queens being placed on the chessboard. The following matrices show typical examples for the case of few possible candidate solutions(10)A=1100110001101001011001100010.Furthermore, the dominated square set has also been coded in a matrix S as shown below; the total number of unique dominated squares is represented by the number of rows. (11)S=11100100000001.The above matrix shows an example instance of a dominated set containing two squares in the chessboard. Furthermore, let us assume that we would like to encode only one candidate solution in a 4×4 chessboard. Figure 3 shows that two queens are placed in the squares labelled 6 and 16. By converting the decimal values of these squares into 8-digit binary code and taking into consideration having two queens, therefore, we get a 1×2 matrix which is shown below:(12)A=0000011000010000.Furthermore, to identify the dominated squares by the two queens placed in the chessboard, (2) to (7) must be applied. Accordingly, Figure 3 shows that all squares in the chessboard except label 3 are dominated by the two queens. Therefore, the dominated set S is as follows:(13)S=1,2,4,5,6,7,8,9,10,11,12,13,14,15,16.By converting the elements of S into 8-digit binary code we will get the following dominated set matrix S:(14)S=000000010000001000000011⋮⋮00010000.Illustration of typical crossover operations is as follows:15a1100100⟹11011100011110001010015b0011111⟹000100011000001111110.


## 4.2. Initial Population and Fitness Evaluation

A random population consisting of 100 individuals (possible candidate solutions) is generated at the initialization stage of the GA making sure that queens are placed in different squares in the board. The domination rate of the queens is computed using the fitness function as modeled in Section2. The selection criteria of our proposed techniques are as follows. Individuals are sorted based on their fitness value and the top 50% of the population (candidates with the potential fitness capability) will be allowed to survive and will be considered into the next generation. Candidates whose fitness capability is below 50% will be discarded (they will not be allowed to survive). Subsequent to this selection process, the classical roulette-wheel selection method has been adopted for selecting individuals that will be mated for reproduction.


## 4.3. Crossover and Offspring Generation

The new generation is produced by implementing the one-point crossover between two parents. The steps involved in the proposed crossover operator can be described as follows:(i)
Two individuals are selected according to the selection operator.(ii)
Generate a random crossover point in the two parents.(iii)
Exchange genetic materials after the crossover point.(iv)
Validate new individuals so that the individuals are retained within the boundaries of the chessboard.(v)
If an offspring’s location happens to be to zero owing to stochastics, generate a random adjustment point.(vi)
Change the value of the adjustment position to 1.(vii)
If an offspring’s location is larger thann×n, based on the chessboard size change the value of the digits of the chromosome causing this issue to 0.Equation 15a shows an example of a crossover operation between two parents to produce two children (offspring); 15b shows an example of a crossover operation to illustrate the validation and adjustment process.Furthermore, we have also implemented mutation with the probability of 0.05. In mutation, we simply select two random positions for the selected individuals and substitute the values of these positions to their complements (i.e., change zero to one and vice versa). In order to avoid the production of individuals outside the boundaries of the chessboard, the same crossover validation and adjustment mechanism have been found to be efficient.


## 5. Experiments and Results

The proposed GA has been implemented using MATLAB and experimented using a 2.6 Ghz PC enabled with Intel i5 processor installed with Microsoft Windows 8 operating system. It was independently tested using a different size of the chessboard starting from the common chessboard size8×8 to 11×11. In each test instance the number of queens placed in the chessboard is gradually incremented starting from the lower bounds reported in the literature until the maximum fitness has been reached. Furthermore, the proposed GA was iterated 1000 times for each instance and the best fitness values were recorded. The results in this contribution are reported after running the GA for five times for each test instance. Table 2 shows a summary of the maximum fitness reached by the GA for the value of n=8 to n=11 as well as the queen numbers placed in the chessboard. The results obtained were promising and close to upper bounds reported in the literature for MDSQP.Table 2
Progression of fitness values:n is the board size and k is number of queens placed on the board.
n
k
Fitness value
8
3
0.88
4
0.95
5
1
9
5
0.99
6
1
10
5
0.95
6
0.97
7
1
11
6
0.97
7
1It can be noticed that the GA could cover 88% and 95% of the8×8 chessboard by placing three and four queens on the board, respectively. The GA was also able to find the optimal solution for the same size board when placing five queens meaning that the domination number of 8×8 chessboard is five (i.e., γ(Qn)). These findings compare well with the results reported in the literature. As the proposed GA is considered to be a pioneer on the literature considering the MDSQP, the obtained results will be compared with the values in the literature which have been derived mathematically. Table 3 shows the optimal domination numbers obtained by the GA compared with these. Table 2 shows also that the GA was able to dominate 99% of the 9×9 chessboard when five queens have been placed in the board, although five is derived as the domination number for a 9×9 chessboard (γQn=5). However, an optimal solution was reached by increasing number of queens placed on the board to six (γQn=6) (see Table 3). Similarly, five was reported as the domination number for the case of 10×10 and 11×11 chessboard; however, the GA was not able to cover the whole board. In fact, only 95% of the board was covered when n=10 and five queens were placed (k=5) (see Table 2). The domination percentage has been improved slightly when adding one queen (k=6) to 10×10 board. However, an optimal solution was found when placing seven queens to the board in the case of n =10, 11 (γQn=7). All solutions produced were graphically simulated by the GA at the end of the execution. Figure 4 shows the simulations pertaining to the optimal solutions of the proposed GA for the case of n=8 to 11. The red circles (dots) represent the queens and the blue circles represent the dominated squares in a typical n×n chessboard. It also shows the fitness value of the presented solution corresponding to the generation number of the solution. In addition, the performance of the proposed GA solution was measured after the execution of each test instance. The results indicated that the performance in terms of fitness value is increasing over iterations. Due to the space limitation we present the performance results of the 10×10 chessboard in Figure 5. It can clearly be observed that the fitness values in all the cases have been improved when the iterations tend to approach their upper limits.Table 3
The obtained results by the GA and domination numbersγQn reported by the literature.
n
8
9
10
11
GA
5
6
7
7
Literature
5
5
5
5Figure 4
Optimal solutions yielded by the proposed GA based technique. Red dots represent queens and blue dots represent squares dominated by the queens.
(a)
n
=
8
(b)
n
=
9
(c)
n
=
10
(d)
n
=
11Figure 5
Performance of the GA for a typical case;n=10 and k=5,6 and 7.It can be seen that the solutions yielded by the proposed technique could yield a good domination performance (95% to 99%) even for larger board sizes, particularly for the cases ofn=10 and n=11.


## 6. Conclusion

In this paper, we have proposed agenetic algorithm (GA) based technique to solve the classicalMinimum Dominating Set of Queens Problem(MDSQP). Experimental results demonstrate that the proposed GA based solution was able to find optimal to near optimal solutions for even large sizes of boards (n=10 and n=11). For the case of a typical 8×8 chessboard, the proposed solution yielded a perfect optimal solution on a par with the solutions reported in the literature. Furthermore, experimental results also systematically demonstrate that the average fitness value approached towards the maximum over subsequent iterations. These results will be a basis for our future work where we intend to deploy other bioinspired computing techniques such as membrane computing.



---

*Source: 5650364-2017-06-04.xml*