 Today's lecture, we are going to look at modeling oscillations in couple of different systems. So, in this lecture, we are going to build a system dynamics model of a business decision making potentially resulting in oscillatory behavior. We are making this model, we will try to understand what causes oscillations, oscillatory behavior in system dynamic models. Let us consider a production inventory scenario, let us consider labor intensive industry as follows. A village cottage industry makes handicrafts, say dolls. The company's production completely depends on the number of people employed. Each employee makes 50 dolls a month and are contracted to do so. Since the sale is about 1000 lamps per month, the company would like to maintain 1000 lamps in inventory. The company adjusts any discrepancy inventory level within 2 months on an average. Based on the required production to fill the inventory gap, the company estimates the required people and hire or fire employees. The average hiring or firing delay is half a month. We would like to model and simulate this stock flow diagram over a 2 year period. Now, whenever we are presented with such scenarios, we would like to see what is the stock and flows within this system. Now, let us go back and read the description to see whether we can identify some stocks and flows. One of the obvious thing is, we can get an example of a physical inventory system is when you free this system, we end up seeing a lot of inventory, right? So inventory becomes a natural stock within the system. So inventory will be a stock. Now, if inventory is a stock, then something should be the flow into and out of the inventory. So, whenever sales happen, the inventory is going to reduce, right? That is pretty intuitive. So, sales becomes a flow out of the which reduces the inventory levels and what adds to the inventory, production. Companies production must add to the inventory. So, production is another flow that affects your stock of inventory. Now, what could be the other stock? In a company or a factory, whenever you can imagine a snapshot of a factory, only couple of things that you are going to see, imagine a photo that is taken of factory, you are going to see machines, you are going to see inventory of goods and you are going to also see the employees or the people. So, the next stock could be the employees or the people in the company. Let us see, based on the people or employees here, let us just circle, the employees as could be the another stock. And it clearly says that these employees can be hired or fired on a short-term basis. So, this hiring or firing is just the act of hiring or firing itself becomes a flow which is governed by hiring and firing delay, which is likely different. So, now we identified the basic stocks and flows for this scenario. So, let us go ahead and develop a stock flow model. Let us look at the stocks and flows, we have just written it, so let us just write it out, the stocks are inventory and employees, when the flows that is flow in to the inventory is going to be production, flow out of inventory is going to be sales and employees are going to be affected by the hiring or let us just call it as net change in employees. What do we mean by net change in employee numbers? So, this system pretty much captures the following. So, we have inventory, sales, production and here we have employees, let us just call it as net change in employees, just rewriting the stocks and flows in terms of the diagram that we are used to. Now, two things are going to happen if you are in this model, employees somehow is affecting the production and the sales or rather the inventory is somehow going to affect how many employees I need within the system. So, this stock is going to affect the rate at which the inventory stock is going to change, the inventory stock is going to affect the rate at which the employee stock is going to change. Now, let us see how that can be achieved, if you go back to the description, it says that production depends on, completely depends on the number of employee people employed, production completely depends on the number of people employed and each employee makes 50 dollars a month. So, if I know the number of employees and we already know their productivity, so the production can be easily computed by the number of employees times their productivity. Now, the company, the next bullet point, it says that the company would like to maintain 100 lamps in inventory, that means that is your desired inventory level in the company and if there is a gap between this desired level as well as the actual inventory level, it says the company would like to adjust its discrepancy within 2 months. This discrepancy means that if I have too much inventory, then I have to reduce my inventory level. If I have very less inventory, I have to increase my inventory level. How to increase or decrease inventory level? Sales is external to the company, sales is about 100 lamps and it is external to the company. The only way we can adjust the inventory level is by changing the production. Now, what changes the production? Production can only be changed by the number of employees because if you hire an employee, he or she is going to make 50 dolls a month. So only way is if I hire more people, if I want to increase my inventory level or I have to keep less people, so that I can produce less, hence my inventory level will fall down. So if based on the discrepancy inventory, we can compute what is the required production rate that is needed and based on that, we can estimate the number of required number of people and which will then result in hiring or firing, which will affect the net change in the employees, which will affect the employee stock. Now, if we model what I just told in a stock flow diagram, this is what you will see. So we have already seen the inventory production and sales as well as employee and net change in employees as the stocks and flows, let us see what is connecting them. Before that, let us go ahead and write some of the units. So the units of inventory, let us keep it as dolls, so that means sales is going to be dolls per month, production is also going to be dolls per month. Now desired inventory again is going to be dolls, inventory gap is nothing but desired inventory minus actual inventory, average time to close the gap, again it will be in months. We already know the values, the desired inventory value is 1000, average time to close the gap is given as 2 months. Now I have inventory gap and it can take 2 months to close that gap, so desired production can be defined as inventory gap divided by the average time to close the gap, so that is nothing but my dolls per month. So desired production rate is equal to the equations underlying it will be inventory gap over average time to close the gap, now let us go back to the left side, now we have something called as productivity, productivity is nothing but the number of dolls produced per person or per employee and the values has been given as 50 dolls per person. Now number of employees, the units can also be set as a person, thus the production is nothing but productivity into employees, but if you do that you can see that the units of production is actually nothing but just dolls, dolls of productivity, production is defined as productivity multiplied by the number of employees then the units is not going to match. Now in that sense let us actually observe what is happening with employees, the number of employees though it seems like just counting a person it actually varies monthly, so this stock the units of this stock actually has to be person per thus the units of net change in employees will naturally become person per month over month, so this employee stock now represents a number of people in that particular month, hiring and firing delay is goes a month is a units and it has been given as value has been given as 0.5, net change in employee is nothing but the desired number of people divided by the hiring and firing delay, now how do we get the desired number of people, I know how much the production rate we want, we already know that desired production rate and that if you get divided by the productivity we are going to get the desired number of people which will be nothing but units of it will be person per month, so desired production rate is in dolls per month it is converted into person per month through this productivity variable since we know each person is going to make 50 desired number of people can be easily estimated based on the desired production rate, now let us go ahead and try to simulate it, now first again note the model settings you will be using a small time step with RK4 integration to get a good precision, now when we simulate we would like to start the model at dynamic equilibrium, so to do that let us see remember the only values that we know are which has been explicitly given are desired inventory is 1000, time to close gap is 2 month, hiring and firing delay is 0.5 month and productivity is 50 dolls per person, now if it is dynamic equilibrium that means the system should start in a stable state or steady state that has to be no dynamic behavior that is observed, so that will only happen if inventory equals the desired inventory that means inventory value should also be 0, it should also be 1000, the initial value of 1000 is to start model in dynamic equilibrium, now to get the inventory of 1000 already no productivity is 50 that means the number of employees has to be 20, so now if initial inventory equal to 1000 and initial employee is equal to 20 the system will start in dynamic equilibrium, so if I start with this condition system will be dynamic equilibrium, now once we simulate that and verify our model is correct we can induce oscillations by say for example introducing an external spike in sales by say for example 20% increase in sales in week 5, currently the sales value is fixed at 1000 per month, 1000 dolls per month is initial sales value, so we will see what happens at 20% increase in week 5, so we will simulate both these scenarios using Vansum, now let us go to Vansum, opened inventory oscillations model is the exact same model we just saw, sales is constant at 1000 dolls per month, inventory initial value is also 1000 dolls, employee is 20 initially, productivity is 50 dolls per person month, time to close back is 2 and hiring of firing delays 0.5, now if we simulate the model you can see that the model will be in dynamic equilibrium that is the employees shown by the blue line is always at 20 and inventory is always at 1000 system is in dynamic equilibrium, let us induce an external spike that is a 20% increase sudden increase in sales just for one time period that is in time period 5 the sales went to 1200 units after that it fall back to 1000 units, so if we simulate that model first let us just check what happens to sales, sales just showed 20% increase in week 5 then fell back to 1000, let us see what happens to the system in that time until week 5 the system is in stable equilibrium but as soon as an external actually it is an unstable equilibrium as soon as an external force was applied or small perturbation was applied you can see the immediately the inventory level fell down a bit and then story started to recover just because inventory level fell down new people are hired they started producing more inventory and the result was the inventory overshot its target of 1000, inventory is on the right side Y axis, inventory overshot its target since the inventory was too high the company started firing people so they can produce less then inventory fell down lower than the target and as soon as it fell down the target people started to hire more people and so on and so forth resulting in oscillatory behavior over time, so these cycles are also it is a very simplistic model of a business cycle. Now we look at a model on how to build a system dynamics model of predator prey dynamics the graph here shows a dynamic behavior of the predator and prey population over 100 year time period on the left side Y axis we have the population of hare which is nothing but a prey to this predator which is a lynx which is a kind of a large cat whose population is shown by the red line as per the right side Y axis as you can see say for example the early part of the graph say in 1850s you can see here that there is a huge spike in the hare population but after sometime hare population started to fall this would be because the prey the predator that is the lynx started to hunt more and more hares as a result of which the hare population started to diminish as you can see it becomes easier to find their hares right when there are more hare populations easier to find the prey by the predator hence more were hunted the result was there is a natural reduction in the number of hares population which means a predator that is a predator is going to star which means that there is no more predators to hunt the hares and then the hare population again started to grow rapidly and as an as it started to grow rapidly become easier to find more hares by the predator which results in again higher hunting and that resulted in an increase and decrease in a oscillatory fashion or on a cyclic fashion of the both the population of predator as well as the prey. So, this is actually a classical predator prey model actually originally developed by Lotka and Voltaire way back in 1920s now we are going to build a SFD model of this predator prey dynamics. Now, let us look at some basic model assumptions. Let us assume that the prey population as ample food that the food supply of predator population entirely depends on size of the prey population right. Each prey gives rise to a constant number of of swing per year each predator eats constant proportion of the prey population per year that is doubling the prey population will double the number eaten per predator regardless of how big the prey population is. Predator reproduction is directly proportional to prey consume that is certain number of prey consume results in one new predator or in other words like one prey consume produces some fraction of new predator that is you know you need so many prey is to be eaten so the predator actually survives or the chance of predator to reproduce and the young to survive becomes higher and we also assume a constant proportion of the predator population dies per year or as a predator death rate is independent of the amount of food available within the system or within the habitat the stocks and flows. So, we will start with a very for predator and prey models the stocks could be the population of each of the species that is prey population is a stock predator population will be the stock and both these stocks will be affected by flows the prey population is going to be affected by the prey births and deaths prey births and prey deaths and predator population is similarly going to be affected by predator births and predator deaths this will be stocks and flows in our model let us expand a bit here let us expand it a bit and looking at as an SFD structure. So, let us so now we have a prey population prey births and here we have prey deaths here we have predator population so we predator deaths so we predator births. Let us look at all the assumptions that we stated a couple of minutes ago. So, first one each prey gives rise to a constant number of obstetrics per year so this is taken care of so 0.1 is covered here the prey population the prey gives rise to a constant number of offspring per year or constant proportion of offspring per year that can be simply directly captured with some sort of relation like this between the prey population and the prey births. Now, let us look at the last one the constant proportion of the predator population dies per year this again can be straight forward and given by this relation between the predator population predator deaths. Now, let us look at 2 each predator eats constant proportion of prey population per year. So, that means the prey population is somehow affecting the prey deaths. So, this is what is represented by point number 2 we have not explicitly captured it we need to capture it in some fashion we will come to that and in 0.3 the predator reproduction is directly proportional to the prey consume that means the predator reproduction that is a predator's births is directly proportional to the amount of prey that they actually eat. So, that means your prey are affecting how the predators births. So, this is your scenario number 3 of course there is something connecting both the deaths as well as the predators births because the prey population does not affect predator births it is rather the how much a predator how much of the prey is consumed is what is affects the predators birth. So, it is actually the number of prey deaths somehow is affecting the predator births through the prey population. To enable this interaction between the prey and the predator population we are going to introduce a new term or new variable in the model called as predator search efficiency. That means a predator can easily find a prey then they are going hunt more if it takes time or difficult to find prey then that means less preys are going to die. Let us see how it connects in the model. So, this is the classical model and the underlying math behind it. So, X is the population of the prey and Y is the population of predators. For the model purposes let us assume that preys are the rabbits and the predators are nothing but foxes the initial value of rabbit be 5000 and initial value of fox be 100. Now, the change in the prey population is affected by let us say dx by dt is alpha x minus beta x y. So, the first term here represents in both these equations the first term represents it is nothing but its birth rates and second term represents nothing but their death rates. Let us see what these constants represent alpha is a number of upstream per prey per year we can take it as 0.5, beta is the proportion of prey population consumed by one predator per year gamma is the conversion of one prey consumed to new predators will again assume it as 0.01 that is 100 rabbits eaten gives rise to one new fox or rather to sustain one new fox 100 rabbits had to be eaten. Delta is the proportion of predator population drying per year. So, now here we have got these both these represent your birth rates and both these represent the death rates. Delta as it clearly says is a fractional death rate alpha is a fractional birth rate beta is a new variable we are looking at called as predator search efficiency and this gamma is a conversion of one prey consumed in new predators we can call it as kind of conversion efficiency for that. So, let us take a look at how the SD model or stock flow diagram of the same is going to look like. Now the stock flow is going to look like this we have the rabbit population we have the rabbit population rabbit births rabbit deaths and a fractional birth rate and foxes search efficiency which is affecting the foxes birth rate which affects foxes population which affects the foxes deaths. Let us look at some of the let us now go to Winsome and look at the model. Now let us open Winsome and look at the model it is a predator prey model that we have seen. So, now let us look at the rabbit population let us take initial value is 5000 the units is rabbits rabbits birth rate is nothing but rabbits population by the fractional birth rate units is rabbits per year fractional birth rate is taken as 0.5 per year rabbit deaths is given as fox search efficiency multiplied by foxes population multiplied by rabbit population. So, you can see the foxes population nothing but the total population of foxes and rabbits right. So, this fox which results which gives us the total number of rabbits that is going to be hunted by all the population of foxes together. So, that is the rabbit's death rate per year. Now let us look at what is this foxes search efficiency is the foxes search efficiency is you know kind of a fraction or a proportion of the prey rather the rabbit that is hunted by the fox per year. So, here what I assumed it to be about 0.01 per fox per year which is quite a low number. Now moving on to the fox populations the foxes population again the units of foxes is foxes and initial value is 100 foxes death rate is a product of fractional death rate into foxes population foxes units is foxes per year and fractional death rate is taken as about 0.2 per year you know foxes population is also affected birth rates. So, foxes births is affected by 4 parameters foxes search efficiency multiplied by foxes foot conversion efficiency multiplied by rabbit population multiplied by foxes population. Now in this foxes search efficiency multiplied by rabbit population multiplied by foxes population gives the total number of rabbits death rate the total number of rabbits that is consumed. Now for that total number of rabbits consumed what is a fraction that helps in a new fox that is coming in. So, that is that we will get by multiplying the foxes the rabbits death rate by the foxes foot conversion efficiency. So, that is thus foot conversion efficiency is given as 0.01 of foxes by rabbits that is per how many rabbits are required for one fox to sustain and grow. Now let us simulate this model to see what kind of dynamics we encounter like both the stocks click graph and we have got a really interesting looking oscillatory behavior between two population of two species of the prey and the predator the prey of rabbits is the red and foxes is in the blue in the left vertical axis is the population of foxes and right vertical axis is the population of rabbits. Initially you can see that the fox population immediately starts to grow and that is at the expense of heavy hunting of rabbit population rabbit population starts to diminish really fast as and as you can see as population goes really low it becomes more and more difficult for foxes to find food right there could be very few rabbits left and it is going to be very difficult to find them in the forest where the foxes. So, as a result the foxes population also starts to decline as the foxes population starts to decline that means less and less foxes are available to hunt the rabbits that means whatever remaining few rabbits are there can sustain and can their population can grow and rabbits their population grows faster and they breed much faster as a result the population rapidly explodes to new highs as more and more rabbits are more and more rabbits are available in the forest the foxes whatever remaining will find food a plenty that means more new foxes can hunt rabbits easily as a result foxes population also slowly grow after time lag after the growth of rabbits population. But as a result when more and more foxes come into play hunting becomes excessive and the rabbit population again starts to fall down and then which soon follows followed by the fall in the foxes population and so on and so forth and so such kind of dynamics is actually common in nature it is not that the foxes and rabbit population remains stable throughout. In fact such kind of sinusoidal behavior or oscillatory behavior between the population of two species is actually quite common coming back to the slides again make note that the model that we simulated used a very small time step RK for integration and the run length of 100 years. The classical predator prey model we are just given the diagram here instead of calling it rabbit and foxes we can replace it with a very generic terminology is called as a prey and predator in this case we can extend the model to variety of scenarios. In fact the prey can actually be grass and the predator could be the say deer or rabbits which eats the grass or prey could be say deer and the predator could be the lions so on and so forth. But a similar structure for a predator and prey population will result in oscillatory behavior among the predator and the prey population. Thank you.