Hello everybody. Welcome to the second part of our tutorial on Agent-Based Modeling. In the first lab, I try to show you what some of the basic elements of the logo environment. And today, I have two main goals. The first one is to just show you how Agent-Based Modeling can be used to address real public health problem. Real obesity issue, and real obesity question. And also in addition to that show you some of more depths of Agent-Based Modeling in NetLogo and go to more of advanced types of the code writing in NetLogo. So, probably you remember from Dr. Jessica Espidion's lecture that it was about price and poverty or economics of obesity and how price can effect people's decision about food and the type of food. And if you notice there are very clear answer that probably is just very hard to understand from the real world. And the question is that, how actually people decide about the type of the food that they purchase and they consume. Is it based on price per calorie? Price per gram? Or price per serving? So this is kind of a very simple question to ask but probably very hard to answer, and today we just want to see how we can address that question in terms of Agent-Based Modelling. So we are going to walk through this current model, so let me just click set-up. So in this model we have an optional number of people in our population, and they have two options. Either they decide about their food based on price per gram or price per calorie. And I should also note that you will have access to these models in your course and you can download them and work on them on your site. So each agent has a specific budget in every day that can allocate to the food. And if it's price per calorie that is selected the agent is going to choose, prioritized food that has lower price per calorie. And if it's price per gram, the agent is going to prioritize price per gram ones. And the way that it works is that every agent at the beginning is going to follow the average diet, average percentage for each of these different categories of food. And then if the cost for that specific diet is higher than the one that that specific agent can afford, then the agent is going to adjust the percentage of the different foods that it's just going to consume. So let's just try price per calorie. I also have two options. Whether the price is going to change or it's just static. It's just fixed, doesn't change. For price per calorie, I already click set-up, let's just do it again. If I click on Go here, Let's just pause it. And you can see that here, I have 14 days of simulation for 9 categories of different foods. And this categories are based on USDA categorization. And you can see the different percentage of food that Asians are consuming on average, based on kilocalorie per day, and this is for the whole population. And for instance you can see that the consumption of grain at this round is at the highest level. And, then here, at the very end, we have fruits and vegetables. And if I change price per calorie to price per gram, then, let's just do the setup and let the population run. And now I'm just going to pause it, you can see that it's just a different pattern, right? And you can see that for example fruits are a bit higher here and vegetables as well. There are different ways that I can possibly as a designer of an Agent-Based Model use this model to answer the question that I have. And the question was that how people actually decide about their food, whether it is price per calorie or price per gram. And, one potential way of doing that is just by kind of having a specific number of rounds of each of those two options. Price per gram and price per calorie. And then, compare the average of this specific rounds. This specific two sets of rounds to what actually is observed in reality. And see that which one of them are closer to real patterns. And if, for instance, if it's closer to price per calorie, then I would argue that price per calorie is closer to what actually people use in their daily decision making about food. So I can also can change price in this model which we are going to also go to further debts in the code in a moment. I can also change the price and in this model the price is supposed to be changing in a monthly interval, so let's just make it back to price per calorie, click on set-up. When I simulate that by clicking the Go, you can see that the patterns are very different and here is about one month, and you can see that each month there is a very different pattern. The agents are following, here is just the third month and I'm going to do that also for price per gram. So I'm going to choose price per gram and price change is still on. And I'm going to click on set-up and then I'm going to click on Go to simulate that. And you can see that here, once again, we can see that there are some different patterns. And you can see that there are essentially very non-linear. Let's just pause it for a second. And it's just kind of very hard to predict what's going to happen. Now let's just go back to the code and try to understand how actually the model is designed. So as I said, I have two purpose of my lecture today. The second part is that you observe the code and have a better understanding of how an Agent-Based Model is usually designed and how does it work. So here I have a set of agents that I call them persons. So breed is usually used to refer to a new type of agents, persons, the whole population of them in person and I have a set of attributes defined for them. The amount of money that they expend on food on a daily basis here. Their gender, the daily energy intake on average. Food share is list that contains the number that shows the percentage of each of those categories of food for the energy intake of the agent. So here you can see those categories similar to the plot that you've seen. Milk, meat, eggs, dried beans and all the way to sugar. And here I have a set of global variables. The important ones are these two calorie average dollar and gram average dollar. This one is a list containing the price for 100 cube calorie, and this one is price for 100 gram. And one thing that I just want to emphasize here is that all of these numbers that you see in the model are brought from real surveys or real literature. So for example this one is coming from one of Gernovski's paper. And for example, the other one is coming from another Gernovski's paper. And you can see other links also in the code, and it's just the job of the designer. And if you remember from our lecture on Agent-Based Modeling, this is the job of designer. And should go to the literature and bring those number from the literature. So let's just move on for now. I have a set of procedure that, in the set up, the whole world are being prepared, than for the goal phase which is the simulation phase. So in the setup procedure first I created my list, and I created my agents, and just move them around the map randomly. And I also have a rate here 70%, so here in our model we are only simulating energy intake at home. We are not talking about energy intake outside home because it's just very hard to map it to different categories of food because outside of home you have labor costs, you have teams and other things. So we are only thinking about calories that are taken at home. And here the 70% shows that on average this amount of the energy intake are taken from the food inside the home. And then here we have our population, half of them are female, the other half are male. And then here also based on their gender they have a daily energy intake that follows a normal distribution. And once again, you can see that these numbers are brought from this source and they are also multiplied by this rate that I just set, 70% here. And here at the beginning I just want to make sure that prices are set up and I have price per calorie and price per gram, so let's just here go and see how do they work. I can do that here by clicking here on procedure and jumping to those procedure that I'm looking for, update food price calorie here. And you can see that, once again, some numbers from Gernovski's paper are used to create our initial price for 100 calorie, and here in this procedure price for 100 gram. So now let's just go back to the setup. And here, and I also have another procedure here set energy density that shows the energy density of each food and is used for calculation of the cost. Here you can see that similar to any good practice of developing and code writing. It's been tried to add as many other comments to the model, so that's also a good practice e to keep in mind. And then we have the go procedure here, so as I said at the beginning all of the persons in the simulations make their diet such that they just follow the average diet based on the survey data. And you can see here and go and look at what's happening actually, and then this procedure choose food, then what does it do? Let's just go, choose food which is here, and then if it's price per calorie then it's just going to refine food share based on the price per calorie. If it's based on price per gram, it's just going to refine food based on that list. So let's just go to refine food. Refine food here. And here you can see that, I don't want to go to details, but here you can see that If the cost of this food share that is allocated based on the average diet is higher than what actually the agent can afford then there are some updates happening here. Basically, if it's just price per calorie, those that have lower price per calorie will have higher number and those that have more price per calorie will have a lower number. So let's just go back to the simulation here and you can see that if the price change is chosen every month then price is updated. And then we have updating plot that just updates the graphs that you saw on the interface. And it just goes to the next day here. So, once again the importance of this example is for you to just recognize how Agent-Based Modelling can be used to address such a complex question of how people actually choose their food. So I'm encouraging you to just spend some more time on this model and just observe different patterns, probably get different results. One possibility, one good candidate here is to just go and see the variations for the whole population. Because this chart here on right, just shows the mean of population. Then it's just, could be like a very large standard deviation throughout the whole population. And that's just very good candidate if you want to do that. And also to see other patterns and recognize how these type of model can be used to address and answer original research questions of how people actually go and chose their food.