Comments (3)
Partially done!
I've added this feature to R5R core jar. We have three functions:
r5_core$setNumberOfThreadsToMax()
Tells R5 core to let the JVM handle parallelism.
r5_core$setNumberOfThreads(int t)
Tells R5 core to use a specific number of threads.
r5_core$getNumberOfThreads()
We can use this function to check the current configuration.
Now, we need to add nice R wrappers around those functions.
from r5r.
##### Reprex 1 - Controlling Number of Threads #####
options(java.parameters = "-Xmx16G")
library(r5r)
path <- system.file("extdata", package = "r5r")
r5r_core <- setup_r5(data_path = path)
##### input
origins <- destinations <- read.csv(system.file("extdata/poa_hexgrid.csv", package = "r5r"))[1:100,]
trip_date = "2019-05-20"
departure_time = "14:00:00"
mode = c('WALK', 'TRANSIT')
max_street_time = 600L
max_trip_duration = 600L
##### Max threads
r5r_core$setNumberOfThreadsToMax()
system.time(
df <- travel_time_matrix( r5r_core = r5r_core,
origins = origins,
destinations = destinations,
trip_date = trip_date,
departure_time = departure_time,
mode = mode,
max_street_time = max_street_time,
max_trip_duration = max_trip_duration
)
)
# user system elapsed
# 12.982 0.864 1.647
##### Six threads
r5r_core$setNumberOfThreads(6L)
system.time(
df2 <- travel_time_matrix( r5r_core = r5r_core,
origins = origins,
destinations = destinations,
trip_date = trip_date,
departure_time = departure_time,
mode = mode,
max_street_time = max_street_time,
max_trip_duration = max_trip_duration
)
)
# user system elapsed
# 19 5.794 1.278 1.460
##### Single thread (sequential)
r5r_core$setNumberOfThreads(1L)
system.time(
df3 <- travel_time_matrix( r5r_core = r5r_core,
origins = origins,
destinations = destinations,
trip_date = trip_date,
departure_time = departure_time,
mode = mode,
max_street_time = max_street_time,
max_trip_duration = max_trip_duration
)
)
# user system elapsed
# 4.915 0.436 4.586
from r5r.
Done. I've implementer a nThread
parameter to both routing functions. As follows:
#' @param nThread numeric, The number of threads to use in parallel computing.
#' Defaults to use all available threads (Inf).
from r5r.
Related Issues (20)
- Trouble Installing R5R in R: Fatal error HOT 2
- Error testing R5 v7.1 - does not have member field 'int maxDestinations' HOT 1
- Error in .jcall("RJavaTools", "Z", "hasField", .jcast(x, "java/lang/Object"), : java.lang.NullPointerException: Cannot invoke "Object.getClass()" because "<parameter1>" is null HOT 39
- Update required JDK version in Getting Started vignette HOT 6
- r5r v2.0 on CRAN HOT 1
- Isochrones in low-road density contexts HOT 7
- network.dat not built after running setup_r5 HOT 8
- Recurring issue from issue #382: Isochrones in low-road density contexts HOT 1
- Error in .jcall("RJavaTools", "Ljava/lang/Object;", "invokeMethod", cl, : java.util.concurrent.ExecutionException: java.lang.ArrayIndexOutOfBoundsException HOT 4
- Code redundancy in R5TravelTimeComputer
- convinient function to check Java version HOT 9
- Transit mode not used, problems with GTFS data? HOT 9
- Error using setup_r5() HOT 3
- Errors with setup_r5() HOT 10
- Issues with travel_time_matrix including reasonable transit times HOT 1
- r5r Not recognizing Java Version HOT 21
- Initialize_r5r_core HOT 15
- java.lang.ArrayIndexOutOfBoundsException error when calling accessibility HOT 6
- Max Walk Time HOT 3
- Catchments at different times HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from r5r.