|
|||
|
Home Download Help Forum Resources Extensions FAQ NetLogo Publications Contact Us Donate Models: Library Community Modeling Commons Beginners Interactive NetLogo Dictionary (BIND) NetLogo Dictionary User Manuals: Web Printable Chinese Czech Farsi / Persian Japanese Spanish
|
NetLogo Models Library: | ||
|
Note: If you download the NetLogo application, every model in the Models Library is included. |
This model is based on the original Flocking model that has birds follow exactly the same set of rules, from which flocks emerge. It demonstrates using a Python package, scikit-learn, within a NetLogo model through the py extension in order to cluster the birds into groups, who are given matching colors in the view.
In the setup procedure, py:setup py:python is used to start the Python session and py:run is used to let Python import the numpy and scikit-learn packages for use during the model run. If you do not have these packages installed, the py extension will show an error. Please install these packages in your Python environment before running the model.
The modifications for clustering are in the go procedure, where py:set is used to pass turtle data to Python as the coords variable and the vision NetLogo variable as the eps variable.
Then py:runresult is called to use the dbscan() Python function on the NetLogo data and the resulting cluster data is sent back to NetLogo and stored in the clusters variable.
Finally, the clusters data is used to color the turtles into their groups.
See the original Flocking model for details on how the flocking-specific code works.
There is a bundle of other Python extension demo models, py-demo-models.zip, available on the Python extension site.
(back to the NetLogo Models Library)