Genetic algorithms solution

To solve the graph coloring problem using a genetic algorithm, we've created the Python program 03-solve-graphs.py, which is located at https://github.com/PacktPublishing/Hands-On-Genetic-Algorithms-with-Python/blob/master/Chapter05/03-solve-graphs.py.

Since the solution representation we chose for this problem is a list of integers, we need to expand the genetic approach of using a binary list a little bit.

The following steps describe the main points of our solution:

  1. The program starts by creating an instance of the GraphColoringProblem class with the desired NetworkX graph to be solved the familiar Petersen graph in this case, and the desired value for hardConstraintPenalty, which is set by the HARD_CONSTRAINT_PENALTY ...

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.