
NetLogo – A multi-agent programmable modeling environment - tosh
https://ccl.northwestern.edu/netlogo/
======
eggy
I used NetLogo and a example file that I modified to demonstrate to non-techie
designers why the doors they were proposing for a theater were too few and too
narrow. The scrambling arrows representing people colliding and changing
directions and the traffic made it very apparent. Simply telling them code
requires X and you have Y wasn't as poignant. We wound up using NetLogo for
other types of presentations.

------
lettergram
Years ago I wrote an application which was essentially a neural circuit of a
sea slug (they only eat and forage) with my now wife.

[https://austingwalters.com/modeling-and-building-robotic-
sea...](https://austingwalters.com/modeling-and-building-robotic-sea-slug/)

We then showed how (using netlogo) how when another neural circuit for
aggressive behavior was added (but the connections of the markov chain had yet
to be trained) the sea slugs. After adding the aggressive circuit and letting
generations live and die using a genetic algorithm - it appeared to observers
like the animals became social. I.e. only the territorial sea slugs remained,
and they wouldn’t attack ones of the same species, this proved to be the best
for “survival”.

The goal of the work was to provide insight into what neural circuits can lead
to social behavior. Specifically, what environmental conditions can lead to an
evolutionary trait that triggers social like behaviors.

Honestly, idk if you can make any “claims”, but it was a fun undergraduate
project. The best part is we exported the trained models from the Netlogo
program, then imported them into a lego robot. At which point our robot had
learned to be aggressive - I.e. would “chase” people away from the food
source.

~~~
vanderZwan
> _Honestly, idk if you can make any “claims”_

Well, the results are reproducible, and the constraints of the model are
clearly defined in the code.

So you might not be able to generalize claims, but in some sense it is also
better than many papers out there because you can be more precise about
discussing flaws in the model than with empirical data.

------
rootoor
I worked with a grad student in college who was building models in NetLogo for
modeling drug overdoses. It was pretty janky and slow.

They had to run the model millions of times so I had to build NetLogo on our
HPC cluster running Rocks OS and write some magic config in slurm to run it
and it took for ever because about 1/3 of the jobs would fail because they ran
out of ram and would need to be run again.

I’m not sure how much of it was the grad students fault or NetLogos fault but
either way, the experience was quite painful

~~~
frankling_
As for the performance aspect, these kinds of simulations (typically using
fixed time steps and with per-agent decision-making) are a natural fit for
many-core devices. We recently did a survey on that subject [1]. There is a
lot of work being done along these lines right now.

Some groups are also trying to target sequential, parallel and, say, GPU
execution from the same model specification language, which could actually
help with the usability of running such simulations in practice.

[1] [https://arxiv.org/abs/1807.01014](https://arxiv.org/abs/1807.01014)

~~~
veddox
This is interesting. We've been thinking quite a bit about parallelising our
model, but haven't managed it yet. The problem is that although our agents are
mostly independent of each other, they all depend on the shared state of the
world (and modify this, too).

Therefore, if we were to use a multiprocessing setup, we would have to be able
to lock the world object when a process is writing to it; and furthermore,
find a way to pass it around in memory so that all processes have read access
to it. While we know that it should be technically doable, the latency
overhead of the latter has proven prohibitively high.

~~~
frankling_
Yeah, for some models, especially small-scale ones, it can be hard to get a
performance gain. There are actually ways of avoiding the locking, e.g., by
staging the desired actions and then carrying them out afterwards, resolving
conflicts as needed. We actually have a paper on this as well, but I'm going
to stop pushing my research at this point ;)

------
mujoco
For anyone who'd like to try out NetLogo without installing it, you can run
example models and play with the code online in NetLogo Web:
[https://www.netlogoweb.org/launch#https://www.netlogoweb.org...](https://www.netlogoweb.org/launch#https://www.netlogoweb.org/assets/modelslib/Sample%20Models/Computer%20Science/Cellular%20Automata/Life.nlogo)

~~~
vanderZwan
Ironically, if I click that link on mobile it downloads a file

------
jbottoms
Oh, well beyond "very interesting". This type of modeling can yield results
that are otherwise intractable. It is one of the primary reasons Thomas
Schelling received a Nobel prize in economics. It should be in the toolkit of
every applied mathematician or computer scientist.

~~~
xrd
I liked the tutorial #1, linked from here:

[https://ccl.northwestern.edu/netlogo/docs/](https://ccl.northwestern.edu/netlogo/docs/)

Is this only available for use within the GUI?

I can imagine how mathematicians would use it but what would be typical
applications of a computer scientist?

~~~
xrd
Agent script looks like an amazing port:

[http://agentscript.org/](http://agentscript.org/)

Not in love with coffee script anymore but oh well.

The demos are great:

[http://agentscript.org/models/flock.html](http://agentscript.org/models/flock.html)

------
nasir
During our graduation period we used Netlogo for projects of distributed
networks. It was lots of fun to do different simulations. I remember writing
Ant Colongy Optimization and Firefly Synchronization with it and being able to
visually see and tweak parameters.

------
xrd
What other languages provide this kind of model output? It's very interesting.

~~~
falls-to-bits
There are more and more these days. If you want Java/scala-based, the two
biggest ones are: \- MASON:
[https://cs.gmu.edu/~eclab/projects/mason/](https://cs.gmu.edu/~eclab/projects/mason/)
\- Repast:
[https://repast.github.io/index.html](https://repast.github.io/index.html)

For Python, someone else has already mentioned Mesa:
[https://github.com/projectmesa/mesa/](https://github.com/projectmesa/mesa/)

You can find some more lists at
[https://www.comses.net/](https://www.comses.net/) \-- sadly
[https://en.wikipedia.org/wiki/Comparison_of_agent-
based_mode...](https://en.wikipedia.org/wiki/Comparison_of_agent-
based_modeling_software) looks fairly sparse / a little outdated (though I
have only passing familiarity with most of those).

Finally, I think a great technical source of theory about these models comes
from Cosma Shalizi's notebook on ABM: [http://bactra.org/notebooks/agent-
based-modeling.html](http://bactra.org/notebooks/agent-based-modeling.html)
He's one of the single best sources I've seen for describing systems for
formally estimating ABMs.

Netlogo is great for fast prototyping, but at least as of ...well a number of
years ago now, there was a noticeable lack of scientific computing libraries.
For example numerical optimization routines were _extremely_ basic. I had to
use a user-contributed package to solve a root finding problem.

Honestly for this type of work I typically write my own from scratch in
Python. Here's a great set of lectures and code from Blake LeBaron, "from
sratch" in Python, for finance ABMs:
[http://people.brandeis.edu/~blebaron/classes/agentfin/](http://people.brandeis.edu/~blebaron/classes/agentfin/)
...and here's a nice from scratch Schelling model in Python:
[https://lectures.quantecon.org/py/schelling.html](https://lectures.quantecon.org/py/schelling.html)

~~~
xrd
Terrific summary, thanks so much.

------
zeptomu
> NetLogo is a multi-agent programmable modeling environment.

What does that even mean? That description fits nearly every commonly used
programming language and runtime.

~~~
reuven
Most programming languages don't use the multi-agent paradigm. It's a
different way of thinking about problems, in which you describe how each type
of agent should interact with others, and then you let them run and play out
the scenario.

It's true that you can implement multi-agent programming in other languages,
but it's very natural and clear in NetLogo.

PS: I did my PhD in the group that produces NetLogo, and continue to be blown
away from the language and what you can do with it, even though I don't use it
on a daily basis any more.

~~~
veddox
I am in a research group that does ecological modelling, so I've heard a fair
bit about NetLogo, though I haven't used it myself.

I quite like its approach - like you say, it's a very natural way to do agent-
based modelling. I also think its a good beginners' language for modellers who
know their field (e.g. ecology) but haven't yet learnt how to program. Lastly,
I like it's GUI integration.

However, I am somewhat put off by its verbose "toy language" syntax; and I
really can't afford its performance. (We are currently working on a model in
Julia, and even that can take up to several weeks to compute a single run on
our HPC...) So I guess my opinion is that its a fantastic language to learn
about modelling, but not well suited to constructing large, complex and
resource-intensive models.

~~~
TuringTest
Is there a language you would recommend as the next step for someone who has
learned NetLogo? One with better syntax and performance? Maybe a Julia
library?

~~~
veddox
We use Julia in our group and I really like it: the language design is pretty
neat and it offers a very good performance. I don't know of any libraries
targeted specifically at agent-based modelling, though. (But in the end, as an
experienced programmer you don't really need that - plain object-orientation
is enough.)

~~~
reuven
I would argue that for certain kinds of problems, agent-based modeling is
easier to think about and work with than object-oriented programming. It's not
a matter of your programming experience, but rather what you're trying to
model and how.

I've heard great things about Julia, but haven't ever used it. Yet another
thing that's on my list...

