ropensci / nlrx

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

Simulation does not end #26

Closed jholderieath closed 5 years ago

jholderieath commented 5 years ago

I have a simulation that does not seem to end. I have stop conditions in both the model and the nlrx code. I am running on a domino data lab server with plenty of resources left. The results object is just never generated. I am sitting here with the stop sign waiting in my RStudio session. I have uploaded my NetLogo model as a text file.

Any ideas?

image

Summer19.txt


# Unix default NetLogo installation path (adjust to your needs!):
netlogopath <- file.path("/opt/NetLogo/NetLogo 6.1.0")
modelpath <- file.path("/mnt/Summer19.nlogo")
outpath <- file.path("/mnt/results/out")

nl <- nl(nlversion = "6.1.0",
         nlpath = netlogopath,
         modelpath = modelpath,
         jvmmem = 1024)

nl@experiment <- experiment(expname="wild-pigs",
                            outpath=outpath,
                            repetition=1,
                            tickmetrics="true",
                            idsetup="setup",
                            idgo="go",
                            runtime=16,
                            evalticks=seq(1,15),
                            metrics=c("count sows", "count boars","count sounders"),
                            metrics.turtles=list("households" = c("who", "HH_income", "wealthi")),
                            variables = list('sex_ratio' = list(min=0, max=1, step=0.25),
                                             'cdecay' = list(min=0, max=1, step=0.25),
                                             'rule' = list(values=c("\"at-random\"",
                                                                    "\"myopic-pmax\"", 
                                                                    "\"at-random-with-uniform-removal\""))),
                            constants = list("y_corn" = 1500,
                                             "y_soy" = 400,
                                             "y_crp" = 10,
                                             "p_corn" = 4,
                                             "p_soy" = 10,
                                             "p_crp" = 75,
                                             "vc_corn" = 100,
                                             "vc_soy" = 100,
                                             "vc_crp" = 1,
                                             "defaultLitter" = 8,
                                             "minSounderN" = 5,
                                             "maxSounderN" = 20,
                                             "pig_range" = 20,
                                             "brange" = 10,
                                             "init_sounder" = 5,
                                             "init_hh" = 45,
                                             "epsilon" = 1.19E-7,
                                             "too-close" = 1.1,
                                             "too-far" = 4.1,
                                             "step-size" = 1,
                                             "uniform_removal" = 0.5,
                                             "max_pigs" = 500)
                            )

nl@simdesign <- simdesign_simple(nl=nl,
                              nseeds=3)

results <- run_nl_one(nl, seed = getsim(nl, "simseeds")[1], siminputrow = 1)

# Attach results to nl object:
setsim(nl, "simoutput") <- results

# Write output to outpath of experiment within nl
write_simoutput(nl)

# Do further analysis:
analyze_nl(nl)
nldoc commented 5 years ago

Thank you very much for your feedback. I checked your model code and I am quite sure that the problem is connected to the R extension you are using in your model (see issue #24). Please try to stop the underlying r session manually, by adding r:stop to the idfinal field of the experiment,

jholderieath commented 5 years ago

Yes. Thank you! This is great BTW.

nldoc commented 5 years ago

Good news and thank you for the positive feedback 😃