Introduction to Genetic Algorithms + Knapsack

studied byStudied by 3 people
5.0(1)
learn
LearnA personalized and smart learning plan
exam
Practice TestTake a test on your terms and definitions
spaced repetition
Spaced RepetitionScientifically backed study method
heart puzzle
Matching GameHow quick can you match all your cards?
flashcards
FlashcardsStudy terms and definitions

1 / 29

flashcard set

Earn XP

Description and Tags

30 Terms

1
what is a genetic algorithm?
algorithms inspired by evolutionary biology
New cards
2
when are genetic algorithms helpful?
helpful for areas where no solution seems available - GAs can find partial answer (near optimal solution) but other methods might be better
New cards
3
what features of genetic algorithms mimic evolution?
evolution process

gene

chromosomes

gene pool

adaptation
New cards
4
what is the evolution process?

the change in the gene pool over time

  • genes mutate randomly which introduces variation to gene pool

  • individuals survive through natural selection

  • populations evolve and breed via recombination

New cards
5
what is a gene?
biological hereditary unit passed on for generations
New cards
6
what is a chromosome?
cells where the nucleus contains multiple genes
New cards
7
what is a gene pool?
set of genes for a species
New cards
8
what is adaptation?
change in environment causes change in gene pool for survival
New cards
9
what is the representation for a genetic algorithm?
  • each gene is a binary digit

  • a chromosome is a single string of genes (digits)

  • a solution to a problem is encoded as a chromosome

New cards
10
how are the components for heuristic algorithms similar to genetic algorithms?
  • encoding = representation

  • encoding must cover whole search space (gene pool)

  • fitness function uses to rate the solution the chromosome represents

New cards
11
what is the knapsack problem?
  • NP-complete problem

  • given n items, each with a weight and value, determine the items to include in the knapsack so that the total weight is less than or equal to a given limit and the total value is as large as possible

<ul><li><p>NP-complete problem</p></li><li><p>given n items, each with a weight and value, determine the items to include in the knapsack so that the total weight is less than or equal to a given limit and the total value is as large as possible</p></li></ul>
New cards
12
what is the representation of the knapsack problem using genetic algorithms?

eg. binary encoding where 1 - take item, 0 - don’t take the item and length - number of items we have to consider

invalid solution could be all 1s, means the weight limitation stated in the problem brief would be invalid

to deal with them

  • create only valid chromosomes from start by catering to conditions

  • create any solution and deal with validity afterwards

consider this when we create a representation

<p>eg. binary encoding where 1 - take item, 0 - don’t take the item and length - number of items we have to consider</p><p>invalid solution could be all 1s, means the weight limitation stated in the problem brief would be invalid</p><p>to deal with them</p><ul><li><p>create only valid chromosomes from start by catering to conditions</p></li><li><p>create any solution and deal with validity afterwards</p></li></ul><p>consider this when we create a representation</p>
New cards
13
what is the fitness function for the knapsack problem?
  • total value

  • low value = bad, high value - good, easy-to-compare solutions

  • invalid solutions can be given the total value = 0

New cards
14
what is a population?
the number of chromosomes alive at any time
New cards
15
what are the generations?
the number of times breeding has occurred, aka. the number of times a population is created (older generation produces new generation)
New cards
16
how does a genetic algorithm work \[informal\] ?
  • create population of random chromosomes

  • each chromosome scored with fitness function

  • create a new generation through genetic operators - selection/ crossover/ mutation

  • repeat until complete - best solution found

New cards
17
what are the 3 genetic operators for Holland’s genetic algorithms?
crossover

mutation

selection
New cards
18
what is crossover?
breeding, passing genes of 2 parents to create children
New cards
19
what crossover operators are there?
  • one point crossover - Holland original

  • uniform crossover - improvement

New cards
20
what is CP/ P - crossover point?
a random number up to the size of the chromosome generated, in order to split both parent chromosomes into 2 sections
New cards
21
what is one point crossover?

chromosomes [with n genes] move to the crossover pool with CP chance

  1. each chromosome is randomly paired with another chromosome (A and B)

  2. for each pair, a crossover point P is randomly generated with a value between 2 and n-1

  3. to create 2 children (C and D),

    1. all genes from 1 → P from parent A are given to child C

    2. all genes from 1 → P from parent B are given to child D

    3. all genes from P+1 → n from parent A are given to child C

    4. all genes from P+1 → n from parent B are given to child D

  4. the children are added to the population

<p>chromosomes [with n genes] move to the crossover pool with CP chance</p><p></p><ol><li><p>each chromosome is randomly paired with another chromosome (A and B)</p></li><li><p>for each pair, a crossover point P is randomly generated with a value between 2 and n-1</p></li><li><p>to create 2 children (C and D),</p><ol><li><p>all genes from 1 → P from parent A are given to child C</p></li><li><p>all genes from 1 → P from parent B are given to child D</p></li><li><p>all genes from P+1 → n from parent A are given to child C</p></li><li><p>all genes from P+1 → n from parent B are given to child D</p></li></ol></li><li><p>the children are added to the population</p></li></ol>
New cards
22
what is uniform crossover?

more powerful crossover where for each gene there is a 50% chance the child C will get the gene from parent A and 50% chance child C will get the gene from parent B. child D will get the gene from the opposing parent

  • each bit is treated separately instead of separating the whole chromosome into only 2 chunks.

eg. for parent 1, P1 has 50/50 chance to be for child 1 or 2

  • if it goes to child 1, child 2 gets the corresponding gene in parent 2

  • and vice versa

<p>more powerful crossover where for each gene there is a 50% chance the child C will get the gene from parent A and 50% chance child C will get the gene from parent B. child D will get the gene from the opposing parent</p><ul><li><p>each bit is treated separately instead of separating the whole chromosome into only 2 chunks.</p></li></ul><p></p><p>eg. for parent 1, P1 has 50/50 chance to be for child 1 or 2</p><ul><li><p>if it goes to child 1, child 2 gets the corresponding gene in parent 2</p></li><li><p>and vice versa</p></li></ul>
New cards
23
what is mutation?
small random change in gene to get a new solution

allows GA to explore more of search space and avoid falling into local optima
New cards
24
how does the mutation operator work?

each bit [gene] of a chromosome is given a probability MP of inverting.

eg.

1 turns into 0

0 turns into 1

New cards
25
what is selection?
keeping the chromosomes with the best fitness functions from one generation to the next generation where the new population formed is equal in size to the original population
New cards
26
how does the selection operator (roulette wheel) work?
the change of a chromosome surviving to the next generation is proportional to it’s fitness vs. the total fitness of others.

\
a roulette wheel is formed where chromosomes with better finesses have larger portions of the wheel and therefore once the wheel is spun, have a higher chance of being selected by the selection point to continue to the next generation
the change of a chromosome surviving to the next generation is proportional to it’s fitness vs. the total fitness of others. 

\
a roulette wheel is formed where chromosomes with better finesses have larger portions of the wheel and therefore once the wheel is spun, have a higher chance of being selected by the selection point to continue to the next generation
New cards
27
what parameters are needed for Holland’s Genetic Algorithm
NG - number of generations (iterations), how long it will take, how many populations will be created

PS - population size, how many chromosomes will be in population, will remain the same number in each generation?

CP - crossover probability

MP - mutation probability

n - length of a chromosome
New cards
28
what is the pseudocode for Holland’s Genetic Algorithm?
knowt flashcard image
New cards
29
what are the recommended parameter values for Holland’s GA?
knowt flashcard image
New cards
30
what are the applications of genetic algorithms?
Numerical optimisation

aircraft design

image processing

dna analysis

vehicle routing problems

Ai search
New cards

Explore top notes

note Note
studied byStudied by 42 people
931 days ago
5.0(1)
note Note
studied byStudied by 81 people
770 days ago
5.0(1)
note Note
studied byStudied by 102 people
772 days ago
5.0(2)
note Note
studied byStudied by 58 people
418 days ago
5.0(1)
note Note
studied byStudied by 4459 people
702 days ago
5.0(12)
note Note
studied byStudied by 73 people
313 days ago
5.0(1)

Explore top flashcards

flashcards Flashcard (22)
studied byStudied by 16 people
832 days ago
5.0(2)
flashcards Flashcard (22)
studied byStudied by 9 people
182 days ago
4.0(2)
flashcards Flashcard (21)
studied byStudied by 81 people
698 days ago
3.9(7)
flashcards Flashcard (101)
studied byStudied by 149 people
515 days ago
5.0(1)
flashcards Flashcard (25)
studied byStudied by 4 people
847 days ago
5.0(1)
flashcards Flashcard (62)
studied byStudied by 10 people
759 days ago
5.0(1)
flashcards Flashcard (26)
studied byStudied by 267 people
544 days ago
5.0(2)
flashcards Flashcard (52)
studied byStudied by 76 people
733 days ago
5.0(2)
robot