AnyLogic 9
Expand
Font size

RoadNetworkDescriptor

RoadNetworkDescriptor is an optional block that allows to control all vehicles located in a road network. This block allows you to set actions to be executed for each car in different cases: for example, on entering the network, on entering the road, on changing lane, and so on.

This block also enables the road density map, which displays the current state of traffic jams on the roads of the network.

Parameters

Road network
The road network that this block configures.
Syntax: RoadNetwork roadNetwork
Set new value at runtime: set_roadNetwork(new value)
Road section length
The length of the road segment. Cannot be less than 1 meter. All roads in the network are split by sections of the same length (the section at the end of the road can be shorter). These sections are used in density maps and average speed reporting.
Syntax: double roadSectionLength
Set new value at runtime: set_road SectionLength(new value)

Density map

Enable density map
Controls the visibility of the traffic density map. The traffic density map is a semi-transparent coloring of roads depending on the average speed of a car on each section of the road. The traffic density map is displayed in both 2D and 3D animation.
Syntax: boolean enableDensityMap
Set new value at runtime: set_enableDensityMap(new value)
Green speed level
[Visible and applies only if the Enable density map option is set]
If the average speed on a road section is greater than or equal to the value of this parameter, the road density map for this section is displayed in green. The value of the Green speed level parameter must always be greater than the value of the Red speed level parameter.
Syntax: double greenSpeedLevel
Set new value at runtime: set_greenSpeedLevel(new value)
Red speed level
[Visible and applies only if the Enable density map option is set]
If the average speed on a road section is less than or equal to the value of this parameter, the road density map for that segment is displayed in red.
Syntax: double redSpeedLevel
Set new value at runtime: set_redSpeedLevel(new value)
Map transparency (0..1)
[Visible and applies only if the Enable density map option is set]
Transparency of the density map. The value of this parameter can be in the range [0..1]. 0 — opaque map, 1 — transparent map.
Syntax: double densityMapTransparency
Set new value at runtime: set_densityMapTransparency(new value)

Actions

On enter network
The code to execute each time a car enters the road network.
Local variable: car — The car that enters the road network
On exit network
The code to execute each time a car exits the road network.
Local variable: car — The car that enters the road network
On enter road
The code to execute each time a car enters a road.
Local variables:
car — The car that enters a road
Road road — The road that is being entered by the car
boolean isRoadForward — true if the car enters the road in the forward direction, false otherwise
On exit road
The code to execute each time a car exits a road.
Local variables:
car — The car that exits a road
Road road — The road that is being exited by the car
boolean isRoadForward — true if the car was moving on the road in the forward direction, false otherwise
On enter intersection
The code to execute each time a car enters an intersection.
Local variables:
car — The car that enters an intersection
Intersection intersection — The intersection that is being entered by the car
On exit intersection
The code to execute each time a car exits an intersection.
Local variables:
car — The car that exits an intersection
Intersection intersection — The intersection that is being exited by the car
On lane change
The code to execute each time a car completes a lane change.
Local variables:
car — The car that completes the lane change
Road road — The road that car is on during the lane change
boolean isRoadForward — true if the car moves on the road in the forward direction, false otherwise
int previousLaneIndex — The 0-based index of the lane that was left by the car
int currentLaneIndex — The 0-based index of the lane that the car arrived at
On stop
The code to execute each time a car stops. There can be several reasons for a car to stop:
  • there is a car in front of it that is not moving,
  • the car’s preferred speed is set to 0,
  • the car has stopped before the stop line,
  • the car has reached the target bus stop or parking space.
Local variables:
car — The car that stopped
Road road — The road that the car is on when it stopped, or null if the car stopped outside any road (for example, at an intersection)
boolean isRoadForward — true if the car was moving on the road in the forward direction, false otherwise
On resume moving
The code to execute each time a car resumes moving after a stop.
Local variables:
car — The car that resumed moving
Road road — The road that the car is on when resuming the movement, or null if the car is outside any road (for example, at an intersection)
boolean isRoadForward — true if the car is moving on the road in the forward direction, false otherwise
On car clicked
The code to execute each time a car is clicked with the mouse.
Local variable: car — The car that is clicked with the mouse

Additional options

Automatically resolve deadlocks
Toggles the resolution of deadlocks. The deadlock is a situation where cars are in each other’s way and cannot continue moving. If this option is selected, AnyLogic will identify the deadlocks and temporarily allow the cars to pass through each other to avoid the complete block of the model.
Syntax: boolean automaticallyResolveDeadlocks
Set new value at runtime: set_automaticallyResolveDeadLocks(new value)
Precision of geometric calculations
The precision of geometric calculations (in pixels). Can be changed if the model cannot run with the current settings.
Syntax: double geometricCalculationsPrecision
Set new value at runtime: set_geometricCalculationsPrecision(new value)
Precision of temporal calculations
The precision of temporal calculations (in seconds). Can be changed if the model cannot run with the current settings.
Syntax: double temporalCalculationsPrecision
Set new value at runtime: set_temporalCalculationsPrecision(new value)

Functions

Cars
Function Description
int size() Returns the number of cars in the road network.
Agent getCar(int index) Returns the car in this road network with the given index, or null if there is no such car.
index — The index of the car to return.
How can we improve this article?