Adding Complex Genetypes closes #322 #343
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR closes issue #322.
I made a comment on it a month ago, how this could be implemented. The way i described it on issue #322 was only partially possible. This means to ensure the program still runs the same i made only slight changes. I did not allow the user to write the gene in nested array form like i said i would, but i kept the gene_structure parameter. Therefore the user now gives num_genes and all other parameters, as well as the new gene_structure parameter to describe the nested form of its genes.
For example given a gene length of 8 the user proposes the following structure [2,1,1,1,3], then the gene has the form [ [i_0,i_1], i_2, i_3, i_4, [i_5,i_2,i_6] ].
The gene_structure then is used to calculate boundaries via the np.cumsum method.
np.cumsum(gene_structure) == num_genes; must be given.
Once a gene_structure is given it is absolute, and all genes will be in this form.
Boundaries is an array that holds all the indices that can be chosen as crossoverpoint. The length of the gene_structure parameter is continously used instead of num_genes or the offspring length for the mutation methods in order to ensure that the probabilities of mutation are the same for all genetypes regardless of their length.
The algorithm itself still uses a 1 dimensional array even when using the gene_structure. When the gene_structure is given it simply respects the boundaries and ensures atomicity. Meaning crossovers can not happen inbetween an array. Also if a complex genetype is selected to mutate all values inside will mutate (atomicity).
The fitnesswrapper was not implemented, since i did not allow the user to give nested arrays, therefore the user uses the fitness function the same way as before, control over every allele was already given.
Also added some test to confirm functionality.
Documentation should be added automatically by following the given pattern.
Some Mutation methods are slightly altered, but the functionality is the same. Uniform use of the boundaries is applied. Meaning if no gene_structure is given the boundaries are idx, idx+1 resulting in the loop with an start, end index working the same for both a given gene_structure and None.
For further questions you can address me.