Implementation of GA using Python
In this section, we will learn how GA can be implemented in Python to optimize a mathematical function. We will use the same function that we have talked about earlier in this lesson. The mathematical function that we want to maximize is stated below:
The implement of the algorithm is discussed step-by-step in the rest of this section.
xxxxxxxxxx
genes = 2
chromosomes = 10
lb = -5
ub = 5
populationSize = (chromosomes, genes)
generations = 50
mattingPoolSize = 6
offspringSize = populationSize - mattingPoolSize
OUTPUT
:001 > Cmd/Ctrl-Enter to run, Cmd/Ctrl-/ to comment