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

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

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 Hussein-Mahfouz linked an issue Dec 13, 2024 that may be closed by this pull request
2 tasks
@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".

@@ -94,6 +98,11 @@ def calculate_od_distances(
projected_epsg: int
EPSG code for the projected CRS (default is 3857). We need a metric crs
to calculte distances in meters.
detour_factor: float
Factor to adjust the estimated distance.
decay_rate: float
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed, for the decay rate, two things that might be worth adding to config docs:

  • Add description around the decay rate being the inverse of the distance (in units of the data, e.g. metres) at which the scaling from using the detour factor to Euclidean distance reduces by $\exp(-1)$
  • Add link with interactive plot for exploring setting the decay rate

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