Generating a bit pattern with predefined parameters
Now that we know the basic concepts behind a GA, let's see how to use it to solve some problems. We will be using a Python package called DEAP
. You can find all the details about it at http://deap.readthedocs.io/en/master. Let's go ahead and install it by running the following command:
$ pip3 install deap
Now that the package is installed, let's quickly test it. Go into the Python shell by typing the following command:
$ python3
Once you are inside, type the following:
>>> import deap
If you do not see an error message, you are good to go.
In this section, we will use a variant of the One Max algorithm. The One Max algorithm tries to generate a bit string that contains the maximum number of ones. It is a simple algorithm, but it's helpful to get familiar with the library in order to better understand how to implement solutions using GAs. In this case, a bit string may...