O'Reilly logo

Genetic Algorithms and Machine Learning for Programmers by Frances Buontempo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Did It Work?

Whichever function and algorithm you chose, you might end up with a turtle in your bag. If you don’t set the limits in the simulated annealing, you might end up with a turtle off the edge of the screen.

Hill Climbing

With the slightly slanting bag, and a sensible step size, around 0.1, your turtle can settle down in the bottom of the bag as shown in the figure.

images/Optimize/slanty_bag_300.png

He’s settled on the far right corner of the bag. If you make a larger step size, for example, the whole width of the bag, the turtle will get stuck quickly. You see this clearly when you try a different function, such as

 f = ​lambda​ x: math.fabs(x)

This gives you a v-shape. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required