Genex v0.2.0 Genex.Operators.Mutation View Source
Implementation of several population mutation methods.
Mutation takes place according to some rate. Mutation is useful for introducing novelty into the population. This ensures your solutions don't prematurely converge.
Future versions of Genex will provide the ability to define the "aggressiveness" of mutations. As of this version of Genex, mutations effect the ENTIRE chromosome.
Link to this section Summary
Functions
Perform a bit-flip mutation.
Performs a gaussian mutation.
Perform inversion mutation on a random slice.
Perform inversion mutation on a known slice.
Performs Polynomial Bounded mutation.
Perform a scramble mutation.
Performs a scramble mutation of a known slice.
Performs uniform integer mutation.
Link to this section Functions
bit_flip(chromosome, radiation)
View Sourcebit_flip(Genex.Chromosome.t(), float()) :: Genex.Chromosome.t()
Perform a bit-flip mutation.
This mutation performs a binary XOR on every gene in the Chromosome.
Returns Chromosome
.
Parameters
chromosome
-Chromosome
to mutate.
gaussian(chromosome, radiation)
View Sourcegaussian(Genex.Chromosome.t(), float()) :: Genex.Chromosome.t()
Performs a gaussian mutation.
This mutation generates a random number at random genes in the chromosome. The random number is from a normal distribution produced from the mean and variance of the genes in the chromosome.
Returns Chromosome
.
Parameters
chromosome
-Chromosome
to mutate.radiation
- Aggressiveness of mutation.
invert(chromosome, radiation)
View Sourceinvert(Genex.Chromosome.t(), float()) :: Genex.Chromosome.t()
Perform inversion mutation on a random slice.
This mutation reverses (inverts) a random slice of genes of the Chromosome.
Returns %Chromosome{}
.
Parameters
chromosome
-Chromosome
to mutate.radiation
- Aggressiveness of mutation
invert(chromosome, start, finish)
View Sourceinvert(Genex.Chromosome.t(), integer(), integer()) :: Genex.Chromosome.t()
Perform inversion mutation on a known slice.
This mutation reverses (inverts) a known slice of genes of the Chromosome.
Returns %Chromosome{}
.
Parameters
chromosome
:Chromosome
to mutate.start
: Start of slice.finish
: End of slice.
Examples
iex> c1 = %Elixir.Genex.Chromosome{genes: [1, 2, 3, 4, 5], size: 5}
iex> invert(c1, 2, 4)
%Elixir.Genex.Chromosome{genes: [1, 2, 4, 3, 5], size: 5}
iex> c1 = %Elixir.Genex.Chromosome{genes: [1, 2, 3, 4, 5], size: 5}
iex> invert(c1, 10, 3)
%Elixir.Genex.Chromosome{genes: [1, 2, 3, 4, 5], size: 5}
iex> c1 = %Elixir.Genex.Chromosome{genes: [1, 2, 3, 4, 5], size: 5}
iex> invert(c1, 0, 10)
%Elixir.Genex.Chromosome{genes: [5, 4, 3, 2, 1], size: 5}
Performs Polynomial Bounded mutation.
See NSGA-II algorithm.
Returns Chromosome
.
Parameters
chromosome
-Chromosome
to mutate.radiation
eta
low
high
scramble(chromosome, radiation)
View Sourcescramble(Genex.Chromosome.t(), float()) :: Genex.Chromosome.t()
Perform a scramble mutation.
This mutation shuffles the genes of the Chromosome between 2 random points.
Returns %Chromosome{}
.
Parameters
chromosome
:Chromosome
to mutate.radiation
: Aggressiveness of the mutation.
scramble(chromosome, start, finish)
View Sourcescramble(Genex.Chromosome.t(), integer(), integer()) :: Genex.Chromosome.t()
Performs a scramble mutation of a known slice.
This mutation shuffles the genes of a Chromosome between 2 known points.
Parameters
chromosome
:Chromosome
to mutate.start
: First scramble point.finish
: Second scramble point.
Examples
iex> c1 = %Elixir.Genex.Chromosome{genes: [1, 2, 3, 4, 5], size: 5}
iex> scramble(c1, 10, 4)
%Elixir.Genex.Chromosome{genes: [1, 2, 3, 4, 5], size: 5}
uniform_integer(chromosome, radiation, min, max)
View Sourceuniform_integer(Genex.Chromosome.t(), float(), integer(), integer()) :: Genex.Chromosome.t()
Performs uniform integer mutation.
This mutation generates a random number at random genes in the chromosome.
Returns Chromosome
.
Parameters
chromosome
-Chromosome
to mutate.radiation
- Aggressiveness of mutation.min
- lower boundmax
- upper bound