def __init__(self): Genotype.__init__(self, orig_size_xyz=IND_SIZE) self.add_network(CPPN(output_node_names=["phase_offset"])) self.add_network(CPPN(output_node_names=["material_present"])) self.add_network(CPPN(output_node_names=["stiffness"])) self.add_network(CPPN(output_node_names=["stress_adaptation_rate"])) self.to_phenotype_mapping.add_map(name="phase_offset", tag="<PhaseOffset>") self.to_phenotype_mapping.add_map(name="material_present", tag="<Data>", func=one_muscle, output_type=int) self.to_phenotype_mapping.add_map(name="stiffness", tag="<Stiffness>", func=partial(rescaled_positive_sigmoid, x_min=MIN_ELASTIC_MOD, x_max=MAX_ELASTIC_MOD), params=[MIN_ELASTIC_MOD, MAX_ELASTIC_MOD], param_tags=["MinElasticMod", "MaxElasticMod"]) self.to_phenotype_mapping.add_map(name="stress_adaptation_rate", tag="<StressAdaptationRate>", func=partial(rescaled_positive_sigmoid, x_min=-MAX_ADAPTATION_RATE, x_max=MAX_ADAPTATION_RATE), params=[MIN_ELASTIC_MOD, MAX_ELASTIC_MOD, MAX_STIFFNESS_CHANGE, MAX_ADAPTATION_RATE, GROWTH_MODEL, MIN_DEVO], param_tags=["MinElasticMod", "MaxElasticMod", "MaxStiffnessChange", "MaxAdaptationRate", "GrowthModel", "MinDevo"])
def __init__(self): Genotype.__init__(self, orig_size_xyz=IND_SIZE) self.add_network(CPPN(output_node_names=["phase_offset"])) self.add_network(CPPN(output_node_names=["material_present"])) self.add_network(CPPN(output_node_names=["stiffness"])) self.add_network(CPPN(output_node_names=["adaptation_rate"]) ) # mapping to the phenotype is zeroed out self.to_phenotype_mapping.add_map(name="phase_offset", tag="<PhaseOffset>") self.to_phenotype_mapping.add_map(name="material_present", tag="<Data>", func=one_muscle, output_type=int) self.to_phenotype_mapping.add_map( name="stiffness", tag="<Stiffness>", func=partial(rescaled_positive_sigmoid, x_min=MIN_ELASTIC_MOD, x_max=MAX_ELASTIC_MOD), params=[MIN_ELASTIC_MOD, MAX_ELASTIC_MOD], param_tags=["MinElasticMod", "MaxElasticMod"])
def __init__(self): # We instantiate a new genotype for each individual which must have the following properties Genotype.__init__(self, orig_size_xyz=IND_SIZE) # The genotype consists of a single Compositional Pattern Producing Network (CPPN), # with multiple inter-dependent outputs determining the material constituting each voxel # (e.g. two types of active voxels, actuated with a different phase, two types of passive voxels, softer and stiffer) # The material IDs that you will see in the phenotype mapping dependencies refer to a predefined palette of materials # currently hardcoded in tools/read_write_voxelyze.py: # (0: empty, 1: passiveSoft, 2: passiveHard, 3: active+, 4:active-), # but this can be changed. self.add_network(CPPN(output_node_names=["shape", "muscleOrTissue"])) self.to_phenotype_mapping.add_map( name="material", tag="<Data>", func=make_material_tree, dependency_order=["shape", "muscleOrTissue"], output_type=int) # BUGFIX: "tissueType" was not listed self.to_phenotype_mapping.add_output_dependency(name="shape", dependency_name=None, requirement=None, material_if_true=None, material_if_false="0") self.to_phenotype_mapping.add_output_dependency( name="muscleOrTissue", dependency_name="shape", requirement=True, material_if_true=None, material_if_false="2") # BUGFIX: was material_if_false=1
def __init__(self): Genotype.__init__(self, orig_size_xyz=IND_SIZE) self.add_network(CPPN(output_node_names=["initial_size"])) self.to_phenotype_mapping.add_map(name="initial_size", tag="<InitialVoxelSize>", logging_stats=[ np.median, np.mean, np.std, count_negative, count_positive ]) self.add_network(CPPN(output_node_names=["final_size"])) self.to_phenotype_mapping.add_map(name="final_size", tag="<FinalVoxelSize>", logging_stats=[ np.median, np.mean, np.std, count_negative, count_positive ])
def __init__(self): Genotype.__init__(self, orig_size_xyz=IND_SIZE) self.add_network(CPPN(output_node_names=["initial_size"])) self.to_phenotype_mapping.add_map(name="initial_size", tag="<InitialVoxelSize>", logging_stats=[np.median, np.mean, np.std, count_negative, count_positive]) self.add_network(CPPN(output_node_names=["final_size"])) self.to_phenotype_mapping.add_map(name="final_size", tag="<FinalVoxelSize>", logging_stats=[np.median, np.mean, np.std, count_negative, count_positive]) # self.add_network(CPPN(output_node_names=["start_growth_time"])) # self.to_phenotype_mapping.add_map(name="start_growth_time", tag="<StartGrowthTime>", func=positive_sigmoid, # logging_stats=[np.median, np.mean, mean_abs, np.std, std_abs]) self.add_network(CPPN(output_node_names=["growth_time"])) self.to_phenotype_mapping.add_map(name="growth_time", tag="<GrowthTime>", func=positive_sigmoid, logging_stats=[np.median, np.mean, mean_abs, np.std, std_abs])
def __init__(self): Genotype.__init__(self, orig_size_xyz=IND_SIZE) self.add_network(CPPN(output_node_names=["phase_offset"])) self.to_phenotype_mapping.add_map(name="phase_offset", tag="<PhaseOffset>", logging_stats=None) self.add_network(DirectEncoding(output_node_name="material_present", orig_size_xyz=IND_SIZE), freeze=True) self.to_phenotype_mapping.add_map(name="material_present", tag="<Data>", output_type=int, logging_stats=None)
def __init__(self): # We instantiate a new genotype for each individual which must have the following properties Genotype.__init__(self, orig_size_xyz=IND_SIZE) # Let's add a first CPPN to the genotype. It dictates a continuous phenotypic trait, # the actuation phase of each voxel with respect to a global CPG-like sinusoidal signal self.add_network(CPPN(output_node_names=["phase_offset", "frequency"])) # Let's map this CPPN output to a VXA tag named <PhaseOffset> self.to_phenotype_mapping.add_map(name="phase_offset", tag="<PhaseOffset>", func=partial(rescaled_positive_sigmoid, x_min=0, x_max=2*math.pi)) self.to_phenotype_mapping.add_map(name="frequency", tag="<TempPeriod>", env_kws={"frequency": frequency_func}) # tag actually doesn't do anything here # Now adding a second CPPN, with three outputs. "shape" the geometry of the robot # (i.e. whether a particular voxel is empty or full), # if full, "muscleOrTissue" dictates whether a voxel is actuated or passive. The third output, "stiffness", # is another continuous attribute, the stiffness (elastic modulus) of each voxel # (overrides elastic mod defined in the materials palette) self.add_network(CPPN(output_node_names=["shape", "muscleOrTissue", "stiffness"])) # Once remapped from [-1,1] to [MIN_ELASTIC_MOD, MAX_ELASTIC_MOD] through "func", # the "stiffness" output goes directly to the <Stiffness> vxa tag as a continuous property. # We also pass min and max elastic mod as sub-tags of <Stiffness> (will be used by VoxCad) self.to_phenotype_mapping.add_map(name="stiffness", tag="<Stiffness>", func=partial(rescaled_positive_sigmoid, x_min=MIN_ELASTIC_MOD, x_max=MAX_ELASTIC_MOD), params=[MIN_ELASTIC_MOD, MAX_ELASTIC_MOD], param_tags=["MinElasticMod", "MaxElasticMod"]) # The mapping for materials depends on both "shape" and "muscleOrTissue", through the following dependencies. # Basically, if "shape" is false (cppn output < 0), the material with id "0" is assigned (-> empty voxel). # If, instead, "shape" is true (cppn output > 0), we look at the "muscleOrTissue" output to determine # whether the material is actuated (id = 3) or passive (id = 1). These material IDs are refer to a # fixed palette of materials, currently hardcoded in tools/read_write_voxelyze.py self.to_phenotype_mapping.add_map(name="material", tag="<Data>", func=make_material_tree, dependency_order=["shape", "muscleOrTissue"], output_type=int) self.to_phenotype_mapping.add_output_dependency(name="shape", dependency_name=None, requirement=None, material_if_true=None, material_if_false="0") self.to_phenotype_mapping.add_output_dependency(name="muscleOrTissue", dependency_name="shape", requirement=True, material_if_true="3", material_if_false="1")
def __init__(self): Genotype.__init__(self, orig_size_xyz=IND_SIZE) # quadrupedal structure self.add_network(DirectEncoding(output_node_name="material", orig_size_xyz=IND_SIZE), freeze=True) self.to_phenotype_mapping.add_map(name="material", tag="<Data>", output_type=int, logging_stats=None) # controller (phi; phase-offsets) self.add_network(CPPN(output_node_names=["phase_offset"])) self.to_phenotype_mapping.add_map(name="phase_offset", tag="<PhaseOffset>")
def __init__(self): # We instantiate a new genotype for each individual which must have the following properties Genotype.__init__(self, orig_size_xyz=IND_SIZE) # The genotype consists of : # - a single Compositional Pattern Producing Network (CPPN), with multiple inter-dependent outputs determining # the material constituting each voxel (e.g. two types of active voxels, actuated with a different phase, two # types of passive voxels, softer and stiffer). The material IDs that you will see in the phenotype mapping # dependencies refer to a predefined palette of materials currently hardcoded in tools/read_write_voxelyze.py: # (0: empty, 1: passiveSoft, 2: passiveHard, 3: active+, 4:active-), but this can be changed. self.add_network( CPPN(output_node_names=[ "shape", "newOrOld", "newMuscleOrTissue", "oldMuscleOrTissue", "newMuscleType", "newTissueType", "muscleType", "tissueType" ])) self.to_phenotype_mapping.add_map(name="material", tag="<Data>", func=make_material_tree, dependency_order=[ "shape", "newOrOld", "newMuscleOrTissue", "oldMuscleOrTissue", "newMuscleType", "newTissueType", "muscleType", "tissueType" ], output_type=int) self.to_phenotype_mapping.add_output_dependency(name="shape", dependency_name=None, requirement=None, material_if_true=None, material_if_false="0") self.to_phenotype_mapping.add_output_dependency( name="newOrOld", dependency_name="shape", requirement=True, material_if_true=None, material_if_false=None) self.to_phenotype_mapping.add_output_dependency( name="newMuscleOrTissue", dependency_name="newOrOld", requirement=True, material_if_true=None, material_if_false=None) self.to_phenotype_mapping.add_output_dependency( name="oldMuscleOrTissue", dependency_name="newOrOld", requirement=False, material_if_true=None, material_if_false=None) self.to_phenotype_mapping.add_output_dependency( name="newMuscleType", dependency_name="newMuscleOrTissue", requirement=True, material_if_true="8", material_if_false="9") self.to_phenotype_mapping.add_output_dependency( name="newTissueType", dependency_name="newMuscleOrTissue", requirement=False, material_if_true="6", material_if_false="7") self.to_phenotype_mapping.add_output_dependency( name="muscleType", dependency_name="oldMuscleOrTissue", requirement=True, material_if_true="3", material_if_false="4") self.to_phenotype_mapping.add_output_dependency( name="tissueType", dependency_name="oldMuscleOrTissue", requirement=False, material_if_true="1", material_if_false="2") self.materials = dict() self.materials["6"] = NewMaterial(name="New_Passive_Soft", rgb=(0.6, 0.3, 0), type="tissue", young_modulus=5000000.0, density=1e+006, cte=0) self.materials["7"] = NewMaterial(name="New_Passive_Hard", rgb=(0.3, 0, 0), type="tissue", young_modulus=500000000.0, density=1e+006, cte=0) self.materials["8"] = NewMaterial(name="New_Active_+", rgb=(1, 1, 0), type="muscle", young_modulus=5000000.0, density=1e+006, cte=0.05) self.materials["9"] = NewMaterial(name="New_Active_-", rgb=(1, 0.5, 0), type="muscle", young_modulus=5000000.0, density=1e+006, cte=-0.05) self.materials = collections.OrderedDict(sorted( self.materials.items()))