[R-sig-dyn-mod] R vs. fortran for simulation
Thomas Petzoldt
Thomas.Petzoldt at TU-Dresden.de
Sun Nov 6 19:42:45 CET 2011
Dear Miachael,
first of all: I agree completely with Stephen Ellner and had exactly the
same experience with both ODE/PDEs and ABMs:
1) Models in R run slower than C/C++ or Fortran, butprogramming in R is
much faster than in C.
2) You can always implement time-critical parts (and only these!) in C
or Fortran and then link this to R for data management and visualization
-- and you do nothing wrong if you implement your first prototypes in
pure R.
For ABMs, I use data frames for the individuals, so can use R's
vectorized facilities in a very natural and seemingly quasi-parallel
way. Just do computations on the whole data frame or use subset, see
http://www.jstatsoft.org/v22/i09
Examples of dynamic models implemented in R vs. C/Fortran and can be
found in several conference talks and papers, including an extensive
discussion of performance issues:
Soetaert, K. Petzoldt, T. & Setzer, R. W. (2010): Solving differential
equations in R: package deSolve. Journal of Statistical Software 33(9),
1-25. http://www.jstatsoft.org/v33/i09
Petzoldt T. (2009): Dynamic simulation models - is R powerful enough?
UseR!2009, July 8-10, Rennes, France
http://www.agrocampus-ouest.fr/math/useR-2009/slides/Petzoldt.pdf
Petzoldt, T. and Soetaert, K. (2011): Using R for Systems Understanding
- A Dynamic Approach. UseR!2011, August 16-18, University of Warwick,
Coventry, UK,
http://desolve.r-forge.r-project.org/slides/petz_soet2011.pdf
... and even more about this can be found on:
http://desolve.r-forge.r-project.org/
Thank you for asking this question
Thomas P.
More information about the R-sig-dynamic-models
mailing list