BayAreaMetro / tm2py

Travel Model Two - python edition
https://bayareametro.github.io/tm2py/
Apache License 2.0
2 stars 8 forks source link

🐛 Bug: Volume Delay Functions are incorrectly applied #124

Open DavidOry opened 6 months ago

DavidOry commented 6 months ago

Describe the bug

The volume delay functions used in tm2py should align with the methods used in TM1, as defined here. It appears that the translation to tm2py did not account for the change in the facility types. In TM1, the facility types are as follows:

  1. Freeway-to-freeway connector (BPR)
  2. Freeway (BPR)
  3. Expressway (Akcelik)
  4. Collector (Akcelik)
  5. Freeway ramp (Akcelik)
  6. Dummy link (N/A)
  7. Major arterial (Akcelik)
  8. Managed Freeway (BPR)
  9. Special facility (BPR)
  10. Toll plaza (Akcelik)

For the new TM2 networks, the facility types are as follows:

  1. Freeway
  2. Expressway
  3. Ramp
  4. Divided Arterial
  5. Undivided Arterial
  6. Collector
  7. Local
  8. Dummy

It appears from this code that Akceliks are being applied to the old facility types -- see this snippet:

akcelik_vdfs = [3, 4, 5, 7, 8, 10, 11, 12, 13, 14]

-->

Progress:

To Reproduce

Magic number error

Failing tests

Triggering line of code

(https://github.com/BayAreaMetro/tm2py/blob/develop/tm2py/components/network/highway/highway_network.py#L264)

Thoughts on resolution

This array should be:

akcelik_vdfs = [2, 3, 4, 5, 6, 7]

This retains the magic number problem, but fixes the bug. It's also not clear where in the code the BPR parameters are applied for the other facility types.

Full stack trace

Environment

Operating system: Context (conda, jupyter, etc): Environment (e.g. output from conda list):

DavidOry commented 6 months ago

@inrokevin, @e-lo: do either of you know where the BPR parameters are defined in the system?

FYI @lmz, @gregerhardt, @i-am-sijia

DavidOry commented 6 months ago

@arashasadabadi It looks like the critical speeds you have defined here are not correct. See here for the correct values. These need to be mapped to the correct facility types. Please reference a commit here that fixes this problem.

DavidOry commented 6 months ago

BPR parameters are here: https://github.com/BayAreaMetro/tm2py/blob/bart_transit_improvements_aa/tm2py/components/network/create_tod_scenarios.py#L157