ropensci / nlrx

nlrx NetLogo R
https://docs.ropensci.org/nlrx
GNU General Public License v3.0
77 stars 12 forks source link

help wanted on Error "Temporary simulation output file not found" #55

Closed skyafter closed 2 years ago

skyafter commented 2 years ago

Hi,

I was trying to test the example codes in the Wolf-sheep model but found a constant error stopping any further running. The example codes I used are the sensitivity test and ABCmcmc_Marjoram calibration. I have read debugging notes in the ??run_nl_all() and think that there is no problem with file paths and software installation. I hope I could get some help or inspiration here if anybody knows how to fix it. Thanks in advance.

The error is:

Error in util_gather_results(nl, outfile, seed, siminputrow) : 
  Temporary simulation output file not found: E:/OUT\Rtmp2lBq1P\nlrx_seed_1257402563_row_1_1abc6a2c4941.csv.
Either the simulation did not run or crashed, check the debugging section in ??run_nl_all() for help.
In addition: Warning message:
The `path` argument of `write_lines()` is deprecated as of readr 1.4.0.
Please use the `file` argument instead.
This warning is displayed once every 8 hours.
Call `lifecycle::last_warnings()` to see where this warning was generated. 

The code I use is:

library(nlrx)
Sys.setenv(JAVA_HOME="C:/Program Files/Java/jdk1.8.0_301/bin")
# 1. Windows default NetLogo installation path (adjust to your needs!)
netlogopath <- file.path("C:/Program Files/NetLogo 6.2.0")
modelpath <- file.path(netlogopath, "app/models/Sample Models/Biology/Wolf Sheep Predation.nlogo")
outpath <- file.path("E:/Temp") #this is a new folder created for this experiment

nl <- nl(nlversion = "6.2.0",
         nlpath = netlogopath,
         modelpath = modelpath,
         jvmmem = 1024)
nl@experiment <- experiment(expname = "wolf-sheep-morris",
                            outpath = outpath,
                            repetition = 1,   
                            tickmetrics = "true",
                            idsetup = "setup",  
                            idgo = "go",        
                            runtime = 500,
                            metrics=c("count sheep", "count wolves", "count patches with [pcolor = green]"),
                            variables = list("initial-number-sheep" = list(min=50, max=150, step=10, qfun="qunif"),
                                             "initial-number-wolves" = list(min=50, max=150, step=10, qfun="qunif"),
                                             "grass-regrowth-time" = list(min=0, max=100, step=10, qfun="qunif"),
                                             "sheep-gain-from-food" = list(min=0, max=50, step=10, qfun="qunif"),
                                             "wolf-gain-from-food" = list(min=0, max=100, step=10, qfun="qunif"),
                                             "sheep-reproduce" = list(min=0, max=20, step=5, qfun="qunif"),
                                             "wolf-reproduce" = list(min=0, max=20, step=5, qfun="qunif")),
                            constants = list("model-version" = "\"sheep-wolves-grass\"",
                                             "show-energy?" = "false"))
nl@simdesign <- simdesign_lhs(nl, samples=500, nseeds=1, precision=3)
library(future)
plan(multisession)
results <- run_nl_all(nl, split=10)
bitbacchus commented 2 years ago

Hi,

I think the problem might be with your PATH and/or JAVA_HOME variables. Try Sys.setenv(JAVA_HOME="C:/Program Files/Java/jdk1.8.0_301") (without /bin) and see if this works. If it doesn't work, please type echo %PATH% and echo %JAVA_HOME% in your terminal. There should be something like C:\Program Files\Java\jdk1.8.0_301 for JAVA_HOME but C:\Program Files\Java/jdk1.8.0_301\bin in PATH. If it doesn't, see, e.g. https://javatutorial.net/set-java-home-windows-10 for reference.

skyafter commented 2 years ago

Thanks that solved my problem!