The Knapsack Problem is a combinatorial optimization problem, which search out a best solution from among many other feasible solutions. It is concerned with a fixed size knapsack that has positive integer capacity (or volume) V. There are n numbers of distinct items that may potentially be placed in the knapsack. Item i has a positive integer capacity(volume) Vi and integer benefit Bi. In addition, there are Qi quantity of item i available, where quantity Qi is a integer with positive value satisfying 1 ≤ Qi ≤∞.
Let Xi determines how many quantity of item i are to be filled into the knapsack. The aim is to:
Maximize
N
∑ Bi Xi i = 1
Subject to the constraints
N
∑ Vi Xi ≤V i = 1
And
0 ≤ Xi ≤Qi
If one or …show more content…
A state space tree is a rooted tree where each level represents a choice in the solution space that depends on the level above and any possible solution is represented by some path starting out at the root node and ending at a leaf node. The root node, by definition, has level 0 and represents the state where no partial solution has been made. A leaf has no offspring and represents the state where all choices making up a solution have been made. In the context of the Knapsack problem, if there are N possible items to choose from, then the kth level represents the state where it has been decided which of the first k items have or have not been filled into the knapsack also there are 2k nodes on the kth level and the state space tree’s leaves are all on level N …show more content…
Outline of basic GA s
1. Start: Randomly generate a population of N chromosomes.
2. Fitness: Calculate the fitness of all chromosomes.
3. Create a new population:
a. Selection: Randomly select 2 chromosomes from the population.
b. Crossover: Perform crossover on the 2 chromosomes selected.
c. Mutation: Perform mutation on the chromosomes obtained.
4. Replace: Replace the current population with the new population.
5. Test: Test whether the end condition is satisfied. else stop. If not, return in current population and go to Step 2.
Each repetition of this process is called generation. The entire generation sets are called a run. [14][16].
Complexity
The complexity of the genetic algorithm depends on the number of items (N) and the number of chromosomes in each generation (Size). It is