|
SELAB3 Python Code
|
File that brings together all morphological evolution related function like the general evolution process and all related functions for mutation, crossover and selection. More...
Functions | |
| List[Arm] | morphevo.evolution.run_evolution (Optional[List[Arm]] children=None) |
| Evolve arms with following scheme: More... | |
| List[Arm] | morphevo.evolution.selection (Callable selection_function, List[Arm] population) |
| Do a selection on a list of parents given a selection function. More... | |
| List[Arm] | morphevo.evolution.mutate (Callable mutation_function, List[Arm] parents) |
| Do a mutation on a list of parents given a mutation function. More... | |
| List[Arm] | morphevo.evolution.selection_fitness (List[Arm] population) |
| Do selection on the fitness of the arm. More... | |
| List[Arm] | morphevo.evolution.selection_success_rate (List[Arm] population) |
| Do selection on the success_rate of the arm. More... | |
| List[Arm] | morphevo.evolution.selection_fitness_diversity (List[Arm] population) |
| Do selection in a fitness-diversity way. More... | |
| Arm | morphevo.evolution.select_next_parent (List[Arm] population, List[Arm] parents) |
| Select the next parent that will be added to the parents. More... | |
| float | morphevo.evolution.calculate_fitness (Arm arm) |
| Calculate the fitness of a genome by calculating its coverage. More... | |
| float | morphevo.evolution.calculate_diversity (Arm arm, List[Arm] others) |
| calculate how diverse an arm is compared to others. More... | |
| List[float] | morphevo.evolution.calculate_selection_scores (List[float] population_fitnesses, List[float] population_diversities) |
| Calculate a score on which selection can be done for fitness-diversity selection. More... | |
| List[Arm] | morphevo.evolution.mutate_with_crossover (List[Arm] parents) |
| Do mutation with morphevo configuration parameters. More... | |
| List[Arm] | morphevo.evolution.mutate_with_crossover_coevolution (List[Arm] parents) |
| Do mutation with coevolution configuration parameters. More... | |
| def | morphevo.evolution.create_crossover_children (List[Arm] parents, int amount) |
| Function to create crossover children, pick 2 random parents, check if they are the same. More... | |
| def | morphevo.evolution.save_best_genome (Arm arm, int generation) |
| Save the genome of an arm to a file. More... | |
File that brings together all morphological evolution related function like the general evolution process and all related functions for mutation, crossover and selection.
| float morphevo.evolution.calculate_diversity | ( | Arm | arm, |
| List[Arm] | others | ||
| ) |
calculate how diverse an arm is compared to others.
(others is probably the already selected parents in the fitness-diversity selection).
| arm | The arm you want to compare to others to calculate diversity score. |
| others | The other arms you want to compare to. |
| float morphevo.evolution.calculate_fitness | ( | Arm | arm | ) |
Calculate the fitness of a genome by calculating its coverage.
| arm | The arm of which you want to calculate fitness. |
| List[float] morphevo.evolution.calculate_selection_scores | ( | List[float] | population_fitnesses, |
| List[float] | population_diversities | ||
| ) |
Calculate a score on which selection can be done for fitness-diversity selection.
First normalize fitness and diversity scores. Then calculate the distance to (1,1). If fitness and diversity are 1,1 this means 100% fit and 100% diverse from all previously selected parents.
| population_fitnesses | The fitnesses of a population. |
| population_diversities | The diversities of a population. |
| def morphevo.evolution.create_crossover_children | ( | List[Arm] | parents, |
| int | amount | ||
| ) |
Function to create crossover children, pick 2 random parents, check if they are the same.
If not do the crossover else pick again.
| parents | A list of parents to choose from. |
| amount | The amount of crossover children you want. |
| List[Arm] morphevo.evolution.mutate | ( | Callable | mutation_function, |
| List[Arm] | parents | ||
| ) |
Do a mutation on a list of parents given a mutation function.
| mutation_function | The function used for mutation. |
| parents | The parents that will be mutated. |
| List[Arm] morphevo.evolution.mutate_with_crossover | ( | List[Arm] | parents | ) |
Do mutation with morphevo configuration parameters.
First make normal children by mutating parents, after that crossover children are added if specified in config.
| parents | The parents of which you want to make children. |
| List[Arm] morphevo.evolution.mutate_with_crossover_coevolution | ( | List[Arm] | parents | ) |
Do mutation with coevolution configuration parameters.
First make normal children by mutating parents, after that crossover children are added if specified in config.
| parents | The parents of which you want to make children. |
| List[Arm] morphevo.evolution.run_evolution | ( | Optional[List[Arm]] | children = None | ) |
Evolve arms with following scheme:
| children | Optional list of children to start from. Else children will be randomly generated. |
| def morphevo.evolution.save_best_genome | ( | Arm | arm, |
| int | generation | ||
| ) |
Save the genome of an arm to a file.
| arm | The arm of which you want to save the genome. |
| generation | The generation in which the genome was evaluated. |
| Arm morphevo.evolution.select_next_parent | ( | List[Arm] | population, |
| List[Arm] | parents | ||
| ) |
Select the next parent that will be added to the parents.
Do this by making a consideration between fitness and diversity.
| population | Current population. |
| parents | Current list of parents. |
| List[Arm] morphevo.evolution.selection | ( | Callable | selection_function, |
| List[Arm] | population | ||
| ) |
Do a selection on a list of parents given a selection function.
| selection_function | The function used for selection. |
| population | The parents that will be selected from. |
| List[Arm] morphevo.evolution.selection_fitness | ( | List[Arm] | population | ) |
Do selection on the fitness of the arm.
| population | The population on which you want to do selection. |
| List[Arm] morphevo.evolution.selection_fitness_diversity | ( | List[Arm] | population | ) |
Do selection in a fitness-diversity way.
| population | The population on which you want to do selection. |
| List[Arm] morphevo.evolution.selection_success_rate | ( | List[Arm] | population | ) |
Do selection on the success_rate of the arm.
This is for the coevolution loop, success_rate is calculated in the rl step.
| population | The population on which you want to do selection. |