Skip to content

Commit

Permalink
WIP direct tree in manager_pop. Also check previous commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Aart Stuurman committed Aug 16, 2021
1 parent 80f2044 commit fb6853e
Showing 1 changed file with 40 additions and 27 deletions.
67 changes: 40 additions & 27 deletions experiments/examples/manager_pop.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,16 @@
)
from pyrevolve.evolution.selection import multiple_selection, tournament_selection
from pyrevolve.experiment_management import ExperimentManagement
from pyrevolve.genotype.plasticoding import PlasticodingConfig
from pyrevolve.genotype.plasticoding.crossover.crossover import CrossoverConfig
from pyrevolve.genotype.plasticoding.crossover.standard_crossover import (
standard_crossover,
from pyrevolve.genotype.direct_tree.direct_tree_config import DirectTreeGenotypeConfig
from pyrevolve.genotype.direct_tree.direct_tree_crossover import (
crossover_list as direct_tree_crossover_list,
)
from pyrevolve.genotype.direct_tree.direct_tree_genotype import (
Genotype as DirectTreeGenotype,
)
from pyrevolve.genotype.direct_tree.direct_tree_mutation import (
mutate as direct_tree_mutate,
)
from pyrevolve.genotype.plasticoding.initialization import random_initialization
from pyrevolve.genotype.plasticoding.mutation.mutation import MutationConfig
from pyrevolve.genotype.plasticoding.mutation.standard_mutation import standard_mutation
from pyrevolve.util.supervisor.analyzer_queue import AnalyzerQueue
from pyrevolve.util.supervisor.simulator_queue import SimulatorQueue

Expand All @@ -33,23 +35,27 @@ async def run():
population_size = 100
offspring_size = 50

genotype_conf = PlasticodingConfig(
max_structural_modules=20,
allow_vertical_brick=True,
use_movement_commands=True,
use_rotation_commands=False,
use_movement_stack=True,
)

mutation_conf = MutationConfig(
mutation_prob=0.8,
genotype_conf=genotype_conf,
genotype_conf: DirectTreeGenotypeConfig = DirectTreeGenotypeConfig(
max_parts=50,
min_parts=10,
max_oscillation=5,
init_n_parts_mu=10,
init_n_parts_sigma=4,
init_prob_no_child=0.1,
init_prob_child_block=0.4,
init_prob_child_active_joint=0.5,
mutation_p_duplicate_subtree=0.2,
mutation_p_delete_subtree=0.2,
mutation_p_generate_subtree=0.2,
mutation_p_swap_subtree=0.2,
mutation_p_mutate_oscillators=0.5,
mutation_p_mutate_oscillator=0.5,
mutate_oscillator_amplitude_sigma=0.3,
mutate_oscillator_period_sigma=0.3,
mutate_oscillator_phase_sigma=0.3,
)

crossover_conf = CrossoverConfig(
crossover_prob=0.8,
)
# experiment params #
mutation_conf = genotype_conf
crossover_conf = genotype_conf

# Parse command line / file input arguments
settings = parser.parse_args()
Expand Down Expand Up @@ -79,20 +85,27 @@ async def run():

population_conf = PopulationConfig(
population_size=population_size,
genotype_constructor=random_initialization,
genotype_constructor=lambda conf, _id: DirectTreeGenotype(
conf, _id, random_init=True
),
genotype_conf=genotype_conf,
fitness_function=fitness.displacement_velocity,
mutation_operator=standard_mutation,
mutation_operator=lambda genotype, gen_conf: direct_tree_mutate(
genotype, gen_conf, in_place=False
),
mutation_conf=mutation_conf,
crossover_operator=standard_crossover,
crossover_operator=lambda parents, gen_conf, _cross_conf: direct_tree_crossover_list(
[p.genotype for p in parents], gen_conf
),
crossover_conf=crossover_conf,
selection=lambda individuals: tournament_selection(individuals, 2),
parent_selection=lambda individuals: multiple_selection(
individuals, 2, tournament_selection
),
population_management=steady_state_population_management,
population_management_selector=tournament_selection,
population_management_selector=None,
evaluation_time=settings.evaluation_time,
grace_time=settings.grace_time,
offspring_size=offspring_size,
experiment_name=settings.experiment_name,
experiment_management=experiment_management,
Expand Down

0 comments on commit fb6853e

Please sign in to comment.