Building on top of the 'RcppArmadillo' linear
algebra functionalities to do fast spatial interaction models in the
context of urban analytics, geography, transport modelling. It uses
the Newton root search algorithm to determine the optimal cost
exponent and can run country level models with thousands of origins
and destinations. It aims at implementing an easy approach based on
matrices, that can originate from various routing and processing steps earlier in an workflow.
Currently, the simplest form of production, destination and
doubly constrained models are implemented.
Schlosser et al. (2023)
This aims at providing a set of fast, memory efficient functions to perform spatial interaction modelling, also called gravity modelling. Currently, the doubly and singly constrained models are implemented for canonical set of constraints. Future versions will aim to implement more origin and destination constraints as well. It was developed in the context of studying commuter flows by active travel (cycling & walking ) in Great Britain as part of a project at CASA, UCL.
Not yet on CRAN, so please install the development version of cppSim
with:
# install.packages(C("devtools","pak"))
devtools::install_github("ischlo/cppSim")
# pak::pak("ischlo/cppSim")
The package comes with sample data sets that allow to test the functions right away as well as see the type of input that is recommended.
cppRouting package.Refer to the vignette to find some theory on SIMs and a naive
implementation in R.
Using the built-in data sets flows_test and distance_test, we can
run a test by following the example This is a basic example which shows
you how to solve a common problem:
library(cppSim)
## basic example code
data("flows_test")
data("distance_test")
model_test <- run_model(
flows = flows_test,
distance = distance_test
)
For an example of what can be done with this package, please refer to the publication on active travel spatial interaction models in London for which it was originally developed.
The accompanying code for the analysis is provided in the
ischlo/quant_cycle_walk
repository.
This package has some dependencies that might need manual installation, although the most important external ones have been provided with the source code.
The package uses the armadillo
library, which is imported and linked automatically when the package is
installed.
On the R side, it uses Rcpp [@eddelbuettel2011] and RcppArmadillo
[@eddelbuettel2014].
Compared to the equivalent functions implemented in pure R, it runs
about x10 faster for a $\sim 1000 \times 1000$ OD matrix, the speed up
is increasingly more significant as matrices get bigger.
[1] "/Users/cenv1069/Library/R/arm64/4.4/library/cppSim/extdata/benchmark_test.rds"
To cite package 'cppSim' in publications use:
Schlosser I (2023). _cppSim: Fast and Memory Efficient Spatial
Interaction Models_. doi:10.5281/zenodo.14367756
<https://doi.org/10.5281/zenodo.14367756>,
<https://ischlo.github.io/cppSim/>.
A BibTeX entry for LaTeX users is
@Manual{,
title = {cppSim: Fast and Memory Efficient Spatial Interaction Models},
author = {Ivann Schlosser},
year = {2023},
doi = {10.5281/zenodo.14367756},
url = {https://ischlo.github.io/cppSim/},
}