Skip to content

08 Lane assignment: heuristic (Step 5, lanes.assignment_method = "heuristic")

Entry function:

from trajlab.processing.lanes import LaneAssignmentParams, assign_lanes

result = assign_lanes(tracks, params=LaneAssignmentParams(method="heuristic"), road_length_m=ref_line.length)
tracks, events = result.tracks, result.events

Purpose

The per-point labels of Step 4 flicker near lane boundaries and can place two vehicles in one lane at one time. The heuristic turns them into one piecewise-constant lane sequence per vehicle (lane_fixed): lanes change only at detected lane changes, and space-time conflicts are resolved. The library default is the HMM (09); the heuristic is selected with lanes.assignment_method = "heuristic".

Interface

Pipeline step Requires columns Produces columns Further output columns
lane_correction id, datum, pos_lon, pos_lat, lane, speed lane_fixed is_changing_lane, is_lateral_excursion, lane_conflict_resolved, lane_fixed_unresolved, lane_confidence, lane_posterior_margin, suspected_duplicate_track, lane_conflict_unresolved

The heuristic writes lane_fixed, is_changing_lane, is_lateral_excursion and lane_conflict_resolved; the HMM-specific columns are absent. Configuration: lane_change.* (07) and lanes.assignment_method.

Method

  1. Lane change vs. excursion: a detector interval (07) is a lane change if the lateral position crosses the boundary between the start-lane center and the next center in the direction of the movement and the corrected lane before the interval differs from the one after it (for a track starting or ending inside the interval, its first/last position counts). Otherwise it is a lateral excursion: aborted lane changes and large movements within a lane. Excursions do not change lane_fixed; their window is flagged is_lateral_excursion and the event stores max_lateral_offset_m.
  2. Crossover times: the moment the vehicle crosses the boundary $(c_{start} + c_{end})/2$ between the source and target lane centers. Vehicles without a detected manoeuvre whose start and end lanes differ get one crossover at the same boundary.
  3. Segments: between crossovers lane_fixed is the lane whose center is nearest to the segment's mean pos_lat.
  4. Conflict resolution: two vehicles overlap in one lane if $|s_a - s_b| < (L_a + L_b)/2 + 1.0$ m at the same time. They are sorted laterally and reassigned to adjacent distinct lanes minimizing the combined lateral offset to the lane centers; lane 0 is a candidate only inside auxiliary-lane zones; with fewer than two valid lanes a conflict is left. Changed rows are marked lane_conflict_resolved. Lane-change flags at the very start or end of a track are snapped to the nearest lane.

Design choices

The choices below are made for this library unless a paper is named; the evidence for each is given under "Source" (a test, a script of applications/ant2027/ or a measurement named in the text).

  • Kept as an option, not the default. Against the HMM without damped conflict resolution the heuristic had fewer in-lane overtakings on Sites 1 and 2 (0.33 vs 0.55 per 100 vehicle-km), but more in congestion (4.0 vs 1.7) and a lower synthetic lane-change F1 (0.71 vs 0.76). With damped conflict resolution the HMM is also better on lane ground truth (exiD: accuracy 99.24 vs 98.98 %, lane-change F1 0.974 vs 0.940), so the HMM is the default (09). The heuristic stays useful as a simple, deterministic comparison.

Validation and limitations

  • tests/processing/test_processing.py, tests/processing/test_conventions.py, tests/processing/lane_changes/test_events.py, tests/processing/lanes/test_conflicts.py, golden master (tests/processing/test_golden_master.py).
  • Sites 1 and 2 with restricted GMM, constant HGV correction and stitching: in-lane overtakings 0.33 per 100 vehicle-km (HMM 0.55; per-point GMM 7.3; fixed lane widths 12.3). All remaining events are in campaign 1b; campaigns 1a and 2 have none. In the two congested directions the heuristic is worse than the HMM (4.0 vs 1.7 per 100 vehicle-km).
  • Synthetic (40 scenarios, measured error model): accuracy 99.79 %, lane-change F1 0.71 (HMM 0.76).
  • Each segment is decided on its own; no probabilistic smoothing across segments.