Mutation

Mutation

class gaggle.operators.mutation.mutation.Mutation(ga_args: GAArgs = None)[source]

Bases: object

The parent class for any Mutation Operator. It gives a basic function to mutate a whole population once the function for mutating a single individual is specified

abstract mutate_individual(individual: Individual) Individual[source]

Speficies how to mutate a single individual :param individuals: a single individual to mutate

Returns:

A single individual after mutation

mutate_pop(manager: PopulationManager) PopulationManager[source]

Calls the mutate_individual function for each member of the population :param manager: PopulationManager object holding the current population

Returns:

Modified PopulationManager object

Mutation_factory

class gaggle.operators.mutation.mutation_factory.MutationFactory[source]

Bases: object

Factory that generates pre-existing available mutation operators. MutationFactory.mutations stores said mutation operators as a dictionary with their name as the key and the uninitialized mutations object as the value.

classmethod from_ga_args(ga_args: GAArgs = None) Mutation[source]

Initializes the requested mutation from the dictionary of available mutations.

This is done by using the attribute ga_args.mutation as the lookup key to MutationFactory.mutations.

Parameters:

ga_args – GAArgs object for the current run

Returns:

An initialized mutation class object.

classmethod get_keys()[source]

Returns the list of currently registered mutations

mutations = {'normal': <class 'gaggle.operators.mutation.base_mutations.normal_mutation.NormalMutation'>, 'uniform': <class 'gaggle.operators.mutation.base_mutations.uniform_mutation.UniformMutation'>}
classmethod update(key, mutation)[source]

Add a new mutation operator to the dictionary of mutations that can be created.

It is added to MutationFactory.mutations

Parameters:
  • key – mutation name that will be used as the dictionary lookup key

  • mutation – mutation class object, it needs to not be already initialized