Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

R handing after Java finished computing #95

Open
WillRust303 opened this issue Mar 19, 2024 · 1 comment
Open

R handing after Java finished computing #95

WillRust303 opened this issue Mar 19, 2024 · 1 comment
Labels
investigate This issue needs further technical investigation

Comments

@WillRust303
Copy link

WillRust303 commented Mar 19, 2024

Hi there,

I am trying to calculate the CPU time for a broad range of netlogo sims, however at the moment I am only running one simulation and timing that. I have noticed that simulations (even for one, small simulation) takes ~7x longer on nrlx than it does in NetLogo (NetLogo ~1 min, nlrx ~7 mins). Looking at the Processes in Windows Task Manager, it seems that when I run the sim from nlrx, java starts computing and then after about a minute, java finishes and closes. R then hangs for the remaining time before completeing its process.

I see other issues posted here on similar issues but the response is typically due to running too many sims / parameters. Whereas I am running only one simulation. I have pasted my code below:

R Code

Sys.setenv(JAVA_HOME='C:/Program Files/Java/jre-1.8')

netlogopath <- file.path("C:/Program Files/NetLogo 6.0.3")
modelpath <- "AJ2015_upscale_test.nlogo")
outpath <- file.path("C:/out")

#~~~~~~~~~~~~~~OPEN MODEL AND TEST~~~~~~~~~~~~~~~~~~#
nl <- nl(nlversion = "6.0.3",
nlpath = netlogopath,
modelpath = modelpath,
jvmmem = 2048*8)

nl@experiment <- experiment(expname = "worms",
outpath = outpath,
repetition = 1,
tickmetrics = "true",
idsetup = "setup",
idgo = "go",
runtime = 7300,
evalticks = seq(1,7300),
constants = list("Application_Rate" = 0,
"Application_Year" = 0,
"Application_Day" = 0,
"Initial_Number_Adults" = 300,
"Initial_Number_Juveniles" = 300,
"Initial_Number_Cocoons" = 300),
metrics.turtles = list("turtles" = c("who", "xcor", "ycor", "mass", "age", "breed")))

eval_variables_constants(nl)

nl@simdesign <- simdesign_simple(nl = nl, nseeds = 1)
start <- Sys.time()
results <- run_nl_all(nl = nl)
end <- Sys.time()

difftime(end, start, units = "mins")

Any help you could give would be great! Thanks again.

@nldoc
Copy link
Contributor

nldoc commented Aug 5, 2024

Hi @WillRust303,
Thank you for the issue report.
It is not completely unexpected that R takes some time after a simulation has finished. This is because the NetLogo output needs to be post-processed to generate a tidy R tibble format from the csv output. For example, lists take quite some parsing time. In your example above, you are including turtle metrics, whose parsing time heavily depends on the number of individuals. You might want to check show many individuals you have in your model.
Please try to run the model without turtle metrics and check if it still takes that much post-processing time.

Unfortunately, I barely have time to develop the package aside from critical failures and general maintenance. However, I assume, the post-processing could be optimized quite a bit (in terms of flexibility (speaking of nested lists for example) and performance). I cannot promise anything, but I hope to find a slot for looking into it in the next weeks.

@nldoc nldoc added the investigate This issue needs further technical investigation label Aug 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
investigate This issue needs further technical investigation
Projects
None yet
Development

No branches or pull requests

2 participants