Simple_Energy_Predation_Operator.py

Meow

Energy_Diversity_Scheme.py, Geoffrey Weal, 28/10/2018

This is one of the Diversity schemes that can be used by the genetic algorithm program. This is the Energy Diversity Scheme.

This scheme works by preventing the population from having clusters with the same energy existing in the population at any one time.

Organisms.GA.Predation_Operators.Energy_Predation_Operator_Scripts.Simple_Energy_Predation_Operator.Check_for_Issue_with_Scheme_with_collection(self, collection)

This method allows us to check that the collection does not violate the simple diversity scheme after it has been perform on the collection.

The collection is either the Population of Offspring_Pool.

Parameters:

collection (Population or Offspring_Pool) – This is the collection to record. This is either the instance of the Population or the Offspring_Pool

Organisms.GA.Predation_Operators.Energy_Predation_Operator_Scripts.Simple_Energy_Predation_Operator.assess_for_violations(self, offspring_pool)

This will assess which offspring to remove before the natural selection process.

The offspring are assessed against clusters in the population. Offspring are removed from the offsprings if: * They have an energy equal to another offspring * They have an energy equal to another cluster in the population.

Parameters:

offsprings (Offspring_Pool) – This is the offspring that you want to add eventually using the natural selection process to the population.

Organisms.GA.Predation_Operators.Energy_Predation_Operator_Scripts.Simple_Energy_Predation_Operator.check_initial_population(self, return_report=False)

This definition is responsible for making sure that the initialised population obeys the Energy Diversity Scheme.

Here, the clusters in the population are checked to see if they have the same energy. This is needed for after the population has been initally populated with randomly generated clusters and clusters the user has specified.

Parameters:

return_report (bool.) –

Returns:

Contains a list of [the index of cluster in pop, the dir of the cluster] that have been removed from the population as they violate the Energy Diversity Scheme. * same_energies_report ({int: [int,…]}): Contain a more detailed report of what this method has done by returning a dictorary in the format of {dir of kept cluster: [list of dirs of clusters that have been removed because they have the same energy as the cluster that was kept.]}

Return type:

  • clusters_to_remove ([[int,str],…])