Closed yyzeng closed 2 years ago
Hmm, that is kinda odd. Can you please try to run the experiment from the command line (i.e. mimicking what nlrx does)?
cd "C:\Program Files\NetLogo 6.2.0"
)netlogo-headless.bat --model "C:\PATH\TO\YOUR\Fire.nlogo" \
--experiment NAME_OF_YOUR_EXPERIMENT \
--table -
Thanks, Sebastian
Yes - I use windows' cmd.exe to run the codes, and it finish in 1 minite and show me lots results.
Hmm, that is kinda odd. Can you please try to run the experiment from the command line (i.e. mimicking what nlrx does)?
- open a terminal window (https://www.wikihow.com/Open-Terminal-in-Windows)
- go to the NetLogo directory (i.e.
cd "C:\Program Files\NetLogo 6.2.0"
)
- run netlogo's BehaviorSpace as described here: https://ccl.northwestern.edu/netlogo/docs/behaviorspace.html#advanced-usage, i.e. run
netlogo-headless.bat --model "C:\PATH\TO\YOUR\Fire.nlogo" \ --experiment NAME_OF_YOUR_EXPERIMENT \ --table -
Thanks, Sebastian
Thanks. Yes - I use windows' cmd.exe to run the codes, and it finish in 1 minite and show me lots results. By the way, I have reinstalled and tried netlogo 6.0.4, R 3.6 and nlrx 3.0. None of them is helpful. 😢
Hi there
Any update on this issue? I'm having what seems to be a very similar problem but on a Mac. All code as copied from my nlxr example (wolf-sheep) and adjusted for my version of Netlogo.
library(nlrx)
Sys.setenv(JAVA_HOME = ("/Library/Java/JavaVirtualMachines/jdk-17.0.1.jdk/Contents/Home"))
netlogopath <- file.path("/Applications/NetLogo 6.2.1")
modelpath <- file.path(netlogopath,
"models/Sample Models/Biology/Wolf Sheep Predation.nlogo")
outpath <- file.path("~/OneDrive - University of Strathclyde/ABM WORK/ABM REPOSITORY")
nl <- nl(nlversion = "6.2.1",
nlpath = netlogopath,
modelpath = modelpath,
jvmmem = 1024)
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", "count patches with [pcolor = green]"),
variables = list('initial-number-sheep' = list(min=50, max=150, qfun="qunif"),
'initial-number-wolves' = list(min=50, max=150, qfun="qunif")),
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"))
nl@simdesign <- simdesign_lhs(nl=nl,
samples=100,
nseeds=3,
precision=3)
results <- run_nl_all(nl = nl)
I can't find any problem with the paths and don't get any errors just a very slow running R which is clearly trying to follow to commands but no hint of Netlogo opening up to start the experiment and I have to interrupt it after several minutes of nothing.
R, Netlogo, JAVA, and nlrx all latest versions R seems to accept all the the commands without error messages...
I'm not the most tech savvy when it comes to using the terminal to check functions/processes but all help pages and advice have been checked and genuinely can't see what I've done wrong...
Sorry, I had no time to look into this issue lately. But I am planning to investigate this in December.
Many thanks for any help
Same here. I am using the sample code. It takes ages...
As an update, I've tried running on a parallel windows 10 desktop. As per yyzeng's experience. Using the command centre as administrator I can run the wolf-sheep experiment with results in a minute, but nlrx through netlogo is trying to something but failing.
I couldn't run it through command without administrator privileges (access denied which was the same on my mac desktop) but when i set up as admin on widows, no problems. Is there maybe something missing running R as a user?
I finally found the time to deal with this issue. Sorry that it took so long.
The problem is with how NLRX currently works. Technically, for each simulation run, in @yyzeng s example 100 x 10 = 1000 simulations, a new NetLogo instance is started and the model is loaded. This takes about 4 sec on my computer, so a total of 4000 sec, just under 67 minutes. The simulations themselves probably take less than a second.
Ss a rule of thumb: Runtime in NLRX = # simulations x (4 s + simulation time)
If you use NetLogo's BehaviourSpace, NetLogo is started only once (or several times, if you use several cores), so you save the whole overhead.
The behavior of NLRX can be quite handy (or at least is less relevant) if you have simulations that take longer and/or you can distribute the simulations over many CPUs (e.g. on an HPC of a university). But if you want to run a lot of simulations, each of which is short, the overhead is unfortunately very significant.
Unfortunately, I do not have a short-term solution.
In principle, I have two ideas on how to improve the performance in the future:
(1) I could write a function to run experiments designed with BehaviourSpace with NLRX and no overhead. But I'm not sure if this is useful at all because then you could also run the simulations directly in Behaviourspace.
(2) there is the possibility to control NetLogo directly and run several simulations one after the other without having to restart NetLogo every time. You could define chunks, i.e. a certain number of simulations, which are executed on a NetLogo instance. However, this needs a bit more development effort and I don't think I'll get to it in 2022. But I will write an issue about it, maybe there is someone else who would like to do it.
What do you think?
Thanks bitbacchus.
So for my understanding (I'm fairly new to all this) a shorter volume of long simulations should work ok?
For my own purposes, I was excited at the ability to run it and collect data directly into R especially the LHS rather than behaviour spaces forced-grouping for sensitivity analysis.
My model takes 5-10mins to run and collects a lot of data. Technically for robustness and accuracy I only need 350-400runs so may still be good for me but access to CPU beyond my own desktops is limited.
Personally, the second option absolutely makes sense but as a user who combines ABM with DES and long-times series, anything that will bypass the limitations of excel as the output Id be happy with that.
Thanks again for looking into this. Any other suggestions for how I can overcome this shortfall in behaviour space/excel would be appreciated from any direction
So for my understanding (I'm fairly new to all this) a shorter volume of long simulations should work ok?
Well, it works for sure. You just have to add a 4 sec overhead for each parameter set/simulation run. The shorter the simulations the more the relative impact of the overhead.
For my own purposes, I was excited at the ability to run it and collect data directly into R especially the LHS rather than behaviour spaces forced-grouping for sensitivity analysis.
Yes, that was one of the main reasons to develop NLRX in the first place
My model takes 5-10mins to run and collects a lot of data. Technically for robustness and accuracy I only need 350-400runs so may still be good for me but access to CPU beyond my own desktops is limited.
Yes, for a 5-10 mins runtime 4 sec of overhead doesn't ma a difference at all. I'd use a parallel job e.g. with future then it is an overnight job.
Thanks again for looking into this. Any other suggestions for how I can overcome this shortfall in behaviour space/excel would be appreciated from any direction
The only way to overcome behaviour space's shortcomings that I see is to use NLRX ;-) I think I didn't get what Excel has to do here?
I'm giving it a go. There may have been an issue with my r extension. I'd been playing around with it before. Now it all seems to work fine.
managed to run the wolf sheep example by playing around with the number of samples to gauge the time requirements and it all ran perfectly.
I'm running a simple sim on a parallel windows desktop for my model with 400 runs and will update on how it works
Thanks again, knowing the time limitations helps. I was maybe just being little impatient but understanding how it works under the hood
ps the excel thing was just alluding to the fact that my temporary solution (using behaviour space alone for the verification) was to do 20runs at a time 20 times as excel.csv holds just over a million rows and would drop everything after that without warning. the need to load separately then paste to create the full dataset (approx 20 000 000 rows) was a bind
Hi, I'm having a similar issue with the nlrx package. When I run the wolf-sheep model it runs perfectly but when I try to run my own model it just runs endlessly and doesn't ever produce results. It's not an error in the actual model because I can run it fine in Netlogo (but not behaviour space). I think this is an issue with the R extension so just wondered if @njirvine had any ideas how to solve this? Thanks!
Hi there
I’m no expert but I have managed to make a lot mistakes and work though them. Main lessons I learned were: Removal of any user interaction prompts Checking the parameters of experiment once you have saved as an object Read through the printed check of the experiment to make sure everything is ticked (green) except the results as they aren’t available
This may be too obvious to be relevant but have you set a tick end in the experiment?
Whenever mine was just running forever but not producing results it was usually an error in the instructions to the run the model not the model itself.
Get Outlook for iOShttps://aka.ms/o0ukef
From: jen-boyd @.>
Sent: Thursday, June 16, 2022 4:15:18 PM
To: ropensci/nlrx @.>
Cc: Nicola Irvine @.>; Mention @.>
Subject: Re: [ropensci/nlrx] Why nlrx
takes soooooo long to run on my computer? (#57)
CAUTION: This email originated outside the University. Check before clicking links or attachments.
Hi, I'm having a similar issue with the nlrx package. When I run the wolf-sheep model it runs perfectly but when I try to run my own model it just runs endlessly and doesn't ever produce results. It's not an error in the actual model because I can run it fine in Netlogo (but not behaviour space). I think this is an issue with the R extension so just wondered if @njirvinehttps://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnjirvine&data=05%7C01%7Cnicola.irvine%40strath.ac.uk%7C2198253cff7945598e6708da4fab06bf%7C631e0763153347eba5cd0457bee5944e%7C0%7C0%7C637909893207685803%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=z28MfpkDrcPKFxfgIDipuReD1TY9%2F9svD4g6Pbsj2LM%3D&reserved=0 had any ideas how to solve this? Thanks!
— Reply to this email directly, view it on GitHubhttps://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fropensci%2Fnlrx%2Fissues%2F57%23issuecomment-1157780153&data=05%7C01%7Cnicola.irvine%40strath.ac.uk%7C2198253cff7945598e6708da4fab06bf%7C631e0763153347eba5cd0457bee5944e%7C0%7C0%7C637909893207685803%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=luKdPo5pvU62azJfjqrQ%2F6rnUQFrDy%2FxUrBdOr3ImWc%3D&reserved=0, or unsubscribehttps://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAQDLTXI3N742QDBQEZGYYSTVPNAINANCNFSM5EXSSOJA&data=05%7C01%7Cnicola.irvine%40strath.ac.uk%7C2198253cff7945598e6708da4fab06bf%7C631e0763153347eba5cd0457bee5944e%7C0%7C0%7C637909893207685803%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=1T4t%2BR%2BSVaJN3QCpkNINzdygPPzf%2FB7meo6QHXYL3so%3D&reserved=0. You are receiving this because you were mentioned.Message ID: @.***>
Hereafter is my codes:
The codes took almost two hours to run in my computer with
Intel(R) Xeon(R) CPU E3-1505M v6 @ 3.00GHz
and32G RAM
.But if I used netlogo's BehaviorSpace to do the same job, it finished in 1 minute! Below is the xml setting I distill from the saved
.nlogo
file.Something wrong? Thank you!