Adaptation of a Mosquito Swarm Algorithm to Solve a Binary Knapsack Problem

The paper tackled one of the artificial intelligence algorithms which is Mosquito swarm algorithm as a nature inspired algorithms, to solve 0-1 knapsack an optimization problem through adaptation steps of a Mosquito swarm algorithm and the inspiration coming from the behavior of Mosquitoes, in addition to propose steps (update) for Chemical sensors, Heat sensors and location of Mosquito, to find an optimal solution in small search space and small computational requirements. A program is written in MATLAB 7.10 مlanguage to simulate this algorithm with 0-1 knapsack problem. The experimental results in this research showed effective approach, easy implementation of algorithm to find optimal solution.


Introduction
Recently in computer science, there is an increased interest in computational approaches that are inspired by the principles of nature and that can solve difficult problems. Whereas, physical and biological sciences try to find microscopic laws that extrapolate to the macroscopic realm, computer science is principally synthetic and is concerned with the construction of algorithms that may be inspired by physics or biology.
Computing can be seen as a property of nature, therefore by mimicking natural phenomena; it is possible to construct new intelligent algorithms for solving computationally difficult problems called Nature -inspired algorithms [3,4]. They mimic different natural systems and processes using mathematical models and algorithms.
This research presents the classical 0-1 Knapsack problem to pick up items for a knapsack for maximum total value, so that the total resource required does not exceed the resource constraint R of the knapsack. The classical 0-1 Knapsack problem and its variants are used in many resource management applications such as cargo, loading, industrial production, menu planning, and resource allocation in multimedia servers [1].
In 2012,Yan et al used particle swarm optimization algorithm to solve the traveling salesman problems and experiment results are efficient than the genetic algorithm. In 2013, Feng et al proposed a new branch of biology inspired algorithm Mosquito host seeking algorithm and they are applied to solve traveling salesman problem. The proposed Mosquito host seeking algorithm is fundamentally different from the other popular nature algorithm in its motivation, principle, the optimization mechanism and so on.. they showed the actual times and iterations used to solve traveling salesman problems on a cluster, which can verify the efficiency and parallelism of Mosquito host seeking algorithm.
This research aims to adaptive a Mosquito swarm algorithm to solve a binary Knapsack problem coming from the behavior of Mosquitoes, to find an optimal solution in small search space and small computational requirements. This research is proposed (update) for Chemical sensors, Heat sensors and location of Mosquito. Locally, this research is a first study so that other researches are not available to be compared with it.
In this paper, besides this an introductory section; section 2 presents the problem definition. In section 3 described particle swarm optimization algorithm, methodology of Mosquito swarms algorithm. Section 4 described proposed steps to solve knapsack problem using Mosquito algorithm by experimented results, flowchart of the problem and problem instance. Finally, conclusions, recommendations in section 5 and section 6 respectively.

Problem Definition
The name knapsack problem invokes the image of the backpacker who is constrained by a fixed-size knapsack, and so must fill it only with the most useful and portable items [9]. The binary knapsack problem is one of the most important models in combinatorial optimization, having numerous real life applications as well as being an important sub-problem in several algorithms for more complex problems [2,7]. For the 0-1 knapsack problem, it involves with selecting items or projects to maximize total profit without exceeding the existing capital budget or knapsack capacity. The problem has several applications in naval, financial management and steel industry [10]. Suppose a hitch-hiker has to fill up his knapsack by selecting from among various possible objects those which will give him maximum comfort. This knapsack problem can be mathematically formulated by numbering the objects from 1 to n and introducing a vector of binary variables x j , (j =1,---,n) having the following meaning: [6] 1 If object j is selected x j = 0 Otherwise Then, if p j is a measure of the comfort given by object j, w j its size and C the size of the knapsack, our problem will be to select, from among all binary vectors X satisfying the constraint The one which maximizes the objective function The problem is to find an optimal subset of items so as to maximize the total profits subject to the knapsack's weight capacity. The profits, weights and capacities are positive integers. Figure (1) illustrated knapsack problem graphically.

Particle Swarm Optimization Algorithm
Particle swarm optimization algorithm was an intelligent technology first presented in 1995 by Eberhart and Kennedy, and it was developed under the inspiration of behavior laws of bird flocks, fish schools and human communities [5].
A basic variant of the particle swarm optimization works by having a population (called a swarm) of candidate solutions (called particles). These particles are moved around in the search-space according to a few simple formula. The movements of the particles are guided by their own best known position in the search-space as well as the entire swarm's best known position. When improved positions are being discovered, these will then come to guide the movements of the swarm. The process is repeated and by doing so, it is hoped, but not guaranteed, that a satisfactory solution will eventually be discovered. Particle swarm optimization achieves its optimum solution by starting from a group of random solution and then searching repeatedly. Particle swarm optimization is a meta-heuristic as it makes few or no assumptions about the problem [11]. Swarm algorithms refers to any algorithm that models the grouping of insects and zooplankton swarms by social behavior. The swarm algorithms are inspired by the insect swarms and zooplankton swarms [8].

Mosquito Swarms Algorithm
Ruiz-Vanoye and Díaz-Parra in (2012) propose the Mosquito swarm algorithm. The Mosquito swarm algorithm is considered as a meta-heuristics algorithm, a bioinspired algorithm, parallel or distributed algorithm based on the research on the social behavior of mosquito swarm. Mosquitoes (gnats) have sensors designed to track their prey: A) Chemical sensors, mosquitoes can sense carbon dioxide and lactic acid up to 36 meters away. Mammals and birds give off these gases as part of their normal breathing. Certain chemicals in sweat also seem to attract mosquitoes. B) Heat sensors, mosquitoes can detect heat, so they can find warm-blooded mammals and birds very easily once they get close enough. A mosquito swarm exists close to areas with standing water [8]. In this research, an algorithm called Mosquito algorithm has been used, which is a bio-inspired computing technique inspired by host-seeking behavior of mosquitoes swarms. In the real world, both male and female mosquitoes are nectar feeders, but the female of many species is also capable of drinking blood. Only female mosquitoes search the host (object) to attack. Female mosquitoes hunt their blood host by detecting carbon dioxide (CO2) and 1-octen-3-ol (C 8 H 16 O) from a distance. Female mosquitoes have host-seeking behavior, but male ones do not. As shown in Figure (2) a swarm of mosquitoes is randomly searching the host (object) to attack. We can summarize three steps of mosquito's host-seeking behavior as follows [3]: 1. The mosquito looks for carbon dioxide or smelling substance. 2. It distinguishes the smell it loves, and then seeks towards a high-concentration location.
3. It makes a descent when it feels the radiated heat of the host.

Methodology of Mosquito Swarms Algorithm
Below a description of the structure of the Mosquito algorithm in general [8]. Input: number of mosquitoes (m). 1-Initialize a mosquito population with Chemical Sensors (CS) and Heat Sensors (HS). 2. Generating the initial locations (x) of the mosquitoes (m). 3. Initialize the temperature (t) and maximum temperature (T). 4. Repeat (total of mosquitoes) by parallel and/or distributed processing. 5. Repeat (maximum temperature). 6. Generate new solutions by adjusting the Heats (HS) and updating the locations (x). 7. Verify and assign the feasibility of the solution by the Chemical Sensor (CS). 8. Select the best solution (S). 9. While t < T 10. While (m total of mosquitoes) 11. Report the best solutions.

Experimental Results with Proposed Steps
Below the proposed steps in this research to solve Knapsack problem by using Mosquito algorithm. Artificial mosquitoes can move towards the host (goal) under the factors as follows:  The personal host-seeking behavior.  The aggregate host-seeking behavior.  The attraction of the host.  The motion that is related to social coordination's among the swarm of artificial mosquitoes (update of location). In this research, we proposed the steps to initialize factors as CS, HS and location (x) as follows: If we have n objects and p j is a profit value, w j its size and C the size of the knapsack as in table (1). Table ( x i = (∑ CS j + HS i /z j ) * c , z j is objective function of the current solution. , where c is learning factor. In this research, learning factor c = 2. Step2: Find best solution with objective function: IF z is the objective function of Mosquitoes swarm ={z1,z2,…..zm} then best solution is max {z1, z2, …, zm}. Let S* , assign the best solution. Let x* , assign best location x. Step3: Iteration by parallel do the following: Generate a new solution by adding the item that is not found in the previous solution and, then adjusting heats (HS) and updating the locations (x) by using sub steps A, B and C in step1.
Step4: Verify and assign the feasibility of the solution by the chemical sensor (CS) by: IF current solution is better than S* then, S* = current solution. X* = current position.

Goto step 5 ElSE
Do not change S* Step5: IF T =10 then, report the best solution that contains subset of items that satisfies the maximum objective function and constraints with capacity = C. Go to step 7 ElSE Step6: Repeat the steps from step 3.
Step7: End. Figure (3) below illustrates the flowchart of the Knapsack problem solution by Mosquito algorithm:

Problem Instance
There are 8 items where each item j has a weight w j , a benefit or profit value p j and the knapsack capacity must carry items of total weight at most (102) as in table (2).  Items  1  2  3  4  5  6  7  8  Weights  2  20  20  30  40  30  60 10  Profit values  15  100  90  60  40  15  10 1 Solution: 1-The initial population of our problem is as shown in table (3), representation of general problem in Figure ( 4).   [  See column  3 of table 4, (m1 and m6) has the same weight but we take m6 because it satisfies maximum z, so, it becomes best z* solution up now.

Figure (5) Representation of Ten Solutions and How Far From Optimal Solution
3-During the steps of mosquito algorithm to this problem, we found two types of solutions feasible and not feasible; not feasible solution that is far from optimal solution. after generating a new solution and updating HS, CS and locations in iteration 2. We obtain table (5), also m6 is the optimal solution. After iteration 3, we obtain the results described in table (6). (m3, m7 and m8) all of them satisfy the capacity of knapsack, but we consider m7 as an optimal solution because it satisfies the maximum benefit of items, see Figure (6). Finally, the optimal solution is [ 1 1 1 1 0 1 0 0] which has items {1,2,3,4 and 6}. Figure (7) provided a graphic illustration of relationship between the solutions and their locations in our example in three iterations.

Conclusions
In this research, we present proposed steps (update) for Chemical sensors, Heat sensors and location of Mosquito to solve Knapsack problem by using Mosquito algorithm. This research shows a great efficiency in solving this problem by Mosquito algorithm. The advantage of this research is to reach easily into optimal solution of Knapsack problem by partical swarm optimization as Mosquito algorithm for any size of a knapsack problem, so that, we used a big size as 8 items and size 10 of population that generate all possible solutions, there are 2 n subsets generated compared with the classical methods.

Recommendations
The Mosquito swarms algorithm considerd as a new method to solve combinatorial optimization problem to reach the optimal solution of types for Knapsack problem such as Bounded knapsack problem, Subset-sum Knapsack problem, Change making Knapsack problem and Binary Multiple knapsack problem. Solving Knapsack problem by meta heuristic algorithms as Tabu search, Ant colony and Cuckoo search method.