 So, without further ado, here's a brief look at what we're going to cover in today's session. So we're going to open one model called CSV model in NetLogo. We're going to talk a little bit about navigating tabs and what's in the tabs. We're going to run it as random right to a CSV file and read from a CSV file. We will also open a second model in NetLogo called GIS Commute. We will run that as random with various settings. We'll look at the code and folders for data files, and we'll run that same model with non-random settings. So that is with settings that are created by importing shapefiles into NetLogo. And then there's time for questions. Hopefully, everyone who's joined in this session today will have followed the instructions in the email I sent out to have downloaded an installed NetLogo and run through some of the sort of basic tutorials that I linked to in that email. And we'll have downloaded these models from our GitHub repo. If not, please find that email and get on with it. Otherwise, you're going to really struggle to keep up. And at the end, there is an evaluation. As Sorcha mentioned, please do fill that out. So I'm going to just stop sharing my PowerPoint. And then I will reshare my screen in a moment. But let me close PowerPoint first because otherwise it's going to try and take up all my bandwidth, not literal bandwidth, metaphorical. There's a question in the chat. Let's just address that real quick. OK, no, looks like not. So I will share my screen again. And we'll start with let's go with the CSV model. Right, so this is what it looks like when you open up the CSV model in NetLogo. It looks very blank. Don't feel intimidated about this. It's fine. This model can also be found if you go to the file command models library. Code examples, I believe it is extension examples, CSV, CSV example. This is the same thing, but I have edited the code slightly to make it clear what we're doing. So I will skip that. I will point out you can open and play with any of the models in this model library. And all of the ones here in the code example section are really very, very minimal working examples of how to do a particular thing like import CSV files or write out to CSV files. All of the ones in sample models are a bit more geared towards investigating an interesting question. Have a look through the models library. You cannot break anything even if you absolutely mess it up. It will not mess it up from the models library. You can always get it back the way it was. So the first thing you generally do when you open a model is you look at the buttons. So setup is an easy one, but it doesn't look like anything has changed really. These buttons were grayed out and now they're clickable, but we don't kind of know what's going on here. So let's look at the info tab. This tab gives us a little bit of background about what this model is and what it's supposed to do. And you can read through this, but it's quite, there's also things to notice. So these are maybe buttons you should pay attention to in this model. Because this model is such a minimal working example, there is very little written in the info tab. You can also look at the code tab. You can see at the top that it calls for a CSV extension. And here's the one of the things that I've edited in this code as opposed to the one you get from the models library. So I've added this little code about open it, navigate tabs, run as random, write to file, read from file, experiment with a new CSV file, question mark, that's if we have time. So these are the tabs, interface, the info and the code. So let's start with interface, generate turtles. Now this creates a random placement of turtles. Side note, in net logo, agents are called turtles. It is just one of those like historical features of the programming language. This puts them just about anywhere you want. Now if you want a copy of where those turtles are, what size they are, what their orientation is, what their heading is, all of these things, you can click write turtles to CSV. But let's just double check what write turtles to CSV actually does. What it does is it uses the CSV extension to file turtles CSV. So this means it creates a new CSV file called turtles.csv that lists the x-coordinate, y-coordinate, so the x and y location of each turtle, the size, color and heading of each turtle in that order. So if we do this, write turtles to CSV, we saw the little green, sorry, blue circle saying, oh, it's done something, but nothing has changed in our, on our interface tab. That's because writing to a file is not something that's visible in the interface tab. If we were to navigate to where this NetLogo model is stored on our computer, we would then see the file generated. Let me see, I think I'm sharing this window rather than this display. So let me stop share, I'll switch to share the display. No, sorry, there we go. And this means when I change to a different model, it will change with me. Now I could open up that folder, let me go ahead and do that. And you should see this, Sorcia or Joe, let me know if you can't see this. So now I have a folder here called turtles and it is a, let's see if I can change this, comma separated values file. Now this was just created just now and that shows that it was an output of me having clicked that button in the CSV example. Now you think, okay, this is quite boring. Let's ask turtles to die and let's do it again, generate turtles. Now these are all random, so they're in a different place. I will write turtles to CSV and switch back to here. There's now a new folder, it's overwritten, so this is important to know. It overwrites that file rather than creating a new file. If you want to create a new file with a new output, you have to specify your right to CSV code differently. And we'll talk about that a little bit more in the second model that we look at. But what about this, what about this read turtles from CSV? Let's go back to the code and look at the command read turtles from CSV. This asks file close all, so it closes all open files. If it just double checks to make sure that this file, turtles underscore gridlike.csv exists, if it does not, it gives me an error message saying this file doesn't exist. Actually, this should say turtles underscore gridlike. Oh, would help if I could spell like, save that. So I've asked for this file. It says no file with that name, try pressing right turtles to CSV. But if that file does exist, then it opens that file and iterates over that one row of the file at a time, creating a turtle in that location. So the location of item one for x-coordinate, item two for y-coordinate, sizes three, colors, well, starts at zero. And then finally, heading. So what do these files look like? That's a good point. We didn't open turtles.csv, oops, would help if I double clicked, recognizing it properly. The random file that we exported when it created it randomly gives us these five columns. So the x-coordinate, y-coordinate, size, color, heading. So if I do turtles gridlike, what does this look like? Well, it's going to be in the same format. It's going to be x-coordinate, y-coordinate, size, color, heading. So the same setup as the output, but this time it's going to take it as input. So let's go back to the interface, read turtles from CSV. So now gives me this much less random set of turtles that are in x-coordinate and y-coordinates that are broadly gridlike, but the heading and color and size is still quite randomly distributed. Now if I wanted instead of gridlike diagonal, I happen to know that I have a second file in the same folder called diagonal. Just double check to make sure my code is fine. I will set up, that clears everything. Read turtles from CSV, oops, don't know why it is still, oh, I didn't save, that's why. Always save, nope, still not. I don't know why set up, diagonal, oh, because this one still says gridlike. Right, there are much better ways of doing this. As you can see, me manually changing three things is not great. I should have an interface button here where I put the name of a file that I think should exist and it uses that for all of those positions. But instead, this time, they're all appearing on the diagonal. They're still quite random for color, heading, and size. But their locations match the inputs on a different input CSV. So I want everyone to feel free to ask questions. You can turn on your mic if you want, you can ask them in the chat. Try and do this, try and open the model and change from gridlike to diagonal or diagonal to gridlike or in fact, turtles with no underscore gridlike or underscore diagonal. And you can import the random out port that you had saved from a different run. So I want everyone to have a go at that. Try letting me know, do you have any questions, any comments? Oh, I've got, I should turn off my break reminder because otherwise it'll tell me, stop working so much, you need to take breaks. It's an RSI program. Right, any questions? Does anyone need me to explain any of these buttons again or explain the code tab? Please let me know if you cannot even open the folders. If the whole thing has set your computer on fire, you're allowed to tell me that. I don't think I can help you, but you're allowed to tell me. Getting a deafening silence from everyone in the Zoom. Which is, here we go, there's a question. Okay, if each turtle has an X and Y coordinate, does the diagonal function remove those not on the line? I'm confused about what that is showing. No, each turtle does have an X and Y coordinate. And that's true no matter where in the model they are. So when I generate random turtles, these also all have an X and Y coordinate. You can see this by right clicking on them and inspecting the turtle. Let's have a look. This one's X coordinate is this massive number, negative 2.58 and a whole lot of things. And its Y coordinate is 14.46 and a whole lot more things. What happens with diagonal is that we are asking the model rather than randomly generating turtles everywhere with X and Y coordinates, we are asking it to only create a turtle in the location where there is an X and Y coordinate specified on this input. So what the model is doing is it is finding a file that matches the right name that I've given it in the same folder as the model because I'm not specifying subfolders. So here's my CSV example, here's my turtle's diagonal. So in here it's saying create a turtle at negative 16, negative 16, make it size 2, color 75, heading 176. Create another turtle at negative 15, negative 15, make it size 5, color 115, heading 318. Does this make more sense? So the file, because I've told it create turtles from this file, this file called turtles diagonal, the model is going through this file one line at a time and creating one turtle for each line of this file. So there are 33 turtles in this file and 33 turtles and they are all on this line, not because I told it to make diagonal turtles, but because I told it to make turtles from this file and I've called that file diagonal and in fact all of those turtles are on a diagonal line because when I created that file I picked negative 16, negative 16, negative 15, negative 15, negative 14, negative 14, that kind of thing. When I open turtle's grid like, in this case there is still a turtle, yeah, sorry, there is a turtle at negative 12, negative 12, same as in the diagonals, but there's also turtles at negative 12, 0, 12, negative 4, 8, negative 4. So this is what creates the grid pattern instead of the diagonal pattern because the input that I've given it is saying where to put the turtles. So hopefully that answers your question. Please let me know if it is not properly answered or if anyone else has other questions because that's a good question. It's not always, it's clear to me because I've been working with this for a while that when I say open this file, read it line by line to create turtles, that makes sense for me but I'm very used to the command's open file, create turtles. If you've not worked with NetLogo before that won't make much sense. Julia? Yes. I just wanted to say that actually attendees can't turn on their microphones. Oh right. No. Okay. I'm going to use the Q&A for shorter questions. If someone does need to go on the mic, I can sort of change them to a panellist temporarily but just in case anyone's wondering why I ask questions that way, my bad. Sorry for the confusion there. Yeah, if you do want to turn on your mic and ask a question, you'll have to chat to Sorsa in the chat function basically. Otherwise, yeah, you can just write them into the Q&A function and let me know that way. I'm happy to read out your questions and answer them. I'm happy to listen to you ask your questions directly. I'm quite flexible in this way. Let's go back to the example. You'll notice that when I have all the diagonal turtles on and I ask it to generate turtles, the diagonal turtles are still there because I have not asked it to kill the turtles. Likewise, if I ask it to generate and then add the diagonal, it does that. So whichever order it comes in, you can do that. You can access the data for the turtles in the GitHub. I linked to this earlier, but maybe one of my team members wants to share the link. It's fairly straightforward. github.com, UK Data Service Open agent-based modeling. Within that, there's a folder called 2022 Training Series. Within that are folders for slide decks, the GIS commute model, and the CSV model. Right now, we're working with CSV model, which contains files, including turtles diagonal and turtles grid-like, which you can upload to the CSV example. So you can, of course, create your own file if you want to create exactly one turtle and in exactly one place. You can do that. You could, for example, take one of these folders. Let's save as just underscore one and just delete everything. Maybe let's put this at the origin, which is 00. Make it big. And let's save that. So now let's go back to our model. So now just one is here. It's also a comma-separated-values file. That's important. And let's, where am I? If just underscore one does not exist, tell me there is no file called just underscore one. But if it does exist, open the file called just underscore one. Let's save. Let's just check the code real quick. This little check at the top. No errors flagged interface. Let's set up one, just one turtle. And he's big because I set size five. I could have set size 10. He could have made a massive, or her massive, them massive. I could have changed the direction. I could have changed the color. I could have done a lot of things. And you're welcome to do that. It's useful to play around with how what you do in a CSV file in a completely separate program changes what happens here in NetLogo. So that's another thing you can do as an exercise. So you could say experiment with making a new CSV file to read from. So let's comment this out. And I'll put just one. But you can make your own. You can make five. You can put them in a ring. You can, you know, put them in a zigzag pattern. You can make four, but one in each corner, whatever you like. It's useful to have a play around with this. And it is useful to always make sure you save changes to your local version of the file if you want to keep them again. If you think it's a real hassle to try and change all of those things, it's definitely something that you could do is create an input on the interface. So you might add input here, global variable, file name and encode instead of just, you know, in I'd have to double check on the dictionary. But actually, let's go to the NetLogo dictionary. The NetLogo dictionary, I recommended you bookmark it if you're working in NetLogo at all, even if you're experienced with NetLogo, like I'm looking in the dictionary right now, just control F input or whatever it is that you're trying to find out about. And, you know, user input, OK, reports the string that a user types into an entry field in a dialogue with title value. So show user input. What is your name? OK, interact. So I will grant you that this is not the most helpful example from the dictionary, but lots of things are helpful. What you would want to do is change the code so that instead of CSV to file, it says CSV to file user input dot CSV. I won't necessarily do that now. If you're interested, I can maybe do that live to Twitch or something like that. And you can you can watch me figure out how to do it live. I don't want to do it now because it might derail our entire session. So please do let me know if you have more questions about this or if we should go on to the tram commute model, because I think that will take much more time. So I'll give you a couple of more minutes to ask questions on CSV. I'll upload export model, but you if you don't have anything more to say about this, that's not a problem. We'll go on to the tram commute and and there will be time for lots of questions there. I'm going to assume that no one has issues with this, I guess. No one's saying any anything. OK, so let's go to the tram commute model, which is a much bigger model. If you'll see there's way more buttons here, there is an input value. So this value turns out to be what I want the export file to be named. So let's see, let's let's start off at the first. So again, there is an info time. What is it, how it works, how do you use it, things to notice, things to try extending the model, how to cite it, copyright and license, all this kind of stuff. I mean, for you as someone who's just getting used to the model, what is it is probably useful, how it works, how to use it and things to notice. A more advanced thing would be things to try, which is things like adapting the model for your own purposes and code. Likewise, it's a lot of code. It's a lot more code than the first one, but don't worry about it. We're not going to do that much with the code because you can change input and output variables quite easily by just replacing certain things in the code rather than writing code from scratch. So again, the workshop tasks are here. They will be open the GIS commute model in NetLogo, run as random, experiment with various settings, examine code folders for data files, run as GMLAs, experiment with various settings. This will be slow. I will warn you because there is a lot of data. If you import real world data, it tends to slow it right down. So you need to either have a toy version of your data where there's there's less of it or be prepared to let it run overnight because it can take a long time. And then we'll experiment with exporting data. So here in the interface, first off, I want to point out there's a drop down menu. You can choose GMLAs are that sounds for a Greater Manchester local authorities. I forget where the R comes from. Don't worry about it or random. So let's start with random. If you hit set up, it starts filling in a map. Oh, very interesting. Why has it done this? Oh, gosh, that's a lot. Your options are to go, which is a go for it's got this little like recycle logo kind of thing. That means it goes forever. It keeps running until it's something within the code itself tells it to stop or you can go once, which it just runs the model one step and lets you look at what's happened. And then you can run it another step and look at what's happened and run another step and look at what's happened. Now we'll point out the set up button is still blacked out. And the little wheel is spinning, indicating that the model is working at setting it up. So this is a much bigger model than the CSV example. It will take longer to set up. It will take longer to run. Don't worry about it too much. Let's talk a little bit about these other these things are switches that can be other on or off. Garrulous, you're welcome to experiment, but it will get annoying real fast. I use it when bug testing, because it means that the the model basically prints out everything that it does down here in the command center. You don't need it to run it. Label tram stops. I have as off label local authorities. I have as off reduced population for display is up is on because I want to have fewer going on. We've got a question. Does Julia have a cheat sheet for NetLogo functions? The cheat sheet is basically the dictionary. Oh, yeah. So if we go right to the top. You know, all of these things are commands in NetLogo. These are called primitives, which are things that NetLogo recognizes as a command. You can also create your own commands, but those are not primitives. So let's go right to the top and we can. Look a bit more about this. So the categories are things like things to do with turtles. Things to do with patches, things to do with links, agent set. Some of this will be more clear if you've gone through the tutorials because it talks about difference between patches and agents. Talks about control and logic. Talks about the world and the perspective. So yes, I do have a cheat sheet, but it's probably not as cheating as as you're hoping because it is massive. The NetLogo dictionary, right? Setup is finished. You can tell because the setup button is now blue again and the little spinning spinning circle is gone. So what I'm going to do is go forever. Importantly, I do want to point out off, export data is off. This means it will not write out a file and yeah, so this should be fine for now. So I'm going to let it go. And you can see, hopefully, if your screen, maybe I can make this bigger. Yeah, there we go, zoom in a little bit. You can see there's little green characters like moving around. So the little arrows, they're just like moving along on these. What are they doing? Actually, I'll tell you a little bit about the logic of this model is that each of these colored patches represents a local authority. And each of the... There's houses, there's tram stops, and then there's in places to go that are not houses. And the houses have agents in them at the start of the model. And what they do is they find their nearest tram stop, they go along it until they get to the place that they want to go and then they get off, spend some time there and go back. Basically, it's a commuting model. This is really hard to see. So how about we reduce the number of generated authorities? Let's go down to three. And let's say there's only 15 tram stops and let's say there's only 50 people. So these are settings that I'm changing and the number generated places. Let's take that right down to, so there's 13 places. Let's set it up again so we can see the local authorities forming. So there's only two now because I specified only two. It also set up much faster, you'll see. These are the little tram stops. They're shaped like trains. Of course, trains and trams are similar. These are the institutions. The houses are covered in agents right now, but let's inspect a place. This one, I've chosen sort of a museum as a logo. Again, it's got an X coordinate and a Y coordinate. You know, it's a size three. I could have made that a five or a 10 if you wanted them to be massive. But it's fine. And let's look at some agents. Now I called them denizens for some reason because I thought it sounded like a cool word. So here we get a little zoom in on this agent who's located on a house. Again, there's an X coordinate and a Y coordinate. The who, every agent has a who, which is like its unique identifying number. So let's let this model go once. You can see that the agents have sort of moved off. Let's see if we can keep following an agent. So he's moved off the house and is now here. If we go once, oh, we're, you know, our little view is following him. As he or her, as he goes out. Now he's almost at a tram stop. Oh, I thought that was a train, but now it looks like a little fast food restaurant. And now he's on the tram stop and now he's traveling on the tram line to another tram stop and on tram line to another tram stop. And he keeps going along tram stops to tram stops until he gets to a bank. I don't know wherever he's going. So that's what happens when you click go once and you're following it. Live follows that agent. So you can see one agent moving around, which is obviously hard to see. Otherwise, if you just hit go, they're all zooming around. Little green, green arrow is just moving through the area. Okay. Any questions so far on random? So I'm not seeing any questions coming in. So I want you to, if you're following along, try exporting a random thing. You can export from the model you're already building. You can, you know, set up again. This time I've got three local authorities. So here we go this time. Now, because I've hit set up that old agent is now gone. He's dead. So you have to find a new one if you're going to follow a new one. But because I have export data set to on. And I hit go. Little agents are going to zip around. But this time their movements are going to be recorded in my export. Let's have a look at what is exported. Here we go. Random random one. And then a large number because I don't want the files to overwrite every time. So I have appended it with a little bit of code that keeps it. That essentially generates a sort of long random number at the end. Meaning trans or vet the output is very unlikely to overwrite previous outlook. Output. So let's open this and have a look at what's in here. Right. So what we've got is a commuter. So this looks like it's asking all of the agents, all of the denizen agents, all the little people moving around. To list the where they started, where they're going. Sorry, the local authority of where they were going, where they were. Let me try again. Each agent lists his own name, which in this case is a number. Which house he started at, which local authority he started at, where he was going, the local authority of where he was going, and how long it took him to get there. Now, if we, this is commuter number 205. Let's see if we get 205 anywhere else. Ah, here he is. So this time. 205 started at 81. Went to 93. And it took him 16. Time steps to do that. So this time, instead of going from home. To, you know, the bank, he went from the bank to his office or, you know, the shopping mall or whatever, wherever these little digital agents are going. And it took him longer. Let's see if we can find, do we have any other 205s? Yep, here he is. This time. Started at one place. Went right back to it. Two steps. So he just stepped away and came back. Maybe he went out for a cigarette. Maybe he just grabbed, you know, some fresh air. Maybe he had like a really infuriating phone call at work. He just needed to like go look at a flower outside the building. You never know. So that's what this. Output looks like, because in this model. I ask every agent as soon as he gets to where he's going. To add a line to this output. So there you go. Any questions. You must have some questions. This is covering a lot of ground. I'm astonished if you don't have questions. Why don't you have questions? All right. Don't got them. You don't got them. Let me know if you do. Right. So I'm going to. Turn off the export. And this time. Set it up with. Well, I'm going to give you a little bit of time to play with these settings. To change the number generated local authorities. You know, Pardon me, the number generated tram stops, number generated places and the max random population. You know, we, you can play with a label local authorities. I think in random that only like gives them labels. The number. So zero. And one. That's a little thing. But play with those a little bit. Have a look at the export. You can click go once several times if you don't want to just let it run on and on. Maybe you've got like a laptop that's already on its last legs and you're like, actually, I think it might be. Push it over the edge to do a lot of computation right now. But that's all right. Any questions at all. That looks like there was some discussion in the chat. No. Not really. Okay. In that case, if no one has questions about running. The tram commute model in random mode. I'm going to switch it to a greater Manchester local authorities. Now this is going to take a while to set up. So you can see it's gone black. Oh, there they are. The local authorities are labeled because I have this set to label. They're but they're labeling slowly because this is a slow process. They'll come up. Don't worry. They. This process is derived. By feeding it instead of CSVs like we fed the basic CSV import model. This time we're feeding it shape files. Shape files are. Like CSVs, they're great big lists of coordinates, but instead of just. Being. You know. X, Y size color heading, they are like. Lots of coordinates to delineate the outline of a polygon and then they also feature things like the shape files. So I'm going to go back to that. The location of that pop polygon. I have accidentally labeled the tram stops, I think. I don't know why did this is just filling up with. Rochdale and old them. So I'm going to. Probably reinitiate this in a minute because this looks ridiculous. Also because I have tram commute only. It is only considering local authorities that have. Metrolink stations. They have to get left out. It's a shame that people in Wigan Bolton and Stockport cannot travel by Metrolink. At least not easily. They would have to tram travel into another local authority. Let me. Not label. That I mean set this up again. It'll look a little bit nicer. So while it's setting up, let's look at the code a little bit. This one. This one has three extensions. So these are three. Extra bits of code that we are requiring. Beyond the basic net logo. One for GIS that's needed for importing shape files. And W is for networks. And CSV is for importing and exporting CSV files. Now. Let's see. In this model, there's a lot of if then statements. Because it needs to know. If the little drop down menu on the interface, if it's set to random, you do a random setup. If it's not set to random, you do a input setup. So that input is then based on the input. The name. You gave it in the input file. So if it sets up random. It runs through this procedure, you know, sets the world to a certain size and it creates, you know, some random local authorities and it starts building them and it colors them in. What were you too much about that. If it's not a random input. If it's instead based on a coordinate system. What you do is you load coordinate system. From a folder. In this case, I'm telling it to look in a folder called model that data. And then you're going to find whatever was. In the drop down menu from projection. From the interface. And look for the dot PRJ. That's a projection. But this does. I've written a lot of help for this model because I know that we're using it as a learning exercise. This sets the coordinate system or projection for the whole model. So this is effectively. Like here, when I say resize world. Minus 90, 90 minus 90, 90. That's the how big the model sort of dimensions should be. In this case, I'm saying, I don't know how big it is. Look in this dot PRJ file and set it to be as big as that tells you it ought to be. Then. I tell it to load the model. Of GM tram stops dot shape file. This loads all of your. I also have. Tram lines current. That's a shape file. And GM local authorities. That's a shape file. So there's three shape files loaded into this model. One is for the outline of the local authorities. One is for the location of the tram stops. And one is for where the tram lines go. So these are three different kinds of objects in shape files. One is points. That's a tram stops. One is lines. That's tram lines. One is polygons. That's the outline of the local authorities. So that's a three shape files loaded into this model. One is for the outline of the local authorities. I want it to say. All three of those together. Consider the total outer edge. To be. Like the world envelope is everything. Needed. Size wise to fit all of those things. And then I start building things like tram stop connections. This comes from a CSV file. And that tells me which trams stops are. Connected to which other trams stops. So this is a lot to throw at you. I know, but I've already done it. You're welcome to play with it. You're welcome to try substituting other things if you want. So if you have another shape file that has, you know. The. Underground in London. You know, you can get shape files of London local authorities. You can get, you know, shape files of. You know, underground tram stops and underground. Tram lines. You can build your own version of this. If you want, it will not be easy. But you can do it. Okay. We've got two participants raised hand. You're welcome to submit questions. To the Q&A. Or you can ask. So should it turn on your mic. Just wait for those questions to come through. Either. Ask. So should it turn on your mic. Yeah. You can send a message in the chat. Asking sources. To turn on your mic. Or you can submit a question to the Q&A function. Either of those are options. If I don't know what your question is, I will struggle to answer it. Although I may hit on it accidentally. So I'll keep rambling. Yeah. When I press the GMLAs are, there's an error that said the file cannot be found. This probably means that you have not copied the files. The entire structure. Of the GitHub repo. Properly. So you might want to see from where your model is. Is it in a folder called model data. And the files are in there. So, for example, in here. My model is sitting here. There's a folder in there. There's a file in there. So you might want to see from where your model is. Is it in a folder called model data. And the files are in there. There's a folder in the same location. Within that is where I have all of the. Files that I'm. Um, referring to within the code. If you don't have all of this copied properly, then it will be tricky for the code to find the files. If you do have all of this copied properly. Um, I guess. Yeah, have you, have you changed the code in any way? Or is anyone else having the same problem? Maybe there's a another issue. So it looks like that one might be answered. Um, yeah. So back to here. So probably it's done loading by now it is. And you see this one is much easier to look at. Because I have taken labels off because otherwise it just, it's a lot easier to build up with labels because there are so many things in this model. If we look at this total population. That is, um. Yeah, that's the total number of agents. I believe. No, probably just, um, denizens. So there's also like thousand. Over a thousand houses. There's lots of places. There's tram stamps. It's, there's a lot of things. There's only going to hit go once because there's so many that it's going to be hard to see them moving. But you can hit it a few times. You can see the little greens moving around. They're sliding along the links. They're going places. They're probably going to the Lowry. It's a good place to go right by a tram stop. Um, that's a good question. The question is what software do we need to work with these shape files? There are lots of options. There's Gis and Q Gis are both files. Programs for working with geospatial. Um, files. You can also work in our. And depending on what you want to do with the files, I would recommend, like if you want to. I've included two different. Our scripts here. Um, that will show you how to open the GM LA's file. It either with, uh, RGDL. That's one package you can use to work with shape files or SF. That's a different package you can use to work with shape files. Those are both valid options. Uh, if we have time, I can open. The R studio and show you what these files are like, but they're also quite self-explanatory if you've worked with our, and they will look like craziness if you have not worked with R. So I won't go into it right now because, you know, it was easy enough to open the CSV files in Excel and show you what those, the contents of those looked like. It is not easy to. Show you the contents of shape files. If you've never worked with our. But do let me know if you're interested in seeing more of those. Essentially what these two are files show you is how to open the files. How to add a new column. How to create a small visual representation. How to, um, sort of edit the files a little bit and then save them again as shape files. So initially what I did when I got these files, I got blank shape files. They were just the shapes of the places. And I added a column that had population in it. So I found the population for each of these local authorities and added that in a separate column. And I refer to that in my NetLogo code. So any feature of those files, and you can look at those features in R or QGIS or something like that. You can specify in, um, NetLogo by referring to it. So when you import the shape files into NetLogo, you import all of the features of those files. And you can tell NetLogo to look within those features for things like, you know, the local authorities name, the local authorities population. These are features I made sure were in the shape files. And you can then work with those values within NetLogo. So all of my local authorities have, you know, if I inspect this patch, it recognizes that it should be called Stockport. Because when I created that patch, I told it to look at the shape file and look at what this space belonged to. You know, in terms of, according to the shape file, what part of the shape was this? This is the Stockport shape. Over here, you know, we get this house. I think the house is also, yeah, the house is also recognized what local authority they're in. This one recognizes that it's in Manchester. Because when I'm building those agents, I tell it to reference the shape file features. Hopefully that answers your question. It might just have confused you more. Do let me know. Any other questions? So again, you can output these things, which is probably more random than outputting random things. So you can say there are seven places in this. You can see seven. So I'll call this seven places set up once more. This will take a little while. Don't worry about these warnings. It's just telling you that reloading, hitting setup will not change the projection, which thanks, I didn't ask it to. I don't know why it gives you that warning. It's a really unhelpful warning. It's like when you open a door to get a warning that says warning, the door is open. Thanks. So while this is setting up, let's just have another quick look at the code. So there's separate codes to set up trams. And each of these also asks you, are we doing a random model or are we doing an input model? And then there's set up houses and places code. Again, asks you, are we doing a random model or a setup model? And as before, to set up denizens, you know, are we random? Are we created? There is a lot of code in here. I have also created a lot of commentary comments on these codes. So hopefully it is not as thoroughly confusing as it would be otherwise. Finally, there is a to go command. So when you hit go with the little recycle button, the go forever or the go once, this is what it tells you to do. The basic go process is ask the people if the distance between next location and your, basically if your is check, like, are you within one step of your desired location? If so, hop directly to your desired location. Otherwise, follow the path one step towards your desired location. So if the distance to next location is zero, you know, if they're at the next location, then essentially they reset the travel timer. They print, this is the export function. They print starting place, local authority of starting place, destination, local authority of destination, and the travel timer. The travel timer increases by one for every step they take when they're not at their final location. And then they set, you know, set destination one of my places. So basically they pick randomly from a list of places that they go reset their travel timer to zero and start heading off on their next location. Obviously, this isn't totally accurate to real life people. Many of us spend time at locations rather than immediately heading off. But we are not necessarily trying to be accurate. We are trying to be interesting. Like in this case, we're just basically showing how do you import shapefiles and make arguably reasonable questions about those shapefiles. In this case, like how long does it take people to get from one place to another using a tram network? It's an interesting enough question. If you wanted to be much more realistic about it, you could. You could certainly rather than local authorities and population by local authorities. You could have much smaller output areas that you get census shapefiles for much smaller output areas. And you could have those with the population per much smaller output area. And therefore it's much more accurate about where people start and where their nearest tram stop is. And, you know, maybe whether they're even likely to take the tram. In the model, everyone goes by tram, which is not realistic. But you could say, you know, if someone is within a certain distance of the tram stop and the weather is nice, then they go by tram. If they're beyond that distance or if the weather is terrible, maybe they go by car instead. You know, and we can try and explore what the traffic is going to be like on a given day based on where people are, how many people are there, the weather is like maybe curtain policies as well. If we put tram prices up or people less likely to take the tram. If we put parking prices up or people less likely to drive because they need to park and that's expensive. Right, so let me know. You can try exporting from a non random model as well. Let's go forever for, you know, I don't know. You can see how many ticks you have only eight ticks so far because this is such a big model. Time moves relatively slow. But sounds much more existential and philosophical than it is. It just means like, how long does it take the computer to ask every single one of those agents. And yet, if you if no, I do your turn and then and your turn and then your turn and then your turn. It just takes a while if you've got, you know, 1,374 people to ask. That's that's a lot of turn ticking. Right, do we have any questions? I think I might have scared you all because this is not a lot of questions. You can ask me questions about anything it doesn't have to be directly about this model it can be about net logo or anything else. I mean, I'm not guaranteed to answer all questions but. Right, so if we look in our top level folder. This is where our tram commute model is located. This is where it has put the export gml a seven places from 205 today. So, even if I were to export the same model again with no other settings it would create different things because there is still randomness within the generation process. And it would not overwrite this file because there is a random aspect to how this file name is created. Anyone want to ask me anything time do we have. Actually what time are we supposed to finish this is an hour session or an hour and a half hour and a half. We've got plenty of time. Please do ask. Go through some other models in the models library if you want to just see some stuff like this model is slow so it's a little bit hard to show you. Lots of interesting behavior. But it was important to show you that you can get really accurate maps in terms of where your tram stations are located where your local authority boundaries are by using real world data. That is more useful to people who work in social sciences for example, who know how many people, you know, are within the catchment area for this school or how many people visit that doctor's surgery on a given day. How can you get moving agents to interact with one another in this model you can't this model does not have agent interactions other models do. There's lots of models that do. Let's just pop into the models library. Let's just cut those changes. So let's say social system models cooperation, for example, that's probably that probably has a lot of interaction rumor mill segregation. Kind of you have to define for yourself what the interaction looks like. But let's go with actually bird flocking is a good one flocking. Okay, so what this is. It's a model of how birds that initially start out as random. We're looking on what we assume about their vision and how much how close they want to be to each other and how sharply they can turn how long it takes them to form flocks. And in this case, they're interacting in the sense that they're sensing each other so their vision controls how much how far ahead they can see. And they're how rapidly they can turn determines whether or not they're going to fall in line behind someone who crosses directly across them or who's just ahead of them. You can see pretty quickly. They start to form these like patterns where they're all closely following on to each other. And this is not only how they find the groups but how they stay in the groups. And this is a kind of interaction in that they're sensing each other and changing their behavior based on that. And if we look at the code for this. What it does is it asks turtles to flock that is a custom code to flock is find flock mates. So essentially it's saying like, is there anybody that I'm trying to be together with. If there are any, it finds the nearest neighbor, identifies the distance between itself and that neighbor and based on that distance, it will either move away that's got too close. It'll be like, oh, I'm slowing down a little bit. If it's not too close. It tries to join the same angle. And it tries to get closer. In this case, this is a certain kind of interaction based on vision and behavior. Other models will do things like where's the economics ones. I don't know. You can just search economics bidding markets. In this model, they bid. So essentially they say a thing someone else recognizes that thing and reacts to it. And then that person in turn says something back. Fruit Wars. I don't know this one. Non zero some economic environments encourage cooperation and discourage violence. Sugar scape is an interesting one. This is about how regions build up to make use of local resources and how sort of chains of communities evolve. That's quite interesting. Definitely recommend you play with the sugar scape models if you're interested in interactions. Yeah, hopefully that answers your question. The short answer is how do you get moving agents to interact with each other is you have to make sure that they have code that tells them how to interact with each other. The tram commute model does not have that code. Lots of other models do and you can look at those models to see how they do it. Anyone else have questions. Anyone else want me to open any of these other models library of course you're welcome to play with the models library on your own. Really you cannot break it. Even if you, you know, open up a model like sugar scape. Go to the code. Delete it all. You can't permanently delete it for everyone else. It's fine. It doesn't matter. You can you cannot mess these up. You can always restart them. So when if I were to shut this it would say do you want to save these changes. And if I said yes, it would save them locally to my computer. It wouldn't save anything like on the the big net logo servers. So I could always go back to the original files. If I needed no problems. I will just discard them because I do not need those changes. Those do not help me. All right. Anyone have questions about creating input files or creating, you know, about exporting files. We'll talk a lot more about exporting in the next workshop in two weeks. Because in that one, we will look at the behavior space, which is how you set up experiments to run automatically. And within that you can automatically get a report from each experiment. It will export things. You can also, as in this case, create reports cumulatively throughout the run by asking agents, you know, Oh, have you reached your destination in that case, log your journey? You know, just write a quick file log on your journey. But yeah, it depends. So maybe you want to tell me about some of the research questions you have or things that you would like to use agent based modeling for. And I can maybe talk about some of the models that that might be useful or some of the concepts that might be useful. I'm shutting that logo though. So I'll open that back up. I'm astonished that there aren't more questions. Because I would be baffled at this point. Let's go with some models from the library. I always quite like fractals. Oh, you know, cellular automata. These are good ones. Not quite what I meant. Let's say setup. See if this is going doesn't seem to be that is not the model that I thought it was. Now, I will open a different one. There we go life. Okay, in this model. We have patches rather than agents. And these patches interact. So each of these patches looks around at its neighbors. And if it counts so many neighbors that are red, it turns red. And if it counts so many neighbors that are not read, it turns not read. So let's we can see each one of these. Oh, yeah, you know, it's changing based on what's around it. But if we go forever, we see interesting patterns forming, including ones that perpetually cycle through certain kinds of called like stars and spinners. You get ones that are called gliders that you'll just see. They keep going across the screen. You'll get, you'll see ones that perpetually form gliders. And you'll see some of them burn out. You know that the interactions just work in a certain way that they die out. They are no longer dynamic. And you can see like this sort of creeping thing is wiping out some of the ones that were there. There was spinners there and they're they're gone. Oh, is this guy going to eat these spinners? It looks like he is. Yep. And now they're dead. You know, they're digital patches. They're not really dead. Maybe that's a big exaggeration. An interesting sort of way of showing that even patches that do not go anywhere and do nothing but turn from red to blue can still show interesting emergent properties like remaining within this sort of semi stable continuously spinning pattern. So we can set it up random again. Again, go forever. We'll say we'll see some of the same patterns. You still see some of those spinners, but not in the same places necessarily. You know, and that's, it's just that's the look of the draw sometimes. It's also the option to draw, which means you can just add your own in there. But if you just add random dots, they pretty much die out instantly. If you add big solid shapes, they can die out too. Oh, there's a glider. You see him moving. There he is. There's one. Oh, they go so quickly. As soon as you see him there, they're gone. Yeah, so it's interesting stuff. This one I quite like. Yeah, as a model I quite like life. Right. No one has any questions and I'm starting to wonder is this because I'm talking too fast or I'm being confusing. I'll stop sharing my screen and I will stare directly into the camera. Any questions? All right. Seems not. I mean, you can probably go early if you want, or I could open the R script if you want to see what the R studio scripts look like. Oh, got a question. Can you go through a little bit more detail about the code in the commute? Sure. Let me just open that up. Right. The code in the commute model. I mean, I've been working a lot with NetLogo and it took me, I don't know, a few weeks of solid being furious about it not working the way I thought it should. And then I got it working and then something happened to it and it stopped working and then it's back to working. So I do not feel like this is a typical starter model. This is not something I would recommend to people who have no experience with NetLogo set out to build for themselves as a first time. Let me share my screen. Okay. So here we are back with the commute model code. Let me know exactly what you want to know about it because there's a lot I can talk about code in general, or I can talk about this particular code, and I'm not quite sure what you want. So globals are variables that are set at the level of the entire model per run. So things like the output file name, this comes from an input. This is something that I determined by writing into this file here. I could call it wibble, at which point the global variable would be set to wibble. I could call it, you know, potato, and that would be what the global variable output file name would be set as. Others are based on the internal functioning of the model. So things like the tram stop data set comes from either the tram stops that are generated through the random creation functions or the tram stops that are fed to it by input. Okay, please show GIS load coordinate system command. It throws a runtime error exception for me with file not found. Again, I would say if you're getting a file not found, the problem is not necessarily the command. It's where you have your model located in relation to the file. But let's see. GIS parentheses load phrase not found. Let's just try load. Okay, load coordinate system. Let's close this. Okay, this is part of the setup input. So if you do not have your tram commute model, the this is the net logo file, if you do not have that located in a folder, which has a sub folder model data. And within that sub folder has the, you know, GLRAs dot PRJ, the tram lines current shape file, the tram stop shape file, all of these things are things that this code calls on. So it's going to call on dot PRJ dot shape dot shape, all of these things. Now, if you don't have it set up in the same relative location, so a folder called model data with the, you know, the different PRJ or model data tram stops. It won't find those files. It won't understand the directions you're giving it. So what you need to do is either put it in the same folder as those things and take this part away so that it just looks like, just looks like that. So load tram stop, dm tram stop stop. Or so you either need to put it into the right structure or change this code so that it matches the structure you have. Hopefully. Well, it's possible that you're missing a file. It depends on how, how your cloning works. Does it tell you which file it's missing? In theory it should tell you the error message should say which file is not found. That might help. But yeah, it's possible you can clone sub folders from GitHub and not the entire thing. But hopefully your error message tells you which file is not found. Barring that you can, you know, change the code to match the files you do have. So if it can't find, you know, gm tram stops dot shape, then name something that it can find to gm tram stops dot shape, or change this to the name of your file. That is one of the complications of working with external data. So CSV files or dot shape files or dot prj files is that there is the added complication of making sure that the folder structure is properly maintained so that you can your code can look around it and find the things and get the things that it needs from the different folders. Yeah, I don't know Joe, have you tried cloning the GitHub? Did you have the same problem? Is this a problem with how things are stored in the GitHub repo? Hello, sorry, I was demoted to an attendee so I could ask questions. No, I haven't tested the GitHub, so not sure if it's your issue. Okay. It seems like more than one person has had this question of not finding the files. So, I don't know, it might be worth testing, but... Yeah, we can make a note to look at it after this and see if we can recreate it and then the GitHub will get an update if there's a problem. Yeah, if you're following the GitHub repo, it would show any updates that I make. So I can definitely, you know, we can test it on our own and maybe reload the, you know, update the folder structure to make sure that it works. Alternatively, yeah, you might just delete your copy of the GitHub repo and try reinstalling it to see if maybe it was just that it hadn't copied the full structure properly. I don't know. Yeah, any other questions? Defining silence. We've only got four minutes left, so there's time if you have questions. You are, of course, also welcome to send me messages, either emails or tweets, or you can comment on things in the GitHub repo. If you get it working, you can try pushing to the GitHub repo, you know, you can... There's lots of ways to interact. Yeah, I mean, in theory, though, I mean, there's... There are also model library... I'll discard these changes. There are model library examples of GIS extension. So in addition to mine, mine uses both CSV and GIS, and in theory addresses a social science research question about, like, how people move. But there are also other ones that just show you different examples of, like, how you can build maps based on GIS files. Mine is based on these, so it uses more or less the same basic code of loading a coordinate system. You know, and then sort of loading points, lines, and polygons and setting a world envelope to be the union of all of those things. But you might have better luck with this one because this one is being provided by the model's library. You won't struggle to find the files because the files are already built into NetLogo, essentially. So you can play around with how you add different kinds of things that you can label. You know, you can switch to highlight large cities. Why is there one in Antarctica? That doesn't seem right. Set up highlight large cities. There we go. You know, display elevation, countries using links, I don't know, display cities. Yeah, so this, you know, there's different model libraries, model's library code you can use as well. There's a gradient example. This one, if I remember correctly, is about watersheds and water flow. So you can sort of see, you can make it go. You can see how if things fall on something with this shape, where do they go? And this is a little bit like, you know, people, if people move to an area where, how are they going to travel? What roads are they going to use? What tram lines are going to be the most sensible for them to go to? Things like that. So it, although this one is based on a very sort of physical science kind of concept, the broad applications can be applied outside of the initial scope as well. All right. Any further questions? Oh, got some in the chat. All right. Well, I think that's the end of it. That's our hour and a half. So it's been lovely speaking to you digitally. And I hope you learned something about using models that read and write to CSV and that input shapefiles to do things based on the real world. If not, you know, don't worry about it too much. There's always time to come back later and see more explanations from other people or from me in the future. In two weeks, we will be looking at creating experiments in a NetLogo model and how you can export the results from those experiments to CSV.