Genetic Algorithms: Programming by the Seat of Your Genes
-
Upload
jeremy-fisher -
Category
Technology
-
view
506 -
download
1
Transcript of Genetic Algorithms: Programming by the Seat of Your Genes
![Page 1: Genetic Algorithms: Programming by the Seat of Your Genes](https://reader031.fdocuments.in/reader031/viewer/2022021919/5880e2c71a28ab0d358b51a7/html5/thumbnails/1.jpg)
GENETIC ALGORITHMS
PROGRAMMING BY THE SEAT OF YOUR GENES!
JEREMY FISHER
!@THISISROOT
JUNE 29, 2016
![Page 2: Genetic Algorithms: Programming by the Seat of Your Genes](https://reader031.fdocuments.in/reader031/viewer/2022021919/5880e2c71a28ab0d358b51a7/html5/thumbnails/2.jpg)
Genetic algorithms are a biologically inspired stochastic metaheuristic for
combinatorial search and optimization.
![Page 3: Genetic Algorithms: Programming by the Seat of Your Genes](https://reader031.fdocuments.in/reader031/viewer/2022021919/5880e2c71a28ab0d358b51a7/html5/thumbnails/3.jpg)
Genetic algorithms are a biologically inspired stochastic metaheuristic for
combinatorial search and optimization fancy method of trial-and-error.
![Page 4: Genetic Algorithms: Programming by the Seat of Your Genes](https://reader031.fdocuments.in/reader031/viewer/2022021919/5880e2c71a28ab0d358b51a7/html5/thumbnails/4.jpg)
EVOLUTIONARY ALGORITHM COMPLEXITY
Binary encoding Single Point Crossover Uniform Crossover Proportionate Selection Tournament Selection
List Encoding Value Encoding Permutation Encoding Parallel GAs Ordered Crossover Partially Matched Crossover
Cycle Crossover Tree Encoding Edge Recombination Distributed GAs Multi-Objective Fitness Functions Diploidism
Coevolutionary Algorithms Genetics-Based Machine Learning Genetic Programming Estimation of Distribution Algorithms
BEGINNER ADVANCEDINTERMEDIATE
![Page 5: Genetic Algorithms: Programming by the Seat of Your Genes](https://reader031.fdocuments.in/reader031/viewer/2022021919/5880e2c71a28ab0d358b51a7/html5/thumbnails/5.jpg)
GENETIC ALGORITHMS IN THE WILDOperations Research
Sociology
Game Theory
Economics
Financial Trading
Biology
![Page 6: Genetic Algorithms: Programming by the Seat of Your Genes](https://reader031.fdocuments.in/reader031/viewer/2022021919/5880e2c71a28ab0d358b51a7/html5/thumbnails/6.jpg)
GENETIC ALGORITHM LIFECYCLE1. Create a population of random
chromosomes (solutions).
2. Score each chromosome in the population for fitness.
3. Create a new generation through mutation and crossover.
4. Repeat until done.
5. Emit the fittest chromosome as the solution.
⋆⋆⋆ ⋆⋆⋆⋆⋆⋆ ⋆⋆⋆
⋆⋆⋆ ⋆⋆⋆⋆⋆⋆ ⋆⋆⋆
⋆⋆⋆ ⋆⋆⋆⋆⋆⋆ ⋆⋆⋆
⋆⋆⋆
![Page 7: Genetic Algorithms: Programming by the Seat of Your Genes](https://reader031.fdocuments.in/reader031/viewer/2022021919/5880e2c71a28ab0d358b51a7/html5/thumbnails/7.jpg)
TERMINOLOGY
… 1 0 10Chromosome a.k.a.
Genotype, Organism, Creature, Member, Individual, Solution
Allele
Locus
![Page 8: Genetic Algorithms: Programming by the Seat of Your Genes](https://reader031.fdocuments.in/reader031/viewer/2022021919/5880e2c71a28ab0d358b51a7/html5/thumbnails/8.jpg)
TERMINOLOGY
-3 -2.5 -2 -1.5 -1 -0.5 0 0.5 1 1.5 2 2.5 3
-0.8
0.8
1.6
2.4
3.2
Fitness Landscape
![Page 10: Genetic Algorithms: Programming by the Seat of Your Genes](https://reader031.fdocuments.in/reader031/viewer/2022021919/5880e2c71a28ab0d358b51a7/html5/thumbnails/10.jpg)
0/1 KNAPSACK PROBLEM
Given a set of items, each with a quantified weight and value ($), what combination of items will:
1. Fit inside a knapsack capable of carrying a fixed amount of weight?
2. Maximize the value of the knapsack’s payload?
15 lbs
7. SOLUTION6. MUTATION5. CROSSOVER4. SELECTION3. FITNESS2. CREATION1. ENCODING0. PROBLEM
![Page 11: Genetic Algorithms: Programming by the Seat of Your Genes](https://reader031.fdocuments.in/reader031/viewer/2022021919/5880e2c71a28ab0d358b51a7/html5/thumbnails/11.jpg)
ENCODING SCHEMES
1 0 0 1 0 1 1 0
BINARY ENCODING
10 3 22 19 65 97 22 41
VALUE ENCODING
A B C D E F G H
PERMUTATION ENCODING
G C F A B D E H
10 3 22 19
LIST ENCODING
19 65 97 35 41 10
7. SOLUTION6. MUTATION5. CROSSOVER4. SELECTION3. FITNESS2. CREATION1. ENCODING0. PROBLEM
![Page 12: Genetic Algorithms: Programming by the Seat of Your Genes](https://reader031.fdocuments.in/reader031/viewer/2022021919/5880e2c71a28ab0d358b51a7/html5/thumbnails/12.jpg)
0/1 KNAPSACK PROBLEM
A
10 lbs | $11
B4 lbs | $8
C5 lbs | $6
D2 lbs | $12
15 lbsE
8 lbs | $5
F2 lbs | $8
G6 lbs | $4
H
7 lbs | $13
7. SOLUTION6. MUTATION5. CROSSOVER4. SELECTION3. FITNESS2. CREATION1. ENCODING0. PROBLEM
![Page 13: Genetic Algorithms: Programming by the Seat of Your Genes](https://reader031.fdocuments.in/reader031/viewer/2022021919/5880e2c71a28ab0d358b51a7/html5/thumbnails/13.jpg)
BINARY ENCODING
A B C D E F G H
7. SOLUTION6. MUTATION5. CROSSOVER4. SELECTION3. FITNESS2. CREATION1. ENCODING0. PROBLEM
![Page 14: Genetic Algorithms: Programming by the Seat of Your Genes](https://reader031.fdocuments.in/reader031/viewer/2022021919/5880e2c71a28ab0d358b51a7/html5/thumbnails/14.jpg)
BINARY ENCODING
A B C D E F G H
7. SOLUTION6. MUTATION5. CROSSOVER4. SELECTION3. FITNESS2. CREATION1. ENCODING0. PROBLEM
![Page 15: Genetic Algorithms: Programming by the Seat of Your Genes](https://reader031.fdocuments.in/reader031/viewer/2022021919/5880e2c71a28ab0d358b51a7/html5/thumbnails/15.jpg)
BINARY ENCODING
A B C D E F G H10 lbs
$114 lbs $8
5 lbs $6
2 lbs $12
8 lbs $5
2 lbs $8
6 lbs $4
7 lbs $13
1 0 1 0 1 0 1 0
WEIGHT: 29 lbs VALUE: $26
7. SOLUTION6. MUTATION5. CROSSOVER4. SELECTION3. FITNESS2. CREATION1. ENCODING0. PROBLEM
![Page 16: Genetic Algorithms: Programming by the Seat of Your Genes](https://reader031.fdocuments.in/reader031/viewer/2022021919/5880e2c71a28ab0d358b51a7/html5/thumbnails/16.jpg)
INITIALIZE THE POPULATION
1 0 1 1 0 1 1 0
7. SOLUTION6. MUTATION5. CROSSOVER4. SELECTION3. FITNESS2. CREATION1. ENCODING0. PROBLEM
![Page 17: Genetic Algorithms: Programming by the Seat of Your Genes](https://reader031.fdocuments.in/reader031/viewer/2022021919/5880e2c71a28ab0d358b51a7/html5/thumbnails/17.jpg)
INITIALIZE THE POPULATION
1 0 1 1 0 1 1 01 1
7. SOLUTION6. MUTATION5. CROSSOVER4. SELECTION3. FITNESS2. CREATION1. ENCODING0. PROBLEM
![Page 18: Genetic Algorithms: Programming by the Seat of Your Genes](https://reader031.fdocuments.in/reader031/viewer/2022021919/5880e2c71a28ab0d358b51a7/html5/thumbnails/18.jpg)
INITIALIZE THE POPULATION
1 0 1 1 0 0 0 0
7. SOLUTION6. MUTATION5. CROSSOVER4. SELECTION3. FITNESS2. CREATION1. ENCODING0. PROBLEM
![Page 19: Genetic Algorithms: Programming by the Seat of Your Genes](https://reader031.fdocuments.in/reader031/viewer/2022021919/5880e2c71a28ab0d358b51a7/html5/thumbnails/19.jpg)
INITIALIZE THE POPULATION
0 0 1 1 0 1 0 1
7. SOLUTION6. MUTATION5. CROSSOVER4. FITNESS3. CREATION3. CREATION2. ENCODING1. PROBLEM 7. SOLUTION6. MUTATION5. CROSSOVER4. SELECTION3. FITNESS2. CREATION1. ENCODING0. PROBLEM
![Page 20: Genetic Algorithms: Programming by the Seat of Your Genes](https://reader031.fdocuments.in/reader031/viewer/2022021919/5880e2c71a28ab0d358b51a7/html5/thumbnails/20.jpg)
FITNESS FUNCTION
Maximize value
Maximize weight to limit
def score(self, chromosome): weight, value = self.assess(chromosome)
if weight > self.max_weight: return 0.0
if value <= 0: return 0.0
wt = 1 / (1 + self.max_weight - weight) vl = 1 - 1 / value return wt + vl * self.value_bias
7. SOLUTION6. MUTATION5. CROSSOVER4. SELECTION3. FITNESS2. CREATION1. ENCODING0. PROBLEM
![Page 21: Genetic Algorithms: Programming by the Seat of Your Genes](https://reader031.fdocuments.in/reader031/viewer/2022021919/5880e2c71a28ab0d358b51a7/html5/thumbnails/21.jpg)
FITNESS FUNCTION
def score(self, chromosome): weight, value = self.assess(chromosome)
if weight > self.max_weight: return 0.0
return 1 - 1 / value
Maximize value
Don’t exceed weight limit
7. SOLUTION6. MUTATION5. CROSSOVER4. SELECTION3. FITNESS2. CREATION1. ENCODING0. PROBLEM
![Page 22: Genetic Algorithms: Programming by the Seat of Your Genes](https://reader031.fdocuments.in/reader031/viewer/2022021919/5880e2c71a28ab0d358b51a7/html5/thumbnails/22.jpg)
FITNESS FUNCTION
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
-1
-0.75
-0.5
-0.25
0.25
0.5
0.75
1
1.25
1.5
1.75
2
2.25
2.5
7. SOLUTION6. MUTATION5. CROSSOVER4. SELECTION3. FITNESS2. CREATION1. ENCODING0. PROBLEM
y=1-1/xy=x
![Page 23: Genetic Algorithms: Programming by the Seat of Your Genes](https://reader031.fdocuments.in/reader031/viewer/2022021919/5880e2c71a28ab0d358b51a7/html5/thumbnails/23.jpg)
PROPORTIONATE SELECTION
1 0 1 1 0 1 10 0 0 1 0 1 1 01 1 0 0 1 1 1 10 0 1 1 1 1 0 10
1 0 0 1 0 0 11 1 1 0 1 0 0 10 0 0 1 0 0 1 10 1 0 0 1 0 1 11
$40 $30 $25 $20
$20 $15 $10 $5
7. SOLUTION6. MUTATION5. CROSSOVER4. SELECTION3. FITNESS2. CREATION1. ENCODING0. PROBLEM
![Page 24: Genetic Algorithms: Programming by the Seat of Your Genes](https://reader031.fdocuments.in/reader031/viewer/2022021919/5880e2c71a28ab0d358b51a7/html5/thumbnails/24.jpg)
PROPORTIONATE SELECTION
$40 $30 $25 $20 $20 $15 $10 $5
7. SOLUTION6. MUTATION5. CROSSOVER4. SELECTION3. FITNESS2. CREATION1. ENCODING0. PROBLEM
![Page 25: Genetic Algorithms: Programming by the Seat of Your Genes](https://reader031.fdocuments.in/reader031/viewer/2022021919/5880e2c71a28ab0d358b51a7/html5/thumbnails/25.jpg)
PROPORTIONATE SELECTION
Most direct path to convergence
Enables elitism
7. SOLUTION6. MUTATION5. CROSSOVER4. SELECTION3. FITNESS2. CREATION1. ENCODING0. PROBLEM
![Page 26: Genetic Algorithms: Programming by the Seat of Your Genes](https://reader031.fdocuments.in/reader031/viewer/2022021919/5880e2c71a28ab0d358b51a7/html5/thumbnails/26.jpg)
TOURNAMENT SELECTION
1 0 1 1 0 1 10 0 0 1 0 1 1 01 1 0 0 1 1 1 10 0 1 1 1 1 0 10
1 0 0 1 0 0 11 1 1 0 1 0 0 10 0 0 1 0 0 1 10 1 0 0 1 0 1 11
7. SOLUTION6. MUTATION5. CROSSOVER4. SELECTION3. FITNESS2. CREATION1. ENCODING0. PROBLEM
![Page 27: Genetic Algorithms: Programming by the Seat of Your Genes](https://reader031.fdocuments.in/reader031/viewer/2022021919/5880e2c71a28ab0d358b51a7/html5/thumbnails/27.jpg)
TOURNAMENT SELECTION
1 0 1 1 0 1 10 0 0 1 0 1 1 01 1 0 0 1 1 1 10 0 1 1 1 1 0 10
1 0 0 1 0 0 11 1 1 0 1 0 0 10 0 0 1 0 0 1 10 1 0 0 1 0 1 11
$30 $20
$15
7. SOLUTION6. MUTATION5. CROSSOVER4. SELECTION3. FITNESS2. CREATION1. ENCODING0. PROBLEM
![Page 28: Genetic Algorithms: Programming by the Seat of Your Genes](https://reader031.fdocuments.in/reader031/viewer/2022021919/5880e2c71a28ab0d358b51a7/html5/thumbnails/28.jpg)
TOURNAMENT SELECTION
1 0 1 1 0 1 10 0 0 1 0 1 1 01 1 0 0 1 1 1 10 0 1 1 1 1 0 10
1 0 0 1 0 0 11 1 1 0 1 0 0 10 0 0 1 0 0 1 10 1 0 0 1 0 1 11
$30 $20
$15
7. SOLUTION6. MUTATION5. CROSSOVER4. SELECTION3. FITNESS2. CREATION1. ENCODING0. PROBLEM
![Page 29: Genetic Algorithms: Programming by the Seat of Your Genes](https://reader031.fdocuments.in/reader031/viewer/2022021919/5880e2c71a28ab0d358b51a7/html5/thumbnails/29.jpg)
TOURNAMENT SELECTION
Fewer fitness function invocations
Built-in scaling
1 0 1 1 0 1 10 0 0 1 0 1 1 01 1 0 0 1 1 1 10 0 1 1 1 1 0 10
1 0 0 1 0 0 11 1 1 0 1 0 0 10 0 0 1 0 0 1 10 1 0 0 1 0 1 11
7. SOLUTION6. MUTATION5. CROSSOVER4. SELECTION3. FITNESS2. CREATION1. ENCODING0. PROBLEM
![Page 30: Genetic Algorithms: Programming by the Seat of Your Genes](https://reader031.fdocuments.in/reader031/viewer/2022021919/5880e2c71a28ab0d358b51a7/html5/thumbnails/30.jpg)
SINGLE-POINT CROSSOVER
1 0 1 1 0 1 0 1
1 1 0 1 1 1 1 0X
0 1 0 1
1 1 0 1 1 1 1 0
1 0 1 1
7. SOLUTION6. MUTATION5. CROSSOVER4. SELECTION3. FITNESS2. CREATION1. ENCODING0. PROBLEM
![Page 31: Genetic Algorithms: Programming by the Seat of Your Genes](https://reader031.fdocuments.in/reader031/viewer/2022021919/5880e2c71a28ab0d358b51a7/html5/thumbnails/31.jpg)
SINGLE-POINT CROSSOVER
1 0 1 1 0 1 0 1
1 1 0 1 1 1 1 0X
0 1 0 1
1 1 0 1
1 1 1 01 0 1 1
7. SOLUTION6. MUTATION5. CROSSOVER4. SELECTION3. FITNESS2. CREATION1. ENCODING0. PROBLEM
![Page 32: Genetic Algorithms: Programming by the Seat of Your Genes](https://reader031.fdocuments.in/reader031/viewer/2022021919/5880e2c71a28ab0d358b51a7/html5/thumbnails/32.jpg)
UNIFORM CROSSOVER
1 0 1 1 0 1 0 1
1 1 0 1 1 1 1 0X
1 0 1
1 1 0 1 1 1 0
1 0 1 1 0
7. SOLUTION6. MUTATION5. CROSSOVER4. SELECTION3. FITNESS2. CREATION1. ENCODING0. PROBLEM
![Page 33: Genetic Algorithms: Programming by the Seat of Your Genes](https://reader031.fdocuments.in/reader031/viewer/2022021919/5880e2c71a28ab0d358b51a7/html5/thumbnails/33.jpg)
UNIFORM CROSSOVER
1 0 1 1 0 1 0 1
1 1 0 1 1 1 1 0X
1
0
1
1
1
0
1
1
1 01
0
1
1
0
7. SOLUTION6. MUTATION5. CROSSOVER4. SELECTION3. FITNESS2. CREATION1. ENCODING0. PROBLEM
![Page 34: Genetic Algorithms: Programming by the Seat of Your Genes](https://reader031.fdocuments.in/reader031/viewer/2022021919/5880e2c71a28ab0d358b51a7/html5/thumbnails/34.jpg)
COMPARISON
SINGLE POINT CROSSOVER UNIFORM CROSSOVER
num_items=64, population_size=10, iterations=15, elitism=0, seed=“Knapsack01”
7. SOLUTION6. MUTATION5. CROSSOVER4. SELECTION3. FITNESS2. CREATION1. ENCODING0. PROBLEM
Best Mean WorstBest Mean Worst
![Page 35: Genetic Algorithms: Programming by the Seat of Your Genes](https://reader031.fdocuments.in/reader031/viewer/2022021919/5880e2c71a28ab0d358b51a7/html5/thumbnails/35.jpg)
MEASURING PERFORMANCE
Solution fitness
Clock time to converge
Iterations to converge
Number of solutions explored
Inheritability
7. SOLUTION6. MUTATION5. CROSSOVER4. SELECTION3. FITNESS2. CREATION1. ENCODING0. PROBLEM
![Page 36: Genetic Algorithms: Programming by the Seat of Your Genes](https://reader031.fdocuments.in/reader031/viewer/2022021919/5880e2c71a28ab0d358b51a7/html5/thumbnails/36.jpg)
POINT MUTATION
1 0 0 1 0 1 1 00
1
X
1 0 0 1 1 1 0
7. SOLUTION6. MUTATION5. CROSSOVER4. SELECTION3. FITNESS2. CREATION1. ENCODING0. PROBLEM
![Page 37: Genetic Algorithms: Programming by the Seat of Your Genes](https://reader031.fdocuments.in/reader031/viewer/2022021919/5880e2c71a28ab0d358b51a7/html5/thumbnails/37.jpg)
7. SOLUTION
SOLUTION
6. MUTATION5. CROSSOVER4. SELECTION3. FITNESS2. CREATION1. ENCODING0. PROBLEM
0 0 0 0 1 0 0 1 1 0 1 0 0 0 0 0
0 0 1 1 1 0 0 0 0 0 1 1 0 1 1 0
![Page 38: Genetic Algorithms: Programming by the Seat of Your Genes](https://reader031.fdocuments.in/reader031/viewer/2022021919/5880e2c71a28ab0d358b51a7/html5/thumbnails/38.jpg)
7. SOLUTION
SOLUTION
6. MUTATION5. CROSSOVER4. SELECTION3. FITNESS2. CREATION1. ENCODING0. PROBLEM
0 0 1 1 0 1 1 0
A B C D E F G H10 lbs
$114 lbs $8
5 lbs $6
2 lbs $12
8 lbs $5
2 lbs $8
6 lbs $4
7 lbs $13
WEIGHT: 15 lbs VALUE: $30
![Page 39: Genetic Algorithms: Programming by the Seat of Your Genes](https://reader031.fdocuments.in/reader031/viewer/2022021919/5880e2c71a28ab0d358b51a7/html5/thumbnails/39.jpg)
SEATING CHART PROBLEM
What seating arrangement will:
1. Seat people of the same job together?
2. Separate loud jobs from quiet jobs?
7. SOLUTION6. MUTATION5. CROSSOVER4. SELECTION3. FITNESS2. CREATION1. ENCODING0. PROBLEM
![Page 40: Genetic Algorithms: Programming by the Seat of Your Genes](https://reader031.fdocuments.in/reader031/viewer/2022021919/5880e2c71a28ab0d358b51a7/html5/thumbnails/40.jpg)
SEATING CHART PROBLEMID Name Role Seat0 Sandra Rodgers Engineer 01 Kirk Spence Engineer 32 Terry Burton Engineer 23 Cindy Hill Engineer 44 Steve Thompson Engineer 65 Laura Juel Engineer 56 Emily Cook Engineer C7 Daniel Barrett Manager 88 Cedric White Manager 99 Emily Grimaud Sales E10 Joseph Johnson Sales B11 Raymond Seery Sales F
0 1
4
2 3
8
C
5 6 7
9 A B
D E F
7. SOLUTION6. MUTATION5. CROSSOVER4. SELECTION3. FITNESS2. CREATION1. ENCODING0. PROBLEM
![Page 41: Genetic Algorithms: Programming by the Seat of Your Genes](https://reader031.fdocuments.in/reader031/viewer/2022021919/5880e2c71a28ab0d358b51a7/html5/thumbnails/41.jpg)
PERMUTATION ENCODINGID Name Role Seat0 Sandra Rodgers Engineer 01 Kirk Spence Engineer 32 Terry Burton Engineer 23 Cindy Hill Engineer 44 Steve Thompson Engineer 65 Laura Juel Engineer 56 Emily Cook Engineer C7 Daniel Barrett Manager 88 Cedric White Manager 99 Emily Grimaud Sales E10 Joseph Johnson Sales B11 Raymond Seery Sales F
0 1
4
2 3
8
C
5 6 7
9 A B
D E F
7. SOLUTION6. MUTATION5. CROSSOVER4. SELECTION3. FITNESS2. CREATION1. ENCODING0. PROBLEM
![Page 42: Genetic Algorithms: Programming by the Seat of Your Genes](https://reader031.fdocuments.in/reader031/viewer/2022021919/5880e2c71a28ab0d358b51a7/html5/thumbnails/42.jpg)
PERMUTATION ENCODING
0 12 3 45 67 8 910 11
7. SOLUTION6. MUTATION5. CROSSOVER4. SELECTION3. FITNESS2. CREATION1. ENCODING0. PROBLEM
![Page 43: Genetic Algorithms: Programming by the Seat of Your Genes](https://reader031.fdocuments.in/reader031/viewer/2022021919/5880e2c71a28ab0d358b51a7/html5/thumbnails/43.jpg)
PERMUTATION ENCODING
0 12 3 45 67 8 910 1112 13 14 15
7. SOLUTION6. MUTATION5. CROSSOVER4. SELECTION3. FITNESS2. CREATION1. ENCODING0. PROBLEM
![Page 44: Genetic Algorithms: Programming by the Seat of Your Genes](https://reader031.fdocuments.in/reader031/viewer/2022021919/5880e2c71a28ab0d358b51a7/html5/thumbnails/44.jpg)
NAÏVE VECTORIZATION0 1
4
2 3
8
C
5 6 7
9 A B
D E F
7. SOLUTION6. MUTATION5. CROSSOVER4. SELECTION3. FITNESS2. CREATION1. ENCODING0. PROBLEM
![Page 45: Genetic Algorithms: Programming by the Seat of Your Genes](https://reader031.fdocuments.in/reader031/viewer/2022021919/5880e2c71a28ab0d358b51a7/html5/thumbnails/45.jpg)
HILBERT VECTORIZATION0 1
3
E F
4
5
2 D C
7 8 B
6 9 A
7. SOLUTION6. MUTATION5. CROSSOVER4. SELECTION3. FITNESS2. CREATION1. ENCODING0. PROBLEM
![Page 46: Genetic Algorithms: Programming by the Seat of Your Genes](https://reader031.fdocuments.in/reader031/viewer/2022021919/5880e2c71a28ab0d358b51a7/html5/thumbnails/46.jpg)
PRESERVING LOCALITY
NAÏVE VECTORIZATION HILBERT VECTORIZATION
7. SOLUTION6. MUTATION5. CROSSOVER4. SELECTION3. FITNESS2. CREATION1. ENCODING0. PROBLEM
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 150 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
vector index
dist
ance
to
orig
in
vector index
dist
ance
to
orig
in
![Page 47: Genetic Algorithms: Programming by the Seat of Your Genes](https://reader031.fdocuments.in/reader031/viewer/2022021919/5880e2c71a28ab0d358b51a7/html5/thumbnails/47.jpg)
PERFORMANCE COMPARISON
NAÏVE VECTORIZATION HILBERT VECTORIZATION
7. SOLUTION6. MUTATION5. CROSSOVER4. SELECTION3. FITNESS2. CREATION1. ENCODING0. PROBLEM
map_size=7x7, population_size=200, iterations=30, elitism=0, seed=“SeatingChart”, crossover=PMX
Best Mean Worst Best Mean Worst
![Page 48: Genetic Algorithms: Programming by the Seat of Your Genes](https://reader031.fdocuments.in/reader031/viewer/2022021919/5880e2c71a28ab0d358b51a7/html5/thumbnails/48.jpg)
INITIALIZE THE POPULATION
2 6 0 1 4 7 3 5
1 7 5 0 4 2 3 6
7 3 1 0 2 6 5 4
7. SOLUTION6. MUTATION5. CROSSOVER4. FITNESS3. CREATION3. CREATION2. ENCODING1. PROBLEM 7. SOLUTION6. MUTATION5. CROSSOVER4. SELECTION3. FITNESS2. CREATION1. ENCODING0. PROBLEM
![Page 49: Genetic Algorithms: Programming by the Seat of Your Genes](https://reader031.fdocuments.in/reader031/viewer/2022021919/5880e2c71a28ab0d358b51a7/html5/thumbnails/49.jpg)
FITNESS FUNCTION0 1
4
2 3
C
5 6 7
A B
D E F
7. SOLUTION6. MUTATION5. CROSSOVER4. SELECTION3. FITNESS2. CREATION1. ENCODING0. PROBLEM
8 9
![Page 50: Genetic Algorithms: Programming by the Seat of Your Genes](https://reader031.fdocuments.in/reader031/viewer/2022021919/5880e2c71a28ab0d358b51a7/html5/thumbnails/50.jpg)
FITNESS FUNCTION0 1
4
2 3
C
5 6 7
A B
D E F
44.033.411.00
48.44
7. SOLUTION6. MUTATION5. CROSSOVER4. SELECTION3. FITNESS2. CREATION1. ENCODING0. PROBLEM
8 9
![Page 51: Genetic Algorithms: Programming by the Seat of Your Genes](https://reader031.fdocuments.in/reader031/viewer/2022021919/5880e2c71a28ab0d358b51a7/html5/thumbnails/51.jpg)
FITNESS FUNCTION0 1
4
2 3
8
C
5 6 7
9 A B
D E F
30.38
7. SOLUTION6. MUTATION5. CROSSOVER4. SELECTION3. FITNESS2. CREATION1. ENCODING0. PROBLEM
![Page 52: Genetic Algorithms: Programming by the Seat of Your Genes](https://reader031.fdocuments.in/reader031/viewer/2022021919/5880e2c71a28ab0d358b51a7/html5/thumbnails/52.jpg)
FITNESS FUNCTION0 1
4
2 3
8
C
5 6 7
9 A B
D E F
-30.3848.44
18.06
7. SOLUTION6. MUTATION5. CROSSOVER4. SELECTION3. FITNESS2. CREATION1. ENCODING0. PROBLEM
![Page 53: Genetic Algorithms: Programming by the Seat of Your Genes](https://reader031.fdocuments.in/reader031/viewer/2022021919/5880e2c71a28ab0d358b51a7/html5/thumbnails/53.jpg)
FITNESS FUNCTION
7. SOLUTION6. MUTATION5. CROSSOVER4. SELECTION3. FITNESS2. CREATION1. ENCODING0. PROBLEM
def score(self, chromosome): seats_role = self.seats_by_role(chromosome)
# Tally attractive score attraction = 0.0 for role, coords in seats_role.iteritems(): attraction += spatial.total_edge_length(coords)
# Tally repulsive score repulsion = 0.0 for role, repulsors in self.repulsion.iteritems(): …
return self.max_distance - attraction + repulsion
![Page 54: Genetic Algorithms: Programming by the Seat of Your Genes](https://reader031.fdocuments.in/reader031/viewer/2022021919/5880e2c71a28ab0d358b51a7/html5/thumbnails/54.jpg)
ORDERED CROSSOVER (OX)
X
2 6 0 1 4 7 3 5
1 7 5 0 4 2 3 67 5 4 3
2 6 0 1
7. SOLUTION6. MUTATION5. CROSSOVER4. SELECTION3. FITNESS2. CREATION1. ENCODING0. PROBLEM
![Page 55: Genetic Algorithms: Programming by the Seat of Your Genes](https://reader031.fdocuments.in/reader031/viewer/2022021919/5880e2c71a28ab0d358b51a7/html5/thumbnails/55.jpg)
ORDERED CROSSOVER (OX)
X
2 6 0 1 4 7 3 5
1 7 5 0 4 2 3 67 5 4 3
2 6 0 1
7. SOLUTION6. MUTATION5. CROSSOVER4. SELECTION3. FITNESS2. CREATION1. ENCODING0. PROBLEM
![Page 56: Genetic Algorithms: Programming by the Seat of Your Genes](https://reader031.fdocuments.in/reader031/viewer/2022021919/5880e2c71a28ab0d358b51a7/html5/thumbnails/56.jpg)
ORDERED CROSSOVER (OX)
X
2 6 0 1 4 7 3 5
1 7 5 0 4 2 3 6
7 5 4 32 6 0 1
7. SOLUTION6. MUTATION5. CROSSOVER4. SELECTION3. FITNESS2. CREATION1. ENCODING0. PROBLEM
![Page 57: Genetic Algorithms: Programming by the Seat of Your Genes](https://reader031.fdocuments.in/reader031/viewer/2022021919/5880e2c71a28ab0d358b51a7/html5/thumbnails/57.jpg)
PARTIALLY MATCHED CROSSOVER (PMX)
X
2 6 0 1 4 7 3 5
0 1 5 7 42 3 6
7. SOLUTION6. MUTATION5. CROSSOVER4. SELECTION3. FITNESS2. CREATION1. ENCODING0. PROBLEM
5 7 2
![Page 58: Genetic Algorithms: Programming by the Seat of Your Genes](https://reader031.fdocuments.in/reader031/viewer/2022021919/5880e2c71a28ab0d358b51a7/html5/thumbnails/58.jpg)
PARTIALLY MATCHED CROSSOVER (PMX)
X
2 6 0 1 4 7 3 5
0 1 5 7 42 3 6
7. SOLUTION6. MUTATION5. CROSSOVER4. SELECTION3. FITNESS2. CREATION1. ENCODING0. PROBLEM
5 7 2
![Page 59: Genetic Algorithms: Programming by the Seat of Your Genes](https://reader031.fdocuments.in/reader031/viewer/2022021919/5880e2c71a28ab0d358b51a7/html5/thumbnails/59.jpg)
PARTIALLY MATCHED CROSSOVER (PMX)
X
2 6 0 1 4 7 3 5
0 1 5 7 42 3 6
7. SOLUTION6. MUTATION5. CROSSOVER4. SELECTION3. FITNESS2. CREATION1. ENCODING0. PROBLEM
5 7 2
0
![Page 60: Genetic Algorithms: Programming by the Seat of Your Genes](https://reader031.fdocuments.in/reader031/viewer/2022021919/5880e2c71a28ab0d358b51a7/html5/thumbnails/60.jpg)
PARTIALLY MATCHED CROSSOVER (PMX)
X
2 6 0 1 4 7 3 5
0 1 5 7 42 3 6
7. SOLUTION6. MUTATION5. CROSSOVER4. SELECTION3. FITNESS2. CREATION1. ENCODING0. PROBLEM
5 7 2 0
![Page 61: Genetic Algorithms: Programming by the Seat of Your Genes](https://reader031.fdocuments.in/reader031/viewer/2022021919/5880e2c71a28ab0d358b51a7/html5/thumbnails/61.jpg)
PARTIALLY MATCHED CROSSOVER (PMX)
X
2 6 0 1 4 7 3 5
0 1 5 7 42 3 6
7. SOLUTION6. MUTATION5. CROSSOVER4. SELECTION3. FITNESS2. CREATION1. ENCODING0. PROBLEM
5 7 2 0
1
![Page 62: Genetic Algorithms: Programming by the Seat of Your Genes](https://reader031.fdocuments.in/reader031/viewer/2022021919/5880e2c71a28ab0d358b51a7/html5/thumbnails/62.jpg)
PARTIALLY MATCHED CROSSOVER (PMX)
X
2 6 0 1 4 7 3 5
0 1 5 7 42 3 6
7. SOLUTION6. MUTATION5. CROSSOVER4. SELECTION3. FITNESS2. CREATION1. ENCODING0. PROBLEM
5 7 2 01
![Page 63: Genetic Algorithms: Programming by the Seat of Your Genes](https://reader031.fdocuments.in/reader031/viewer/2022021919/5880e2c71a28ab0d358b51a7/html5/thumbnails/63.jpg)
PARTIALLY MATCHED CROSSOVER (PMX)
X
2 6 0 1 4 7 3 5
0 1 5 7 42 3 6
7. SOLUTION6. MUTATION5. CROSSOVER4. SELECTION3. FITNESS2. CREATION1. ENCODING0. PROBLEM
5 7 2 01
4
![Page 64: Genetic Algorithms: Programming by the Seat of Your Genes](https://reader031.fdocuments.in/reader031/viewer/2022021919/5880e2c71a28ab0d358b51a7/html5/thumbnails/64.jpg)
PARTIALLY MATCHED CROSSOVER (PMX)
X
2 6 0 1 4 7 3 5
0 1 5 7 42 3 6
7. SOLUTION6. MUTATION5. CROSSOVER4. SELECTION3. FITNESS2. CREATION1. ENCODING0. PROBLEM
5 7 2 014
![Page 65: Genetic Algorithms: Programming by the Seat of Your Genes](https://reader031.fdocuments.in/reader031/viewer/2022021919/5880e2c71a28ab0d358b51a7/html5/thumbnails/65.jpg)
PARTIALLY MATCHED CROSSOVER (PMX)
X
2 6 0 1 4 7 3 5
0 1 5 7 42 3 6
7. SOLUTION6. MUTATION5. CROSSOVER4. SELECTION3. FITNESS2. CREATION1. ENCODING0. PROBLEM
5 7 2 014
6 3
![Page 66: Genetic Algorithms: Programming by the Seat of Your Genes](https://reader031.fdocuments.in/reader031/viewer/2022021919/5880e2c71a28ab0d358b51a7/html5/thumbnails/66.jpg)
PARTIALLY MATCHED CROSSOVER (PMX)
X
2 6 0 1 4 7 3 5
0 1 5 7 42 3 6
7. SOLUTION6. MUTATION5. CROSSOVER4. SELECTION3. FITNESS2. CREATION1. ENCODING0. PROBLEM
5 7 2 014 6 3
![Page 67: Genetic Algorithms: Programming by the Seat of Your Genes](https://reader031.fdocuments.in/reader031/viewer/2022021919/5880e2c71a28ab0d358b51a7/html5/thumbnails/67.jpg)
PERFORMANCE COMPARISON
ORDERED PARTIALLY MATCHED
7. SOLUTION6. MUTATION5. CROSSOVER
map_size=7x7, population_size=200, iterations=30, elitism=0, seed=“SeatingChart”, map_type=naive
Best Mean Worst Best Mean Worst
4. SELECTION3. FITNESS2. CREATION1. ENCODING0. PROBLEM
![Page 68: Genetic Algorithms: Programming by the Seat of Your Genes](https://reader031.fdocuments.in/reader031/viewer/2022021919/5880e2c71a28ab0d358b51a7/html5/thumbnails/68.jpg)
SWAP MUTATION
X 2 6 0 1 4 7 3 5
2 60 14 7 3 5
7. SOLUTION6. MUTATION5. CROSSOVER4. SELECTION3. FITNESS2. CREATION1. ENCODING0. PROBLEM
![Page 69: Genetic Algorithms: Programming by the Seat of Your Genes](https://reader031.fdocuments.in/reader031/viewer/2022021919/5880e2c71a28ab0d358b51a7/html5/thumbnails/69.jpg)
SOLUTION
7. SOLUTION6. MUTATION5. CROSSOVER4. SELECTION3. FITNESS2. CREATION1. ENCODING0. PROBLEM
![Page 70: Genetic Algorithms: Programming by the Seat of Your Genes](https://reader031.fdocuments.in/reader031/viewer/2022021919/5880e2c71a28ab0d358b51a7/html5/thumbnails/70.jpg)
SOLUTION
7. SOLUTION6. MUTATION5. CROSSOVER4. SELECTION3. FITNESS2. CREATION1. ENCODING0. PROBLEM
![Page 71: Genetic Algorithms: Programming by the Seat of Your Genes](https://reader031.fdocuments.in/reader031/viewer/2022021919/5880e2c71a28ab0d358b51a7/html5/thumbnails/71.jpg)
SOLUTION
7. SOLUTION6. MUTATION5. CROSSOVER4. SELECTION3. FITNESS2. CREATION1. ENCODING0. PROBLEM
![Page 72: Genetic Algorithms: Programming by the Seat of Your Genes](https://reader031.fdocuments.in/reader031/viewer/2022021919/5880e2c71a28ab0d358b51a7/html5/thumbnails/72.jpg)
SOLUTION
7. SOLUTION6. MUTATION5. CROSSOVER4. SELECTION3. FITNESS2. CREATION1. ENCODING0. PROBLEM
![Page 73: Genetic Algorithms: Programming by the Seat of Your Genes](https://reader031.fdocuments.in/reader031/viewer/2022021919/5880e2c71a28ab0d358b51a7/html5/thumbnails/73.jpg)
UNBOUNDED KNAPSACK PROBLEM
Given a set of items, each with a quantified weight and value ($), what combination of those items in any amounts will:
1. Fit inside a knapsack capable of carrying a fixed amount of weight?
2. Maximize the value of the knapsack’s payload?
15 lbs
![Page 74: Genetic Algorithms: Programming by the Seat of Your Genes](https://reader031.fdocuments.in/reader031/viewer/2022021919/5880e2c71a28ab0d358b51a7/html5/thumbnails/74.jpg)
UNBOUNDED KNAPSACK PROBLEM
A
10 lbs | $11
B4 lbs | $8
C5 lbs | $6
D2 lbs | $12
20 lbsE
8 lbs | $5
F2 lbs | $8
G6 lbs | $4
H
7 lbs | $13
![Page 75: Genetic Algorithms: Programming by the Seat of Your Genes](https://reader031.fdocuments.in/reader031/viewer/2022021919/5880e2c71a28ab0d358b51a7/html5/thumbnails/75.jpg)
LIST ENCODING
B D E F H
B D E F
A B D E HH
B D AC
E H A
![Page 76: Genetic Algorithms: Programming by the Seat of Your Genes](https://reader031.fdocuments.in/reader031/viewer/2022021919/5880e2c71a28ab0d358b51a7/html5/thumbnails/76.jpg)
UNBOUNDED KNAPSACK PROBLEM
Encoding ListCrossover Cut and Splice / Single Point
Selection ProportionateMutation Point
![Page 77: Genetic Algorithms: Programming by the Seat of Your Genes](https://reader031.fdocuments.in/reader031/viewer/2022021919/5880e2c71a28ab0d358b51a7/html5/thumbnails/77.jpg)
TRAVELING SALESMAN PROBLEM
Minimize the total distance required to visit all stops along a route.
![Page 78: Genetic Algorithms: Programming by the Seat of Your Genes](https://reader031.fdocuments.in/reader031/viewer/2022021919/5880e2c71a28ab0d358b51a7/html5/thumbnails/78.jpg)
TRAVELING SALESMAN PROBLEM
Encoding PermutationCrossover Ordered or Edge Recombination
Selection ProportionateMutation Swap
![Page 79: Genetic Algorithms: Programming by the Seat of Your Genes](https://reader031.fdocuments.in/reader031/viewer/2022021919/5880e2c71a28ab0d358b51a7/html5/thumbnails/79.jpg)
NURSE SCHEDULING PROBLEM
There must always be n nurses scheduled.
A nurse cannot be scheduled while on PTO.
A nurse cannot be scheduled for more than two consecutive shifts.
A nurse should have at least two shifts off between scheduled shifts.
A nurse’s shift preferences should be respected.
7 days / week 3 shifts / day
![Page 80: Genetic Algorithms: Programming by the Seat of Your Genes](https://reader031.fdocuments.in/reader031/viewer/2022021919/5880e2c71a28ab0d358b51a7/html5/thumbnails/80.jpg)
NURSE SCHEDULING PROBLEM
Name Shift Mon Tue Wed Thu Fri Sat SunGrace 1Constance 3 PTO PTORonald 2Robyn 2 PTO PTOJudy 1Amy 1, 2Brad 3Valarie 1 PTOJames 2Thelma 2, 3 PTO… … … … … … … … …
![Page 81: Genetic Algorithms: Programming by the Seat of Your Genes](https://reader031.fdocuments.in/reader031/viewer/2022021919/5880e2c71a28ab0d358b51a7/html5/thumbnails/81.jpg)
NURSE SCHEDULING PROBLEM
Encoding Binary (with constraints)Crossover Single Point Crossover
Selection ProportionateMutation Point
![Page 82: Genetic Algorithms: Programming by the Seat of Your Genes](https://reader031.fdocuments.in/reader031/viewer/2022021919/5880e2c71a28ab0d358b51a7/html5/thumbnails/82.jpg)
ENCODING CONSTRAINTS
1 0
Grace
0
Mon1 2 3
Tues
1 0
1 2 …
… 0 1
Constance
0
Mon1 2 3
Thurs
1 0
1 2 3
1 …
…
…
…
…
…… …Shift
Day
![Page 83: Genetic Algorithms: Programming by the Seat of Your Genes](https://reader031.fdocuments.in/reader031/viewer/2022021919/5880e2c71a28ab0d358b51a7/html5/thumbnails/83.jpg)
WHEN TO EVOLVE
Use a GA on problems when:
There may not be an exact solution
Search spaces are large
The fitness landscape is complex
The best solutions lie on a Pareto front
![Page 84: Genetic Algorithms: Programming by the Seat of Your Genes](https://reader031.fdocuments.in/reader031/viewer/2022021919/5880e2c71a28ab0d358b51a7/html5/thumbnails/84.jpg)
GENETIC ALGORITHMS
SIMULATED ANNEALINGVS
Finds better solutions
Global search
Easily parallelized
Broader applications
Finds solutions faster
Local search
![Page 85: Genetic Algorithms: Programming by the Seat of Your Genes](https://reader031.fdocuments.in/reader031/viewer/2022021919/5880e2c71a28ab0d358b51a7/html5/thumbnails/85.jpg)
GENETIC ALGORITHMS
BRANCH & BOUNDVS
Approximate solutions
Better able to cope with large, complex problems
Best solution, guaranteed
Limited to small problems
O(n log n)
![Page 86: Genetic Algorithms: Programming by the Seat of Your Genes](https://reader031.fdocuments.in/reader031/viewer/2022021919/5880e2c71a28ab0d358b51a7/html5/thumbnails/86.jpg)
GENETIC ALGORITHMS
GRADIENT DESCENTVS
Discrete optimization
Wins at complex fitness landscapes
No calculus required =)
Continuous optimization
Wins at speed
![Page 87: Genetic Algorithms: Programming by the Seat of Your Genes](https://reader031.fdocuments.in/reader031/viewer/2022021919/5880e2c71a28ab0d358b51a7/html5/thumbnails/87.jpg)
GENETIC ALGORITHMS
NEURAL NETWORKSVS
Optimization
Classification (GBML)
Human Comparable Design
Classification†
Pattern recognition
† Also for screenplay creation
![Page 88: Genetic Algorithms: Programming by the Seat of Your Genes](https://reader031.fdocuments.in/reader031/viewer/2022021919/5880e2c71a28ab0d358b51a7/html5/thumbnails/88.jpg)
FURTHER READING
![Page 89: Genetic Algorithms: Programming by the Seat of Your Genes](https://reader031.fdocuments.in/reader031/viewer/2022021919/5880e2c71a28ab0d358b51a7/html5/thumbnails/89.jpg)
LIFE FINDS A WAY…
Special Thanks To:
Brook Graham Dr. Wes Kerr Kyle Putnam
Paul Sipe Jennifer Wadella