A Hybrid Algorithm from Cuckoo Search Method with N-Queens Problem

This paper tackled cuckoo search method. The method is one of optimization methods with N-queens problem through proposed hybridization algorithm which mimics the behavior of cuckoo to reach the solution of N-queens problem. The proposed hybridization algorithm is simulated by using MATLAB 6.5 language to mimic the behavior of some cuckoo. These laid their eggs in the nests of other host birds. If a host bird discovers that the eggs aren't their own, it will either throw these alien eggs away, or abandon its nest and build a new one. To reach the solution for Nqueens problem easily. The experimental results in this paper show the effectiveness and easy implementation to reach solution.


Introduction
Combinatorial optimization problems form a set of problems, which need a considerable effort and time to be solved. Their difficultly lies in the fact that there is no formula for solving them exactly. Every possibility has to be examined in order to find the best solution and the number of possibilities increases exponentially as the size of the problem increases [4]. Classical methods are very limited in solving such problems because a large set of data is to be processed and a large solution space must be explored. So, other methods, known as approximate methods, are used to solve such problems. The aim of an approximate method is to get an accepted solution, not necessary the optimal one. Genetic algorithms, simulated annealing and taboo search are among the most famous approximate methods used in the combinatorial optimization field [3]. The N-queens problem aims at placing N-queens on an N×N chessboard, in such a way that no queen could capture any of the others [3]. The 8queens problem is a well-known puzzle among computer scientists. The problem is to place eight queens on eight different squares on a chess board (which has eight rows and eight columns). Put one queen onto the board at a time and make sure that no constraint is violated, until all eight queens are placed [8].
The N-queens problem is one of the best examples of permutation problems. Permutation optimization problems have been found in many areas. In N-queens problem ensures that at most one queen will be placed in each row, column and diagonals. Cuckoo search is one of the latest nature-inspired metaheuristic algorithms. Combinatorial optimization is a subset of optimization. It has applications in artificial intelligence.
This paper has been attended by the collective intelligent behavior of insects such cuckoo search. It is a branch of artificial intelligence, so that the paper proper a hybrid algorithm from cuckoo search with N-queen problem, to eliminate the row, column and diagonal conflicts and reach to the solution.
In this paper, besides this introductory section, section 2 presents the N-queens problem. The cuckoo search algorithm is described in section 3. Section 4 contains the proposed hybridization algorithm. Experimental results and discussion are examined in section 5. Finally, section 6 concludes this paper.

N-Queens Problem
The N-queens problem is an artificial intelligence problem. It is a general case of the 8-queens problem. This combinatorial optimization problem has been studied for more than a century. The 8-queens problem was first introduced by a chess player, Max Bezel, in 1848. Since 1850, the problem has attracted the attention of several famous mathematicians including Gauss, Polya and Lucas. The N-queens problem can be defined as follows: place N-queens on an N×N chessboard, each queen on a square, so that no queen could capture any of the others, that is, a configuration in which there exists at most one queen on a given row, column or diagonal [3,6]. A line is a maximal co-linear set of squares on the chessboard (in other words, a row, column or diagonal). If one of the squares in a line has a queen in it, that line is said to be closed [6].
The N-queens problem comes from the game of chess, where the queen is the figure that has the ability to move up, down, left, right and diagonally any number of steps in a straight line. The N-queens problem asks how to place N-queens on a N×N square grid in such a way that no queen can attack any other queen on the board. The number of solutions increases exponentially with increasing N [7].

Cuckoo Behavior
A new metaheuristic optimization algorithm, called cuckoo search was developed recently by Xin-She Yang and Suash Deb in 2009, for solving optimization problems [10,11]. Cuckoo birds attract attention of many scientists around the world because of their unique behaviour. They have many characteristics, which differentiate them from other birds, but their main distinguishing feature is an aggressive reproduction strategy. Some species such as the (Ani) and (Guira) cuckoos lay their eggs in communal nests, though they may remove others' eggs to increase the hatching probability of their own eggs [1,2,9,10,11]. Cuckoos engage brood parasitism. It is a type of parasitism in which a bird (brood parasite) lays and abandons its eggs in the nest of another species [1,2,9,11]. Some host birds don't behave friendly against intruders and engage in direct conflict with them. In such situation host bird will throw those alien eggs away. In other its nest and build a new nest elsewhere [1,9].
In general, cuckoo's eggs hatch earlier than their host eggs. As soon as the cuckoo chicks have hatched (and before they can even see), they lift any other eggs they find in the nest onto their backs and then throw them overboard. Hatching early means that cuckoo chicks can oust other bird's eggs, so that they get all the food their foster parents bring home [1,10].

Levy Flights
By observing animals foraging behavior, it can be concluded that animals search for food in a random or quasi-random manner. The foraging trajectory of an animal is a random walk because the next step is based on the current location and the probability of moving to the next location. One type of random walk is levy flights in which the step-lengths are distributed according to a heavy-tailed probability distributed. According to conduct studies, foraging behavior of many flying animals and insects show typical characteristic of these flights [5]. Such behavior has been applied to optimization and optimal search, and preliminary results show its promising capability [9,10]. Many population based methods use random search similar to levy flight [1,9].

Description of the Original Cuckoo Search Algorithm
In order to simplify the description of novel cuckoo search algorithm, three idealized rules can be used: 1. Only one egg at a time is laid by cuckoo. Cuckoo dumps its egg in a randomly chosen nest. 2. Only the best nests with a high quality eggs (better solution) will be passed into next generation. 3. The number of available host nests is fixed. Egg laid by a cuckoo bird is discovered by the host bird with probability [0, 1]. In this case, the host bird has two options. It can either throw the egg away, or it may abandon the nest, and build a brand new nest at nearby location [1,2,9,10,11]. For simplicity, this last assumption can be approximated by the fraction of the n nests are replaced by new nests (with new random solutions). [10]

Original Cuckoo Search Algorithm
Below the steps of original cuckoo search method via levy flights [1,2,9,10] Begin Objective function f(x), x = (x1,x2,…xd) T Generate initial population of n host nests xi (i =1,2,…n) While (t < Max Generation) or (stop criterion) Get a cuckoo randomly by levy flights Evaluate its quality fitness Fi Choose a nest among n randomly (for example j) IF (Fi > Fj) replaces j by the new solution; End A fraction (Pa) of worse nests is abandoned and new ones nests are built; Keep the best solutions or nest with quality solutions; Rank the solutions and find the current best End while Post process and visualize results End

Proposed Algorithm Preliminary
Metaheuristics are used for combinatorial optimization in which an optimal solution is sought over a discrete search space. Popular Metaheuristic for combinatorial problems includes simulated annealing, genetic algorithms, ant colony optimization and tabu search. In computer science, metaheuristic designates a computational method that optimizes a problem by iteratively trying to improve a candidate solution with regard to a given measure of quality. However, metaheuristic doesn't guarantee an optimal solution is ever found.

Proposed Algorithm
Below the steps of proposed hybridization algorithm in detail: Step1: Input N {N represents number of queens}, construct matrix N×N, this matrix represents N-queens problem (chess board). Each cell in the matrix represents a nest of cuckoo. The number of hosts nests is fixed and equal N×N nests.
Step2: Put values in each cell of matrix. {arbitrary values, each value represents the number of eggs which was laid by cuckoo at a time and in each cell (nest) has one or greater than one egg}. Step3: Examine all values in the matrix (nests). Select the maximum value's cell and assigning queen operation in value's position, because the best nests with high quality of eggs (value) will carry over to the next generation. Step4: Delete the row & column corresponding of maximum value from original matrix, thus create new matrix. This operation is similar Cuckoo can throw the egg away. The sized of new matrix is less than original matrix. Therefore, the number of hosts nests is less than original nests. Step5: While the number of queen is greater than zero do Step6: In new matrix, also, select the maximum value's cell.
Step7: IF assigning operation of queen possible; then assigning operation of queen.
Delete the row & column corresponding of maximum value, thus create new matrix. {cuckoo can throw the egg away}. Else conflict operates in assigning. Select next maximum value and examine if assigning operation of queen possible or not. In this case, cuckoo may abandon the nest, and is build a brand new nest at nearby location, this means Go to step 1. Step8: Until the number of queen (N) equals to zero.

Results and Discussion
In this paper, the proposed hybridization algorithm extended to the more complicated case where each nest has multiple eggs reaching the solution.
N-queens problem implementation generally consists of placing queens in a row and column and continuing to place the next queen in next row and column without violating the same row, same column and same diagonal constraint. The results are summarized after running several iterations.
A simple representation where each cell in the matrix represents nest and has number of eggs. The aim is to use the new and potentially better solutions (cuckoo) to replace a not good solution in the nests to reach the solution. Maybe each egg or eggs (value) in single nest (single cell) represents sub-solution. When describing the cuckoo search algorithm, the first assumption in rules of cuckoo search algorithm can be represented by step 1 and step 2 in the proposed algorithm. While, the second assumption rules of cuckoo search algorithm can be represented in step 3 of proposed algorithm through the selection of the maximum value's cell in matrix. From step 4 to step 8, in the proposed algorithm, can be represented by the last assumption in rules of cuckoo search algorithm. Continue these successive operations until assigned or conflict operation. The proposed algorithm executes through N >= 4. For example, to implement the proposed algorithm through N = 4 and the matrix 4×4 in the figure (2) and matrix of N-queens as illustrated in figure (3). Here, select maximum value that is 17 and assigning operation of queen in maximum value's position as follows: 8 10  In the next step, select the maximum value in matrix in figure (6) that is 10. The assigning operation of queen in its position isn't possible because of the conflict operation. Therefore, select next maximum value as 9 and the assigning operation of queen in its position as illustrated in figure (7). Finally, the new matrix becomes in figure (8) and guarantee selects the value as 3 and assigning operation of queen in its position as illustrated in figure (9). The new matrix becomes in the figure (12). The maximum value in new matrix is 7. The assigning operation of queen conflicts in its position as illustrated in figure (13). If we select the value 5 then the assigning is conflict. Here, in this example, several conflicts for assigning of queen are similar by cuckoo which may abandon the nest, and build a brand new nest.

Conclusion
Metaheuristic algorithms such as cuckoo search is becoming a powerful method for solving many tough optimization problems as N-queens problem. Cuckoo search has been derived from the behavior of biological systems and /or physical systems in nature.
This paper, presented a new hybridization algorithm combined with cuckoo search method and N-queens problem to solve it. Our hybrid algorithm has given better result. We can say that the hybrid algorithm is well situated to solve combinatorial optimization problem. The algorithm is very efficient for any value of N >= 4. The solution obtained by cuckoo search is best. Several arbitrary generated data are solved by using the proposed algorithm. Computational results can overcome difficulties of large problem sizes encountered in classical methods. In the N-queens problem the challenge is to place N-queens pieces from the game of chess on a chessboard so that no queen piece is threatening another queen on the board. The problem is a powerful piece and has the ability to attack any other playing piece positioned anywhere else on the same row, column, or diagonals. In the original routine of cuckoo search used one egg in a nest to represent a solution, but in this paper used multiple eggs (value) in a nest. Cuckoo search algorithm is efficient in the applications of optimization problems.