Netlogo is a computer programming and modeling environment
that was designed by Uri Wilensky at Northwestern University.
It was created both to teach people about how to build models, and also
to be used in Complex Systems research.
Netlogo is based on two earlier programming languages, Logo and StarLogo.
All three of these have been used extensively in education,
ranging from elementary school all the way up to graduate school.
In this course, we are going to use NetLogo to demonstrate some of the
key ideas of complex systems research and some of the tools that people use
in studying Complex Systems.
In the various homework assignments in this class, you'll be, um, using Netlogo
to modify and experiment with existing simulations, and if you choose the
advanced homework options, then you will be building your own simulations.
In the rest of this unit, I am going to be going over the fundamentals of
downloading and using NetLogo.
If you haven't had any programming experience, don't worry. NetLogo is
easy to use and accessible to novices, as well as being useful to experts.
However, if you already have programmed in NetLogo,
and are generally familiar with it,
you can skip the rest of the videos in this unit, and go directly to the
homework assignment for Unit 1.
Okay, let's get started.
First, we'll download NetLogo. It's free, and it works on Windows,
Mac OS, and Linux.
I'll bring up a browser window,
and I'll go to the download site, which is:
http://ccl.northwestern.edu/netlogo
This link is also on our Course Materials page of our Course Website.
This brings up the page for downloading, and it has some information about NetLogo.
I'm going to click on download. You can just go ahead and download.
You can enter your information if you want, it's optional.
Okay, I'm running Mac OS X, so I download, okay,
I'm going to save this to my desktop.
And then I open this one up.
Okay, here's a folder called NetLogo 5.0.3.
If you're downloading this at a later date when they have done a later version,
it may have some higher numbers, but I am going to drag this over to my Desktop,
and get rid of the two install files.
And now I have this folder, and in here, I have NetLogo 5.0.3,
so you will see this, or possibly a later version.
This is the file I want to open.
This is the two-dimensional version of NetLogo, there's also a three-dimensional
version, NetLogo 3D, which we will look at a little bit later.
So double-click on this to open it, yes I want to open it.
It takes a while to open, depending on how fast your computer is.
And there it is.
Now I am going to show you how to run an existing NetLogo model.
NetLogo comes with a library of existing models.
You can go to it by going to the File menu,
and choosing the Models Library.
And you can look through all the different disciplines and
different models in each discipline.
I'm going to go to Biology, and go to the Ants model,
and you can read this, in this project a colony of ants forages for food.
Though each ant follows a set of simple rules,
the colony as a whole acts in a sophisticated way.
So let's open that model.
Okay, so, the first thing to do
when you open a new NetLogo model is to go up here to the "Info" tab.
Notice there is an "Interface" tab, "Info" and "Code".
So the "Info" tab tells us a little bit about the model.
Okay, and so it talks about how it works, how to use it,
things to know about the model, some ideas for
how you might extend it, etc...
So you can take a look at that yourself.
I'm going to go back to the interface.
And you'll notice that there's two buttons here, "Setup" and "Go".
Those appear in most NetLogo models, and the first thing
what you always do is push "Setup".
That sets up the simulation. So what we have here is an ant nest,
that's this purple blob with this red circle in the middle,
which is actually where all the ants live.
This slider here, "Population", tells us there are 125 ants.
And the other three blobs are piles of food, and what we are going to see
is a plot of how much food is in each pile over time.
So the ants are going to move out from their nest and look for food.
So I will click on "Go" and you can see them moving around.
So let me stop the model here, by clicking on "Go" again,
and point out some things.
So you see the little ants moving around. They move around randomly
until one of them finds a piece of food, that's a little square here,
of blue color, or one of the other piles.
And then they pick up the food and take it back to the nest.
But as they move back to the nest, they leave a trail of a chemical,
often called 'pheromone', in the real world of ants,
and other ants can pick up on that trail.
So, an ant leaves a trail, sort of guiding
other ants to the location of the food it found.
Now those trails of chemicals diffuse according to this diffusion rate,
here in this slider, that means they spread out from the original trail
across the distance, and they evaporate, according to this rate.
So when the trails evaporate, we stop seeing a trail here.
So let me slow it down, this slider gives you the speed
with which the model goes, so let me click "Go" again.
They're a little slower here, and you can see the trails
being reinforced, evaporating, diffusing,
but if a single ant happens to find the food and can get back to the nest,
and other ants find that trail before it evaporates,
then they can follow the trail.
And you can see over here the food in each pile going down.
Here's the very last pile.
So let me speed this up again.
And you can see the ants. I'll speed it up even more.
So now the ants are going really fast.
And now all the food is gone, the ants have nothing more to look for,
so they are just moving around randomly.
So I'm going to click on "Go" to stop it, and you can see according to this plot
that the ants found all of the food
by about we can see what time-step it is,
about 900 and something time-steps.
So that's with this setting of the parameter.
We actually can change this a little bit, so what happens if we
increase the population size?
So I'm going to move it all the way up to the maximum of 200.
I'm going to click "Setup" again, and then "Go".
And we'll see if that changes the behaviour.
Of course, there's a lot of randomness in this model.
The ants are moving around at random until they find some food,
and they follow the trail if they encounter it.
And we can see that when the population size is higher, that it looks like,
at least on this run, they found all of the food much faster.
But since there is a lot of randomness, you'd have to repeat these
runs may times to get some statistics to see if they really are
finding the food faster on average when the population is higher.
That's one of the great things about NetLogo is that you can
develop these models, and then you can do experiments on them,
using these various interface components to set different variables.
A useful thing I should point out is this "Help" tab in the menu,
which allows you to go to various resources for help,
particularly, the NetLogo User Manual, and the NetLogo Dictionary.
So if I click on the User Manual, it goes to a web page,
which gives a set of tutorials on how to learn to program in NetLogo,
and lots of different reference tools.
So let me come back to this. So we have looked at the "Interface",
and the "Info" tab, so let's look at the "Code".
So the code is written in the NetLogo Programming Language,
which is it's own language, it's very easy to learn.
We will be learning a little bit of it in this course, not all of it, of course,
because that would take it's own entire course, but you will get a feeling for
how to write these models, and how to debug them, and how to run them.
For those of you who are interested, NetLogo itself is based on Java.
It's written in Java, so that's what's sort of under the hood here.
But you don't need to know that to use and program NetLogo.