Skip to content

vehicle_logging_timestep_interval=-1 silently zeroes average_speed, Edie states, and MFD #351

Description

@toruseo

Summary

When vehicle trajectory logging is disabled with World(vehicle_logging_timestep_interval=-1) (the documented memory-saving option), several analyzer outputs silently degrade to zero instead of being reported as unavailable:

  • print_simple_stats() reports average speed: 0.0 m/s (it is an incremental mean over vehicle log records, which never accumulate),
  • Analyzer.compute_edie_state() produces all-zero k_mat / q_mat,
  • consequently macroscopic_fundamental_diagram() draws an empty plot.

Other statistics in the same output block (travel times, completed trips, total distance) remain correct, which makes the zero average speed look like a valid result rather than a missing one.
This affects both the Python and C++ backends equally.

Minimal reproduction

from uxsim import World

def run(cpp, vli):
    W = World(name='t', deltan=5, tmax=3600, print_mode=0, random_seed=0,
              cpp=cpp, vehicle_logging_timestep_interval=vli)
    W.addNode('A', 0, 0); W.addNode('B', 2000, 0); W.addNode('C', 4000, 0)
    W.addLink('AB', 'A', 'B', length=2000, free_flow_speed=20, number_of_lanes=2)
    W.addLink('BC', 'B', 'C', length=2000, free_flow_speed=20, number_of_lanes=2)
    W.adddemand('A', 'C', 0, 3000, flow=0.8)
    W.exec_simulation()
    print(f'cpp={cpp} logging={vli}: average_speed={W.analyzer.average_speed:.1f}')

for cpp in [False, True]:
    for vli in [1, -1]:
        run(cpp, vli)

Output (uxsim 1.14.0):

cpp=False logging=1:  average_speed=20.0
cpp=False logging=-1: average_speed=0.0
cpp=True  logging=1:  average_speed=20.0
cpp=True  logging=-1: average_speed=0.0

(The true average speed is 20 m/s in all four runs; the trips themselves are simulated correctly.)

Suggested fixes (any of these would help)

  • Report nan (or omit the line) for statistics that need vehicle logs when logging is disabled, and/or emit a warning from print_simple_stats() / compute_edie_state();
  • compute the printed average speed from total distance traveled / total travel time, which is already available without vehicle logs;
  • document in vehicle_logging_timestep_interval which analyzer outputs become unavailable when it is set to -1.

(found and reported by my agent)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions