Skip to content

Multiprocessing applies auto operating cost adjustment using worker-local means #45

Description

@jpn--

Description

The SANDAG adjust_auto_operating_cost model produces process-count-dependent results when run as part of a sliced multiprocessing phase.

The model calculates an adjustment factor using:

target_auto_operating_cost / vehicles["auto_operating_cost"].mean()

When this step runs inside a household multiprocess worker, vehicles contains only that worker’s slice. Each worker therefore calculates a different factor instead of using the mean across all simulated vehicles.

Observed behavior

Using the same model inputs:

  • A one-process run calculated a regional adjustment factor of 1.4262046773.
  • A two-process run calculated worker-specific factors of:
    • Worker 0: 1.4267902615
    • Worker 1: 1.4256206636

Each worker’s subset has the requested mean afterward, which can mask the problem in aggregate summaries. However, individual vehicle operating costs differ depending on the number and composition of multiprocessing slices.

Impact

This makes results dependent on the configured process count:

  • Vehicle operating costs are not reproducible across process counts.
  • Auto costs used in downstream utilities and logsums vary by MP process number, typically only a tiny bit, but still some.
  • Mode-choice costs and potentially discrete choices can change.
  • Trip matrices and scenario comparisons can reflect multiprocessing configuration rather than model inputs.
  • The regional mean can still appear correct, making the issue difficult to detect from aggregate validation alone.

This is independent of Sharrow caching or random-number generation; it results from computing a regional statistic on partitioned data.

Expected behavior

The adjustment factor should be calculated once using the complete regional vehicle table. The resulting adjusted vehicle costs should be invariant to the number of multiprocessing workers, apart from negligible floating-point reduction differences.

Proposed fix if desired

Place adjust_auto_operating_cost in an unsliced multiprocessing phase:

  1. Run vehicle type choice in the sliced household phase.
  2. Coalesce worker vehicle tables.
  3. Run adjust_auto_operating_cost once against the complete vehicle table.
  4. Repartition households and persons for the remaining household models.

For example:

- name: mp_households
  begin: av_ownership
  slice:
    tables:
      - households
      - persons

- name: mp_adjust_auto_operating_cost
  begin: adjust_auto_operating_cost

- name: mp_households_post_auto_cost
  begin: transponder_ownership
  slice:
    tables:
      - households
      - persons

Fixing this may be undesirable

  • Adding a coalesce and split incurs performance costs
  • Results are reproducible if process count is held constant
  • At scale, the variation in average auto operating cost across MP processes is typically negligible, leading to changes that are nearly undetectable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions