nlexperiment-package R Documentation

nlexperiment: NetLogo experiments

Description

Exploration of NetLogo (Wilensky 1999) agent based models.

Details

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:

References

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/

Examples

## 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)