コード例 #1
0
    def setUp_failsafe(self, vehicles):
        additional_env_params = {
            "target_velocity": 8,
            "max-deacc": 3,
            "max-acc": 3
        }
        env_params = EnvParams(additional_params=additional_env_params,
                               longitudinal_fail_safe="safe_velocity")

        additional_net_params = {
            "length": 100,
            "lanes": 1,
            "speed_limit": 30,
            "resolution": 40
        }
        net_params = NetParams(additional_params=additional_net_params)

        initial_config = InitialConfig(bunching=10)

        # create the environment and scenario classes for a ring road
        env, scenario = ring_road_exp_setup(vehicles=vehicles,
                                            env_params=env_params,
                                            net_params=net_params,
                                            initial_config=initial_config)

        # instantiate an experiment class
        self.exp = SumoExperiment(env, scenario)
コード例 #2
0
    def setUp_gen_start_pos(
            self, initial_config=InitialConfig()):
        """
        Replace with any scenario you would like to test gen_gaussian_start_pos
        on. In ordering for all the tests to be meaningful, the scenario must
        contain MORE THAN TWO LANES.
        """
        # create a multi-lane ring road network
        additional_net_params = {"length": 230, "lanes": 4, "speed_limit": 30,
                                 "resolution": 40}
        net_params = NetParams(additional_params=additional_net_params)

        # place 5 vehicles in the network (we need at least more than 1)
        vehicles = Vehicles()
        vehicles.add_vehicles(veh_id="test",
                              acceleration_controller=(IDMController, {}),
                              routing_controller=(ContinuousRouter, {}),
                              num_vehicles=15)

        initial_config.spacing = "gaussian_additive"
        if initial_config.downscale == InitialConfig().downscale:
            initial_config.downscale = np.inf

        # create the environment and scenario classes for a ring road
        self.env, scenario = ring_road_exp_setup(net_params=net_params,
                                                 initial_config=initial_config,
                                                 vehicles=vehicles)
コード例 #3
0
    def setUp(self):
        # add a few vehicles to the network using the requested model
        # also make sure that the input params are what is expected
        contr_params = {
            "v0": 30,
            "T": 1,
            "a": 1,
            "b": 1.5,
            "delta": 4,
            "s0": 2,
            "s1": 0,
            "decel_max": -5,
            "dt": 0.1,
            "noise": 0
        }

        vehicles = Vehicles()
        vehicles.add_vehicles(veh_id="test",
                              acceleration_controller=(IDMController,
                                                       contr_params),
                              routing_controller=(ContinuousRouter, {}),
                              num_vehicles=5)

        # create the environment and scenario classes for a ring road
        self.env, scenario = ring_road_exp_setup(vehicles=vehicles)
コード例 #4
0
    def runTest(self):
        # run the experiment for 1 run and collect the last position of all
        # vehicles
        env, scenario = ring_road_exp_setup()
        exp = SumoExperiment(env, scenario)
        exp.run(num_runs=1, num_steps=10)

        pos1 = [exp.env.vehicles.get_speed()]

        # run the experiment for 2 runs and collect the last position of all
        # vehicles
        env, scenario = ring_road_exp_setup()
        exp = SumoExperiment(env, scenario)
        exp.run(num_runs=2, num_steps=10)

        pos2 = [exp.env.vehicles.get_speed()]

        # check that the final position is the same in both instances
        np.testing.assert_array_almost_equal(pos1, pos2)
コード例 #5
0
    def setUp(self):
        # add an extra lane to the ring road network
        additional_net_params = {
            "length": 230,
            "lanes": 2,
            "speed_limit": 30,
            "resolution": 40
        }
        net_params = NetParams(additional_params=additional_net_params)

        # create the environment and scenario classes for a ring road
        self.env, scenario = ring_road_exp_setup(net_params=net_params)
コード例 #6
0
    def setUp(self):
        # add a few vehicles to the network using the requested model
        # also make sure that the input params are what is expected
        contr_params = \
            {"k_d": 1, "k_v": 1, "k_c": 1, "d_des": 1, "v_des": 8,
             "accel_max": 15, "decel_max": -5, "tau": 0, "dt": 0.1, "noise": 0}

        vehicles = Vehicles()
        vehicles.add_vehicles(veh_id="test",
                              acceleration_controller=(BCMController,
                                                       contr_params),
                              routing_controller=(ContinuousRouter, {}),
                              num_vehicles=5)

        # create the environment and scenario classes for a ring road
        self.env, scenario = ring_road_exp_setup(vehicles=vehicles)
コード例 #7
0
    def setUp(self):
        # turn on vehicle arrangement shuffle
        sumo_params = SumoParams(vehicle_arrangement_shuffle=True)

        # place 5 vehicles in the network (we need at least more than 1)
        vehicles = Vehicles()
        vehicles.add_vehicles(veh_id="test",
                              acceleration_controller=(IDMController, {}),
                              routing_controller=(ContinuousRouter, {}),
                              num_vehicles=5)

        initial_config = InitialConfig(x0=5)

        # create the environment and scenario classes for a ring road
        self.env, scenario = ring_road_exp_setup(sumo_params=sumo_params,
                                                 initial_config=initial_config,
                                                 vehicles=vehicles)
コード例 #8
0
    def setUp(self):
        # create a 2-lane ring road network
        additional_net_params = {"length": 230, "lanes": 3, "speed_limit": 30,
                                 "resolution": 40}
        net_params = NetParams(additional_params=additional_net_params)

        # turn on starting position shuffle
        sumo_params = SumoParams(starting_position_shuffle=True)

        # place 5 vehicles in the network (we need at least more than 1)
        vehicles = Vehicles()
        vehicles.add_vehicles(veh_id="test",
                              acceleration_controller=(IDMController, {}),
                              routing_controller=(ContinuousRouter, {}),
                              num_vehicles=5)

        # create the environment and scenario classes for a ring road
        self.env, scenario = ring_road_exp_setup(net_params=net_params,
                                                 sumo_params=sumo_params,
                                                 vehicles=vehicles)
コード例 #9
0
 def setUp(self):
     # create the environment and scenario classes for a ring road
     self.env, scenario = ring_road_exp_setup()
コード例 #10
0
    def setUp(self):
        # create the environment and scenario classes for a ring road
        env, scenario = ring_road_exp_setup()

        # instantiate an experiment class
        self.exp = SumoExperiment(env, scenario)
コード例 #11
0
    def setUp(self):
        # set sumo_params to default
        sumo_params = SumoParams()

        # create the environment and scenario classes for a ring road
        self.env, scenario = ring_road_exp_setup(sumo_params=sumo_params)