Reference
Agent generation
SmartTransitionSim.Rect — TypeRect type represent rectangle area on map
Fields
p1: Latitude-Longitude coordinates of first rectangle cornerp2: Latitude-Longitude coordinates of second rectangle corner
SmartTransitionSim.Agent — TypeAgent type stores information about agents
Fields
smart: logical value indicating if agent use re-routing servicestart_node: starting point of agent's routeend_node: ending point of agent's routeroute: array of nodes determining agent's route (may be changed by re-routing)start_time: time after which agent starts movingtravel_time: time spent in simulationedge: current edge agent is onactive: indicates if agent is active in simulation
SmartTransitionSim.pick_random_node — Functionpick_random_node function is used to get starting and ending node of agents. Nodes are randomly chosen from set of provided areas.
Input parameters
OSMmap: OpenStreetMapX mapData object with road network datarects: vector of Rect types interpreted as a set of rectangle areas
SmartTransitionSim.get_nodes_set — Functionget_nodes_set function is used to get set of nodes within passed area.
Input parameters
OSMmap: OpenStreetMapX mapData object with road network datarects: vector of Rect types interpreted as a set of rectangle areas
SmartTransitionSim.generate_agents — Functiongenerate_agents function creating vector of agents and returning travel time for initial routes travelled with maximal speed
Input parameters
OSMmap: OpenStreetMapX MapData object with road network dataN: number of agents to be generatedStartArea: vector of areas from which agents randomly pick starting pointEndArea: vector of areas from which agents randomly pick ending pointα: percentage of smart agentsk: number of fastest routes used in k-path algorithmT: control variable for k-path algorithm probability distributionAvgStartTime: average agents start time in minutesk_routes_dict: dictionary with multiple shortest paths (values) between vertices (keys)seed: set seed for random function
Rerouting
SmartTransitionSim.k_shortest_path_rerouting! — Functionk_shortest_path_rerouting! change agents current route according to traffic conditions
Input parameters
OSMmap: OpenStreetMapX MapData object with road network datak_routes_dict: dictionary with multiple shortest paths (values) between vertices (keys)inAgent: modified agentspeeds: current speed matrixmax_speeds: matrix with maximal speeds on edgesk: number of fastest routes returnedT: control variable for probability distributionupd_period: update period in seconds - if different from 0 enables rerouting based on distance travelled during one update period
SmartTransitionSim.yen_a_star — Functionyen_a_star is modified version of LightGraphs yenkshortest_paths function
Input parameters
g: road network graphsource: source vertextarget: target vertexdistmx: weight matrixK: number of routes to be calculated
Traffic model
SmartTransitionSim.get_max_densities — Functionget_max_densities calculate maximal traffic densities on all edges
Input parameters
OSMmap: OpenStreetMapX MapData object with road network datadensity_factor: road length reserved for one vehicle
SmartTransitionSim.update_weights! — Functionupdate_weights! change speeds in given speedmatrix for edges listed in newdensities
Input parameters
speed_matrix: matrix with average speeds on edgesnew_densities: dictionary with edges as keys and new traffic density as valuemax_densities: matrix with maximal densitites on edgesV_max: matrix with maximal speeds on edgesV_min: minimal speed on road
SmartTransitionSim.update_weights_and_events! — Functionupdate_weights_and_events! update events time and weights in speed matrix
Input parameters
inAgents: set of agents created with generate_agents functionagents_pos: vector with agents current position (edges)events: vector with events timespeed_matrix: matrix with average speeds on edgesedges: one or two edges that took part in an eventdens: dictionary with current density on edgesmax_densities: matrix with maximal densitiesV_max: matrix with speed limitsV_min: minimal speed allowed on road
SmartTransitionSim.traffic_constants — Functiontraffic_constants create maximal traffic densities and speeds matrices
Input parameters
OSMmap: OpenStreetMapX MapData object with road network datadensity_factor: road length reserved for one vehicle
SmartTransitionSim.init_traffic_variables — Functioninit_traffic_variables create data used in calculating velocities change during simulation
Input parameters
OSMmap: OpenStreetMapX MapData object with road network dataAgents: set of agents created with generate_agents function
SmartTransitionSim.next_edge — Functionnext_edge returns time required to reach next junction for one agent
Input parameters
Agent: single instance of Agentspeeds: current speeds matrixlengths: road lengths matrix
next_edge returns time required to reach next junction for set of agents
Input parameters
Agents: set of agents created with generate_agents functionspeeds: current speeds matrixlengths: road lengths matrix
SmartTransitionSim.update_event_agent! — Functionupdate_event_agent! update densities matrix, progress agents to next edge and deactivate agents
Input parameters
inAgent: agent connected with occuring eventcurr_time: current simulation timedensities: current traffic densitites dictionaryvertices_map: mapping from nodes to vertices
Simulation
SmartTransitionSim.simulation_run — Functionsimulation_run run traffic simulation in two modes.
Input parameters
mode: simulation model switch:base: simulation with regular agents only:smart: simulation with smart agents enabled
OSMmap: OpenStreetMapX MapData object with road network datainAgents: set of agents created with generate_agents functiondensity_factor: road length reserved for one vehiclek_routes_dict: dictionary with multiple shortest paths (values) between vertices (keys)U: period of weights updatesT: distribution parameter in k-shortest path reroutingk: number of fastest routes generated in rerouting functiondebug: debug messages switchtrack_avg_speeds: return average speeds on edges if true
SmartTransitionSim.gather_statistics — Functiongather_statistics return various measures describing TMS model quality
Input parameters
smart_ind: vector with smart agent indicatorstimes_base: agents travelling time in base scenariotimes_smart: agents travelling time in smart scenario
Utilities
SmartTransitionSim.print_map_statistics — Functionprint_map_statistics prints basic map file properties and characteristics of road network (OpenStreetMapX.MapData type) built on top of that
Fields
datapath: path to map filemapfile: map file nameroadclass: highest road classe available on the map