AnyLogic
Expand
Font size

RoadNetworkDescriptor

Optional block. With the help of RoadNetworkDescriptor developers get access to controlling all the vehicles located in one road network. Block allows to set actions which will be executed for each car in the following cases: on entering network, on entering road, on changing the lane, etc.

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

Parameters

Road network
Road network which this block configures.
Syntax: RoadNetwork roadNetwork
Set new value at runtime: set_roadNetwork(new value)
Road section length
Length of road section (cannot be less than 1 meter long). All roads of network are split by sections of the same length (section at the end of 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 traffic density map. Traffic density map is a semi-transparent coloring of roads depending on the average speed of a car on each section of the road. Traffic density map is shown 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 or equal to the value of this parameter, road density map will be shown green for this section. Green speed level parameter value must always be greater than the Red speed level parameter value.
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 or equal to the value of this parameter, road density map will be shown red for this section.
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 density map. Value of this parameter can be in range of [0...1]. 0 — opaque map, 1 — transparent map.
Syntax: double densityMapTransparency
Set new value at runtime: set_densityMapTransparency(new value)

Actions

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

Additional options

Automatically resolve deadlocks
Enables / disables resolution of deadlocks. Deadlock is the situation when cars are in each other’s way and cannot continue movement. If this option is selected, the library will identify deadlocks and temporary allow cars pass through each other to avoid complete blockages of the model.
Syntax: boolean automaticallyResolveDeadlocks
Set new value at runtime: set_automaticallyResolveDeadLocks(new value)
Precision of geometric calculations
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
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.
How can we improve this article?