Esempio n. 1
0
def traffic() -> Traffic:
    car1 = TrafficActor(
        name="car",
        speed=Distribution(sigma=0.2, mean=1.0),
    )
    car2 = TrafficActor(
        name="car",
        speed=Distribution(sigma=0.2, mean=0.8),
        lane_changing_model=LaneChangingModel(impatience=1, cooperative=0.25),
        junction_model=JunctionModel(drive_after_yellow_time=1.0, impatience=0.5),
    )

    return Traffic(
        flows=[
            Flow(
                route=Route(
                    begin=(f"edge-{r[0]}", 0, 30), end=(f"edge-{r[1]}", 0, -30)
                ),
                rate=1.0,
                actors={
                    car1: 0.5,
                    car2: 0.5,
                },
            )
            for r in [("west-WE", "east-WE"), ("east-EW", "west-EW")]
        ]
    )
Esempio n. 2
0
                begin=("edge1", 0, 10), via=("edge0",), end=("edge1", (0, 1, 2), 10)
            ),
            num_laps=1,
        ),
    ],
    overwrite=True,
)

print(f"generate lap mission finished")

# generate social agent routes

impatient_car = TrafficActor(
    name="car",
    speed=Distribution(sigma=0.2, mean=0.5),
    lane_changing_model=LaneChangingModel(impatience=1, cooperative=0.25),
    junction_model=JunctionModel(
        drive_after_red_time=1.5, drive_after_yellow_time=1.0, impatience=1.0
    ),
)

patient_car = TrafficActor(
    name="car",
    speed=Distribution(sigma=0.2, mean=0.5),
    lane_changing_model=LaneChangingModel(impatience=0, cooperative=0.5),
    junction_model=JunctionModel(drive_after_yellow_time=1.0, impatience=0.5),
)

car_type = patient_car
car_name = "patient_car"

traffic = Traffic(
Esempio n. 3
0
    Flow,
    Route,
    RandomRoute,
    TrafficActor,
    Mission,
)

scenario = os.path.dirname(os.path.realpath(__file__))

agent_missions = [
    Mission(Route(begin=("left_in", 0, 80), end=("merged", (0, ), 40))),
    Mission(Route(begin=("left_in", 0, 50), end=("merged", (0, ), 40))),
    Mission(Route(begin=("ramp_in", 0, 80), end=("merged", (0, ), 60))),
    Mission(Route(begin=("ramp_in", 0, 50), end=("merged", (0, ), 60))),
]

gen_missions(scenario, agent_missions, overwrite=True)

gen_traffic(
    scenario,
    Traffic(flows=[
        Flow(
            route=RandomRoute(),
            rate=3600,
            actors={TrafficActor(name="car"): 1.0},
        )
    ]),
    name="random",
    overwrite=True,
)
Esempio n. 4
0
            # Mission(Route(begin=("edge-east", 0, 0), end=("edge-east", 0, -5))),
        ],
        overwrite=True,
    )

print("generate ego agent missions finished")


#########################################
# generate social vehicles
#########################################
sv_nums = [60, 60, 60, 60]

seed = 45

traffic_actor = TrafficActor(name="car", speed=Distribution(sigma=0.1, mean=0.3),)

for scenario_path, sv_num in zip(scenario_paths, sv_nums):
    traffic = Traffic(
        flows=[
            Flow(
                route=RandomRoute(),
                begin=0,
                end=1
                * 60
                * 60,  # make sure end time is larger than the time of one episode
                rate=60,
                actors={traffic_actor: 1},
            )
            for i in range(sv_num)
        ]
    "blocker": (102, 0, 255),
    # "bus": (255, 255, 0),
    # "crusher": (255, 0, 0),
    "stopwatcher": (255, 158, 251),
}

depart_speed = "max"  # sets to max
social_vehicles = {
    "default":
    TrafficActor(
        name="default",
        accel=3.0,
        decel=7.5,
        tau=1.0,
        depart_speed=depart_speed,
        min_gap=Distribution(mean=2.5, sigma=0.05),
        speed=Distribution(mean=1.0, sigma=0.05),
        imperfection=Distribution(mean=0.5, sigma=0.05),
        vehicle_type="passenger",
        lane_changing_model=LaneChangingModel(),
        junction_model=JunctionModel(),
    ),
    "aggressive":
    TrafficActor(
        name="aggressive",
        accel=10.0,
        decel=10.0,
        tau=0.5,
        depart_speed=depart_speed,
        min_gap=Distribution(mean=1.0, sigma=0.1),
        speed=Distribution(mean=1.5, sigma=0.1),
Esempio n. 6
0
    Traffic,
    TrafficActor,
)

social_vehicle_num = 100

ego_missions = [
    Mission(
        route=Route(begin=("edge-south-SN", 1, 10), end=("edge-north-SN", 1, 8)),
    ),
]

stright_traffic_actor = TrafficActor(
    name="car",
    speed=Distribution(sigma=0.2, mean=1),
    lane_changing_model=LaneChangingModel(impatience=0),
    junction_model=JunctionModel(
        drive_after_red_time=1.5, drive_after_yellow_time=1.0, impatience=0.5
    ),
)
scenario = Scenario(
    traffic={
        "basic": Traffic(
            flows=[
                Flow(
                    route=RandomRoute(),
                    rate=1,
                    actors={stright_traffic_actor: 1.0},
                )
                for i in range(social_vehicle_num)
            ]
        )
Esempio n. 7
0
    Route,
    Scenario,
    Traffic,
    TrafficActor,
)

social_vehicle_num = 100

ego_missions = [
    Mission(route=Route(begin=("edge-south-SN", 0, 10),
                        end=("edge-east-WE", 0, 8)), ),
]

right_traffic_actor = TrafficActor(
    name="car",
    speed=Distribution(sigma=0.2, mean=1),
    lane_changing_model=LaneChangingModel(impatience=0),
)
scenario = Scenario(
    traffic={
        "basic":
        Traffic(flows=[
            Flow(
                route=RandomRoute(),
                rate=1,
                actors={right_traffic_actor: 1.0},
            ) for i in range(social_vehicle_num)
        ])
    },
    ego_missions=ego_missions,
)
Esempio n. 8
0
    EndlessMission,
    Flow,
    LaneChangingModel,
    Mission,
    RandomRoute,
    Route,
    SocialAgentActor,
    Traffic,
    TrafficActor,
)

scenario = os.path.dirname(os.path.realpath(__file__))

# Traffic Vehicles
#
car = TrafficActor(name="car", )

cooperative_car = TrafficActor(
    name="cooperative_car",
    speed=Distribution(sigma=0.2, mean=1.0),
    lane_changing_model=LaneChangingModel(impatience=0.1, cooperative=1),
)

aggressive_car = TrafficActor(
    name="aggressive_car",
    speed=Distribution(sigma=0.2, mean=1.0),
    lane_changing_model=LaneChangingModel(impatience=1, cooperative=0.1),
)

horizontal_routes = [("west-WE", "east-WE"), ("east-EW", "west-EW")]
turn_left_routes = [("east-EW", "south-NS")]
Esempio n. 9
0
    Flow,
    Route,
    RandomRoute,
    TrafficActor,
    Mission,
)

scenario = os.path.dirname(os.path.realpath(__file__))

agent_missions = [
    Mission(Route(begin=("left_in", 1, 20), end=("right_out", (0,), 40))),
    Mission(Route(begin=("left_in", 1, 40), end=("off_ramp", (0,), 40))),
    Mission(Route(begin=("left_in", 0, 20), end=("off_ramp", (0,), 40))),
    Mission(Route(begin=("left_in", 0, 50), end=("right_out", (0,), 40))),
]

gen_missions(scenario, agent_missions, overwrite=True)

gen_traffic(
    scenario,
    Traffic(
        flows=[
            Flow(
                route=RandomRoute(), rate=3600, actors={TrafficActor(name="car"): 1.0},
            )
        ]
    ),
    name="random",
    overwrite=True,
)