The following example is using NetLogo Fur model (Wilensky 2003) to show explicit parameter values definition.
There are 5 parameters in the NetLogo Fur model:
ratio
outer-radius-y
inner-radius-y
outer-radius-x
inner-radius-x
But considering constraints and model symmetry we can reduce the parameters to:
ratio
(the inhibitor concentration parameter)rdiff
(the difference between x and y radius) andgap
(distance between inner and outer ellipse)Example below still uses factorial design but on transformed parameter space ratio * rdiff
while keeping the gap
between the circles constant.
#All combinations of ratio x rdiff
param_sets <- expand.grid(
gap = 3,
rdiff = seq(0, 2, by = 0.5),
ratio = seq(0.30, 0.65, by = 0.05)
)
# Add NetLogo variables
param_sets <- transform(param_sets,
inner_radius_x = 3,
outer_radius_x = 3 + gap,
inner_radius_y = 3 + rdiff,
outer_radius_y = 3 + rdiff + gap
)
Instead of list with parameter values as in previous examples, we can use this data frame with explicit parameter sets to define param_values
:
experiment <- nl_experiment(
model_file = "models/Sample Models/Biology/Fur.nlogo",
iterations = 20,
param_values = param_sets, # here param_sets is a data frame
mapping = c(
gap = "",
rdiff = "",
inner_radius_x = "inner-radius-x",
outer_radius_x = "outer-radius-x",
inner_radius_y = "inner-radius-y",
outer_radius_y = "outer-radius-y"
),
patches_after = list(
patches = patch_set(
vars = c("pxcor", "pycor", "pcolor"),
patches = "patches"
)
),
random_seed = 3
)
result <- nl_run(experiment, parallel = TRUE, max_cores = 3)
library(ggplot2)
nl_show_patches(result, x_param = "ratio", y_param = "rdiff") +
scale_fill_manual(values = c("black","white")) +
coord_fixed() +
labs(y=expression(radius[y] - radius[x]), title = "Fur patterns (gap = 3)")