1.5. Initialisation¶
Table of Contents
Simple functions for performing population initialisation.
1.5.1. Custom functions¶
To define a custom init function, the following params are required: - adam - n - island
Example:
def initialise_population_random(adam, n : int = 10, island=None):
population = list()
for i in range(n - 1):
chromosome = island.create_chromosome([x.randomise_new() for x in adam.chromosome])
eve = island.create_individual(adam.fitness_function, chromosome=chromosome)
population.append(eve)
population.append(adam)
return population
1.5.2. Initialisation¶
1.5.2.1. Random Initialisation¶
- natural_selection.genetic_algorithms.operators.initialisation.initialise_population_random(adam, n: int = 10, chromosome_create_func: Optional[Callable] = None, island=None)¶
Classic random initialisation function to create a pool of n individuals from a starting Individual adam.
- Parameters
adam (Individual) – An individual already initialised with a chromosome.
n (int) – Population size (default = 10).
() (chromosome_create_func) – A function to create the chromosome of new individuals. If none, simply deep copy adam’s. (default = None).
island (Island) – Needed to wrap to create_chromosome and create_individual methods (default = None).
- Returns
Population members.
- Return type
list
1.5.2.2. Initialisation with mutation function¶
- natural_selection.genetic_algorithms.operators.initialisation.initialise_population_mutation_function(adam, n: int = 10, chromosome_create_func: Optional[Callable] = None, mutation_params: Optional[dict] = None, island=None)¶
Random initialisation function to create a pool of n individuals from a starting Individual adam, but uses the
island.mutation function
to perform the randomisation.- Parameters
adam (Individual) – An individual already initialised with a chromosome.
n (int) – Population size (default = 10).
() (chromosome_create_func) – A function to create the chromosome of new individuals. If none, simply deep copy adam’s. (default = None).
mutation_params (dict) – The params of the mutation function, these usually need to be higher values, such as higher
prob
value.island (Island) – Needed to wrap to create_chromosome and create_individual methods (default = None).
- Returns
Population members.
- Return type
list