Trying to set up the object persistence using an Rcpp module. I've made a lot of progress on branches rcpp_module (in which I've transformed Community in a module) and record_times (in which I created a new module for the Trajectories). Using a module means that the persistence is handled by an external pointer, so the data is actually in the C layer - but we don't need to worry about managing a single community or garbage collecting. That's some impressive work from the Rcpp team!
Some problems that I've found:
There is some bug related to the number of parameters in the constructor - I can declare constructors with up to 6 parameters, but I apparently can't declare a constructor with more.
We need to optimize some of the code again - I'm getting benchmarks at 80%-100% more time than the original code (but there's a lot of room for optimization) [EDIT: new code is behaving now almost exactly the same as the old, regarding performance ~ 27/06]
While we now can handle lots of simulations inside the same R session, they don't serialize well, meaning that when the session ends, the pointers are gone.
> old_community
Error: external pointer is not valid
This can't be fixed using a simple save(old_community, file='x.rdata'), so we still need the file persistence functions.
Finally, on the branch record_times, I've noticed that I apparently can't declare a function in the Rcpp module that returns a custom class - apart from the class constructor itself! I really don't know how to get around this at the moment.....
And, also, now we need to rewrite all the code from the bottom up, but I think this will be a major improvement :) [EDIT: Everything updated and passing R check ~ 29/06]
Trying to set up the object persistence using an Rcpp module. I've made a lot of progress on branches
rcpp_module
(in which I've transformed Community in a module) andrecord_times
(in which I created a new module for the Trajectories). Using a module means that the persistence is handled by an external pointer, so the data is actually in the C layer - but we don't need to worry about managing a single community or garbage collecting. That's some impressive work from the Rcpp team!Some problems that I've found:
We need to optimize some of the code again - I'm getting benchmarks at 80%-100% more time than the original code (but there's a lot of room for optimization)[EDIT: new code is behaving now almost exactly the same as the old, regarding performance ~ 27/06]This can't be fixed using a simple
save(old_community, file='x.rdata')
, so we still need the file persistence functions.record_times
, I've noticed that I apparently can't declare a function in the Rcpp module that returns a custom class - apart from the class constructor itself! I really don't know how to get around this at the moment.....And, also, now we need to rewrite all the code from the bottom up, but I think this will be a major improvement :)[EDIT: Everything updated and passing R check ~ 29/06]