Output in NetLogo

This presentation discusses interface output in NetLogo. Being able to get data is one of the most important things when you're modeling. This presentation will discuss 2 easy ways to extract data from your NetLogo model. [Slide 1] Gathering data is an important part of modeling. The easiest way to do it is using the interface tab. There are 4 ways, or locations, on the interface tab where you can extract data. You can make a monitor, a graph, you can use the command center or create an output area. This presentation will cover the first 2, monitors and graphs.

[Slide 2] Outputting your data to a monitor is one of the easiest ways to extract data. It requires no commands in the actual code and you just need a variable name. However, it only outputs the current value of the variable, which is continuously updated as the model runs. Here's an example of what it will look like at the interface tab. [Slide 3] To create a monitor on the interface tab, you'll click the drop-down menu on the upper-left-hand-side of the interface tab, where the word button is probably shown, and select monitor in the drop-down menu. Then you will click on the interface tab where you want to add a monitor. Once you do that, the edit dialog box automatically opens. [Slide 4] This is what the edit dialog box looks like for the monitor that we showed before. You can see that there is an area in which you type the actual variable name and you can change the font size or the decimals that the number is shown too, if you like. You can also change the display name, so if you didn't want to have num_sick appear on the interface page, then you could say for instance number of sick in the display. Let's go take a look.

[Slide 5] Here we have a very simple NetLogo epidemiology program, in which we have a number of blue turtles, which represent healthy turtles and 1 red turtle, which represents a sick turtle. When we run the program, you see that the number of sick turtles increases and consequently the number of healthy turtles would decrease, but we can't actually monitor the number of those turtles because we'd have to stop the program and count the turtles every tick, so let's create a monitor. We go up here to the drop-down menu and select monitor. Then we can add a monitor to our interface tab. In this model, the number of sick turtles is represented by the variable num_sick, so we put that here. We could change the actual display name to be number of sick, which might make more sense. Now we can set up the program again. Number of sick is 1. We can see that as the program progresses, the number of sick turtles increases. We can add another monitor. This would be num_healthy. Okay. That's set up again. We have 199 healthy turtles and 1 sick turtles when we start. As we progress, the number of sick turtles increases and the number of healthy turtles decreases.

That's great. Now we can know at all times how many sick and healthy turtles we have, but we can't gather the time data we need from that. We would like to know how many sick turtles there are over time and how many healthy turtles there are over time. Let's go back and see how we could create a graph here in NetLogo. [Slide 6] We'll talk about how to put a simple graph on the NetLogo interface. Outputting a graph to the NetLogo interface tab is just slightly harder than outputting a monitor, but you can output more than one variable at a time in the same box and a line is drawn for each variable. Sometimes graphical information is easier to understand than a simple number because you can see the history of the output. A graph outputs the values of all the variables that are in the graph and it updates it continuously as the model runs.

[Slide 7] To create a graph on the interface tab, you use the same basic method. Click the drop-down menu. Select graph in the drop-down menu. Add it to the interface tab by clicking on the interface tab where you want it and edit the dialog box which automatically opens. [Slide 8] This is what the dialog box looks like. There are slightly more things that you need to put in the dialog box, but it's really relatively easy. Let's go take a look. [Slide 9] Here we are back at the NetLogo program, which shows an epidemic model and we're going to add a graph, so we select plot from the drop-down menu and add our plot to any white area on the screen, where we want to add our plot. This is the default drop-down edit dialog box that you get. We're going to change the name of the plot to sick and healthy turtles, set the X axis to be ticks and the Y axis to be turtles. We have auto scale on, so if we run over 100 ticks, which we're bound to do, it will automatically increase this number. We can show a legend.

We want to change our default values for our plot to count the number of healthy turtles, which in our program has the variable name num_healthy and we'll change the pen name to be healthy too. We're going to add a second line to our graph by adding a pen and change the number of that to be red and we're going to call that sick. We'll plot num_sick. That should be it. Let's see what it looks like. Here we go. The program is running very fast. We can see that we can watch how many sick and healthy turtles there are at any time on this graph here. That's how you add a graph to your interface tab.

[Slide 10] In summary, gathering data is an important part of modeling. There are 4 ways, or locations, that you can gather data on the interface tab. You can create a monitor, which is the easiest way to gather data, but this only outputs the current value of the data and it only outputs one value in each box. However, the data is continuously updated as the model runs. You can output a graph. You can output more than one variable in a graph at any time and it gives you a line for each one. Graphical information can be easier to understand and a graph provides you with a continuous history of the output. There are 2 other ways that you can gather data in the interface tab: a command center and an output area, but we'll be talking about those in a later video.

Thanks for your time.

Output in NetLogo / Page 1 of 3