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

Accessibility discrepancy with and without fare_strcture? #304

Open
Tamarak2 opened this issue Nov 22, 2022 · 4 comments
Open

Accessibility discrepancy with and without fare_strcture? #304

Tamarak2 opened this issue Nov 22, 2022 · 4 comments

Comments

@Tamarak2
Copy link

Hi all!

I've been using the new fares and affordability functions, and I've run into an issue where when using an "infinite" fare cap, I get a substantially different result in running an accessibility analysis than when just using the accessibility tool without any fare information. Should these not be essentially identical? I've wondered if it's something in the transfer settings? This is in fully informal systems where there are no transfers and all prices are at the route level. Any advice would be great,

Thanks!
Tamara

@rafapereirabr
Copy link
Member

Hi @Tamarak2 , thanks for opening this issue. Could you plaste below the code you have used? (a reproducible example would be ideal, but I know it can be difficult to share data sample in some cases).

Yes, the value of max_fare is Inf by default, so the results should be the same. I just tested running the reprex on this vignette with and without setting a value an Inf value to max_fare and the outputs were identical.

@Tamarak2
Copy link
Author

Tamarak2 commented Nov 25, 2022

Thanks!

Yes, I've been assuming it should be coming out the same, but the output when not using the fares at all is about 20% higher than using an Infinite fare - which is also higher than if it wasn't allowing transit use at all, or just misreading it somehow. The InF fare is also higher than when using a restrictive fare.

This is my code for setup of the fare_structure and running the accessibility - I just change the fares in the exported fare structure and read it back.

Another issues I'm hitting is that I get a "null pointer exemption" when creating the fare structure with the debug_path.

fare_structure <- setup_fare_structure(r5r_core, 
                                       base_fare = 30000,
                                       by = "MODE")

fare_structure$max_discounted_transfers <- 0
fare_structure$transfer_time_allowance <- 0

fare_structure$fares_per_type[type == "BUS", unlimited_transfers := FALSE]
fare_structure$fares_per_type[type == "BUS", fare := 30000]
fare_structure$fares_per_type[type == "BUS", allow_same_route_transfer := FALSE]
fare_structure$fares_per_type[type == "BUS", use_route_fare := TRUE]

fare_structure$fares_per_type[type == "TRAM", unlimited_transfers := FALSE]
fare_structure$fares_per_type[type == "TRAM", fare := 30000]
fare_structure$fares_per_type[type == "TRAM", allow_same_route_transfer := FALSE]
fare_structure$fares_per_type[type == "TRAM", use_route_fare := TRUE]

#faresloc <- "..."
write_fare_structure(fare_structure, faresloc)

fare_structure <- read_fare_structure(faresloc, encoding = "UTF-8")

access_hhs_60min <- accessibility(r5r_core = r5r_core,
                             origins = hhs,
                             destinations = jobs,
                             opportunities_colnames = "jpct",
                             mode = modes3,
                             max_walk_time = 20,
                             max_trip_duration = 60,
                             time_window=60,
                             departure_datetime = departure_datetime,
                             decay_function = "step",
                             percentiles = c(10,50,90),
                             cutoffs = 60)
mean(access_hhs_60min$accessibility)

access_hhs_60min3 <- accessibility(r5r_core = r5r_core,
                                  origins = hhs,
                                  destinations = jobs,
                                  opportunities_colnames = "jpct",
                                  mode = modes3,
                                  max_walk_time = 20,
                                  max_trip_duration = 60,
                                  time_window=60,
                                  departure_datetime = departure_datetime,
                                  decay_function = "step",
                                  percentiles = c(10,50,90),
                                  fare_structure = fare_structure,
                                  max_fare = Inf,
                                  cutoffs = 60)

mean(access_hhs_60min3$accessibility)
```

@rafapereirabr
Copy link
Member

Hi @Tamarak2.

As a rule, the accessibility() uses the RAPTOR routing algorithm. However, the function uses the McRAPTOR algorithm when accounting for monetary costs. This is probably what is causing the difference, and we should make this clearer in our documentation. In any case, the difference seems to be quite big and we'll have a closer look at that.

@Tamarak2
Copy link
Author

Tamarak2 commented Dec 5, 2022

Hi @rafapereirabr , thanks for this - I'll let it go trying to align them for the moment.

More generally, any idea why the discrepancy might be emerging? And which one is more accurate?

I'll need to double check but I may be able to share the underlying data to recreate this if it stays non-public.

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

2 participants