Fitness_Operator.py¶
This class is designed to assess replicating features in the population and offspring as well as to provide a fitness factor which allows Natural Selection to differentiate between structures. This class is effectly an interface
-
class
Organisms.GA.Fitness_Operators.Fitness_Operator.
Fitness_Operator
(fitness_information, population, print_details)¶ The Fitness class is designed to determine and assign the appropriate fitness value to clusters created during the genetic algorithm. This class can be thought as an extension of the predation Operator. This class contains all the appropriate steps that are needed for the fitnesses to be efficiency assigned to created clusters.
- There are only two methods that need to be written for the predation Operator that is to be used. These are:
assign_population_fitnesses
assign_all_fitnesses
Note: This class is intended to work as an interface only. Refer to the instruction manual as to how to use this interface to build your own predation Operator.
- Parameters
fitness_information (dict.) – The informatino needed by the Fitness_Operator
population (Organisms.GA.Population) – The population to assign fitnesses to
print_details (bool) – Print the details of the energy fitness operator. True if yes, False if no
-
abstract
assign_all_fitnesses_after_assess_against_predation_operator
(all_offspring_pools, current_generation_no, offspring_to_remove)¶ This method is to be used in the GA program. This will assign all the fitnesses of all clusters in the current generation (population and offspring) after the offspring are assessed to understand if they violate the predation scheme (i.e. an offspring is Class 1 similar to a cluster in the population, or another offspring).
See the description given for the “assign_all_fitnesses” def on what the crux of this method is.
If you write your own diversiy and fitness classes, you do not need to implement this method in your fitness class.
- Parameters
all_offspring_pools (list of Organisms.GA.Offspring_Pool) – All of the offspring_pools
current_generation_no (int) – The current generation
offspring_to_remove (list of int) – a list of all the names of clusters in the offspring that will be removed.
-
abstract
assign_all_fitnesses_after_natural_selection
(current_generation_no)¶ This method is to be used in the GA program. This will assign all the fitnesses to all the clusters in the population before the offspring are assessed to understand if they violate the predation operator (i.e. an offspring is Class 1 similar to a cluster in the population, or another offspring).
See the description given for the “assign_population_fitnesses” def on what the crux of this method is.
If you write your own diversiy and fitness classes, you do not need to implement this method in your fitness class.
- Parameters
current_generation_no (int) – The current generation
-
abstract
assign_all_fitnesses_before_assess_against_predation_operator
(all_offspring_pools, current_generation_no)¶ This method is to be used in the GA program. This will assign all the fitnesses of all clusters in the current generation (population and offspring) before the offspring are assessed to understand if they violate the predation scheme (i.e. an offspring is Class 1 similar to a cluster in the population, or another offspring).
See the description given for the “assign_all_fitnesses” def on what the crux of this method is.
If you write your own diversiy and fitness classes, you do not need to implement this method in your fitness class.
- Parameters
all_offspring_pools (list of Organisms.GA.Offspring_Pool) – All of the offspring_pools
current_generation_no (int) – The current generation
-
abstract
assign_initial_population_fitnesses
()¶ This method is designed to assign fitness values to the clusters of the population only at the start of the GA, when the population has been initialised
This is an abstract method. If you write your own diversiy and fitness classes, you MUST write something for this method.
-
abstract
assign_resumed_population_fitnesses
(resume_from_generation)¶ This method is designed to assign fitness values to the clusters of the population only at the beginning of a resumed GA.
This is an abstract method. If you write your own diversiy and fitness classes, you MUST write something for this method.
- Parameters
resume_from_generation (int) – The current generation to resume from.
-
check
()¶ This method will check that the self.fitness_switch is an available fitness operator.