Dynamic Inertia Weight Particle Swarm Optimization for Solving Nonogram Puzzles

Particle swarm optimization (PSO) has shown to be a robust and efficient optimization algorithm therefore PSO has received increased attention in many research fields. This paper demonstrates the feasibility of applying the Dynamic Inertia Weight Particle Swarm Optimization to solve a Non-Polynomial (NP) Complete puzzle. This paper presents a new approach to solve the Nonograms Puzzle using Dynamic Inertia Weight Particle Swarm Optimization (DIW-PSO). We propose the DIWPSO to optimize a problem of finding a solution for Nonograms Puzzle. The experimental results demonstrate the suitability of DIW-PSO approach for solving Nonograms puzzles. The outcome results show that the proposed DIW-PSO approach is a good promising DIW-PSO for NP-Complete puzzles. Keywords—Non-Polynomial Complete problem; Nonograms puzzle; Swarm theory; Particle swarms; Optimization; Dynamic Inertia Weigh


INTRODUCTION
Most of optimization problems including NP-complete problem, such as Nonograms puzzle, have complex characteristics with heavy constraints.Nonograms are deceptively simple logic puzzles, which is considered as an image reconstruction problem, starting with a blank N × M grid, Fig. 1.a shows an example for 5 x 5 Nonograms puzzle.
The solution of the puzzle is an image grid that satisfies certain row and column constraints.The constraints take the form of series of numbers at the head of each line (row or column) indicating the size of blocks of contiguous filled cells found on that line.
The puzzle solvers need to figure out which square will be left blank (white) and which will be colored (black), based on the numbers at the side of the grid.The resulting pattern of colored or left blank squares makes up a hidden picture, which is the solution to the puzzle.
The resulting picture must obey all the following three conditions: 1) Each picture cell must be either colored or blanked i.e. black or white.
2) The s 1 , s 2 , . . ., s k numbers at the side of the row or column: indicated that there are groups of s 1 , s 2 , and s k filled squares, with at least one blank square between consecutive groups.
3) Between two consecutive black there must be at least one empty cell.For example, in the first row the "3" tells that, somewhere in the row, there are three sequential blocks filled in.Those will be the only blocks filled in, and the amount of space before/after them are not defined.The possible solution for the first row are: The "1 2" in the second columns tells that, somewhere in the column, there is one block filled in, followed by 2 sequential blocks filled in, and also those will be the only blocks filled in, and the amount of space before/after them are not defined.The possible solutions for the second column are: A puzzle is complete when all rows and columns are filled, and meet their definitions, without any contradictions.Fig. 1 shows an example of a Nonograms and its solution.
Several algorithms have applied to find a solution for the Nonograms problem such as an evolutionary algorithm, a heuristic algorithm, and a reasoning framework [2, 3, 4, and 5].
In this paper, a Dynamic Inertia Weight Particle Swarm Optimization (DIW-PSO) algorithm is proposed for solving Nonograms puzzles.In this work, we demonstrate that DIW-PSO can be specified to NP-Complete puzzle.

II. DYNAMIC INERTIA WEIGHT PARTICLE SWARM OPTIMIZATION
Particle swarm optimization (PSO) is a population based stochastic optimization method, which is an efficient and effective global optimizer in the discrete search domain [6].PSO has been successfully applied to a wide variety of problems in mechanical engineering, communication, pattern recognition and diverse fields of science.
In PSO, a multiple random candidate solutions, so-called particles, are maintain in the problem search space, where each particle represents a solution to an optimization problem.Each particle is assessed by fitness function to figure out whether a particle is the problem "best" solution or not.A particle then fly through the problem search space with a randomized velocity by combining the current and best potential solution locations.
The PSO algorithm consists of adjusting the velocity and position of each particle toward new current best and global best locations.At each time step, current position   ���⃗ is updated by velocity and evaluated as a problem solution, in case the particle finds a pattern that is better than any it has found previously, it is recorded in the vector   ���⃗ .And also the best fitness result value is recorded in   , for comparison on the next iterations.The PSO keeps finding better positions and updating both   ���⃗ and pbest  .
Position of individual particles   at  + 1 iteration is modified according to the following [7]: (1) The particle position is adjusted using the particle velocity which is calculated using the following equation [8,9]: , and    : velocity and position of particle  at iteration , -   : best position of particle  at iteration  -  : global best position in the whole swarm until iteration , - 1 : cognitive parameter coefficient, - 2 : social parameter coefficient, - 1 and  2 : predefined random values in rang [0, 1], - : inertia weight factor controlling the dynamics of flying, -: number of particles in the group The inertia weight factor dynamically adjusts the velocity of particle and therefore it controls the exploration and exploitation of the search space.The nonlinearly decreasing inertia weight w is set as follow [10]: where, -  , and   : lower and upper limit value of inertia weights, -  : maximum number of iteration, In each iteration, ω inertia weight will decrease nonlinearly from   to   and  is the nonlinear modulation index.Fig. 2 illustrates PSO search mechanism according to "(1)" and "(2)".The process of PSO algorithm for solving Nonograms puzzles can be summarized as follows: 1) Initialization a population with random positions and velocities of a group of particles in  dimensional problem space while Nonograms puzzles constraints.
2) Position updating 3) Memory updating  and .4) if stopping criteria is satisfied then stop PSO, else go to Step 2.

III. DIW-PSO FOR SOLVING NONOGRAMS PUZZLES
In this section, the DWI-PSO in solving Nonograms puzzle is described.The fitness function has a major role in the DWI-PSO algorithm, since it is the only standard of judging whether a particle is "best" or not.The fitness function for Nonograms puzzles is calculated as follow: where - , is the total number of colored pixels at row r of individual , -  is the total number of colored pixels at row r of the puzzle, - , is the total number of colored pixels at column r of individual , -P  is the total number of colored pixels at column r of the puzzle. The , and  k i = x k i .And also since the �   � < (  ), which indicates that current    is better than   , then set f best g = �   �, and At each iteration step, velocities of all particles are modified using "(2)", so the velocity of particle  at iteration  ( Fig. 3) according to "(1)" is: where = 1 ,  1 =  2 = 2,    = 0,  1 = 0.2,   = 3, and  2 = 0.8 After calculating the velocity, and between successive iterations, the modification of the particle position is controlled by the new calculated velocity.The modified position of    is done by adding the   +1 to the    , as defined in "( 2)": The result of the above equation means that the current particle    must be shifted one cell to right.Fig. 4 illustrates the result of shifting    .Generally, the procedure for the proposed algorithm consists of the following steps: Step 1: Initialization 4. Calculate the inertia weight using (3).
2.8.repeat steps 2.1 -2.4 until a sufficient good fitness or a maximum number of iterations are reached.
Step 3: Terminate DWI-PSO parameters are as in Table 1.To solve the Nonograms puzzle we set the population size equal to the number of rows times number of columns in the Nonograms puzzle, maximum Number of iterations are considered as 10, 20, 50,100 and 1000, respectively, 1 = 2 = 2 , and   and   are equal to the length of the search space [6,11].In addition, the inertia weight starts with 1.4 and decreases nonlinearly to 0.4 [12].

V. CONCLUSION
In this paper, we presented a new algorithm for solving Nonograms.The process of PSO algorithm in finding optimal values follows the social behavior of bird flocks and fish schools which has no leader.Particle swarm optimization consists of a swarm of particles, where particle represent a potential solution.Particle will move through a multidimensional search space to find the best position in that space.Particle swarm optimization (PSO) is a promising scheme for solving NP-complete problems due to its fast convergence, fewer parameter settings and ability to fit dynamic environmental characteristics.
The Nonograms problem is known to be NP-hard.The challenge is to fill a grid with black and white pixels in such a way that a given description for each row and column, indicating the lengths of consecutive segments of black pixels, is adhered to.
Firstly, this paper investigates the principles Nonograms puzzle and the general procedure for finding the puzzle solution.Moreover, the principles and optimization steps of Dynamic Inertia Weight Particle Swarm Optimization DWI-PSO and the influence of different parameters on algorithm optimization has been introduced in details.
In this paper, DWI-PSO has been applied for solving Nonograms puzzle.A dynamic inertia weight introduced to increase the convergence speed and accuracy of the PSO while searching for the best solution from Nonograms puzzle.The excremental results demonstrate the effectiveness, efficiency and robustness of the proposed algorithms for solving large size Nonograms puzzles.
In summary, we presented a DWI -PSO algorithm that has been successfully applied to NP-Complete puzzles.For future work, we will consider DWI-PSO for more challenging NP-Complete puzzles such as the Cross Sum, Cryptarithms, and Corral Puzzle.

Fig. 2 .
Fig. 2. The search mechanism of the particle swarm optimization

Fig. 3 .
Fig. 3.An example to illustrate the Nonograms fitness function

Table 2
shows the success DIW-PSO in solving Nonograms puzzle.Success rate represents the number of runs out of the maximum number of iterations.

TABLE II .
SUCCESS RATE OF VARIOUS METHODS