ropensci / nlrx

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

Simulations takes too long to run and possible not storing results? #101

Open rogerio-bio opened 2 months ago

rogerio-bio commented 2 months ago

Hello, I've been running a model for two days now and there don't seem to be any signs that it will end anytime soon, below is my configuration:

#select version of netlogo you are using 
nl <- nl(nlversion = "6.2.1",
         nlpath = netlogopath,
         modelpath = modelpath,
         jvmmem = 2048)

#this sets up the experimental settings for your model. Check the documentation for information on each parameter. 
#Note in metrics I am saving many outputs.
#However, I'm not including any changing variables, but you can and should in the future. 
#Also, you need at least one constant variable so i chose to keep road effect = none, but that will likely be changed to in the future
nl@experiment <- experiment(expname="scenario-1",
                            outpath=outpath,
                            repetition=28,
                            tickmetrics="true",
                            idsetup="setup",
                            idgo="go",
                            runtime=840,
                            evalticks=seq(48,840),
                            metrics=c("dead-male-chall", "dead-fem-starv", "dead-adult-fem", "dead-adult-male", 
                                      "dead-cub-male", "dead-cub-fem", "dead-juv-male", "dead-juv-fem", "dead-tran-male", 
                                      "dead-tran-fem", "num-infanticide", "count breeding-males", "count breeding-females", 
                                      "count cub-males", "count cub-females", "count juvenile-males", 
                                      "count juvenile-females", "count transient-males", "count transient-females", 
                                      "count males", "count females", "dead-fem-roads1","dead-fem-roads2",
                                      "num-fem-w-off", "mean-female-territory-size", "mean-male-territory-size"),
                            variables = list('males-at-setup' = list(min=10, max=10, qfun="qunif"),
                                             'females-at-setup' = list(min=17, max=17, qfun="qunif")),
                            #constants = list("human-resource-use-pattern" = "\"dist_weighted\""))
                            constants = list("road-effect" = "\"none\"", "park-boundary" ="\"south of East-West highway\"", 
                                             "roadcat_map" = "\"original\"", "red-buffer-1" = 0, "red-buffer-2" = 0, 
                                             "reduction-of-prey"= "\"even\"", "road-mortality" = FALSE))
# variables = list('males-at-setup' = list(min=10, max=11, qfun="qunif"),
#                  'females-at-setup' = list(min=20, max=21, qfun="qunif")),
# constants = list("road-effect" = "/"none/""))

#A simple simulation design. It only runs the model twice using two different random seeds. 
#If you want to run a model with the same setup then you should use the same seed. For now, it is different setups each time for randomization purposes.  
nl@simdesign <- simdesign_simple(nl, nseeds = 1)

#This apparently checks that you set everything up correctly
eval_variables_constants(nl)
print(nl)

#Run the full simulation configuration and save to a file
results <- run_nl_all(nl = nl)

If I understand correctly, I will have 28 simulations, but it has been running for two days. My computer has 32 GB of RAM, the problem could be where the model is running? Would switching to an SSD speed up the process?

Another question, shouldn't a result file appear in R's Global Enviroment?

image

danielvartan commented 1 month ago

The simulations are also taking a long time for me.

It must be something other than the 4 seconds it takes to load a new instance.

I will try to study the package over the next few months. For now, it's barely useful.

rogerio-bio commented 1 month ago

@danielvartan

This simulation takes 4.5 days to be complete (SSD). Using a HD take more than 5 days....

For now, i am running 8 R instances to try to complete my analysis in time.

Edit: Another information - Adding 4 parameters makes the model to take 5 days to complete the runs (SSD)