Netlogo on clusters – splitting up nlogo BehaviorSpace experiments

If you are looking for a script to help you construct individual simulation setup files from a Netlogo BehaviorSpace experiment I ended up writing one. It’s available for download over at github.

Half a year ago or so a student doing an internship at a research group I am working with at the moment wrote a Netlogo simulation for simulation antiretroviral drugs on some specific risk populations. It was a neat little experiment, especially for an internship. Fast forward to a couple of weeks ago, and my modelling colleagues wanted to expand the experiment somewhat, and try out a larger range of free parameters. As the student’s internship is over I was asked to have a look at the netlogo code and to get it running on the cluster.

The program turned out to be easy enough to update, but when I started looking in to distributing the simulations over a cluster I ran in to some trouble. While it is easy to set up experiments in Netlogo’s so-called BehaviorSpace editor, and running these multithreaded, it doesn’t seem like there’s any way of  distributing experiments on a cluster without manually configuring every experiment.

I ended up writing a script, split_nlogo_experiment, that simply takes a name of an experiment as well as the .nlogo file wherein it is stored and then proceeds to reconstruct all possible combinations of parameter values in the same way as BehaviorSpace does. Each combination corresponds to a unique simulation and is saved as an XML file which can be fed back to Netlogo using the –setup-file switch.

This means that you can use the BehaviorSpace editor to create your experiment and then split it up and run each simulation of that experiment individually. This should make it easier to distribute the jobs over a cluster of computers.

I also ended up including functionality to generate scripts, for instance PBS, from a template file. Useful if each job has to be submitted to a queuing system with a configuration file and command.

Posting this here in the hope that it will be useful.  I could not find anything similar online when I was looking. (That doesn’t necessarily mean that there isn’t any better way of solving the problem already out there, or even included in Netlogo without me knowing it. I usually write my cluster simulations in other languages, and have mostly been using Netlogo as a toy earlier.)


Brief examples and running instructions can be found in the README file or on the github wiki. Run splint_nlogo_experiment -h for help on switches and options.


Leave a Reply