KEMBAR78
Knapsack problem solved by Genetic Algorithms | PPTX
Knapsack Problem solved by Genetic Algorithms
Supervisor : Professor G. Papadourakis
1/11/2015
Project: Evolutionary Computation
Knapsack problem first studied by Tobias Dantzig in 1897.
• 1950s First Dynamic programming algorithm, R. Bellman
• 1960s First Branch and Bound algorithm
• 1970s First Polynomial Approximation Schemes, Sahni
• 1990s First Genetic Algorithms implementations, Chu and Beasly
A 1998 study of the Stony Brook University showed, that the knapsack
problem was the 18th most popular algorithmic problem.
The knapsack problem is a problem in combinatorial optimization:
Given a set of items (N), each with a weight (Vi) and a value (Bi),
determine the number of each item (i) to include in a collection so that the
total weight is less than or equal to a given limit (V) and the total value is as
large as possible.
It derives its name from the problem faced by someone who is constrained
by a fixed-size knapsack and must fill it with the most useful items.
Luggage
Having a Journey with a low cost company like Ryanair with
a limitation at your handbag at 10 Kg.
What items should you take?
Burglar’s Dilemma
The burglar is facing a challenge. There are many
items to choose between, each with different value
and weight. The burglar wants to maximize the sum
of the values of the objects, but the sum of the
weight has to be less than 20
Dynamic Programming number of items and the capacity
Genetic Algorithm number of items and number of population
Knapsack Problem NP problem
I. User inputs the number of items he wants.
II. User inputs the name, the weight and the value of each item.
III. User inputs population, generation, crossover, mutation .
IV. Program is running till conditions meet (3 generations without better evolution).
V. Results indicate the whole process and inform the user about the items
he should take to maximize his value.
Item Weight Value
Laptop 6 340
Television 21 560
Painting 10 380
Total knapsack capacity = 28
The fitness function sums the corresponding weights and values for each
population member one by one. It then compares the population member’s total
weight to the knapsack capacity.
if(knapsack capacity >= population’s member total weight)
fitness value = population’s member total value
else
fitness value = 0
A/A Population
(individuals)
Fitness
1 010 560
2 101 720
3 011 0
4 110 900
Programming Language: Java
Environment: Eclipse
Building code from scratch based on other free source code:
• https://gist.github.com/NilsHaldenwang/972159 Ruby Programming Language
• https://github.com/mmmayo13/knapsack-problem-ga
Textbox outputs:
1) Population and Fitness over
generations.
2) Best solution and mean Fitness
over each generation
3) If crossover and mutation was
implemented and how many
times occurred.
4) Informs the user with the
items he should take.
User setting
the number of
items he
wants to take
with him.
User setting
the number of
items he
wants to take
with him.
Program informs the
user, how many
items are left to
input.
Input dialog pop up in order to
take user inputs for each item
with 3 elements, item name,
item value and item weight.
Text fields unlock,
user just configured
10 for capacity, 100
population, 200
generations,
crossover prob. 80%
and mutation prob.
1%.
Finally he’s ready for
execution.
Calculate
optimal list of
items
Optimal list
Criterion met
Initialize Population
Evaluate Population – Fitness Function
Breed Population
Crossover
Mutation
[1] M. Lagoudakis, “The 0-1 knapsack problem—An introductory survey,” Citeseer.
Nj. Nec. Com/151553. Html, 1996.
[2] M. Hristakeva and D. Shrestha, “Solving the 0-1 knapsack problem with genetic
algorithms,” Midwest Instr. Comput. …, 2004.
[3] M. Hristakeva and D. Shrestha, “Different Approaches to Solve the 0/1
Knapsack Problem,” Retrieved Novemb., pp. 0–14, 2004.
[4] J. J. Bartholdi, “Building Intuition,” vol. 115, 2008.
[5] http://www.nils-haldenwang.de/computer-science/computational-
intelligence/genetic-algorithm-vs-0-1-knapsack
[6] https://github.com/mmmayo13/knapsack-problem-ga
[7] L. S. - and M. L. -, “Comparative Study on the Knapsack problem based on PAR
Method and other Methods,” Int. J. Digit. Content Technol. its Appl., vol. 6, no.
18, pp. 211–218, 2012.
[8] C. H. Papadimitriou, “On the Complexity of Integer Programming,” vol. 28, no.
4, pp. 765–768, 1981.
[9] R. C. Eberhart and Y. Shi, Computational Intelligence: Concepts to
Implementations, no. March. 2007.
[10] M. Melanie, “An introduction to genetic algorithms,” Cambridge, Massachusetts
London, England, …, p. 162, 1996.
[11] L. S. - and M. L. -, “Comparative Study on the Knapsack problem based on PAR
Method and other Methods,” Int. J. Digit. Content Technol. its Appl., vol. 6, no.
18, pp. 211–218, 2012.
Knapsack problem solved by Genetic Algorithms

Knapsack problem solved by Genetic Algorithms

  • 1.
    Knapsack Problem solvedby Genetic Algorithms Supervisor : Professor G. Papadourakis 1/11/2015 Project: Evolutionary Computation
  • 2.
    Knapsack problem firststudied by Tobias Dantzig in 1897. • 1950s First Dynamic programming algorithm, R. Bellman • 1960s First Branch and Bound algorithm • 1970s First Polynomial Approximation Schemes, Sahni • 1990s First Genetic Algorithms implementations, Chu and Beasly A 1998 study of the Stony Brook University showed, that the knapsack problem was the 18th most popular algorithmic problem.
  • 3.
    The knapsack problemis a problem in combinatorial optimization: Given a set of items (N), each with a weight (Vi) and a value (Bi), determine the number of each item (i) to include in a collection so that the total weight is less than or equal to a given limit (V) and the total value is as large as possible. It derives its name from the problem faced by someone who is constrained by a fixed-size knapsack and must fill it with the most useful items.
  • 4.
    Luggage Having a Journeywith a low cost company like Ryanair with a limitation at your handbag at 10 Kg. What items should you take? Burglar’s Dilemma The burglar is facing a challenge. There are many items to choose between, each with different value and weight. The burglar wants to maximize the sum of the values of the objects, but the sum of the weight has to be less than 20
  • 5.
    Dynamic Programming numberof items and the capacity Genetic Algorithm number of items and number of population Knapsack Problem NP problem
  • 6.
    I. User inputsthe number of items he wants. II. User inputs the name, the weight and the value of each item. III. User inputs population, generation, crossover, mutation . IV. Program is running till conditions meet (3 generations without better evolution). V. Results indicate the whole process and inform the user about the items he should take to maximize his value.
  • 7.
    Item Weight Value Laptop6 340 Television 21 560 Painting 10 380 Total knapsack capacity = 28 The fitness function sums the corresponding weights and values for each population member one by one. It then compares the population member’s total weight to the knapsack capacity. if(knapsack capacity >= population’s member total weight) fitness value = population’s member total value else fitness value = 0 A/A Population (individuals) Fitness 1 010 560 2 101 720 3 011 0 4 110 900
  • 8.
    Programming Language: Java Environment:Eclipse Building code from scratch based on other free source code: • https://gist.github.com/NilsHaldenwang/972159 Ruby Programming Language • https://github.com/mmmayo13/knapsack-problem-ga
  • 9.
    Textbox outputs: 1) Populationand Fitness over generations. 2) Best solution and mean Fitness over each generation 3) If crossover and mutation was implemented and how many times occurred. 4) Informs the user with the items he should take. User setting the number of items he wants to take with him.
  • 10.
    User setting the numberof items he wants to take with him. Program informs the user, how many items are left to input. Input dialog pop up in order to take user inputs for each item with 3 elements, item name, item value and item weight.
  • 11.
    Text fields unlock, userjust configured 10 for capacity, 100 population, 200 generations, crossover prob. 80% and mutation prob. 1%. Finally he’s ready for execution. Calculate optimal list of items
  • 12.
  • 13.
  • 14.
    Evaluate Population –Fitness Function
  • 15.
  • 16.
  • 17.
  • 18.
    [1] M. Lagoudakis,“The 0-1 knapsack problem—An introductory survey,” Citeseer. Nj. Nec. Com/151553. Html, 1996. [2] M. Hristakeva and D. Shrestha, “Solving the 0-1 knapsack problem with genetic algorithms,” Midwest Instr. Comput. …, 2004. [3] M. Hristakeva and D. Shrestha, “Different Approaches to Solve the 0/1 Knapsack Problem,” Retrieved Novemb., pp. 0–14, 2004. [4] J. J. Bartholdi, “Building Intuition,” vol. 115, 2008. [5] http://www.nils-haldenwang.de/computer-science/computational- intelligence/genetic-algorithm-vs-0-1-knapsack [6] https://github.com/mmmayo13/knapsack-problem-ga
  • 19.
    [7] L. S.- and M. L. -, “Comparative Study on the Knapsack problem based on PAR Method and other Methods,” Int. J. Digit. Content Technol. its Appl., vol. 6, no. 18, pp. 211–218, 2012. [8] C. H. Papadimitriou, “On the Complexity of Integer Programming,” vol. 28, no. 4, pp. 765–768, 1981. [9] R. C. Eberhart and Y. Shi, Computational Intelligence: Concepts to Implementations, no. March. 2007. [10] M. Melanie, “An introduction to genetic algorithms,” Cambridge, Massachusetts London, England, …, p. 162, 1996. [11] L. S. - and M. L. -, “Comparative Study on the Knapsack problem based on PAR Method and other Methods,” Int. J. Digit. Content Technol. its Appl., vol. 6, no. 18, pp. 211–218, 2012.