Agent-based and Individual-based Modeling: A Practical Introduction

Updates and example models for JASSS article on NetLogo execution speed

This page provides updates and example NetLogo files for this publication:
Railsback, S. F., D. Ayllón, U. Berger, V. Grimm, S. L. Lytinen, C. J. R. Sheppard, and J. C. Thiele. 2017. Improving execution speed of models implemented in NetLogo. Journal of Artificial Societies and Social Simulation. 20 (1) 3 which is available at

Updates, additions, and corrections to advice in the article

  • More information on speeding up in-radius and in-cone statements. Robert Grider of the NetLogo development team clarified to us that NetLogo versions through 6.0 were optimized to use in-radius (and in-cone) on the built-in agentsets: turtles, patches, and any breeds that are defined. As a consequence, these primitives are slower for other agentsets, even much smaller ones, and their execution time increases dramatically with the size of the agentset being searched. It was therefore much quicker to use turtles in-radius 10 with [color = blue] than blue-turtles in-radius 10, even if blue-turtles is an agentset containing a small fraction of the turtles. This difference could dramatically speed up models in older versions of NetLogo (in one test case, it reduced execution time by a factor of 20).

    However, this side effect of optimizing in-radius and in-cone was remedied in NetLogo 6.0.1. It is no longer faster to use these primitives on the built-in agentsets (Updated: 15 August 2017)

  • Correction to cost of using links. Section 8 of our paper said that using NetLogo's links agents can be much slower than using state variables to represent relationships among agents or to model networks. The test case that this conclusion was based on had a mistake in it, and the difference between using links and state variables is less than we claimed. Our corrected test with the Wild Dog model found that using links increased execution time by only about 10%. (Added: 8 March 2017)

  • BehaviorSearch now packaged with NetLogo. Section 11 of our paper mentions the BehaviorSearch tool for fitting model parameters. BehaviorSearch is now packaged with NetLogo (version 6.0.1): Look for Behaviorsearch.exe in the same directory as NetLogo.exe. (Added: 15 August 2017)

  • Time extension available for NetLogo 6. Section 10 of our paper discusses the use of discrete event simulation as a way to make some models faster, simpler, and more natural. We mention the "time" extension to NetLogo as a tool for doing discrete event simulation. Colin Sheppard recently produced a version of this extension that is compatible with Version 6 of NetLogo. (Added: 8 March 2017)

    Note that the Mousetrap example model packaged with the extension is different with NetLogo 6 because the stop primitive in the NetLogo 6 version halts execution of the model's schedule. (Added: 15 August 2017)

Example models used in the article

See the "Info" tab in each file for information on its purpose and use. These files were developed in NetLogo version 5.3.

The first file is referred to in paragraph 6.7 of the article. It illustrates use of global agentsets to reduce use of filtering primitives such as with. Right-click here to download With-vs-global-vars.nlogo.

The second file is referred to in paragraphs 6.8 and 6.9 of the article. It illustrates use of patch or turtle agentset variables to reduce use of filtering primitives such as with. Right-click here to download With-vs-agent-vars.nlogo.

The third file is referred to in paragraphs 6.11 and 6.14 of the article. It illustrates use of local agentset variables to reduce use of filtering primitives such as with. Right-click here to download With-vs-local-vars.nlogo.

The fourth file is referred to in paragraphs 3.4 and 9.1 of the article. It calculates execution time of identifying agents within a radius, using both the in-radius and distance myself statements. Right-click here to download InRadius-vs-DistanceMyself.nlogo.