Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use estimated travel distances instead of euclidian distance #80

Merged

Conversation

Hussein-Mahfouz
Copy link
Collaborator

Introduces a new feature to account for detour factors and decay rates when calculating travel distances. These travel distances are used in estimating feasible zones, and in plotting actual vs reported distances. Related to #79

Key changes:

Utility Function Updates:

  • src/acbm/assigning/utils.py: Added _adjust_distance function and updated zones_to_time_matrix to include detour and decay adjustments when calculting travel distance from euclidean distances. To check parameters, see this interactive wolfram alpha plot
  • src/acbm/assigning/feasible_zones_primary.py: Updated get_possible_zones to include detour_factor and decay_rate parameters and adjusted the travel time matrix accordingly.
  • src/acbm/validating/utils.py: Updated calculate_od_distances to include the detour and decay adjustments.

Configuration Updates:

  • config/base.toml: Added detour_factor and decay_rate parameters under the new [feasible_assignment] section.
  • src/acbm/config.py: Introduced FeasibleAssignmentParams class and added it to the Config class.

Script Updates:

  • scripts/3.1_assign_primary_feasible_zones.py: Updated the get_possible_zones function to pass detour_factor and decay_rate to the travel time matrix and filtering functions.
  • scripts/3.3_assign_facility_all.py: Updated the plot_scatter_actual_reported function to use the new parameters when plotting. The distance is calculated from the euclidian distance.
  • scripts/4_validation.py: Added detour_factor and decay_rate parameters to the distance validation plots.

@Hussein-Mahfouz
Copy link
Collaborator Author

Added a test for _adjust_distance here: 18aecb4

TODO: Add a warning to say "default decay rate only works well if the distances are in meters".

@sgreenbury sgreenbury force-pushed the 79-checking-and-validating-travel-distance-assumptions branch from d4dc19d to 7c6e914 Compare January 31, 2025 09:48
@sgreenbury sgreenbury force-pushed the 79-checking-and-validating-travel-distance-assumptions branch from 7c6e914 to 22c98de Compare January 31, 2025 09:54
@sgreenbury
Copy link
Collaborator

Thanks for this @Hussein-Mahfouz, this looks great. I rebased on main and added 22c98de to address the comment we added when reviewing last week and the TODO above so will go ahead and merge.

@sgreenbury sgreenbury merged commit 8f87677 into main Jan 31, 2025
4 checks passed
@sgreenbury sgreenbury deleted the 79-checking-and-validating-travel-distance-assumptions branch January 31, 2025 12:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Checking and validating travel distance assumptions
2 participants