nlexperiment-package | R Documentation |
Exploration of NetLogo (Wilensky 1999) agent based models.
A tool for NetLogo experiment definition, exploring simulation results and model optimization. Makes it easy to turn the cycle of experiment definition, data analysis, visualisations and parameter fitting into readable and reproducible documents.
RNetLogo package (Thiele 2014) is used as an interface to NetLogo environment.
Functions in nlexperiment assume the following steps:
Define NetLogo experiment object with parameter sets,
measures and simulation options
(see nl_experiment
function).
Run experiment (see nl_run
).
The result of running an experiment keeps original
experiment definition
along with the simulation results and makes the process of model analysis
more concise and reproducible.
To run the simulation in parallel working processes
use the parallel
attribute in nl_run
function.
Analyse and present results of simulation(s).
See nl_get_result
for getting different data from
the result and
nl_show_step
,
nl_show_patches
for pre-defined plots.
When additional questions pop out, changes to
experiment will be needed.
Refine the original definition of the experiment by
changing only parameter sets (nl_set_param_values
),
set different measures (nl_set_measures
) or set other simulation
options (nl_set_run_options
).
Wilensky, U. (1999) NetLogo. http://ccl.northwestern.edu/netlogo/. Center for Connected Learning and Computer-Based Modeling, Northwestern University. Evanston, IL.
Thiele, J. (2014) R Marries NetLogo: Introduction to the RNetLogo Package. Journal of Statistical Software 58(2) 1-41. http://www.jstatsoft.org/v58/i02/
The ideas and principles of NetLogo experiment definition is taken from the NetLogo's Behavior Space tool http://ccl.northwestern.edu/netlogo/docs/behaviorspace.html and BehaviorSearch tool http://www.behaviorsearch.org/
## Not run: # Set the path to your NetLogo installation nl_netlogo_path("c:/Program Files (x86)/NetLogo 5.1.0/") # Create NetLogo experiment of Net Logo Fire model experiment <- nl_experiment( model_file = "models/Sample Models/Earth Science/Fire.nlogo", while_condition = "any? turtles", repetitions = 10, run_measures = measures( percent_burned = "(burned-trees / initial-trees) * 100", progress = "max [pxcor] of patches with [pcolor > 0 and pcolor < 55]" ), param_values = list( density = seq(from = 55, to = 62, by = 1) ) ) # Run the experiment using multi-core processing result <- nl_run(experiment, parallel = TRUE) # Get observations data frame dat <- nl_get_run_result(result) # plot percent burned by density library(ggplot2) ggplot(dat, mapping = aes(x = factor(density), y = percent_burned) ) + geom_violin() ## End(Not run)