Nature-inspired optimization algorithms in knapsack problem: A review

: Meta-heuristic algorithms have become an arising field of research in recent years. Some of these algorithms have proved to be efficient in solving combinatorial optimization problems, particularly knapsack problem. In this paper, four meta-heuristic algorithms are presented particle swarm optimization, firefly algorithm, flower pollination algorithm and monarch butterfly optimization in solving knapsack problem as example of NP-hard combinational optimization problems. Based on twenty 0-1 knapsack problem instances, the computational results demonstrated that the binary flower pollination algorithm has the ability to find the best solutions in reasonable time.


Introduction
Combinatorial optimization "problem is a mathematical study of finding optimal solution from a finite set of objects. The popularity of combinatorial optimization problems comes from the fact that the objective function and constraints in many real-world problems have a different nature (nonlinear, nonanalytic, etc.), while the search space is finite. In such problems, exact methods are impractical in finding an optimal solution because the run time is increasing exponentially with the problem size. Therefore, interest in the application of the meta-heuristic algorithms has become a necessary to solve these problems and obtain the results" in a reasonable time [El-Ghazali 2009, Beheshti et al. 2012].
In recent years, the "nature inspired meta-heuristic algorithms have been used successfully for solving hard and complex problems in real-world problems. The meta-heuristic algorithms are stochastic algorithms inspired by the behavior of different species in nature Pirlot (1992) and Osman (1995) define meta-heuristic as follows "A meta-heuristic is an iterative generation process which guides a subordinate heuristic by combining intelligently different concepts for exploring and exploiting the search space using learning strategies to structure information in order to find efficiently near-optimal solutions" [Osman and Kelly 1996]. The metaheuristic algorithms use search strategies and concepts inspired from nature to explore several regions of the search space more effectively and focusing on some likely regions of the search space. Every meta-heuristic algorithm consists of a set of initial population or initial solutions, the sequence of solutions is then examined step by step based on randomization and some specified rules to reach the optimal solution. These algorithms have the ability to deal with many of optimization problems because of its simplicity and flexibility" [Yang 2014a The aim of this paper is to investigate the effectiveness of the nature inspired meta-heuristic algorithms when dealing with a combinatorial optimization problem such as 0-1 knapsack problem.

Related work
Knapsack problem is "a combinatorial optimization problem and NPhard problem. In such problems, there is no effective algorithm to solve all their instances. These problems need alternative methods because exact methods usually cannot deal with the large size of these problems [Yang 2014a, Yang 2015]. There are many meta-heuristic algorithms applied in solving a knapsack problem such as genetic algorithm (GA), particle swarm optimization (PSO), ant colony optimization (ACO), harmony search (HS),and whale optimization algorithm ,and so on.
Particle swarm optimization is one of the meta-heuristic algorithms that has been applied to many combinatorial optimization problems, namely knapsack problem. Bansal and Deep [2012] proposed a new modified binary particle swarm optimization for solving 0-1 knapsack problem and multidimensional knapsack problem, and introduced a new probability function which maintains the diversity in the particle swarm.
The meta-heuristic firefly algorithm was developed by Yang [2008]. Firefly algorithm mimics the behavior of fireflies which is based on flashing and attraction properties of fireflies. Zouache et al. [2015] proposed a new hybrid algorithm that combines firefly algorithm and particle swarm optimization and use the basic concepts of quantum computing to ensure a better solution diversity. The proposed algorithm has been tested on 0-1 knapsack problem and multidimensional knapsack problem. Feng et al. [2017] proposed a novel global firefly algorithm for tackling randomized time-varying knapsack problem .
The flower pollination algorithm is a meta-heuristic algorithm which mimic the pollination characteristics of flowers in plant.

Knapsack problem
Knapsack problem is "one of the NP-hard combinatorial optimization problems which has been widely studied in operation research. Knapsack problem consists of a set of n items, each item i has a profit i c , weight i w and maximum weight capacity M . The objective is to maximize the total profit of the selected items in the knapsack such that the total weights of these items are achieved" ( Mathematically, the knapsack problem can be written as: the penalty function is used to deal with the knapsack problem according to the following equation: and  represent the penalty coefficient. In this paper  is set to 10 10 for all tests. The penalty function can be described in Algorithm 1.

Algorithm 1: Penalty function
A repair operator treats "the infeasible solutions which violates the constraint in Eq. (2) by converting them into feasible solutions and also improve the feasible solutions. The repair operator algorithm can be applied by two stage. The first stage is to convert the infeasible solution into feasible by taking out the items of the lower / ii cw ratio so as the constraint in Eq. (2) is not to exceed the knapsack capacity. The second stage is to improve the feasible solution by adding the items of the high / ii cw ratio to the knapsack with keeping" of the constraint.

Particle Swarm Optimization (PSO)
Particle swarm optimization is one of the meta-heuristic algorithms which was proposed by Kennedy and Eberhart [1995] for "solving continuous optimization problem. Particle swarm optimization is inspired by swarm behavior in nature like birds and fish schooling. The particle swarm optimization algorithm started with number of particles N which fly in the search space to search the best solution. Each particle i has a position   12 , ,......., . Each particle is updated through each iteration based on two values: the first value is the best solution   pbest which has been obtained by the particle, and the second value is the current best value   Gbest which has been obtained in the swarm " ( where t is the current iteration in the algorithm, w refers to the inertia weight. 1 c , 2 c refer to the accelerated variables or learning factors and 1 r , 2 r are the random numbers   0,1  obtained from uniform distribution. The pseudo code of the particle swarm optimization can be shown in Algorithm 2.

Algorithm 2: The pseudo code of the particle swarm optimization algorithm
Particle swarm optimization has been firstly "proposed for continuous optimization problems where velocity and position are real values. Therefore, it is not able to tackle a binary optimization problem such as knapsack problem. Kennedy and Eberhart [1997] developed a new version of particle swarm optimization, called binary particle swarm optimization (BPSO) to deal with problems with binary search space. In BPSO the position of particles takes the values 0 or 1. The velocity updating remains as defined in Eq. (4), then sigmoid function is used to transform the real values to the binary values according to the following equations [Haddar et al. 2016]: Where r is a random number

 
Sv is the sigmoid function.

Firefly Algorithm (FA)
Firefly algorithm is a meta-heuristic algorithm "developed originally by Yang [2008] for solving continuous optimization problems. Firefly algorithm is a simulated behavior of fireflies which based on flashing and attraction properties of fireflies. There are two main points in firefly algorithm: variation of light intensity and formulation of attractiveness. The brightness of firefly depends on the objective function. The attractiveness of firefly is proportional to brightness. Thus, for any two flashing fireflies the less bright one moves towards brighter one, while it will move randomly when there is no brighter one than a specific firefly". The attractiveness  of a firefly with the distance r can be defined as: where r is the distance between two fireflies,  is a light absorption coefficient and 0  is the attractiveness at 0 r  . The distance between two fireflies i and j is computed using the Euclidean distance: where , ik x is the k th component of the i th firefly. The movement of a firefly i attracted by another firefly j that is brighter is computed as: where  is a parameter which controls the step and rand is a random number   Where r is a random number

Flower Pollination Algorithm (FPA)
Yang [2012] proposed "a new algorithm for global optimization called flower pollination algorithm. It is a meta-heuristic algorithm that mimics the nature, inspired of the pollination process in flowers. The pollination in flowers can be take two forms: biotic pollination and abiotic pollination. In the first type, the pollen is transferred by a pollination like insects and animals. While the second form is based on wind and diffusion in the water.
Pollination in flowers can be divided into self-pollination and crosspollination. Self-pollination is transferring the pollens from one flower to the same flower or different flowers in the same plant. Cross-pollination is transferring the pollens from one flower to another flower of a different plant. A flower and its pollen represent a solution of the optimization problem. In the flower pollination algorithm four basic rules are used [ 3. Flower constancy can be considered as the reproduction probability that is proportional to the similarity of two flowers involved. 4. The interaction or switching of local pollination and global pollination can be controlled by a switch probability   0,1 p  . Rules 1 and 3 can be expressed mathematically as: (13) where t i x is the solution vector or the pollen i at iteration t , * g is the current best solution that is found at the current iteration,  is a scaling factor to control the step size,   L  is the step size "in the lévy flights which is representing the strength of the pollination. Since pollinators move over a long distance with various distance steps, a lévy flight can be used to mimic this behavior. That is, 0 L  from a lévy distribution as      (16) For local pollination, rules 2 and 3 can be expressed as: where j x and k x are the pollens (solution vectors) from different flowers of the same plant.
k is the parameter drawn from uniform distribution in   0,1 . To switch between common global pollination to intensive local pollination we used rule 4 [Yang ,2012] suggested that the switch probability or proximity probability is equal to 0.8 p  for most applications. The pseudo code of the flower pollination algorithm can be presented" in Algorithm 4.
Where r is a random number   0,1  ,   Sxis the sigmoid" function.

Monarch Butterfly optimization (MBO)
Wang Deb et al. [2015] proposed a new meta-heuristic "algorithm for continuous optimization problems called monarch butterfly optimization. It is inspired by simulating the migration behavior of the monarch butterflies from northern USA and southern Canada to Mexico every summer. In MBO algorithm the entire population can be divided into two subpopulations, subpopulation 1 and subpopulation 2 which lived in land 1 and land 2 respectively. The number of monarch butterflies in land 1 and land 2 are (NP1=NP*p) and (NP2=NP-NP1) respectively, where NP is the size of the entire population and p is the proportion of monarch butterflies in subpopulation 1. The monarch butterfly optimization algorithm has two main operators: the migration operator and the butterfly adjusting operator"

Migration Operator
The migration process can be described as follows: x at generation t , that is the newly generated position of the monarch butterfly 2 r . Monarch butterfly 2 r is randomly selected from subpopulation 2, where r can be computed as follows: * r rand peri  (22) where peri represents the migration period and rand is a random number in   0,1 . Based on the above analyses, the migration operator can be expressed in" Algorithm 5 , Wang et al. 2016].

Butterfly Adjusting Operator
In butterfly adjusting process, "the position of the monarch butterflies in subpopulation 2 is updated by updating all the elements in monarch butterfly j . If rand p  where rand is a random value in   0,1 then it can be updated as:  (25) where BAR is the butterfly adjusting rate. dx is the walk step of the monarch butterfly j that can be calculated by performing Levy flight :  is the weighting factor that can be calculated by following equation:

max
St   (27) where max S is the max walk step that a monarch butterfly individual can move in one step and t is the current generation. The butterfly adjusting operator" can be described in Algorithm 6 , Wang et al. 2016]. The standard monarch butterfly optimization algorithm was proposed to "handle a continuous optimization problem. In discrete optimization problems the standard method cannot be applied directly to deal with such a problem. Therefore, the sigmoid function is used to convert the continuous values into binary: Where r is a random number   0,1  ,   Sxis the sigmoid" function.  Table (1) shows the comparison results among four meta-heuristic algorithms" (PSO, FA, FPA and MBO) . The computation results for the four algorithms are presented in Table 1. The best solution, mean iteration (average number of iteration for obtaining the optimal solution for all run times of the same instance) and average executed times are used to measure the performance for these algorithms. The average executed times for all algorithms (BPSO, FA, BFPA and BMBO) are (1.53815, 1.52495, 1.1269 and 1.30795 respectively). In order to analyze the results in Table 1 and based on mean iteration and average executed times we can infer the order of the algorithms as follows: (BFPA, BMBO, FA and BPSO). Therefore, the binary flower pollination algorithm gives performance better than other algorithms (BPSO, BFA and BMBO) for solving 0-1 knapsack problem instances. All algorithms (BPSO, BFA, BFPA and BMBO) succeeded in finding the optimal solution for all 0-1 KP instances but BFPA has the least mean iteration and least average executed times compared to other algorithms".

Conclusion
In this paper, four meta-heuristic algorithms for solving knapsack problem have been reviewed. Table (1) shows that the BFPA has fast convergence and stability better than other used algorithms. It may be appropriate to suggest that the best algorithm for solving 0-1 knapsack problem is BFPA. Future work includes using this algorithm for solving other combinatorial optimization problems and hybridization with other algorithms.