Class SimulationEngine
java.lang.Object
real_time_traffic_simulation_with_java.cores.SimulationEngine
Core to control the simulation, center of backend operations.
Manages all other manager classes.
Manages all other manager classes.
-
Constructor Summary
ConstructorsConstructorDescriptionCore to control the simulation, center of backend operations. -
Method Summary
Modifier and TypeMethodDescriptionPrepare data for CSV logging: "Simulation step", "vehicle id","vehicle color", "vehicle speed", "vehicle is on edge", "edge congestion status", "edge average speed", "edge density"Prepare data for PDF summary: 1st element is {edgeCount, tlsCount}, 2nd element is {exportedSimulationStep}, following elements are {edgeID, laneCount, length}Get all IDs: edgesGet all IDs: traffic lightsGet all IDs: vehiclesGet statistics: number of entities in the simulationGet statistics: congestion hotspotsGet statistics: current time stepdouble[]getEdgeStats(String edgeID) Get statistics: chart values (average speed (km/h), density (veh/km), halting number (veh)) of a specific edgegetEdgeTooltip(String edgeID) Get tooltip: edgesGet mapping data: edgesGet mapping data: junctionsGet mapping data: traffic lightsGet mapping data: vehiclesgetTlTooltip(String tlID) Get tooltip: traffic lightsvoidinjectVehicle(int numVehicles, String start_edge_ID, String end_edge_ID, String color, String speed) Inject vehicle: single and batch injection, create route first then create vehicles on that route.voidsetTlPhaseDurations(String tlID, List<Integer> durations) Control traffic light: set phase durations for a traffic lightvoidsetVehicleFilter(String color, String edgeID) Set mapping data: filter vehicles by color and edgevoidControl simulation: advance simulation by one step invalid input: '&' update edge congestion status and traffic light statesvoidControl simulation: stopvoidstressTest(int number_of_vehicles, String start_edge_ID) Inject vehicle: stress test tool, inject 100 vehicles on up to 10 different random routes.voidControl traffic lights: toggle all traffic lightsvoidtoggleSingleTl(String tlID) Control traffic light: toggle single traffic light
-
Constructor Details
-
SimulationEngine
-
-
Method Details
-
stepSimulation
Control simulation: advance simulation by one step invalid input: '&' update edge congestion status and traffic light states- Throws:
IllegalStateException
-
stopSimulation
public void stopSimulation()Control simulation: stop -
getAllEdgeIDs
Get all IDs: edges- Returns:
- List of String edge IDs
- Throws:
ExceptionIllegalStateException
-
getAllVehicleIDs
Get all IDs: vehicles- Returns:
- List of String vehicle IDs
- Throws:
ExceptionIllegalStateException
-
getAllTrafficLightIDs
Get all IDs: traffic lights- Returns:
- List of String traffic light IDs
- Throws:
ExceptionIllegalStateException
-
injectVehicle
public void injectVehicle(int numVehicles, String start_edge_ID, String end_edge_ID, String color, String speed) Inject vehicle: single and batch injection, create route first then create vehicles on that route.
Route ID format: [currentTime]
Vehicle ID format: [routeID]_[index]- Parameters:
numVehicles- Number of vehicles to injectstart_edge_ID- Starting edge IDend_edge_ID- Ending edge IDcolor- Color of the vehicles
-
stressTest
Inject vehicle: stress test tool, inject 100 vehicles on up to 10 different random routes. Create routes first then create vehicles on those routes.
Route ID format: [currentTime]_[index]
Vehicle ID format: [routeID]_[index_of_vehicle_in_this_stress_test]- Parameters:
number_of_vehicles- Number of vehicles to injectstart_edge_ID- Edge ID to inject to
-
toggleAllTls
public void toggleAllTls()Control traffic lights: toggle all traffic lights -
toggleSingleTl
Control traffic light: toggle single traffic light- Parameters:
tlID- Traffic light ID
-
setTlPhaseDurations
-
getMapEdges
-
getMapJunctions
Get mapping data: junctions- Returns:
- List of JunctionData representing junctions shape to be rendered
-
getMapVehicles
Get mapping data: vehicles- Returns:
- List of VehicleData representing vehicles shape to be rendered
-
setVehicleFilter
-
getMapTls
Get mapping data: traffic lights- Returns:
- List of TrafficLightData representing traffic lights shape to be rendered
-
getEdgeTooltip
-
getTlTooltip
-
getCurrentTimeStep
Get statistics: current time step- Returns:
- Formatted statistic string for Dashboard
- Throws:
IllegalStateException
-
getBasicInfo
Get statistics: number of entities in the simulation- Returns:
- Formatted statistic string for Dashboard
-
getCongestionHotspots
Get statistics: congestion hotspots- Returns:
- Formatted statistic string of congested edge IDs for Dashboard
-
getEdgeStats
Get statistics: chart values (average speed (km/h), density (veh/km), halting number (veh)) of a specific edge- Parameters:
vehicleID- ID of the vehicle- Returns:
- Formatted statistic string for Dashboard
- Throws:
IllegalStateException
-
dataForCSV
Prepare data for CSV logging: "Simulation step", "vehicle id","vehicle color", "vehicle speed", "vehicle is on edge", "edge congestion status", "edge average speed", "edge density"- Returns:
- List of String arrays representing data rows
- Throws:
IllegalStateException
-
dataForPDF
Prepare data for PDF summary: 1st element is {edgeCount, tlsCount}, 2nd element is {exportedSimulationStep}, following elements are {edgeID, laneCount, length}- Returns:
- Throws:
IllegalStateException
-