Skip to content

Create a mutation operator randomly changing single genes #36

@gnypit

Description

@gnypit

Right now default mutation in the GeneticAlgorithm class randomly selects whole current generation's members up for re-generation of their entire genome. An alternative is to create a mask of what to change not for the members, but for their genome.

That is:

  • a mask of length computed by a formula similar to current_generation.size * len(Chromosome.genome) should be created;
  • based on the mask, indexes indicated for mutation should be re-calculated to point which members should be changed;
  • mutation operator should 'enter' the member and change single genes based on the mask.

Example:
Let the mutation probability be prob=0.1. Let us have 10 members in a generation, with 20 genes each. This new mutation operator would create a list of 20 * 10 elements, with 1 appearing with prob=0.1 and 0 with probability 1-prob=0.9, like this:
[0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, ...]
In this case, these first 20 elements of the list apply to the first member of the current generation. 5th and 14th gene of this member should be randomly changed, based on provided genome_generator.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions