Math Adventures With Python

Math Adventures With Python — page 9
12 solving Problems Using Genetic algorithms 247 Using a Genetic Algorithm to Guess Phrases 248 Writing the makeList Function 248 Testing the makeList Function 249 Writing the score Function 250 Writing the mutate Function 250 Generating a Random Number 251 Solving the Traveling Salesperson Problem TSP 254 Using Genetic Algorithms 254 Writing the calcLength Method 260 Testing the calcLength Method 261 Random Routes 262 Applying the Phrase-Guessing Mutation Idea 265 Mutating Two Numbers in a List 265 Crossing Over to Improve Routes 269 Summary 271 index 273 Contents in Detail