nl4py

Bringing Your Turtles From NetLogo to Python 🐍🐢

https://github.com/chathika/nl4py

Science Score: 20.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
    Links to: sciencedirect.com
  • Committers with academic emails
    5 of 8 committers (62.5%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (11.6%) to scientific vocabulary

Keywords

agent-based-modeling netlogo python
Last synced: 6 months ago · JSON representation

Repository

Bringing Your Turtles From NetLogo to Python 🐍🐢

Basic Info
  • Host: GitHub
  • Owner: chathika
  • License: gpl-3.0
  • Language: Jupyter Notebook
  • Default Branch: master
  • Homepage:
  • Size: 44.2 MB
Statistics
  • Stars: 52
  • Watchers: 8
  • Forks: 9
  • Open Issues: 6
  • Releases: 0
Topics
agent-based-modeling netlogo python
Created almost 8 years ago · Last pushed almost 4 years ago
Metadata Files
Readme License

Readme.md

Build wheel and Run Unittests Run Unittests

NL4Py

A Python controller interface to NetLogo. NL4Py uses a Remote Procedure Call architecture, allowing Python client code to control NetLogo workspaces on a NetLogoWorkspaceController server. NL4Py supports controlling multiple workspaces through a single Python client.

Read the NL4Py article is on SoftwareX: https://www.sciencedirect.com/science/article/pii/S2352711021001035

NetLogo with GUI control demo

NL4Py has been tested Python 3.6.2

Requirements

  • NL4Py works with NetLogo 6.0, 6.1, and 6.2
  • NL4Py requires JDK 1.8
  • NL4Py requires py4j to be installed with your Python distrubtion

Installation

You can install NL4Py using pip-tools: pip install nl4py

Usage

To use nl4py in your python code use:

python import nl4py

And start the NetLogoControllerServer with:

python nl4py.initialize(netlogo_home : str)

Where netlogo_home refers to the top level directory of your NetLogo installation.

Examples

  1. Example1 : An example of how to run concurrent NetLogo models. To run this example enter the number of desired concurrent runs and the path to your netlogo installation as command line arguments:

python Example1_NRunsOfFireSampleModel.py 200 "C:\Program Files\NetLogo 6.0.4"

  1. Example2 : An example of how to schedule reporters to return simulation state over a range of ticks at a custom tick interval. To run pass in the path to your netlogo installation as a command line argument:

python Example2_ScheduledReporters.py 200 "C:\Program Files\NetLogo 6.0.4"

  1. Example3 : An example of how to run_experiment can be used to easily execute an experiment with parameter variation and return results of multiple reporters. To run pass in the path to your netlogo installation as a command line argument:

python Example3_NRunsOfFireRunExperiment.py 20 "C:\Program Files\NetLogo 6.0.4"

  1. Example4 : An example of how to control the NetLogoGUI. To run pass in the path to your netlogo installation as a command line argument:

python Example4_NetLogoGUIAppControl.py "C:\Program Files\NetLogo 6.0.4"

Also, see these demo jupyter notebooks:

  1. Parameter Calibration
  2. Sensitivity Analysis

Functions

You can create multiple NetLogo HeadlessWorkspaces from Python using the netLogoWorkspaceFactory:

python nl4py.create_headless_workspace() -> nl4py.NetLogoHeadlessWorkspace.NetLogoHeadlessWorkspace

The following HeadlessWorkspace functions are available:

python nl4py.NetLogoHeadlessWorkspace.NetLogoHeadlessWorkspace.open_model(self, path : str) nl4py.NetLogoHeadlessWorkspace.NetLogoHeadlessWorkspace.close_model(self) nl4py.NetLogoHeadlessWorkspace.NetLogoHeadlessWorkspace.command(self, command : str) nl4py.NetLogoHeadlessWorkspace.NetLogoHeadlessWorkspace.report(self, reporter : str) -> str nl4py.NetLogoHeadlessWorkspace.NetLogoHeadlessWorkspace.schedule_reporters(self, reporters : list, startAtTick : int = 0, intervalTicks : int = 1, stopAtTick : int = -1, goCommand : str = 'go') -> list nl4py.NetLogoHeadlessWorkspace.NetLogoHeadlessWorkspace.set_params_random() nl4py.NetLogoHeadlessWorkspace.NetLogoHeadlessWorkspace.get_param_names() nl4py.NetLogoHeadlessWorkspace.NetLogoHeadlessWorkspace.get_param_ranges()

To open the NetLogo application in GUI mode use:

python nl4py.netlogo_app() -> nl4py.NetLogoGUI.NetLogoGUI

Referencing:

Please cite as: Gunaratne, C., & Garibay, I. (2021). NL4Py: Agent-based modeling in Python with parallelizable NetLogo workspaces. SoftwareX, 16, 100801.

NL4Py is based off of David Masad's Py2NetLogo, available at: https://github.com/dmasad/Py2NetLogo

Copyright

Copyright (C) 2018 Chathika Gunaratne, Complex Adaptive Systems Lab, University of Central Florida.

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Owner

  • Name: Chathika Gunaratne
  • Login: chathika
  • Kind: user
  • Company: Oak Ridge National Laboratory

Make turtles, Munge data, Model societies. I also work here: https://gitlab.com/chathika

GitHub Events

Total
  • Watch event: 1
Last Year
  • Watch event: 1

Committers

Last synced: about 2 years ago

All Time
  • Total Commits: 692
  • Total Committers: 8
  • Avg Commits per committer: 86.5
  • Development Distribution Score (DDS): 0.084
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
chathika c****e@g****m 634
chathika c****a@m****u 31
Chathika Gunaratne c****5@u****u 18
root r****t@l****v 3
David Masad d****d@g****m 2
Chathika g****s@o****v 2
Elizabeth E. Esterly e****h@c****u 1
Elizabeth E. Esterly e****y@g****m 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 7 months ago

All Time
  • Total issues: 14
  • Total pull requests: 5
  • Average time to close issues: 7 months
  • Average time to close pull requests: 3 minutes
  • Total issue authors: 14
  • Total pull request authors: 1
  • Average comments per issue: 1.71
  • Average comments per pull request: 0.0
  • Merged pull requests: 4
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • ChaoKing2020 (1)
  • Westlife1002 (1)
  • wmirecon (1)
  • AyeshaZehra (1)
  • selforganizing (1)
  • robertosilviu (1)
  • LaCuneta (1)
  • WesselDeZeeuw (1)
  • bevsxyz (1)
  • brandon-fsu (1)
  • LuxMiranda (1)
  • bryanpiguave (1)
  • ghost (1)
  • NedaMarvasti (1)
Pull Request Authors
  • chathika (5)
Top Labels
Issue Labels
bug (2) question (1) enhancement (1)
Pull Request Labels
enhancement (1)

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 303 last-month
  • Total dependent packages: 2
  • Total dependent repositories: 2
  • Total versions: 44
  • Total maintainers: 1
pypi.org: nl4py

A NetLogo connector for Python.

  • Versions: 44
  • Dependent Packages: 2
  • Dependent Repositories: 2
  • Downloads: 303 Last month
Rankings
Dependent packages count: 7.3%
Stargazers count: 9.3%
Forks count: 11.5%
Dependent repos count: 11.8%
Average: 12.9%
Downloads: 24.5%
Maintainers (1)
Last synced: 6 months ago

Dependencies

src/client/NL4Py/setup.py pypi
  • matplotlib *
  • numpy *
  • pandas *
  • psutil *
  • py4j *