An implementation of an initial scale in solving Binary Knapsack Problem using a Genetic Algorithm

In this paper, we used a new operation in a Genetic Algorithm for solving the binary Knapsack problem depending on it ’ s LP Relaxation solution after eliminating the fractional part of the non-binary values. The benefit is to make a filter to the initial random population from the farness of the optimal solution and unsuitable chromosomes. This good property will be fixed automatically in all generations in the Genetic Algorithm until reaching the optimal binary solution


Introduction to Genetic Algorithm:
A Genetic Algorithm (GA) was first introducted by John Holland for the formal investigation of the mechanisims of natural adaptation but the algorithm has been since modified to solve computational search problems, GA has been used to solve the NP-hard combinatorial problems effectively such as Knapsack Problem.[2] GA is a heuristic search algorithm for the solution of optimization problems in which starting from a random initial guess solution, better descendants are tried in an attempt to find one that is the best under some criteria and conditions.[5] GA is a computer algorithm that searches for good solutions to a problem from among a large number of possible solutions.It begins with a set of candidate solutions (chromosomes) called population.A new population is created from solutions of an old population in hope of getting a better population.Solutions which are chosen to the new solutions (offspring) are selected according to their fitness.The more suitable solutions are the bigger chances they have to produce.
The chromosomes in GAs represent the space of candidate solutions.possible chromosomes encoding are binary, permutation, value, and tree encodings [1].For the Knapsack Problem we use binary encoding, where every chromosome is a string of bits "0" or "1".[4]

Basic operations for Genetic Algorithm:
The basic operations for Genetic Algorithm are, see figure (1), and buttom some outlines of those operations.

Population:
A population of possible solutions is randomly created.As stated before, this will be a population of random sets of 1's and 0's.Weighting more 1's or more 0's is problem-specific.

Fitness:
In order to decide which solutions or chromosomes are better, the idea of fitness is introduced.Each possible solution has a fitness calculated by a fitness function.This fitness function must take into account what the actual problem is asking for and derive some sort of formula to decide how close each chromosome is to solving the problem.The form of the fitness function we used in this paper is is the objective function.

Selection:
The selection operation will find very fit chromosomes to be used as parents of the next generation.Also, since not only the fittest of chromosomes should be able to reproduce, there must be some randomness involved in parents selection .Here are some kinds of selection operation.

(i) Roulette-wheel selection:
Parents are selected according to their fitness.The better chromosomes are the more chances to be selected they have.Imagine a roulette wheel where all chromosomes are placed in the population occupying space according to their fitness function.Then marble is thrown there and it selects the chromosome.A chromosome with bigger fitness will be selected for more times [1].

(ii) Linear rank selection:
In the beginning, the potentially good individuals sometimes fill the population too fast which can lead to premature convergence into local maxima.On the other hand, refinement in the end phase can be slow since the individuals have similar fitness values.These problems can be overcome by taking the rank of the fitness values as the basis for selection instead of the values themselves.

(iii) Tournament selection:
In this scheme, a small group of individuals is sampled from the population and the individual with best fitness is chosen for reproduction.This selection scheme is also applicable when the fitness function is given in implicit form, i.e. when we only have a comparison relation which determines which of the two given individuals is better.[2] Another idea often used is Elitism.This means that the best chromosomes of a generation automatically used to the next generation.This is especially useful to assure that, at worst, the next generation will have a solution as good as the last generation [7].
Crossover: When referring to reproduction in genetic algorithms, the word crossover is used.If you consider that reproduction is really a "crossing over" of two parent's genes into a child, this makes perfect sense.Crossover is preformed by taking two parents chromosomes solutions and swapping a certain number of their bits.seefigure (2).

Figure (2): Flowchart of general crossover operation [3]
Mutation: Mutation is another genetic operation that introduces more randomness to a population.An example of mutation in nature would be albino animals.These animals have an altered genetic make-up that changes their fitness in their environment.GA mutation works the same way.Mutation changes the new child by flipping bits from 1 to 0 or 0 to 1. [7], see figure

Binary Knapsack problem:
The Binary Knapsack Problem is one of the most important model in combinatorial optimization, having numerous real-life applications as well Assume that n items are given, each item having a nonnegative integer profit j p and weight j w , for n j ,..., 2 , 1 = . The problem is to select a subset of the items, so that their overall profit is maximized without using the overall weight to exceed a given capacity C .Formally we may define the problem as: In this case a suitable fractional of items is chosen so that all the remaining capacity is used.The items will be denoted by the split item.The / m w , the corresponding solution value will be: The The Binary Knapsack Problem form will be: Maximize Simply the first item which does not fit into the knapsack according to

Solution:
For each investment, the choice is either invest or not.This leads us to define for ) , by eq. ( 4):

Some known methods for solving BKP:
(i) Branch and Bound method: Branch and Bound (BB) is a well-known approach and general optimization technique which is used especially for NP-hard problems.BB depends on the LP Relaxation solution of the problem and works by branching or partioning it into many smaller subsets (nodes) such that: and this branching operation continues on the feasible solution until reaching to the optimal solution.
(ii) Dynamic Programming: Dynamic Programming (DP) is a mathematical optimzation technique used for making a series of interrelated decisions.Usally, a multi-stage decision process is transformed into a series of single-stage decision process.
DP starts with a small portion of the problem and finds the optimal solution for this smaller problem.It then qradually enlarges the problem, finding the current optimal solution from the previous one, until the original problem is solved in its entirety.For more detials about BB & DP see [8] & [9], respectively.

Genetic Algorithm with LP Relaxation:
Here we are trying to put a new operation in Genetic Algorithm depending on the LP Relaxation solution after elimination the fractional part from the non-binary values and fixing the value of the variable which has the biggest profit in the objective function, this operation works only in the first of the Genetic Algorithm exactly before the fitness step and in the initial random population and automatically the result of this operation is fixed in the other created generations in future under condition that this solution exists in the initial population.We called this algorithm LPG Algorithm and the following is its outlines.

Outlines of the new suggested LPG Algorithm:
Step 1:[Initial Population]: Population of possible solutions is randomly created.
Step 2:[Filtering]: Fix the chromosomes in step1 which have the value of the variable with the largest profit and delete the others which do not have this value.Step 5:[Replace]: Use new generated population for further run of algorithm .
Step 6:[Problem Solved?]:If the end condition is satisfied (like the number of generations or the generated maximum solution is repeated), stop, and return the best solution in current population else go to step 3.

Numerical Results using LPG Algorithm: In Problem (1):
The LP Relaxation solution after cutting the fractional part from the non-binary values will be: (1, 1, 0, 0) which will exist in the initial population.Now, Since 2 x has the largest profit ( 22 2 = p ) therefore we fix only chromosomes in the initial random population with this value (i.e.bit2 =1) and delete the others, this is called filtering.The initial random population will be as follows with size=4: By filtering the population from the chromosomes without (bit2 =1) we get a new population with size=3 which is less than the initial random population size and we continue under this size, such that: From the generations 2 and 3 we got the same maximum solution 42 and this is the optimal solution for our problem and this is the stop criteria.

In Problem (2):
The LP Relaxation solution after cutting the fractional part from the non-binary values will be: (1, 1, 0, 0, 0, 0) which will exist in the initial population.
Since 1 x has the largest coefficient in the objective function therefore we fix only chromosomes in the initial random population with this value (i.e.bit1 =1) and delete the others.The initial random population will be as follows with size=5: We observe that the solution of generation 3 is worse than the solution of generation 2, therefore, we stop the process, and hence the optimal solution is 74000.

Numerical Discussion:
The new genetic algorithm using filtering property in Problem 1 and Problem 2 makes finite reduction for the initial population size such that for problem 1 the initial population size is reduced from 4 chromosomes to 3 and for problem 2 the initial population size is reduced form 5 chromosomes to 3, and this makes reducing the number of generations at least or equal the number of the generations under the general genetic algorithm.

Conclusion:
We have shown that how the genetic algorithm under filtering property can be used to find a good solution for the Binary Knapsack Problem.By using filtering the initial randomly population from the farness and unsuitable chromosomes by choosing only possible chromosomes under the LP Relaxation solution of the problem and this property will be fixed automatically in all generations until reaching the optimal binary solution.
This property makes the Genetic Algorithms more powerful for solving the binary problems and even for problems with a big size of generations.This will be done by reducing this size and by remaining the chromosomes with largest profit which guarantee the existness of the optimal solution by the benefit of the LP Relaxation of these problems.

Start
Randomly choose a crossover point Perform any type of crossover operation Stop Start Randomly choose a mutation point Perform bit inversion at this point Stop as being an important subproblem in several solution algorithms for more complex problems.

Step 3 :
[Fitness]: Evaluate the fitness (function value) of each chromosome in the population.Step 4:[New population]: Create a new population by repeating following steps until the new population is complete.(a):[Selection]:Select the parents chromosomes from a population according to their fitness (the better fitness=the bigger chance to be selected).(b):[Crossover]: Crossover operation is to create a new children (offspring) from the parents, If no crossover was performed, children are exact copy of parents.(c):[Mutation]: Mutation operator is performed by selection of random bits of the chromosome and replacing the value of the bit from "0" to "1" or vice versa.(d):[Accepting]: Place new children in a new population.
By doing crossover operation between the chromosomes in generation 1 we get a new chromosome which builds the generation 2, such that: mutation operation on the chromosome ( 0 1 0 0 ) to the new one ( 0 1 0 1 ) we get the next generation such that: The reason of not taking the chromosomes: ( 1 1 0 1 ) and ( 1 1 1 0 ) is because their solutions are infeasible.Again, by doing crossover operation on generation 2 we get a new generation such that: Doing crossover operation between the chromosomes in generation 1 we get a new generation 2, such that: doing crossover operation on generation 2 we get a new generation such that: solution value LP z to the linear problem is an upper bound on the solution value to the original Knapsack Problem.This means that z .Any feasible solution is, on the other hand, denoted a lower bound z .Obviously, we have (according to the table bottom).The climber knows that he will be able to carry items of total weight at most (14) kg.He would like to pack his knapsack in such a way that he gets the largest possible profit without exceeding the weight limit.
*for the optimal solution value * Now, the first item which does not fit into the knapsack according to