ropensci / nlrx

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

the total number of simulation runs #80

Closed nik1393 closed 1 year ago

nik1393 commented 1 year ago

I'm using simdesign_lhs() to run Latin Hypercube Sampling for my model. I would like to calculate how many total simulation runs nlrx will run. There is an example of an experiment:

variables = list(
"A" = list(min=1, max=3000, step=300, qfun="qunif"),
"B" = list(min=0, max=4, step=1, qfun="qunif"),
"C" = list(min=10, max=100, step=10, qfun="qunif"),
"D" = list(min=0, max=1, step=0.4, qfun="qunif"))
nl@simdesign <- simdesign_lhs(nl, samples = 100,
                                 nseeds=1,
                              precision = 1)

Will it run 1001=100 simulations in total? Maybe this is a correct way to calculate it: (10 100+4 100+10 100+2.5 100)1=2650? i.e. each parameter is divided into intervals (i.e. 10 intervals for the first one), each each of these intervals is sampled by 100 because samples = 100). And because nseeds=1, I multiplied by 1 in the end. Thank you in advance for any help in clarifications!

nldoc commented 1 year ago

The first calculation is correct: 100 simulations. The samples argument decides how many samples are taken from the random space. One sample is one complete set of parameters (A,B,C,D), thus drawing from each parameter distribution once. You can also think of one sample as one row in the nl@simdesign@siminput parameter table. The number of samples (rows in the siminput table) is then multiplied by the number of random seeds (nseeds) to get the full number of simulations. You can also always use print(nl) which will show you the "estimated number of simulations" in the summary table.

Probably the confusion comes from the step argument in the parameter list. Actually, the step argument (defining intervals with specific breaks) is only used in the simdesign_ff and ignored in all others (see https://docs.ropensci.org/nlrx/articles/furthernotes.html#variables-and-constants-definitions). For the latin hypercube, only the min, max and shape (qfun) of the distribution are relevant.

nik1393 commented 1 year ago

Great! Thank you so much for the explanations.