Beispiel #1
0
 "merge-v0": {
     "meta_ac_space":
     lambda relative_goals, multiagent: Box(low=-.5
                                            if relative_goals else 0,
                                            high=.5
                                            if relative_goals else 1,
                                            shape=(1
                                                   if multiagent else 5, ),
                                            dtype=np.float32),
     "state_indices":
     lambda multiagent: [5 * i for i in range(1 if multiagent else 5)],
     "env":
     lambda evaluate, render, n_levels, multiagent, shared, maddpg: FlowEnv(
         flow_params=merge(
             exp_num=0,
             horizon=6000,
             simulator="traci",
             multiagent=multiagent,
         ),
         render=render,
         multiagent=multiagent,
         shared=shared,
         maddpg=maddpg,
     ),
 },
 "merge-v1": {
     "meta_ac_space":
     lambda relative_goals, multiagent: Box(low=-.5
                                            if relative_goals else 0,
                                            high=.5
                                            if relative_goals else 1,
                                            shape=(1
Beispiel #2
0
    def test_single_agent_merge(self):
        # create version 0 of the environment
        env = FlowEnv(
            flow_params=merge(
                exp_num=0,
                horizon=6000,
                simulator="traci",
                multiagent=False
            ),
            version=0
        )
        env.reset()

        # test observation space
        test_space(
            env.observation_space,
            expected_min=np.array([0 for _ in range(25)]),
            expected_max=np.array([1 for _ in range(25)]),
            expected_size=25,
        )

        # test action space
        test_space(
            env.action_space,
            expected_min=np.array([-1.5 for _ in range(5)]),
            expected_max=np.array([1.5 for _ in range(5)]),
            expected_size=5,
        )

        # kill the environment
        env.wrapped_env.terminate()

        # create version 1 of the environment
        env = FlowEnv(
            flow_params=merge(
                exp_num=1,
                horizon=6000,
                simulator="traci",
                multiagent=False
            ),
            version=1
        )
        env.reset()

        # test observation space
        test_space(
            env.observation_space,
            expected_min=np.array([0 for _ in range(65)]),
            expected_max=np.array([1 for _ in range(65)]),
            expected_size=65,
        )

        # test action space
        test_space(
            env.action_space,
            expected_min=np.array([-1.5 for _ in range(13)]),
            expected_max=np.array([1.5 for _ in range(13)]),
            expected_size=13,
        )

        # kill the environment
        env.wrapped_env.terminate()

        # create version 2 of the environment
        env = FlowEnv(
            flow_params=merge(
                exp_num=2,
                horizon=6000,
                simulator="traci",
                multiagent=False
            ),
            version=2
        )
        env.reset()

        # test observation space
        test_space(
            env.observation_space,
            expected_min=np.array([0 for _ in range(85)]),
            expected_max=np.array([1 for _ in range(85)]),
            expected_size=85,
        )

        # test action space
        test_space(
            env.action_space,
            expected_min=np.array([-1.5 for _ in range(17)]),
            expected_max=np.array([1.5 for _ in range(17)]),
            expected_size=17,
        )

        # kill the environment
        env.wrapped_env.terminate()