Optimizing Himmelblau's function with genetic algorithms

The genetic algorithm-based program we created for finding a single minimum of Himmelblau's function resides in the Python 02-optimize-himmelblau.py program, located at:


The program is similar to the one we used for optimizing the Eggholder function, with a few differences highlighted as follows:

  1. We set the boundaries for this function to [-5.0, 5.0]:
BOUND_LOW, BOUND_UP = -5.0, 5.0  # boundaries for all dimensions
  1. We now use Himmelblau's function as the fitness evaluator:
def himmelblau(individual):    x = individual[0]    y = individual[1]    f = (x ** 2 + y - 11) ** ...

Get Hands-On Genetic Algorithms with Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.