HPC module

METS-R HPC is used to control multiple simulation instances that can run and exchange data through WebSocket connects. Apache Kafka is used to explicitly model the data stream. The overall HPC framework is shown in the figure below, note this framework allows us to separate the logics of modeling data processing, decision generation, traffic simulation, and potentially cyber attacks.

HPC framework

HPC framework

Code structure

Four types of classes are used:

  • Client for interfacing the data communication between simulators and other components.

  • Runner for defining different types of experiments.

  • Model for implementing operational algorithms.

  • Config for storing the configuration templates.

Besides these, we provide the example scripts: hpc_example.py,interactive_example.ipynb, cosim_example.py.

Operational algorithms

Eco-routing module

The online energy-efficient routing aims to find the paths with minimal expected energy consumption for multiple EVs (EV taxis and EV buses), which is developed from the sample-efficient online algorithms and the combinatorial multi-arm bandit problem (CMAB). Specifically, we make use of the information obtained from the simulation side to update our eco-routing strategy, as shown below.

The strategy of eco-routing updates

The strategy of eco-routing updates

Bus scheduling module

The demand-adaptive transit planning module generated the EV bus routes and the corresponding transit schedules using hourly-based predicted travel demand from or to the hubs. The demand prediction module was implemented in Python and it stored the demand as a CSV table that can be indexed by hub, date, hour, and taxi zone. The result of the demand prediction module served as the input of the EV transit planning and scheduling algorithms, and the outputs are the EV transit routes and the numbers of assigned EV buses on different routes.

Interactive APIs

The following APIs are implemented to interact with the METS-R SIM, here sim_client is an instance of METSRClient.

STEP

Name

Description

Examples

Return

tick

Move the simulation one tick forward

sim_client.tick()

QUERY

If an agent ID is provided, a query would return the information of the specific agent, otherwise, it will return a list containing the ID of all agents.

Name

Description

Examples

Return

query_vehicle(id=None, private_veh=False, transform_coords=False)

Get the information of one or more vehicles. By default, queries public vehicles. Set private_veh=True for private vehicles and transform_coords=True to convert coordinates to SUMO format.

sim_client.query_vehicle(1, True, True)

x, y, speed, acceleration, bearing, origin zone, destination zone, vehicle state

query_bus(id=None)

Get the information of one or more EV buses.

sim_client.query_bus(37732)

battery state, route ID, current stop, passenger number

query_taxi(id=None)

Get the information of one or more EV taxis.

sim_client.query_taxi(36879)

x, y, passenger number, vehicle state, origin zone, destination zone

query_road(id=None)

Get the information of one or more roads.

sim_client.query_road(100011)

speed limit, number of on-road vehicles, average travel time, road length (m), energy consumed, road type

query_zone(id=None)

Get the information of one or more demand zones.

sim_client.query_zone(0)

vehicle stock, taxi demand, bus demand, x, y, zone type

query_signal(id=None)

Get the information of one or more traffic signals.

sim_client.query_signal(14)

current phase, next phase, next update time

query_chargingStation(id=None)

Get the information of one or more EV charging stations.

sim_client.query_chargingStation(-10)

x, y, number of available chargers

query_coSimVehicle()

Get the vehicle IDs currently located on the co-simulation road.

sim_client.query_coSimVehicle()

list of vehicle IDs on the co-sim road

CONTROL

Name

Description

Examples

Inputs

generate_trip(vehID, origin=-1, destination=-1)

Generate a vehicle trip between origin and destination zones.

sim_client.generate_trip("veh_1", 3, 5)

vehID, origin, destination

generate_trip_between_roads(vehID, origin, destination)

Generate a vehicle trip between origin and destination roads.

sim_client.generate_trip_between_roads("veh_1", "r1", "r2")

vehID, origin, destination

set_cosim_road(roadID)

Set one or more roads for co-simulation.

sim_client.set_cosim_road("road_2")

roadID

release_cosim_road(roadID)

Release one or more co-simulation roads.

sim_client.release_cosim_road("road_2")

roadID

teleport_cosim_vehicle(vehID, roadID, x, y, private_veh=False, transform_coords=False)

Teleport a vehicle to a location on a co-sim road using coordinates.

sim_client.teleport_cosim_vehicle("veh_1", "road_2", 10.5, 25.0)

vehID, roadID, x, y, private_veh, transform_coords

teleport_trace_replay_vehicle(vehID, roadID, laneID, dist, private_veh=False)

Teleport a vehicle using road ID, lane ID, and distance from downstream junction.

sim_client.teleport_trace_replay_vehicle("veh_1", "road_3", 1, 30.0)

vehID, roadID, laneID, dist, private_veh

enter_next_road(vehID, private_veh=False)

Move vehicle to next road in its planned route.

sim_client.enter_next_road("veh_1")

vehID, private_veh

control_vehicle(vehID, acc, private_veh=False)

Directly control vehicle acceleration.

sim_client.control_vehicle("veh_1", 2.5)

vehID, acc, private_veh

update_vehicle_sensor_type(vehID, sensorType, private_veh=False)

Change the sensor type of a vehicle.

sim_client.update_vehicle_sensor_type("veh_1", "LiDAR")

vehID, sensorType, private_veh

dispatch_taxi(vehID, orig, dest, num)

Dispatch a taxi between two zones.

sim_client.dispatch_taxi("taxi_1", 0, 2, 1)

vehID, orig, dest, num

dispatch_taxi_between_roads(vehID, orig, dest, num)

Dispatch a taxi between roads.

sim_client.dispatch_taxi_between_roads("taxi_1", "r1", "r2", 1)

vehID, orig, dest, num

add_taxi_requests(zoneID, dest, num)

Add taxi passenger request at a zone.

sim_client.add_taxi_requests(1, 3, 2)

zoneID, dest, num

add_taxi_requests_between_roads(zoneID, orig, dest, num)

Add road-based taxi request from a zone.

sim_client.add_taxi_requests_between_roads(1, "r1", "r2", 1)

zoneID, orig, dest, num

assign_request_to_bus(vehID, orig, dest, num)

Assign passenger request to a specific bus.

sim_client.assign_request_to_bus("bus_1", 0, 5, 10)

vehID, orig, dest, num

add_bus_requests(zoneID, dest, num)

Add a bus passenger request at a zone.

sim_client.add_bus_requests(2, 5, 15)

zoneID, dest, num

reset(prop_file)

Reset simulation using a specified property file.

sim_client.reset("Data.properties.NYC")

prop_file

reset_map(map_name)

Reset simulation using a predefined map (CARLA, NYC, UA).

sim_client.reset_map("CARLA")

map_name

terminate()

Fully terminate the simulation and close the client.

sim_client.terminate()

None

close()

Close the client while leaving the simulation running.

sim_client.close()

None