Skip to content

Python Extension

Latest
Compare
Choose a tag to compare
@qiemem qiemem released this 08 Mar 17:37
· 4 commits to master since this release

This NetLogo extension allows NetLogo models to run Python code. This allows models to make use of powerful Python libraries, such as numpy, TensorFlow, scipy, and others. It works by starting up a Python session that the model can then run code in and get results from. See the documentation here: https://github.com/qiemem/PythonExtension/blob/master/README.md

Installation instructions

  1. Download the attached zip
  2. Unzip it into the extensions directory of your NetLogo installation.

Thus, your NetLogo extensions directory should contain a folder called py with the following contents:

image

Demo models can be found in the demos folder. They should work with either Python 2 or Python 3.

The demo models depend on a number of libraries, all installable with pip or conda:

Flocking Clusters

  • numpy
  • sklearn

Both Wolf Sheep Predation models

  • numpy
  • matplotlib

Traffic Basic - Reinforcement

  • numpy
  • tensorflow
  • keras

To install all dependencies, run pip install numpy matplotlib sklearn tensorflow keras in your terminal (assuming you have pip).

Changelist

Improvements:

  • Halting the NetLogo model no longer automatically kills the Python session.
  • Halt handling is much more robust in general.
  • Improve documentation