def main(): raylab.register_all_agents() raylab.register_all_environments() with suppress(KeyboardInterrupt): parser = create_parser() args = parser.parse_args() run(args, parser)
def main(): env_args = { "forest_data_path": "/Users/anmartin/Projects/summer_project/hl_planner/forest_data.tiff", "simulation_data_path": "/Users/anmartin/Projects/FormationSimulation/fastsimulation.json", "num_measurements": 6, "max_forest_heights": [60, 90, 45, 38, 30, 76], "orbit_altitude": 757000, "draw_plot": True } parser = rollout.create_parser() args = parser.parse_args() register_env("offline-orekit", lambda _: OfflineOrekitEnv(env_args)) rollout.run(args, parser)
def main(algorithm, config): parser = argparse.ArgumentParser() parser.add_argument('--mode', type=str, default='train') parser.add_argument('--checkpoint', type=str, default='/home/pyang/ray_results/paint') args = parser.parse_args() ModelCatalog.register_custom_model('paint_model', PaintModel) ModelCatalog.register_custom_model('paint_layer_model', PaintLayerModel) def env_creator(env_config): return PaintGymEnv(**env_config) tune.registry.register_env('robot_gym_env', env_creator) experiment_config = { 'paint': { 'run': algorithm, 'env': 'robot_gym_env', 'stop': { 'training_iteration': 100000, # 'timesteps_total': 2000000, }, 'config': config, 'checkpoint_freq': 200, } } experiment_config['paint']['config']['callbacks'] = call_backs if args.mode == 'train': ray.init(object_store_memory=10000000000, redis_max_memory=5000000000, log_to_driver=True) # ray.init(redis_address="141.3.81.143:6379") experiment_config['paint']['config']['env_config'] = _make_env_config() tune.run_experiments(experiment_config) else: experiment_config['paint']['config']['num_workers'] = 2 args.run = experiment_config['paint']['run'] args.env = experiment_config['paint']['env'] args.steps = 300 experiment_config['paint']['config']['env_config'] = _make_env_config( is_train=False) args.config = experiment_config['paint']['config'] args.out = None args.no_render = True run(args, parser)
def train_agent(config): parser = argparse.ArgumentParser( description="Train or Run an RLlib Agent.", formatter_class=argparse.RawDescriptionHelpFormatter) subcommand_group = parser.add_subparsers( help="Commands to train or run an RLlib agent.", dest="command") train_parser = train.create_parser( lambda **kwargs: subcommand_group.add_parser("train", **kwargs)) rollout_parser = rollout.create_parser( lambda **kwargs: subcommand_group.add_parser("rollout", **kwargs)) options = parser.parse_args() register_env('env_mp500lwa4dpg70', env_creator) configFromYaml = { 'train-ppo': { 'env': 'env_mp500lwa4dpg70', 'run': 'PPO', 'config': config, 'checkpoint_freq': 1000, #'local_dir': "~/train_results", 'stop': { "timesteps_total": 1e10, }, } } ray.init() if options.command == "train": configFromYaml['train-ppo']['config']['env_config'] = env_input_config( True) run_experiments(configFromYaml) #train.run(options, train_parser) elif options.command == "rollout": options.run = configFromYaml['train-ppo']['run'] options.env = configFromYaml['train-ppo']['env'] options.no_render = True options.steps = 1000 options.out = None configFromYaml['train-ppo']['config']['env_config'] = env_input_config( False) configFromYaml['train-ppo']['config']['monitor'] = True options.config = configFromYaml['train-ppo']['config'] rollout.run(options, rollout_parser) else: parser.print_help()
def main(algorithm, config): parser = argparse.ArgumentParser() parser.add_argument('--mode', type=str, default='train') parser.add_argument('--checkpoint', type=str, default='/home/pyang/ray_results/paint') args = parser.parse_args() def env_creator(env_config): return ParamTestEnv(**env_config) tune.registry.register_env('param_test_env', env_creator) experiment_config = { 'param_test': { 'run': algorithm, 'env': 'param_test_env', 'stop': { 'training_iteration': 10000, }, 'config': config, 'checkpoint_freq': 200, } } if args.mode == 'train': ray.init(object_store_memory=10000000000, redis_max_memory=5000000000, log_to_driver=True) # ray.init(redis_address='141.3.81.145:6359') tune.run_experiments(experiment_config) else: experiment_config['param_test']['config']['num_workers'] = 2 experiment_config['param_test']['config']['env_config'][ 'train_mode'] = False args.run = experiment_config['param_test']['run'] args.env = experiment_config['param_test']['env'] args.steps = 400 args.config = experiment_config['param_test']['config'] args.out = None args.no_render = True run(args, parser)
def cli(): parser = argparse.ArgumentParser( description="Train or Run an RLlib Agent.", formatter_class=argparse.RawDescriptionHelpFormatter, epilog=EXAMPLE_USAGE) subcommand_group = parser.add_subparsers( help="Commands to train or run an RLlib agent.", dest="command") # see _SubParsersAction.add_parser in # https://github.com/python/cpython/blob/master/Lib/argparse.py train_parser = train.create_parser( lambda **kwargs: subcommand_group.add_parser("train", **kwargs)) rollout_parser = rollout.create_parser( lambda **kwargs: subcommand_group.add_parser("rollout", **kwargs)) options = parser.parse_args() if options.command == "train": train.run(options, train_parser) elif options.command == "rollout": rollout.run(options, rollout_parser) else: parser.print_help()
'SAC', '--env', 'rocketmeister', '--episodes', '10', # '--no-render', ]) config = { 'env_config': { # "export_frames": True, "export_states": True, 'export_string': 'Training1', # filename prefix for exports }, } config_json = json.dumps(config) parser = rollout.create_parser() args = parser.parse_args(string.split() + ['--config', config_json]) # ────────────────────────────────────────────────────────────────────────── # if you want to automate this, by calling rollout.run() multiple times, you # uncomment the following lines too. They need to called before calling # rollout.run() a second, third, etc. time # ray.shutdown() # tune.register_env("rocketgame", lambda c: MultiEnv(c)) # from ray.rllib import _register_all # _register_all() # ────────────────────────────────────────────────────────────────────────── rollout.run(args, parser)
""" This script wraps the rllib rollout command but uses the custom environment. """ from ray.rllib.rollout import create_parser, run from ray.tune.registry import register_env from .env import register_envs register_envs() if __name__ == '__main__': parser = create_parser() parser.set_defaults(env='CavalryVsInfantry', no_render=True) args = parser.parse_args() run(args, parser)
parser = rollout.create_parser() SSBMEnv.update_parser(parser) args = parser.parse_args() config = { "env": ssbm_env.MultiSSBMEnv, "env_config": { "ssbm_config": args.__dict__.copy(), "flat_obs": True, "conv": "slippi", "action_mode": "slippi_repeat", }, "horizon": 1200, "soft_horizon": True, "num_workers": 0, "autoregressive": True, "residual": True, "imitation": False, "model": { "custom_model": "human_action", "use_lstm": True, "lstm_cell_size": 256, "lstm_use_prev_action_reward": True, }, } args.config = config rollout.run(args, parser, config)