Initialise_Population.py
This class is designed
- Organisms.GA.Initialise_Population.Check_Population_against_predation_operator(population, predation_operator)
Checks that all the clusters in this newly initialised population obey the predation operator
- Parameters:
population (Organisms.GA.Population) – The population
predation_operator (Organisms.GA.Predation_Operator) – This is the predation operator
:returns a list of all the clusters that do not obey the predation operator, as well as a report about the issues. :rtype A list of int, and a string
- Organisms.GA.Initialise_Population.Initialise_Population(population, cluster_makeup, surface, Minimisation_Function, memory_operator, predation_operator, fitness_operator, epoch, cell_length, vacuum_to_add_length, r_ij, rounding_criteria, no_of_cpus, previous_cluster_name=0, generation=0, get_already_created_clusters=True, is_epoch=False, epoch_due_to_population_energy_convergence=None)
- This method will initalise the Population by
Placing clusters that the user would like in the initial population
Generate a number of extra clusters so that the population has the desired number of clusters in it.
This method is used when the population is first created when the genetic algorithm is just starting, and when an epoch method is resetting the population with a new population of randomly generated clusters.
- Parameters:
population (Organisms.GA.Population) – The population
cluster_makeup (dict.) – The makeup of the cluster
surface (Organisms.GA.Surface) – This is the surface that the cluster is placed on. None means there is no surface.
Minimisation_Function (__func__) – The minimisation function
memory_operator (Organisms.GA.Memory_Operator) – The memory operator
epoch (Organisms.GA.Epoch) – The epoch method
predation_operator (Organisms.GA.Predation_Operator) – This is the predation operator
fitness_operator (Organisms.GA.Fitness_Operator) – This is the fitness operator
cell_length (float) – This is the length of the square unit cell the cluster will be created in.
vacuum_to_add_length (float) – The amount of vacuum to place around the cluster
r_ij (float) – The maximum distance that should be between atoms to be considered bonded. This value should be as large a possible, to reflected the longest bond possible between atoms in the cluster.
rounding_criteria (int) – The number of decimal places to round the energy of clusters to.
no_of_cpus (int) – The number of cpus available to create clusters
previous_cluster_name (int) – This is the name of the last cluster created in the genetic algorithm. Default: 0
generation (int) – The number of generations that have been performed. Default: 0
get_already_created_clusters (bool.) – Are there clusters that the user created in the population. True if yes, False if no. Default: True
is_epoch (bool.) – Has the genetic algorithm just epoched. Default: False
epoch_due_to_population_energy_convergence (bool.) – Did the genetic algorithm epochbecause the energies of the clusters in the last populatino converge. Default: None
- Returns previous_cluster_name:
This is the name of the last cluster created by this method
- Rtype previous_cluster_name:
int
- Organisms.GA.Initialise_Population.Initialise_Population_with_Randomly_Generated_Clusters(population, cluster_makeup, surface, Minimisation_Function, cell_length, vacuum_to_add_length, r_ij, rounding_criteria, no_of_cpus, memory_operator, predation_operator, fitness_operator, previous_cluster_name)
This method will place a number of randomly generated clusters into the population until it is at the desired size.
- Parameters:
population (Organisms.GA.Population) – The population
cluster_makeup (dict.) – The makeup of the cluster
surface (Organisms.GA.Surface) – This is the surface that the cluster is placed on. None means there is no surface.
Minimisation_Function (__func__) – The minimisation function
cell_length (float) – This is the length of the square unit cell the cluster will be created in.
vacuum_to_add_length (float) – The amount of vacuum to place around the cluster
r_ij (float) – The maximum distance that should be between atoms to be considered bonded. This value should be as large a possible, to reflected the longest bond possible between atoms in the cluster.
rounding_criteria (int) – The number of decimal places to round the energy of clusters to.
no_of_cpus (int) – The number of cpus available to create clusters
predation_operator (Organisms.GA.Predation_Operator) – This is the predation operator
fitness_operator (Organisms.GA.Fitness_Operator) – This is the fitness operator
memory_operator (Organisms.GA.Memory_Operator) – The memory operator
previous_cluster_name (int) – This is the name of the last cluster created in the genetic algorithm.
returns The name of the most recently created cluster by this method in the population. rtype int
- Organisms.GA.Initialise_Population.Place_Already_Created_Clusters_In_Population(population, cluster_makeup, Minimisation_Function, vacuum_to_add_length, r_ij, rounding_criteria, surface, memory_operator, predation_operator, fitness_operator, previous_cluster_name)
This method will place any user created clusters into the population.
- Parameters:
population (Organisms.GA.Population) – The population
cluster_makeup (dict.) – The makeup of the cluster
Minimisation_Function (__func__) – The minimisation function
vacuum_to_add_length (float) – The amount of vacuum to place around the cluster
r_ij (float) – The maximum distance that should be between atoms to be considered bonded. This value should be as large a possible, to reflected the longest bond possible between atoms in the cluster.
rounding_criteria (int) – The number of decimal places to round the energy of clusters to.
surface (Organisms.GA.Surface) – This is the surface that the cluster is placed on. None means there is no surface.
memory_operator (Organisms.GA.Memory_Operator) – The memory operator
predation_operator (Organisms.GA.Predation_Operator) – This is the predation operator
fitness_operator (Organisms.GA.Fitness_Operator) – This is the fitness operator
previous_cluster_name (int) – This is the name of the last cluster created in the genetic algorithm.
:returns The name of the most recently created cluster by this method in the population. :rtype int
- Organisms.GA.Initialise_Population.create_a_cluster(input_data)
This will create a cluster, allowing the user to create cluster via multiprocessing.
- Parameters:
input_data (list of Any) – This tuple contains all the information required to create a new randomly generated cluster.
returns tuple of the index to place the cluster into the population, and the optimised cluster rtype (int,Organisms.GA.Cluster)
- Organisms.GA.Initialise_Population.get_tasks(population, clusters_to_create, cell_length, vacuum_to_add_length, cluster_makeup, surface, r_ij, rounding_criteria, Minimisation_Function, memory_operator)
This is a generator that will allow python to create clusters with multiprocessing.
- Parameters:
population (Organisms.GA.Population) – The population
clusters_to_create (list of int) – This is a list of all the names for the clusters to be given.
cell_length (float) – This is the length of the square unit cell the cluster will be created in.
vacuum_to_add_length (float) – The amount of vacuum to place around the cluster
cluster_makeup (dict.) – The makeup of the cluster
surface (Organisms.GA.Surface) – This is the surface that the cluster is placed on. None means there is no surface.
r_ij (float) – The maximum distance that should be between atoms to be considered bonded. This value should be as large a possible, to reflected the longest bond possible between atoms in the cluster.
rounding_criteria (int) – The number of decimal places to round the energy of clusters to.
Minimisation_Function (__func__) – The minimisation function
memory_operator (Organisms.GA.Memory_Operator) – The memory operator
returns list of all the information needed to create a cluster rtype list of Any