pycellga.mutation package

Submodules

pycellga.mutation.bit_flip_mutation module

class pycellga.mutation.bit_flip_mutation.BitFlipMutation(mutation_cand: Individual = None, problem: AbstractProblem = None)[source]

Bases: MutationOperator

BitFlipMutation performs a bit flip mutation on an individual in a Genetic Algorithm.

Parameters:
  • mutation_cand (Individual, optional) – The candidate individual to be mutated (default is None).

  • problem (AbstractProblem, optional) – The problem instance that provides the fitness function (default is None).

__init__(mutation_cand: Individual = None, problem: AbstractProblem = None)[source]

Initialize the BitFlipMutation object.

Parameters:
  • mutation_cand (Individual, optional) – The candidate individual to be mutated (default is None).

  • problem (AbstractProblem, optional) – The problem instance that provides the fitness function (default is None).

mutate() Individual[source]

Perform a bit flip mutation on the candidate individual.

A single bit in the candidate’s chromosome is randomly selected and flipped (i.e., a 0 is changed to a 1, or a 1 is changed to a 0).

Returns:

A new individual with the mutated chromosome.

Return type:

Individual

pycellga.mutation.byte_mutation module

class pycellga.mutation.byte_mutation.ByteMutation(mutation_cand: Individual = None, problem: AbstractProblem = None)[source]

Bases: MutationOperator

ByteMutation operator defined in (Satman, 2013). ByteMutation performs a byte-wise mutation on an individual’s chromosome in a Genetic Algorithm.

Parameters:
  • mutation_cand (Individual, optional) – The candidate individual to be mutated (default is None).

  • problem (AbstractProblem, optional) – The problem instance that provides the fitness function (default is None).

__init__(mutation_cand: Individual = None, problem: AbstractProblem = None)[source]

Initialize the ByteMutation object.

Parameters:
  • mutation_cand (Individual, optional) – The candidate individual to be mutated (default is None).

  • problem (AbstractProblem, optional) – The problem instance that provides the fitness function (default is None).

mutate() Individual[source]

Perform a byte-wise mutation on the candidate individual.

A single byte in one of the candidate’s chromosome’s floating-point numbers is randomly selected and either incremented or decremented by 1, wrapping around if necessary.

Returns:

A new individual with the mutated chromosome.

Return type:

Individual

pycellga.mutation.byte_mutation_random module

class pycellga.mutation.byte_mutation_random.ByteMutationRandom(mutation_cand: Individual = None, problem: AbstractProblem = None)[source]

Bases: MutationOperator

ByteMutationRandom operator defined in (Satman, 2013). ByteMutationRandom performs a random byte mutation on an individual’s chromosome in a Genetic Algorithm.

Parameters:
  • mutation_cand (Individual, optional) – The candidate individual to be mutated (default is None).

  • problem (AbstractProblem, optional) – The problem instance that provides the fitness function (default is None).

__init__(mutation_cand: Individual = None, problem: AbstractProblem = None)[source]

Initialize the ByteMutationRandom object.

Parameters:
  • mutation_cand (Individual, optional) – The candidate individual to be mutated (default is None).

  • problem (AbstractProblem, optional) – The problem instance that provides the fitness function (default is None).

mutate() Individual[source]

Perform a random byte mutation on the candidate individual.

A single byte in one of the candidate’s chromosome’s floating-point numbers is randomly selected and mutated to a random value.

Returns:

A new individual with the mutated chromosome.

Return type:

Individual

pycellga.mutation.float_uniform_mutation module

class pycellga.mutation.float_uniform_mutation.FloatUniformMutation(mutation_cand: Individual = None, problem: AbstractProblem = None)[source]

Bases: MutationOperator

FloatUniformMutation performs a uniform mutation on an individual’s chromosome in a Genetic Algorithm.

Parameters:
  • mutation_cand (Individual, optional) – The candidate individual to be mutated (default is None).

  • problem (AbstractProblem, optional) – The problem instance that provides the fitness function (default is None).

__init__(mutation_cand: Individual = None, problem: AbstractProblem = None)[source]

Initialize the FloatUniformMutation object.

Parameters:
  • mutation_cand (Individual, optional) – The candidate individual to be mutated (default is None).

  • problem (AbstractProblem, optional) – The problem instance that provides the fitness function (default is None).

mutate() Individual[source]

Perform a uniform mutation on the candidate individual.

Each gene in the candidate’s chromosome is mutated by adding or subtracting a random float uniformly sampled from [0, 1]. The mutation is rounded to 5 decimal places.

Returns:

A new individual with the mutated chromosome.

Return type:

Individual

pycellga.mutation.insertion_mutation module

class pycellga.mutation.insertion_mutation.InsertionMutation(mutation_cand: Individual = None, problem: AbstractProblem = None)[source]

Bases: MutationOperator

InsertionMutation performs an insertion mutation on an individual’s chromosome in a Genetic Algorithm.

Parameters:
  • mutation_cand (Individual, optional) – The candidate individual to be mutated (default is None).

  • problem (AbstractProblem, optional) – The problem instance that provides the fitness function (default is None).

__init__(mutation_cand: Individual = None, problem: AbstractProblem = None)[source]

Initialize the InsertionMutation object.

Parameters:
  • mutation_cand (Individual, optional) – The candidate individual to be mutated (default is None).

  • problem (AbstractProblem, optional) – The problem instance that provides the fitness function (default is None).

mutate() Individual[source]

Perform an insertion mutation on the candidate individual.

A gene in the candidate’s chromosome is randomly selected and moved to a new position in the chromosome.

Returns:

A new individual with the mutated chromosome.

Return type:

Individual

pycellga.mutation.mutation_operator module

class pycellga.mutation.mutation_operator.MutationOperator[source]

Bases: object

mutate()[source]

pycellga.mutation.shuffle_mutation module

class pycellga.mutation.shuffle_mutation.ShuffleMutation(mutation_cand: Individual = None, problem: AbstractProblem = None)[source]

Bases: MutationOperator

ShuffleMutation performs a shuffle mutation on an individual’s chromosome in a Genetic Algorithm.

Parameters:
  • mutation_cand (Individual, optional) – The candidate individual to be mutated (default is None).

  • problem (AbstractProblem, optional) – The problem instance that provides the fitness function (default is None).

__init__(mutation_cand: Individual = None, problem: AbstractProblem = None)[source]

Initialize the ShuffleMutation object.

Parameters:
  • mutation_cand (Individual, optional) – The candidate individual to be mutated (default is None).

  • problem (AbstractProblem, optional) – The problem instance that provides the fitness function (default is None).

mutate() Individual[source]

Perform a shuffle mutation on the candidate individual.

A subsequence of genes in the candidate’s chromosome is randomly selected and shuffled.

Returns:

A new individual with the mutated chromosome.

Return type:

Individual

pycellga.mutation.swap_mutation module

class pycellga.mutation.swap_mutation.SwapMutation(mutation_cand: Individual = None, problem: AbstractProblem = None)[source]

Bases: MutationOperator

SwapMutation performs a swap mutation on an individual’s chromosome in a Genetic Algorithm.

Parameters:
  • mutation_cand (Individual, optional) – The candidate individual to be mutated (default is None).

  • problem (AbstractProblem, optional) – The problem instance that provides the fitness function (default is None).

__init__(mutation_cand: Individual = None, problem: AbstractProblem = None)[source]

Initialize the SwapMutation object.

Parameters:
  • mutation_cand (Individual, optional) – The candidate individual to be mutated (default is None).

  • problem (AbstractProblem, optional) – The problem instance that provides the fitness function (default is None).

mutate() Individual[source]

Perform a swap mutation on the candidate individual.

Two genes in the candidate’s chromosome are randomly selected and swapped.

Returns:

A new individual with the mutated chromosome.

Return type:

Individual

pycellga.mutation.two_opt_mutation module

class pycellga.mutation.two_opt_mutation.TwoOptMutation(mutation_cand: Individual = None, problem: AbstractProblem = None)[source]

Bases: MutationOperator

TwoOptMutation performs a 2-opt mutation on an individual’s chromosome in a Genetic Algorithm.

Parameters:
  • mutation_cand (Individual, optional) – The candidate individual to be mutated (default is None).

  • problem (AbstractProblem, optional) – The problem instance that provides the fitness function (default is None).

__init__(mutation_cand: Individual = None, problem: AbstractProblem = None)[source]

Initialize the TwoOptMutation object.

Parameters:
  • mutation_cand (Individual, optional) – The candidate individual to be mutated (default is None).

  • problem (AbstractProblem, optional) – The problem instance that provides the fitness function (default is None).

mutate() Individual[source]

Perform a 2-opt mutation on the candidate individual.

A segment of the candidate’s chromosome is randomly selected and reversed.

Returns:

A new individual with the mutated chromosome.

Return type:

Individual

Module contents