from examples.experiment_functions import SMSwarmExperimentRunner from examples.experiment_template import SingleExperiment # Important variables. from neat.state_machine_genome import StateMachineGenome experiment_name = 'SM_4_reference_block_long' num_steps = 3000 num_generations = 200 num_runs = 1 config_name = 'config-state_machine' if __name__ == '__main__': env = gym.make('tiling-pattern11x11-block-v0') runner = SMSwarmExperimentRunner(env, num_steps) # Create learning configuration. local_dir = os.path.dirname(__file__) config_path = os.path.join(local_dir, config_name) config = neat.Config(StateMachineGenome, neat.DefaultReproduction, neat.DefaultSpeciesSet, neat.DefaultStagnation, config_path) # Create and run experiment. experiment = SingleExperiment(config, runner, num_generations, experiment_name) for i in range(num_runs): experiment.run(experiment_name + str(i))
from examples.experiment_functions import NEATSwarmExperimentRunner from examples.experiment_template import SingleExperiment # This script describes an state machine experiment where all the values are specified in a config file. # Config file can and should be given as a parameter. from neat import Config, DefaultReproduction, DefaultSpeciesSet, DefaultStagnation, DefaultGenome from neat.state_machine_genome import StateMachineGenome if __name__ == '__main__': if len(sys.argv) != 2: print('One argument expected, which is the path to the config file.') else: config_name = sys.argv[1] # Create learning configuration. local_dir = os.path.dirname(__file__) config_path = os.path.join(local_dir, config_name) config = Config(DefaultGenome, DefaultReproduction, DefaultSpeciesSet, DefaultStagnation, config_path) env = gym.make(config.env_name) runner = NEATSwarmExperimentRunner(env, config.num_steps) # Create and run experiment. experiment = SingleExperiment(config, runner, config.num_generations, config.experiment_name) for i in range(config.num_runs): experiment.run(config.experiment_name + str(i))
import gym from examples.experiment_functions import NEATSwarmExperimentRunner from examples.experiment_template import SingleExperiment # Important variables. experiment_name = 'NEAT_foraging_11x11_static' num_steps = 3000 num_robots = 5 num_generations = 100 num_runs = 5 config_name = 'config-feedforward-11x11' if __name__ == '__main__': env = gym.make('foraging11x11-static-v0') runner = NEATSwarmExperimentRunner(env, num_steps) # Create learning configuration. local_dir = os.path.dirname(__file__) config_path = os.path.join(local_dir, config_name) config = neat.Config(neat.DefaultGenome, neat.DefaultReproduction, neat.DefaultSpeciesSet, neat.DefaultStagnation, config_path) # Create and run experiment. experiment = SingleExperiment(config, runner, num_generations, experiment_name) experiment.run(experiment_name)
num_robots = 5 num_generations = 100 num_runs = 1 config_name = 'config-feedforward-50x50' gym.register(id='foraging50x50-distance-sum-v0', entry_point='gym_multi_robot.envs:ForagingEnv', kwargs={ 'env_storage_path': 'foraging50x50.pickle', 'game_cls': ClosestGame }) if __name__ == '__main__': env = gym.make('foraging50x50-distance-sum-v0') runner = NEATSwarmExperimentRunner(env, num_steps) # Create learning configuration. local_dir = os.path.dirname(__file__) config_path = os.path.join(local_dir, config_name) config = neat.Config(neat.DefaultGenome, neat.DefaultReproduction, neat.DefaultSpeciesSet, neat.DefaultStagnation, config_path) # Create and run experiment. experiment = SingleExperiment(config, runner, num_generations, experiment_name, 2) for i in range(num_runs): experiment.run(experiment_name + str(num_runs))