Hello, I am pursuing the development of an individual-based model in R but there is a series of technical issues for which I don't know where to find information. I have written R functions before for simple simulations, but this model will have more complexities and each individual will need to be evaluated in many aspects at each time step. My major concern is that I don't know how to make my program more efficient in terms of using computer memory and computation time. What is the maximum matrix size that R could handle? I have read that R could interact with C and that that can be an "extremely effective mode for numerical computation" (Bates and DebRoy, DSC 2003 Working Papers). I have looked for papers on HOW TO make R and C interact but I can not find many references and would appreciate suggestions. Would my model benefit from using object oriented programming in terms of making the procedures go faster in terms of updating matrices after time steps? Thank you for your time. Dulce M. Bustamante Ph.D. Candidate Florida Medical Entomology Laboratory University of Florida 200 9th Street SE Vero Beach, FL 32962
Improving efficiency in a simulation model
5 messages · Dulce M. Bustamante, Farrar.David at epamail.epa.gov, Tyler Smith +2 more
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-ecology/attachments/20081009/b6e18f66/attachment.pl>
"Dulce M. Bustamante" <dbusta1 at ufl.edu> writes:
I have written R functions before for simple simulations, but this model will have more complexities and each individual will need to be evaluated in many aspects at each time step. My major concern is that I don't know how to make my program more efficient in terms of using computer memory and computation time.
gc() will give you a snapshot of the current memory use of R. Rprof and related functions in the proftools library provide ways to identify the parts of your simulation that are particularly time-consuming. These are the bits you may want to convert to C. The help files for these functions has pointers to other useful tools. Also, see the 'Writing R Extensions manual'.
I have read that R could interact with C and that that can be an "extremely effective mode for numerical computation" (Bates and DebRoy, DSC 2003 Working Papers). I have looked for papers on HOW TO make R and C interact but I can not find many references and would appreciate suggestions.
The 'Writing R Extensions' manual that comes with the standard distribution includes lots of info on passing data back and forth between R and C. C code runs a lot faster than R, especially when you've got a lot of loops. On the other hand, converting R loops to R vector/matrix operations can make a big difference too.
Would my model benefit from using object oriented programming in terms of making the procedures go faster in terms of updating matrices after time steps?
I don't know if OO will make your programs run any faster, but it may make them easier to understand and maintain. Cheers, Tyler --
5 days later
Hello, you can use (in a pure R approach) the simecol package which interfaces C to speed up simulations. http://simecol.r-forge.r-project.org/. Furthermore you can also have a look at my application which connects Java and R and is an development environment for ecological models based on an Eclipse Rich Client Platform. http://www.uni-bielefeld.de/biologie/Oekosystembiologie/bio7app/index.html As already noted an object oriented approach makes a lot of sense when developing an IBM model for structuring, readability and reusability. Here you can find a good book about IBM models in general: http://www.amazon.com/Individual-based-Modeling-Princeton-Theoretical-Computational/dp/0691096651/ref=pd_bbs_sr_1?ie=UTF8&s=books&qid=1224055984&sr=8-1 With kind regards M. Austenfeld
View this message in context: http://n2.nabble.com/Improving-efficiency-in-a-simulation-model-tp1313929p1336463.html Sent from the r-sig-ecology mailing list archive at Nabble.com.
6 days later
You may also want to take a look at the simecol pakage. http://simecol.r-forge.r-project.org/ Julian
Dulce M. Bustamante wrote:
Hello, I am pursuing the development of an individual-based model in R but there is a series of technical issues for which I don't know where to find information. I have written R functions before for simple simulations, but this model will have more complexities and each individual will need to be evaluated in many aspects at each time step. My major concern is that I don't know how to make my program more efficient in terms of using computer memory and computation time. What is the maximum matrix size that R could handle? I have read that R could interact with C and that that can be an "extremely effective mode for numerical computation" (Bates and DebRoy, DSC 2003 Working Papers). I have looked for papers on HOW TO make R and C interact but I can not find many references and would appreciate suggestions. Would my model benefit from using object oriented programming in terms of making the procedures go faster in terms of updating matrices after time steps? Thank you for your time. Dulce M. Bustamante Ph.D. Candidate Florida Medical Entomology Laboratory University of Florida 200 9th Street SE Vero Beach, FL 32962
_______________________________________________ R-sig-ecology mailing list R-sig-ecology at r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-ecology