def test_single_agent_highway_single(self): # create the base environment env = FlowEnv( flow_params=highway_single( multiagent=False ), multiagent=False, shared=False, version=1 ) env.reset() # test observation space test_space( env.observation_space, expected_min=np.array([-float("inf") for _ in range(50)]), expected_max=np.array([float("inf") for _ in range(50)]), expected_size=50, ) # test action space test_space( env.action_space, expected_min=np.array([-1 for _ in range(10)]), expected_max=np.array([1 for _ in range(10)]), expected_size=10, ) # kill the environment env.wrapped_env.terminate()
def test_single_agent_ring_small(self): # create the base environment env = FlowEnv( flow_params=ring_small( num_automated=1, horizon=1500, simulator="traci", multiagent=False ), version=0 ) env.reset() # test observation space test_space( env.observation_space, expected_min=np.array([-np.inf for _ in range(3)]), expected_max=np.array([np.inf for _ in range(3)]), expected_size=3, ) # test action space test_space( env.action_space, expected_min=np.array([-1]), expected_max=np.array([1]), expected_size=1, ) # kill the environment env.wrapped_env.terminate()
def test_single_agent_ring(self): # create the base environment env = FlowEnv( flow_params=ring( num_automated=5, simulator="traci", multiagent=False ), multiagent=False, shared=False, version=1 ) env.reset() # test observation space test_space( env.observation_space, expected_min=np.array([-float("inf") for _ in range(25)]), expected_max=np.array([float("inf") for _ in range(25)]), expected_size=25, ) # test action space test_space( env.action_space, expected_min=np.array([-1 for _ in range(5)]), expected_max=np.array([1 for _ in range(5)]), expected_size=5, ) # kill the environment env.wrapped_env.terminate()
def test_single_agent_ring(self): # create the base environment env = FlowEnv( env_name="ring", env_params={ "num_automated": 1, "horizon": 1500, "simulator": "traci", "multiagent": False }, version=0 ) env.reset() # test observation space test_space( env.observation_space, expected_min=np.array([-np.inf for _ in range(3)]), expected_max=np.array([np.inf for _ in range(3)]), expected_size=3, ) # test action space test_space( env.action_space, expected_min=np.array([-1]), expected_max=np.array([1]), expected_size=1, ) # kill the environment env.wrapped_env.terminate()
def test_multi_agent_figure_eight(self): # create the base environment env = FlowEnv( env_name="figure_eight", env_params={ "num_automated": 1, "horizon": 1500, "simulator": "traci", "multiagent": True }, version=0 ) env.reset() # test observation space pass # TODO # test action space pass # TODO # kill the environment env.wrapped_env.terminate() # create the environment with multiple automated vehicles env = FlowEnv( env_name="figure_eight", env_params={ "num_automated": 14, "horizon": 1500, "simulator": "traci", "multiagent": True }, version=1 ) env.reset() # test observation space pass # TODO # test action space pass # TODO # kill the environment env.wrapped_env.terminate()
def test_multi_agent_figure_eight(self): # create the base environment env = FlowEnv( flow_params=figure_eight( num_automated=1, horizon=1500, simulator="traci", multiagent=True ), version=0 ) env.reset() # test observation space pass # TODO # test action space pass # TODO # kill the environment env.wrapped_env.terminate() # create the environment with multiple automated vehicles env = FlowEnv( flow_params=figure_eight( num_automated=14, horizon=1500, simulator="traci", multiagent=True ), version=1 ) env.reset() # test observation space pass # TODO # test action space pass # TODO # kill the environment env.wrapped_env.terminate()
def test_multi_agent_ring(self): # create the base environment env = FlowEnv( flow_params=ring( num_automated=5, simulator="traci", multiagent=True ), multiagent=True, shared=False, version=1 ) env.reset() # test the agent IDs. self.assertListEqual( sorted(env.agents), ['rl_0_0', 'rl_0_1', 'rl_0_2', 'rl_0_3', 'rl_0_4']) # test observation space test_space( env.observation_space["rl_0_0"], expected_min=np.array([-float("inf") for _ in range(5)]), expected_max=np.array([float("inf") for _ in range(5)]), expected_size=5, ) # test action space test_space( env.action_space["rl_0_0"], expected_min=np.array([-1]), expected_max=np.array([1]), expected_size=1, ) # kill the environment env.wrapped_env.terminate()
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()
def test_single_agent_figure_eight(self): # create the base environment env = FlowEnv( flow_params=figure_eight( num_automated=1, horizon=1500, simulator="traci", multiagent=False ), version=0 ) env.reset() # test observation space test_space( env.observation_space, expected_min=np.array([0 for _ in range(28)]), expected_max=np.array([1 for _ in range(28)]), expected_size=28, ) # test action space test_space( env.action_space, expected_min=np.array([-3]), expected_max=np.array([3]), expected_size=1, ) # kill the environment env.wrapped_env.terminate() # create the environment with multiple automated vehicles env = FlowEnv( flow_params=figure_eight( num_automated=14, horizon=1500, simulator="traci", multiagent=False ), version=1 ) env.reset() # test observation space test_space( env.observation_space, expected_min=np.array([0 for _ in range(28)]), expected_max=np.array([1 for _ in range(28)]), expected_size=28, ) # test action space test_space( env.action_space, expected_min=np.array([-3 for _ in range(14)]), expected_max=np.array([3 for _ in range(14)]), expected_size=14, ) # kill the environment env.wrapped_env.terminate()
def test_multi_agent_ring_small(self): # create the base environment env = FlowEnv( flow_params=ring_small( num_automated=1, horizon=1500, simulator="traci", multiagent=True ), multiagent=True, shared=False, version=1 ) env.reset() # test the agent IDs. self.assertListEqual(env.agents, ["rl_0_0"]) # test observation space test_space( env.observation_space["rl_0_0"], expected_min=np.array([-5 for _ in range(3)]), expected_max=np.array([5 for _ in range(3)]), expected_size=3, ) # test action space test_space( env.action_space["rl_0_0"], expected_min=np.array([-1]), expected_max=np.array([1]), expected_size=1, ) # kill the environment env.wrapped_env.terminate() # create the environment with multiple automated vehicles env = FlowEnv( flow_params=ring_small( num_automated=4, horizon=1500, simulator="traci", multiagent=True ), multiagent=True, shared=True, ) env.reset() # test the agent IDs. self.assertListEqual( env.agents, ["rl_0_0", "rl_1_0", "rl_2_0", "rl_3_0"]) # test observation space test_space( env.observation_space, expected_min=np.array([-5 for _ in range(3)]), expected_max=np.array([5 for _ in range(3)]), expected_size=3, ) # test action space test_space( env.action_space, expected_min=np.array([-1]), expected_max=np.array([1]), expected_size=1, ) # kill the environment env.wrapped_env.terminate()
def test_single_agent_merge(self): # create version 0 of the environment env = FlowEnv( env_name="merge", env_params={ "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( env_name="merge", env_params={ "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( env_name="merge", env_params={ "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()
def test_single_agent_figure_eight(self): # create the base environment env = FlowEnv( env_name="figure_eight", env_params={ "num_automated": 1, "horizon": 1500, "simulator": "traci", "multiagent": False }, version=0 ) env.reset() # test observation space test_space( env.observation_space, expected_min=np.array([0 for _ in range(28)]), expected_max=np.array([1 for _ in range(28)]), expected_size=28, ) # test action space test_space( env.action_space, expected_min=np.array([-3]), expected_max=np.array([3]), expected_size=1, ) # kill the environment env.wrapped_env.terminate() # create the environment with multiple automated vehicles env = FlowEnv( env_name="figure_eight", env_params={ "num_automated": 14, "horizon": 1500, "simulator": "traci", "multiagent": False }, version=1 ) env.reset() # test observation space test_space( env.observation_space, expected_min=np.array([0 for _ in range(28)]), expected_max=np.array([1 for _ in range(28)]), expected_size=28, ) # test action space test_space( env.action_space, expected_min=np.array([-3 for _ in range(14)]), expected_max=np.array([3 for _ in range(14)]), expected_size=14, ) # kill the environment env.wrapped_env.terminate()