Skip to content

The knapsack problem is tried solving by genetic algorithm.

Notifications You must be signed in to change notification settings

iamardatasyurek/Knapsack-Problem

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 

Repository files navigation

Knapsack-Problem

In this project, the knapscak problem is solved by genetic algorithm. The solving is compared on CPU and GPU.

Used the ILGPU library to run through the GPU.

Steps

Step 1

  • Creating items with weight and amount values.
  • Creating chromosomes from items.
  • Calculating fitness values of chromosomes.

Step 2

  • Calculating probabilities from fitness values.
  • Calculating cumulative totals of probabilities.

Step 3

  • Selection of parents with using cumulative totals
  • Crossing genes of the parents

Parents
parents

Crossover Type 1
crossovertype1

Crossover Type 2
crossovertype2

Note: In the GPU calculation, only type 1 crossover was used.

Step 4

  • Mutation of 30-50% of the total chromosomes
  • Alteraion a random number of genes

mutation

Step 5

  • Ranking by amount value
  • Removal of excess chromosomes

Step 6

  • Go to Step 2 and repeat as many times as the number iteration

About

The knapsack problem is tried solving by genetic algorithm.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages