def setUp(self): # create the environment and scenario classes for a ring road self.env, self.scenario = grid_mxn_exp_setup() self.env.reset() # instantiate an experiment class self.exp = Experiment(self.env)
def test_collide_inflows(self): """Tests collisions in the presence of inflows.""" # create the environment and scenario classes for a ring road sim_params = SumoParams(sim_step=1, render=False) total_vehicles = 0 vehicles = VehicleParams() vehicles.add(veh_id="idm", acceleration_controller=(SimCarFollowingController, {}), routing_controller=(GridRouter, {}), car_following_params=SumoCarFollowingParams( tau=0.1, carFollowModel="Krauss", minGap=2.5, speed_mode=0b00000, ), num_vehicles=total_vehicles) grid_array = { "short_length": 100, "inner_length": 100, "long_length": 100, "row_num": 1, "col_num": 1, "cars_left": 0, "cars_right": 0, "cars_top": 0, "cars_bot": 0 } additional_net_params = { "speed_limit": 35, "grid_array": grid_array, "horizontal_lanes": 1, "vertical_lanes": 1 } inflows = InFlows() inflows.add(veh_type="idm", edge="bot0_0", vehs_per_hour=1000) inflows.add(veh_type="idm", edge="top0_1", vehs_per_hour=1000) inflows.add(veh_type="idm", edge="left1_0", vehs_per_hour=1000) inflows.add(veh_type="idm", edge="right0_0", vehs_per_hour=1000) net_params = NetParams(no_internal_links=False, inflows=inflows, additional_params=additional_net_params) env, _ = grid_mxn_exp_setup(row_num=1, col_num=1, sim_params=sim_params, vehicles=vehicles, net_params=net_params) # go through the env and set all the lights to green for i in range(env.rows * env.cols): env.k.traffic_light.set_state(node_id='center' + str(i), state="gggggggggggg") # instantiate an experiment class exp = Experiment(env) exp.run(50, 50)
def setUp(self): # create the environment and scenario classes for a grid network self.env, _ = grid_mxn_exp_setup(row_num=2, col_num=2) self.env.reset() # instantiate an experiment class self.exp = Experiment(self.env)
def setUp(self): vehicles = Vehicles() vehicles.add(veh_id="idm", acceleration_controller=(IDMController, {}), routing_controller=(GridRouter, {}), sumo_car_following_params=SumoCarFollowingParams( min_gap=2.5, tau=1.1), num_vehicles=16) self.env, scenario = grid_mxn_exp_setup(row_num=1, col_num=3, vehicles=vehicles)
def test_collide(self): """Tests collisions in the absence of inflows.""" # create the environment and scenario classes for a ring road sim_params = SumoParams(sim_step=1, render=False) total_vehicles = 20 vehicles = VehicleParams() vehicles.add( veh_id="idm", acceleration_controller=(SimCarFollowingController, {}), routing_controller=(GridRouter, {}), car_following_params=SumoCarFollowingParams( tau=0.1, carFollowModel="Krauss", minGap=2.5, speed_mode=0b00000, ), num_vehicles=total_vehicles) grid_array = { "short_length": 100, "inner_length": 100, "long_length": 100, "row_num": 1, "col_num": 1, "cars_left": int(total_vehicles / 4), "cars_right": int(total_vehicles / 4), "cars_top": int(total_vehicles / 4), "cars_bot": int(total_vehicles / 4) } additional_net_params = { "speed_limit": 35, "grid_array": grid_array, "horizontal_lanes": 1, "vertical_lanes": 1 } net_params = NetParams( no_internal_links=False, additional_params=additional_net_params) self.env, self.scenario = grid_mxn_exp_setup( row_num=1, col_num=1, sim_params=sim_params, vehicles=vehicles, net_params=net_params) # go through the env and set all the lights to green for i in range(self.env.rows * self.env.cols): self.env.traci_connection.trafficlight.setRedYellowGreenState( 'center' + str(i), "gggggggggggg") # instantiate an experiment class self.exp = Experiment(self.env) self.exp.run(50, 50)
def test_collide_inflows(self): """Tests collisions in the presence of inflows.""" # create the environment and scenario classes for a ring road sumo_params = SumoParams(sim_step=1, sumo_binary="sumo") total_vehicles = 12 vehicles = Vehicles() vehicles.add(veh_id="idm", acceleration_controller=(SumoCarFollowingController, {}), routing_controller=(GridRouter, {}), sumo_car_following_params=SumoCarFollowingParams( tau=0.1, carFollowModel="Krauss", minGap=2.5), num_vehicles=total_vehicles, speed_mode=0b00000) grid_array = {"short_length": 100, "inner_length": 100, "long_length": 100, "row_num": 1, "col_num": 1, "cars_left": 3, "cars_right": 3, "cars_top": 3, "cars_bot": 3} additional_net_params = {"speed_limit": 35, "grid_array": grid_array, "horizontal_lanes": 1, "vertical_lanes": 1, "traffic_lights": 1} inflows = InFlows() inflows.add(veh_type="idm", edge="bot0_0", vehsPerHour=1000) inflows.add(veh_type="idm", edge="top0_1", vehsPerHour=1000) net_params = NetParams(no_internal_links=False, in_flows=inflows, additional_params=additional_net_params) self.env, self.scenario = grid_mxn_exp_setup(row_num=1, col_num=1, sumo_params=sumo_params, vehicles=vehicles, net_params=net_params) # go through the env and set all the lights to green for i in range(self.env.rows * self.env.cols): self.env.traci_connection.trafficlight.setRedYellowGreenState( 'center' + str(i), "gggggggggggg") # instantiate an experiment class self.exp = SumoExperiment(self.env, self.scenario) self.exp.run(50, 50)
def setUp(self): tl_logic = TrafficLights(baseline=False) phases = [{ "duration": "31", "minDur": "8", "maxDur": "45", "state": "GGGrrrGGGrrr" }, { "duration": "6", "minDur": "3", "maxDur": "6", "state": "yyyrrryyyrrr" }, { "duration": "31", "minDur": "8", "maxDur": "45", "state": "rrrGGGrrrGGG" }, { "duration": "6", "minDur": "3", "maxDur": "6", "state": "rrryyyrrryyy" }] tl_logic.add("center0", phases=phases, programID=1) tl_logic.add("center1", phases=phases, programID=1, offset=1) tl_logic.add("center2", tls_type="actuated", phases=phases, programID=1) tl_logic.add("center3", tls_type="actuated", phases=phases, programID=1, maxGap=3.0, detectorGap=0.8, showDetectors=True, file="testindividuallights.xml", freq=100) env, scenario = grid_mxn_exp_setup(row_num=1, col_num=4, tl_logic=tl_logic) self.exp = SumoExperiment(env, scenario)