This is a small Rcpp
model tying together a number of interesting tools to get at a persistent question of the co-variation of two orthogonal but related 'animal personality' traits.
-
Clone the repository using SSH by running
git clone git@github.com:pratikunterwegs/noisewalker.git
-
In
R
, build the package usingdevtools::build()
-
In
R
, install the package usingdevtools::install()
-
Try out the model using the script
scripts/check_noisewalker.R
The spatially explicit resource landscape is modelled using noise
, provided by FastNoiseLite
.
Competition among animals is modelled as a cost of proximity to other animals, and inter-individual distances are calculated using boost
Rtrees.
Animal movement and behaviour is probabilistic, with hudreds of thousands of calls to std::bernoulli_distribution
, not to mention setting up this distribution. This is (hopefully) speeded up by using the GNU Scientific Library random number distributions.
The simulations are disguised as easy-to-use R
functions, using Rcpp
to obscure the scary C++
code that lies beneath. The simulation data are also returned to R
, as well known objects (lists and data.frames).
GSL and Boost are ridiculously difficult to use on Windows (coming from Linux) --- but Rcpp
extension packages BH
(Boost Headers) and RcppGSL
allow for this to happen seamlessly.
However, some manual tinkering is required to get GSL libraries on Windows: Download local323.zip
from http://www.stats.ox.ac.uk/pub/Rtools/libs.html and place contents of local323/lib/x64
in C:\local\lib
.
GSL works out of the box on Linux systems with libgsl
installed.
In R
, make sure the GSL path is known by running:
Sys.setenv("LIB_GSL" = "C:/local323")