grantbrown / ABSEIR

A Flexible and Computationally Efficient SEIRS Modeling Framework
6 stars 3 forks source link

Sorry for the (extremely) late reply. #7

Closed oyeadegboye closed 4 years ago

oyeadegboye commented 4 years ago

Sorry for the (extremely) late reply.

This isn't a feature I've been using much, but I've finally gotten around to reintroducing/testing it.

Check out the following example: based on the 1995 Kikwit data

The basic idea is to leave the future data as NA's in the data model, but still provide any temporal co-variate information required to make projections. The way this is coded, it shouldn't have a huge cost over running the models without keeping track of compartments, except with a large number of spatial locations.

Originally posted by @grantbrown in https://github.com/grantbrown/ABSEIR/issues/3#issuecomment-273838581

oyeadegboye commented 4 years ago

Hi Grant, I ran the example provided on R 3.6.2 using ABSEIR_1.2.4 , however R crashed each time. Thanks

grantbrown commented 4 years ago

Are you on Windows? I've also recently had trouble and am currently investigating if changes in R or Rtools on Windows may be related.

oyeadegboye commented 4 years ago

Yes, I am on Windows. Do I need to downgrade?

grantbrown commented 4 years ago

No, I'm going to try and investigate - I don't want to recommend anything until I figure out where the issue is definitely coming from.

grantbrown commented 4 years ago

Sorry for the delays, I've had limited time to investigate this. I've confirmed that when the code is compiled in single-threaded mode, things seem to work as expected. I've also done some analysis with Valgrind and haven't seen any obvious problems. My working hypothesis is that there's something wrong with the threading code on Windows machines, but I'm not sure exactly what's causing it.

My recommendation for now is to download a copy of the L1 branch from this GitHub repository, and then install it locally. Before you install, replace line 2 from the /src/Makevars file with:

PKG_CPPFLAGS= -DSPATIALSEIR_SINGLETHREAD -Wno-ignored-attributes -pthread -I./include
grantbrown commented 4 years ago

Oops, didn't mean to close. Anyway, you can install the package by running

R CMD INSTALL ABSEIR

in the directory where the ABSEIR folder is located (assuming you have R on your system path). Alternatively, you can use the devtools::install function to install it from within R. Let me know if you need any additional info on those steps, sorry for the inconvenience.

oyeadegboye commented 4 years ago

Thank you so much, I am trying it but I could not install the new ABSEIR directly in R. Could you please break down the steps a little further? Thanks

grantbrown commented 4 years ago
  1. Download a copy of this repository directly by clicking the "Clone or Download" button and selecting a zip file

  2. Extract the zip file to a folder (like Documents)

  3. Go into the "src" folder (ABSEIR/src), and edit the line which starts with "PKG_CPPFLAGS" to read as follows, using a plain text editor like notepad or notepad++:

    PKG_CPPFLAGS= -DSPATIALSEIR_SINGLETHREAD -Wno-ignored-attributes -pthread -I./include

  4. Load an R session, install the "devtools" package, and run:

    library(devtools) devtools::install("/path/to/ABSEIR/folder/goes/here")

of course, substituting your path for the one given above.

Does that help?

oyeadegboye commented 4 years ago

Thank you it works now, however I will need to run it on a computer or cloud with multiple cores due to the following errors: Initializing Model Components ...Building data model ...Building distance model ...Building exposure model ...Building initial value container ...Building reinfection model ...Building sampling control model Errors generated: <Rcpp::exception in new_CppObject_xp(fields$.module, fields$.pointer, ...): Error: multiple cores requested for ABSEIR compiled in single thread mode> Error in value[3L] : Aborting Timing stopped at: 0 0 0

grantbrown commented 4 years ago

When compiled with this option, the number of cores specified in the sampling control object must be set to 1. Alternatively, you could use the L1 branch compiled normally on a Linux machine until we figure out why Windows machines are having trouble with the threading code.

oyeadegboye commented 4 years ago

Thanks it worked when n_cores=1. Thank you

grantbrown commented 4 years ago

I believe the latest version on the master branch should solve your issue, allowing multiple cores to be used again. Apologies for the slow fix - closing for now, but please let me know if you continue to have issues.