def __init__(self, verbose = False): self.verbose = verbose # Read the current experiment's parameters params = ExperimentParameters() # Create a Turtle that will be used to render the trees. Its parameters will be updated when needed. turtle = Turtle() # Initialize the genetic evolver lsystem = ParametricLSystem(params.randomSeed) generator = PlantsIncrementalGenerator(params.randomSeed, # We use a PlantsIncrementalGenerator, so that everything evolved here is plant-like parameterized=True, # Woooo definesProbability=0, #TODO: fix! defines are not working because they are not saved with the instances! constantsProbability=1 ) generator.setLSystem(lsystem) generator.targetIterations = params.targetIterations #generator.branchProbability = 0.7 #generator.mutation_steps_at_once = params.mutationStepsAtOnce generator.verbose = False generator.verbose_super = False evolver = GeneticEvolver(turtle) evolver.setGenerator(generator) evolver.initialPopulationGenerationChoice = InitialPopulationGenerationChoice.RANDOMIZED #evolver.populationInitialisationComplexifySteps = 2 # A good number to obtain a randomized tree without taking too much time evolver.discardEmptyEvolutions = True evolver.discardLSystemsLargerThan = 1000 evolver.verbose = False evolver.mini_verbose = False evolver.recap_verbose = False self.params = params self.evolver = evolver
class OBJECT_OT_AbstractOperatorLSystem(bpy.types.Operator): def execute(self, context): self.tree_creator = bpy.types.Scene.tree_creator self.current_genetic_instance = bpy.types.Scene.current_genetic_instance return {'FINISHED'} def createGenerator(self): # Parameters that are not saved in the genetic instance (common for all instances) parameterized = getattr(self.tree_creator,'parameterized') #TODO: The generator could be created only ONCE for all operators, and is not used by all of them! #self.generator = IncrementalGenerator( self.generator = PlantsIncrementalGenerator( parameterized = parameterized, definesProbability = getattr(self.tree_creator,'defines_probability'), constantsProbability = 1#getattr(self.tree_creator,'constants_probability') ) self.generator.setLSystem(self.current_genetic_instance.lsystem) self.generator.targetIterations = getattr(self.tree_creator,'target_iterations') self.generator.branchProbability = getattr(self.tree_creator,'branch_probability') self.generator.mutation_steps_at_once = getattr(self.tree_creator,'mutation_steps')
def createGenerator(self): # Parameters that are not saved in the genetic instance (common for all instances) parameterized = getattr(self.tree_creator,'parameterized') #TODO: The generator could be created only ONCE for all operators, and is not used by all of them! #self.generator = IncrementalGenerator( self.generator = PlantsIncrementalGenerator( parameterized = parameterized, definesProbability = getattr(self.tree_creator,'defines_probability'), constantsProbability = 1#getattr(self.tree_creator,'constants_probability') ) self.generator.setLSystem(self.current_genetic_instance.lsystem) self.generator.targetIterations = getattr(self.tree_creator,'target_iterations') self.generator.branchProbability = getattr(self.tree_creator,'branch_probability') self.generator.mutation_steps_at_once = getattr(self.tree_creator,'mutation_steps')