averbraeck / opentrafficsim

Open Source Multi-Level Traffic Simulator
BSD 3-Clause "New" or "Revised" License
28 stars 8 forks source link

New lane structure #118

Closed WJSchakel closed 2 months ago

WJSchakel commented 2 months ago

The current lane structure assumes one record at the longitudinal coordinate of 0m, on each relative lane. E.g. that there would be one record for one lane to the right of the GTU. However, this is not true. For example:

Therefore the lane structure must supply a set of lanes, from which neighboring GTUs and objects can be found. Many perception categories and classes such as lane change incentives rely on taking a single record to the left or right, to derive information in a search starting from this record. These algorithms all need to be updated.

WJSchakel commented 2 months ago

The new LaneStructure builds the structure every time step, but only to a limited range of about 300m downstream and upstream. Longitudinal search has absolute priority over lateral search. Lateral search will skip any lane that was already found longitudinally.

In any upstream search, when a lateral move is made, the relative lane of this laterally found lane remains the same as the lane it is found from. This is because if a lateral move is made, it is the only way the GTU can ever get in interaction with the ego GTU. For example: when the left lane merges with the right lane before reaching an acceleration lane, traffic on this left lane of the two can be laterally considered to be on the same lane as the acceleration lane.

The class can provide:

WJSchakel commented 2 months ago

Overall the data structure is simpler and more robust. GTU's can now use the shoulder if they need to.

WJSchakel commented 2 months ago

A small test with the short merge demo revealed that where the old lane structure took a total of 3662ms to be created during one hour of simulation, this was only 26ms for the new data structure.