Comprehensive_Energy_Predation_Operator_fitness.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.Comprehensive_Energy_Predation_Operator_fitness.Check_for_Issue_with_Scheme_with_collection(self, collection)

This method allows us to check that the collection does not violate the comprehensive 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

class Organisms.GA.Predation_Operators.Energy_Predation_Operator_Scripts.Comprehensive_Energy_Predation_Operator_fitness.Cluster_Block(collection, collection_type, index)

This is used by the Remove_Cluster_Due_To_Diversity_Violation definition to store information in an easy way to help the user understand what is going on in this method

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

  • collection_type (str.) – This describes if the cluster recorded is in the population (given as ‘pop’) or the offspring (given as ‘off’).

  • index (int) – The position/index of the cluster in the collection.

Organisms.GA.Predation_Operators.Energy_Predation_Operator_Scripts.Comprehensive_Energy_Predation_Operator_fitness.assess_for_violations_force_replacement(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 offspring_pool if: * They have an energy equal to another offspring * They have an energy equal to another cluster in the population.

Parameters:

offspring_pool (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.Comprehensive_Energy_Predation_Operator_fitness.assess_for_violations_no_force_replacement(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 offspring_pool if: * They have an energy equal to another offspring * They have an energy equal to another cluster in the population.

Parameters:

offspring_pool (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.Comprehensive_Energy_Predation_Operator_fitness.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.) – This indicates if the user want to return a report on which clusters were removed and why (i.e. what clusters it was similar to energetically.)

Returns:

Contains a list of [the index of cluster in pop, the name of the cluster] that have been removed from the population as they violate the Energy Diversity Scheme. * Energy_Diversity_report ({int: [int,…]}): Contain a more detailed report of what this method has done by returning a dictorary in the format of {name of kept cluster: [list of names 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],…])