If you are making your own evolutionary algorithm, there are several files that you should edit
This file defines what an individual is (in a class). Generically, an individual is simply an ordered collection of chromosomes. The original implementation treats each chromosome differently. Therefore, all the chromosomes of an individual are maintained in a list as opposed to a set.
Also implemented in this file are methods to the individual class that help identify an individual, define its hash, test its equality to another individual instance, etc
This file contains the functions that define population generation. The important function defined here is genPop(), which may be used as an interface to creating unique individuals.
Parameters: |
|
---|---|
Return type: | list of unique individuals. Uniqueness is defined by Individual.__eq__ |
chromGenfuncs is a list of functions. The idea here is that each individual in the population is made up of C chromosomes. These C chromosomes are generated independently of each other for each individual in the initial population. Therefore, there must be exactly C functions listed in chromGenfuncs. The i th function in chromGenfuncs will be used to generate the i th chromosome of each individual
chromGenParams is a list of tuples. There should be exactly as many tuples in this list, as there are functions in chromGenfuncs. To generate the ith chromosome for each individual in the population, the ith function in chromGenfuncs is called with the parameters in the ith tuple of chromGenParams as follows:
chromGenfuncs[i](*chromGenParams[i])
Though that is the general idea behind how genPop() works, it actually performs this call in a for loop over a zip() of chromGenfuncs and chromGenParams
This file contains all selection functions for evaluating the fitness of any individual of the population. The main function in this file is called score().
Parameters: |
|
---|---|
Return type: | number (the fitness of the individual) |
Note
if the individual being evaluated by this function (p) was not in SCORES before the function is executed, it will be inserted into SCORES by this function. Thus, SCORES is modified in-place by this function as required.
This file contains all selection functions for selecting individuals from a population for any purpose.
There are three important functions already implemented:
Parameters: |
|
---|---|
Return type: | list of individuals |
Parameters: |
|
---|---|
Return type: | single individual |
Parameters: |
|
---|---|
Return type: | list of 3-tuples (Individual, lowerBound, UpperBound) |
All functions that have to do with crossing over chromosomes between individuals are defined here. There is no generic driver function here as crossovers are defined per GA.
All functions that have to do with mutating chromosomes between individuals are defined here. There is no generic driver function here as mutations are defined per GA