def main(): env = gym.make('SlimeVolley-v0') env.seed(123) POPULATION_SIZE = 20 MAX_GENERATION = 100 MUTATION_RATE = 0.4 CROSSOVER_RATE = 0.7 INPUT_SIZE = 12 OUTPUT_SIZE = 3 assert POPULATION_SIZE % 2 == 0 p = Population(DeepMLPTorchIndividual(INPUT_SIZE, 0, OUTPUT_SIZE), POPULATION_SIZE, MAX_GENERATION, MUTATION_RATE, CROSSOVER_RATE, 0.0) p.set_population([ DeepMLPTorchIndividual(INPUT_SIZE, 0, OUTPUT_SIZE) for _ in range(POPULATION_SIZE) ]) p.run( env, generation, verbose=True, log=True, output_folder=f'model-layers={INPUT_SIZE}-{HIDDEN_SIZE}-{OUTPUT_SIZE}', save_as_pytorch=False)
if __name__ == '__main__': env = gym.make('BipedalWalker-v2') env.seed(123) POPULATION_SIZE = 10 MAX_GENERATION = 10 MUTATION_RATE = 0.01 CROSSOVER_RATE = 0.8 INPUT_SIZE = 24 OUTPUT_SIZE = 4 assert POPULATION_SIZE % 2 == 0 p = Population(DeepBipedalWalkerIndividual(INPUT_SIZE, 0, OUTPUT_SIZE), POPULATION_SIZE, MAX_GENERATION, MUTATION_RATE, CROSSOVER_RATE, 0.0) p.set_population([ DeepBipedalWalkerIndividual(INPUT_SIZE, 0, OUTPUT_SIZE) for _ in range(POPULATION_SIZE) ]) p.run( env, generation, verbose=True, log=True, output_folder=f'model-layers={INPUT_SIZE}-{HIDDEN_SIZE}-{OUTPUT_SIZE}', save_as_pytorch=False) env.close()