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

bug: too many decimal places in the output of pareto_frontier() #307

Open
rafapereirabr opened this issue Nov 24, 2022 · 1 comment
Open

Comments

@rafapereirabr
Copy link
Member

In the output of the pareto_frontier() function, the values in the monetary_cost column have long tail decimal places. Perhaps these values should be rounded to the second decimal place?

reprex

library(r5r)

# build transport network
data_path <- system.file("extdata/poa", package = "r5r")
r5r_core <- setup_r5(data_path = data_path)

# load origin/destination points
points <- read.csv(file.path(data_path, "poa_hexgrid.csv"))[1:5,]

# load fare structure object
fare_structure_path <- system.file(
  "extdata/poa/fares/fares_poa.zip",
  package = "r5r"
)

fare_structure <- read_fare_structure(fare_structure_path)

departure_datetime <- as.POSIXct(
  "13-05-2019 14:00:00",
  format = "%d-%m-%Y %H:%M:%S"
)

pf <- pareto_frontier(
  r5r_core,
  origins = points,
  destinations = points,
  mode = c("WALK", "TRANSIT"),
  departure_datetime = departure_datetime,
  fare_structure = fare_structure,
  fare_cutoffs = c(4.5, 4.8, 9, 9.3, 9.6)
)
head(pf)


pf$monetary_cost[4]
#> 4.8

pf$monetary_cost[4] == 4.8
#> FALSE

pf$monetary_cost[4] * 10000000000
#> 48000001907
@mattwigway
Copy link
Contributor

Internally, I recommend doing everything in integers, to avoid floating point roundoff. I ran into this in Boston (I think) where there is one journey that is $8.20, but floor(8.2 * 100) = 819. Better to just convert everything to cents/whatever the indivisible currency units locally are.

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