Exemplo n.º 1
0
    def test_prev_edge_internal_links(self):
        """
        Tests the prev_edge() method in the presence of internal links.
        """
        env, scenario = figure_eight_exp_setup()
        prev_edge = scenario.prev_edge("bottom_upper_ring_in", 0)
        expected_prev_edge = [(':bottom_upper_ring_in_0', 0)]

        self.assertCountEqual(prev_edge, expected_prev_edge)
Exemplo n.º 2
0
    def test_next_edge_internal_links(self):
        """
        Tests the next_edge() method in the presence of internal links.
        """
        env, scenario = figure_eight_exp_setup()
        next_edge = env.k.scenario.next_edge("bottom", 0)
        expected_next_edge = [(':center_1', 0)]

        self.assertCountEqual(next_edge, expected_next_edge)
Exemplo n.º 3
0
    def setUp(self):
        # place 15 vehicles in the network (we need at least more than 1)
        vehicles = Vehicles()
        vehicles.add(veh_id="test",
                     acceleration_controller=(IDMController, {}),
                     routing_controller=(ContinuousRouter, {}),
                     num_vehicles=15)

        initial_config = InitialConfig(x0=150)

        # create the environment and scenario classes for a ring road
        self.env, scenario = figure_eight_exp_setup(
            initial_config=initial_config, vehicles=vehicles)
Exemplo n.º 4
0
    def test_next_prev_edge_figure_eight(self):
        """
        Tests the next_edge() and prev_edge() methods for the figure eight.
        """
        env, _ = figure_eight_exp_setup()

        next_edge = env.k.network.next_edge("bottom", 0)
        expected_next_edge = [(':center_1', 0)]
        self.assertCountEqual(next_edge, expected_next_edge)

        prev_edge = env.k.network.prev_edge("bottom", 0)
        expected_prev_edge = [(':bottom_0', 0)]
        self.assertCountEqual(prev_edge, expected_prev_edge)
Exemplo n.º 5
0
    def test_num_lanes_junctions(self):
        """
        Tests the num_lanes() method when called on junctions
        """
        additional_net_params = {"radius_ring": 30, "lanes": 3,
                                 "speed_limit": 60, "resolution": 40}
        net_params = NetParams(no_internal_links=False,
                               additional_params=additional_net_params)

        env, scenario = figure_eight_exp_setup(net_params=net_params)

        self.assertEqual(scenario.num_lanes("bottom_upper_ring_in"), 3)
        self.assertEqual(scenario.num_lanes(":top_upper_ring_0"), 3)
    def setUp(self):
        # place 15 vehicles in the network (we need at least more than 1)
        vehicles = VehicleParams()
        vehicles.add(veh_id="test",
                     acceleration_controller=(IDMController, {}),
                     routing_controller=(ContinuousRouter, {}),
                     car_following_params=SumoCarFollowingParams(min_gap=0),
                     num_vehicles=15)

        initial_config = InitialConfig(x0=150)

        # create the environment and network classes for a ring road
        self.env, _, _ = figure_eight_exp_setup(initial_config=initial_config,
                                                vehicles=vehicles)
Exemplo n.º 7
0
    def test_edge_length_junctions(self):
        """
        Tests the speed_limit() method when called on junctions
        """
        additional_net_params = {"radius_ring": 30, "lanes": 1,
                                 "speed_limit": 60, "resolution": 40}
        net_params = NetParams(no_internal_links=False,
                               additional_params=additional_net_params)

        env, scenario = figure_eight_exp_setup(net_params=net_params)

        self.assertAlmostEqual(
            scenario.edge_length(":center_intersection_0"), 5.00)
        self.assertAlmostEqual(
            scenario.edge_length(":center_intersection_1"), 6.20)
Exemplo n.º 8
0
    def test_num_lanes_junctions(self):
        """
        Tests the num_lanes() method when called on junctions
        """
        additional_net_params = {
            "radius_ring": 30,
            "lanes": 3,
            "speed_limit": 60,
            "resolution": 40
        }
        net_params = NetParams(additional_params=additional_net_params)

        env, network = figure_eight_exp_setup(net_params=net_params)

        self.assertEqual(env.k.network.num_lanes("bottom"), 3)
        self.assertEqual(env.k.network.num_lanes(":top_0"), 3)
Exemplo n.º 9
0
    def test_speed_limit_junctions(self):
        """
        Tests the speed_limit() method when called on junctions
        """
        additional_net_params = {
            "radius_ring": 30,
            "lanes": 1,
            "speed_limit": 60,
            "resolution": 40
        }
        net_params = NetParams(additional_params=additional_net_params)

        env, scenario = figure_eight_exp_setup(net_params=net_params)

        self.assertAlmostEqual(env.k.scenario.speed_limit("bottom"), 60)
        self.assertAlmostEqual(env.k.scenario.speed_limit(":top_0"), 60)
Exemplo n.º 10
0
    def test_edge_length_junctions(self):
        """
        Tests the speed_limit() method when called on junctions
        """
        additional_net_params = {
            "radius_ring": 30,
            "lanes": 1,
            "speed_limit": 60,
            "resolution": 40
        }
        net_params = NetParams(additional_params=additional_net_params)

        env, _ = figure_eight_exp_setup(net_params=net_params)

        self.assertAlmostEqual(
            env.k.network.edge_length(":center_0"), 9.40)  # FIXME: 6.2?
        self.assertAlmostEqual(
            env.k.network.edge_length(":center_1"), 9.40)  # FIXME: 6.2?
Exemplo n.º 11
0
 def setUp(self):
     # create the environment and scenario classes for a figure eight
     env, self.scenario = figure_eight_exp_setup()
Exemplo n.º 12
0
 def setUp(self):
     # create the environment and network classes for a figure eight
     self.env, _ = figure_eight_exp_setup()