예제 #1
0
train_pop = optimizer.pop
MyPhenotype = train_pop.phenotype
MyGenotype = train_pop.genotype

# get the current run champion
starting_robot = None
for ind in train_pop:
    if ind.fitness == train_pop.best_fit_so_far:
        starting_robot = ind

CONTROLLER_0 = starting_robot.genotype.to_phenotype_mapping["phase_offset"][
    "state"]
CONTROLLER = np.rot90(CONTROLLER_0, k=(SEED - 1) / 5, axes=(0, 1))

pre_damage_shape = quadruped(QUAD_SIZE)
post_damage_shape = quadruped(QUAD_SIZE, cut_leg=0, patch_mat=0, half_cut=True)

MyGenotype.NET_DICT = {
    "phase_offset": CONTROLLER,
    "material": post_damage_shape
}


class MyGenotype(Genotype):
    def __init__(self):
        Genotype.__init__(self, orig_size_xyz=IND_SIZE)

        # pre-optimized controller (phi; phase-offsets)
        self.add_network(DirectEncoding(output_node_name="phase_offset",
                                        orig_size_xyz=IND_SIZE),
예제 #2
0
TIME_TO_TRY_AGAIN = 30
MAX_EVAL_TIME = 75

SAVE_VXA_EVERY = MAX_GENS + 1  # never
CHECKPOINT_EVERY = 1  # gen(s)

FITNESS_TAG = "normAbsoluteDisplacement"

RUN_DIR = "run_{}".format(SEED)
RUN_NAME = "RegenQuad"

# copy the simulator executable into the working directory
sub.call("cp {}/voxelyzeMain/voxelyze .".format(SIMULATOR_DIR), shell=True)
sub.call("chmod 755 voxelyze", shell=True)

pre_damage_shape = quadruped(QUAD_SIZE)
post_damage_shape = quadruped(QUAD_SIZE)
post_damage_shape[:IND_SIZE[1] / 2, :IND_SIZE[1] / 2, :IND_SIZE[2] /
                  2] = 0  # leg 1
post_damage_shape[IND_SIZE[1] / 2:, :IND_SIZE[1] / 2, :IND_SIZE[2] /
                  2] = 0  # leg 2
# post_damage_shape[:IND_SIZE[1]/2, IND_SIZE[1]/2:, :IND_SIZE[2]/2] = 0  # leg 3
# post_damage_shape[IND_SIZE[1]/2:, IND_SIZE[1]/2:, :IND_SIZE[2]/2] = 0  # leg 4


class MyGenotype(Genotype):
    def __init__(self):
        Genotype.__init__(self, orig_size_xyz=IND_SIZE)

        # quadrupedal structure
        self.add_network(DirectEncoding(output_node_name="material",
예제 #3
0
class MyGenotype(Genotype):
    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)

        self.add_network(DirectEncoding(output_node_name="init_size", orig_size_xyz=IND_SIZE), freeze=True)
        self.to_phenotype_mapping.add_map(name="init_size", tag="<InitialVoxelSize>", logging_stats=None)


my_quad = quadruped(IND_SIZE)
size = np.ones_like(my_quad, dtype=float)
MyGenotype.NET_DICT = {'material_present': my_quad, 'init_size': size}


if not os.path.isfile("./" + RUN_DIR + "/pickledPops/Gen_0.pickle"):

    random.seed(SEED)
    np.random.seed(SEED)

    my_sim = Sim(dt_frac=DT_FRAC, simulation_time=SIM_TIME, fitness_eval_init_time=INIT_TIME)

    my_env = Env(temp_amp=TEMP_AMP, frequency=FREQ, muscle_stiffness=STIFFNESS, growth_amp=GROWTH_AMPLITUDE)

    my_objective_dict = ObjectiveDict()
    my_objective_dict.add_objective(name="fitness", maximize=True, tag="<normAbsoluteDisplacement>")