Exemplo n.º 1
0
    # NODES = sorted([236, 237, 186, 170, 141, 162, 140, 238, 142, 229, 239, 48, 161, 107, 263, 262, 234, 68, 100, 143])
    # NODES = sorted([236, 237, 186, 170, 141])
    NODES = sorted([236, 237, 186, 170, 141, 162, 140, 238, 142, 229])
    initial_vehicle = args.init_veh
    iterations = args.iter
    vehicle_speed = args.veh_speed
    if file_conf is not None:
        NODES = sorted(file_conf.pop("nodes", NODES))
        initial_vehicle = int(file_conf.pop("init_veh", initial_vehicle))
        iterations = int(file_conf.pop("iter", iterations))
        vehicle_speed = int(file_conf.pop("veh_speed", vehicle_speed))

    update_graph_file(os.path.join(CONFIG, 'gps.csv'),
                      os.path.join(CONFIG, 'aam.csv'), NODES)
    update_vehicle_initial_distribution(veh_dist=[initial_vehicle] *
                                        len(NODES),
                                        nodes=NODES,
                                        speed=vehicle_speed)

    ray.init()
    nodes_list = [str(x) for x in NODES]
    configure = ppo.DEFAULT_CONFIG.copy()
    # configure['vf_share_layers'] = False
    configure['env'] = TaxiRebalance
    configure['num_workers'] = args.num_cpu if args.num_cpu is not None else 1
    configure['num_gpus'] = args.num_gpu if args.num_gpu is not None else 0
    configure['vf_clip_param'] = args.vf_clip
    configure['lr'] = args.lr
    configure['train_batch_size'] = args.tr_bat_size
    configure['rollout_fragment_length'] = args.wkr_smpl_size
    configure['sgd_minibatch_size'] = args.sgd_bat_size
    configure['env_config'] = {
Exemplo n.º 2
0
                        type=float,
                        default=3e-3)
    parser.add_argument('--e_lr',
                        nargs='?',
                        metavar='<entropy learning rate>',
                        type=float,
                        default=3e-3)
    args = parser.parse_args()

    # NODES = sorted(pd.read_csv(os.path.join(CONFIG, 'aam.csv'), index_col=0, header=0).index.values.tolist())
    # NODES = sorted([236, 237, 186, 170, 141, 162, 140, 238, 142, 229, 239, 48, 161, 107, 263, 262, 234, 68, 100, 143])
    NODES = sorted([236, 237, 186, 170, 141])

    update_graph_file(os.path.join(CONFIG, 'gps.csv'),
                      os.path.join(CONFIG, 'aam.csv'), NODES)
    update_vehicle_initial_distribution(
        [int(args.init_veh) for i in range(len(NODES))], nodes=NODES)

    ray.init()
    with open(graph_file, 'r') as f:
        node_list = json.load(f)
    node_list = [x for x in node_list]

    configure = sac.DEFAULT_CONFIG.copy()
    configure['env'] = TaxiRebalance
    try:
        with open(args.config, 'r') as file:
            file_conf = json.load(file)
    except FileNotFoundError:
        configure['num_workers'] = args.num_cpu
        configure['num_gpus'] = args.num_gpu
        configure['timesteps_per_iteration'] = 300  # MDP steps per iteration