ropensci / nlrx

nlrx NetLogo R

Home Page:https://docs.ropensci.org/nlrx

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

nlrx taking a very long time to run

rfgoldberg opened this issue · comments

Hi there. nlrx has been taking a very long time to run models for me, and I tried to see how long only one would take to isolate the issue. The basic wolf sheep predation model with all constants specified to only one option, using only one seed, and one repetition still takes about 5 minutes. Based on what I saw was written previously about similar issues, the headless version should run in a few seconds, and a model with nlrx should take a few seconds by itself + 4seconds. I ran the default headless netlogo model also detailed in a similar post, but instead of 1 minute, that takes about 5 minutes to run. I always get the output expected in both situations though, with no errors of any kind. I kept the temp files too, csv and xml, which also look fine. I've tried increasing the memory allocated as well. System info and code below. Of note, I'm running this in Rstudio hosted on a Linux server. Appreciate any assistance and please let me know if I need to provide more info.

R code

`options(java.parameters = "-Xmx32g")
library(nlrx)
library(progressr)
library(furrr)
library(tictoc)
wd <- "/opt/"
wd_home <- "[pathway...]"
netlogopath <- file.path(paste0(wd,"NetLogo-6.4.0-64"))

Create nl object

netlogopath <- file.path(paste0(wd,"NetLogo-6.4.0-64"))
modelpath <- file.path(netlogopath, "models/Sample Models/Biology/Wolf Sheep Predation.nlogo")
outpath <- file.path(wd_home)
nl <- nl(nlversion = "6.4.0-64",
nlpath = netlogopath,
modelpath = modelpath,
jvmmem = 90000)

single run

nl@experiment <- experiment(expname="wolf-sheep",
outpath=outpath,
repetition=1,
tickmetrics="true",
idsetup="setup",
idgo="go",
runtime=50,
evalticks=seq(40,50),
metrics=c("count sheep", "count wolves"),
constants = list("model-version" = ""sheep-wolves-grass"",
"grass-regrowth-time" = 30,
"sheep-gain-from-food" = 4,
"wolf-gain-from-food" = 20,
"sheep-reproduce" = 4,
"wolf-reproduce" = 5,
"show-energy?" = "false",
"initial-number-sheep" = 100,
"initial-number-wolves" = 25))
nl@simdesign <- simdesign_simple(nl=nl,
nseeds=1)

eval_variables_constants(nl) #should print "all valid" message

Run all simulations (loop over all siminputrows and simseeds)

tic()
results <- run_nl_one(nl = nl,seed = 123, siminputrow = 1,cleanup.csv = FALSE,cleanup.xml = FALSE )
toc()`

Run in terminal

cd "/opt/NetLogo-6.4.0-64" ./netlogo-headless.sh \ --model "models/IABM Textbook/chapter 4/Wolf Sheep Simple 5.nlogo" \ --experiment "Wolf Sheep Simple model analysis" \ --table ~/wsp5-table-output.csv

Sys.info

R version 4.3.2 (2023-10-31)
Platform: x86_64-redhat-linux-gnu (64-bit)
Running under: Red Hat Enterprise Linux 8.9 (Ootpa)

Matrix products: default
BLAS/LAPACK: /usr/lib64/libopenblaso-r0.3.15.so; LAPACK version 3.9.0

locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_US.UTF-8
[6] LC_MESSAGES=en_US.UTF-8 LC_PAPER=en_US.UTF-8 LC_NAME=C LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

time zone: America/New_York
tzcode source: system (glibc)

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] tictoc_1.2 furrr_0.3.1 future_1.33.1 progressr_0.14.0 nlrx_0.4.4

Hi @rfgoldberg did you find any solutions?

Hello, unfortunately, not yet. I'm working with the netlogo developers right now to see why netlogo headless is taking so long. We're wondering if that's also the reason that nlrx isn't working as it should. I'll post an update if we find the solution.