NetLogo: Difference between revisions

From SESLINK Wiki
Jump to navigation Jump to search
Line 33: Line 33:


== NetLogo model documentation ==
== NetLogo model documentation ==
Henrik has written a small utility to generate documentation of NetLogo code, called NetLogoDoc. It's inspired by the [https://en.wikipedia.org/wiki/Pydoc PyDoc] and [https://en.wikipedia.org/wiki/Javadoc JavaDoc] documentation generators. As of January 2017 it's still very primitive, but can be helpful if one is trying to collaborate with other researchers.  
Henrik has written a small utility to generate documentation of NetLogo code, called NetLogoDoc. It's inspired by the [https://en.wikipedia.org/wiki/Pydoc PyDoc] and [https://en.wikipedia.org/wiki/Javadoc JavaDoc] documentation generators. As of January 2017 it's still very primitive, but can be helpful if one is trying to collaborate with other researchers. It requires Python to be installed on your machine. This is already in place on machines provided by the project, but your local machine may need to be updated.  


It can be found in the [https://github.com/hwarpefelt/netlogodoc NetLogoDoc section of Henrik's private github account]. This page also contains usage instructions.
It can be found in the [https://github.com/hwarpefelt/netlogodoc NetLogoDoc section of Henrik's private github account]. This page also contains usage instructions.

Revision as of 13:22, 12 January 2017

NetLogo is the main modeling software used by the SESLINK group. It is available from the NetLogo webpage. This page outlines a few tips and tricks for using NetLogo more effectively.

Running NetLogo headless

NetLogo can be run in what is called "headless mode", which means that it runs simulations without showing a graphical user interface (GUI). This speeds up computation quite a bit, but has the drawback that there is no user feedback during the simulation run.

To run NetLogo headless, one needs to invoke it from the command line. The commands for this are explained in the NetLogo documentation.

In order to make this process a little bit easier, the SESLINK group has a ready-made package for running NetLogo headless. It's designed for UNIX systems (Linux and MacOS X) and runs in the command line. Please note that running NetLogo headless requires that the Java Runtime Environment (JRE) is installed on the machine. This is already in place on machines provided by the project, but your local machine may need to be updated.

Step-by-step guide:

  • Download the package from here. (BETA PACKAGE AS OF 2017-01-10 - MAY NOT WORK AS EXPECTED)
  • Put it in the desired location on the machine that will be running the simulation (for example on an AWS machine)
  • Unzip it using the unzip command: unzip netlogo-headless.zip
  • Put your .nlogo file and any accompanying files in the same directory
  • Invoke the run shell script: ./run
    • The script should now provide usage instructions. If you get an error, please consult a senior modeler in the group.
    • The syntax for running an experiment is: ./run MODEL EXPERIMENT. If we want to run the Exp1 experiment for the MyModel model, the command is: ./run MyModel.nlogo Exp1
  • The results will be saved in the NetLogo table format to a file named MODEL_EXPERIMENT_output.csv. As per the example above, the output file becomes MyModel_Exp1_output.csv

The triple quotes problem

One common problem with putting NetLogo runs into R is that the output from NetLogo encapsulates string (text) values in triple quotes ("""text"""). This confuses R, and makes importing the data somewhat difficult. To solve this we have written a small script that fixes the problem. It requires Python to be installed on your machine. This is already in place on machines provided by the project, but your local machine may need to be updated.

Step-by-step guide:

  • Download the file from here
  • Put the script in the same folder as the data file you want to process
  • Invoke the script using: python stripquotes.py FILENAME where filename is the name of your data file.
    • For example, if you want to process the data file MyModel_Exp1_output.csv you issue the command python stripquotes.py MyModel_Exp1_output.csv
  • The end result will be written to the file fixed_FILENAME. Using the previous example, the file will be called fixed_MyModel_Exp1_output.csv

Please note that running this script on a data file will double the amount of storage space used for data. If you have large data files this may create significant storage requirements.

NetLogo model documentation

Henrik has written a small utility to generate documentation of NetLogo code, called NetLogoDoc. It's inspired by the PyDoc and JavaDoc documentation generators. As of January 2017 it's still very primitive, but can be helpful if one is trying to collaborate with other researchers. It requires Python to be installed on your machine. This is already in place on machines provided by the project, but your local machine may need to be updated.

It can be found in the NetLogoDoc section of Henrik's private github account. This page also contains usage instructions.