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

max_trip_duration should be limited by cutoffs #348

Closed
rafapereirabr opened this issue Sep 8, 2023 · 1 comment
Closed

max_trip_duration should be limited by cutoffs #348

rafapereirabr opened this issue Sep 8, 2023 · 1 comment

Comments

@rafapereirabr
Copy link
Member

rafapereirabr commented Sep 8, 2023

In the accessibility function, max_trip_duration is set to 120 (minutes) by default. So R5 will search routes to really further away places. However, I understand that when a user sets cutoffs = 30​, the max_trip_duration should automatically be affected. It seems like this is not happening.

obs. having a max_trip_duration longer than cutoffs does NOT affect accessibility estimates, but it does affect computation time.

@rafapereirabr
Copy link
Member Author

The solution would be to add this line of code:

 # cap trip duration with cutoffs
  if(!is.null(cutoffs)){
    max_trip_duration <- ifelse(max_trip_duration > max(cutoffs), max(cutoffs), max_trip_duration)
  
  if(max_trip_duration < max(cutoffs)){stop("'max_trip_duration' cannot be shorter than 'max(cutoffs)'")}
  }

before the accessibility() function runs:

  max_walk_time <- assign_max_street_time(
    max_walk_time,
    walk_speed,
    max_trip_duration,
    "walk"
  )
  max_bike_time <- assign_max_street_time(
    max_bike_time,
    bike_speed,
    max_trip_duration,
    "bike"
  )
  max_car_time <- assign_max_street_time(
    max_car_time,
    8, # 8 km/h, R5's default.
    max_trip_duration,
    "car"
  )
  max_trip_duration <- assign_max_trip_duration(
    max_trip_duration,
    mode_list,
    max_walk_time,
    max_bike_time
  )

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

No branches or pull requests

1 participant