Download presentation
Presentation is loading. Please wait.
1
Transporting Perishable Goods (ANEB-TSP) The Art of Implementing an EA Assignment 1 CS 348 Fall 2008
2
Asymmetric Non-Euclidean Bottleneck TSP 1 2 4 5 3 Travel Time (hours) 7 15 10 11 6 8 12 14
3
Dataset File Format Number of vertices v e s1 d1 w1 s2 d2 w2 … s d w Number of edges Edge info: Source vertex Destination vertex Edge weight Example: 5 10 1 4 10 4 1 14 4 3 6 3 4 8 3 5 11 5 3 11 … 1 2 4 5 3 7 15 10 11 6 8 12 14
4
Individual Genotype Representation Permutations 1 2 4 5 3 7 15 10 11 6 8 12 14 Possible Permutations 1 4 3 5 2 5 2 1 4 3 2 5 3 4 1 Cycle 1 Cycle 2
5
Permutation Creation 1.Create array 2.Number in-order 3.Loop i ← 1 to N 1.j ← random ≥ i 2.Swap(A[i], A[j]) 123456423156435162
6
Individual Datastructure A standard EA solution will usually have 2 data members –Genotype –Fitness Fitness is stored to avoid recalculation –For static problem environments
7
Fitness Calculation Find the edge with the largest weight in the trial solution (the permutation) –weights are given in the datafile Fitness should be inversely proportional to the largest weight –Objective function vs. Fitness function –Ideas Fitness = - largest weight Fitness = 1 / largest weight – Highest fitness value will be the best individual
8
Program Requirements Read from a configuration file Complete 1+ runs of the EA Write information to a log file
9
Required Parameters in Configuration File ( datafile ) Dataset file ( logfile ) Log file ( popsize ) Population size ( offsize ) Offspring per generation ( tournsize ) Tournament size ( maxeval ) Maximum evaluations ( runs ) Number of runs ( seed ) Random seed
10
Initial Setup Open configuration file Parse values into variables Read datafile describing the TSP dataset Seed random number generator
11
Random Number Generator Is a datastructure Updates internal variables every time a random number is requested Seed only once Use quality RNG –the Mersenne Twister http://www- personal.engin.umich.edu/~wagnerr/MersenneTwister.htmlhttp://www- personal.engin.umich.edu/~wagnerr/MersenneTwister.html
12
EA Run –Pass in all configuration data Create data structures for population/offspring – population [ popsize ] – offspring [ offsize ] Initialize population with random individuals – evalcount = popsize While( evalcount < maxevals ) –For # of children (offsize) Select two parents by two n-ary tournaments Recombine using cut-and-crossfill Mutate offspring Evaluate child’s fitness ( evalcount++ ) –Sort and elitist survival selection
13
Parent Selection Create tournsize random numbers for each parent to be selected ( r1 … rn ) Parent 1 –max_fitness(population[ r1 ]... population[ rn ]) Parent 2 –generate new random numbers ( t1 … tn ) –max_fitness(population[ t1 ]... population[ tn ])
14
Recombination (“cut-and-crossfill”) 436125243156 Child 436215
15
Recombination (“cut-and-crossfill”) 1.Used[] ← boolean array of all false’s 2.XPoint ← random from 1 to N 3.For (i ← 1 to XPoint) 1.Child[i] ← ParentA[i] 2.Used[Child[i]] ← true 4.j ← 0 5.For (i ← XPoint to N ) 1.While(Used[ParentB[j]]) 1.j ← j + 1 2.Child[i] ← ParentB[j]
16
Bonus – Implementing Another Recombination Method Many ways to implement crossover for a permutation –Affects performance of the EA Examples – Chapter 3 –Partially Mapped Crossover (PMC) –Edge Crossover –Order Crossover –Cycle Crossover
17
Mutation 1.i ← random from 1 to N 2.j ← random from 1 to N 3.Swap(Child[i], Child[j]) 436215
18
Truncation Survival Selection Combine population and offspring into one group Sort by fitness Keep the best popsize individuals in the population
19
Bonus – Compare to a Heuristic Implement or test a good existing heuristic for the ANEB-TSP Statistically compare to the EA Code for the heuristic is due along with the report
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.