Professional Documents
Culture Documents
AnyLogic 6 System Dynamics Modeling Tutorial
AnyLogic 6 System Dynamics Modeling Tutorial
1992-2007 XJ Technologies
http://www.xjtek.com
Contents
CONTENTS ............................................................................................................................... 3 BASS DIFFUSION MODEL ...................................................................................................... 4 STEP 0. ANALYZING THE MODEL ......................................................................................... 5 STEP 1. CREATING A NEW MODEL ...................................................................................... 6 STEP 2. ADDING STOCKS ...................................................................................................... 8 STEP 3. ADDING ADOPTION FLOW .................................................................................... 10 STEP 4. ADDING CONSTANTS............................................................................................. 12 STEP 5. DEFINING INITIAL VALUES OF STOCKS.............................................................. 14 STEP 6. ADDING AUXILIARIES ............................................................................................ 15 STEP 7. CONFIGURING SIMULATION ................................................................................. 18 STEP 8. RUNNING THE MODEL ........................................................................................... 20 STEP 9. ADDING CHARTS .................................................................................................... 24
1992-2007 XJ Technologies
http://www.xjtek.com
1992-2007 XJ Technologies
http://www.xjtek.com
1992-2007 XJ Technologies
http://www.xjtek.com
2. Specify the name of the model. In the Model Name edit box, type Bass Diffusion.
3. Specify the location where you want to store your model file. Browse for the existing folder using the Browse buton, or type the name of the folder you want to create in the Location edit box. 4. Click Finish. New model is created. The diagram you see in the center of the workspace is the graphical editor. To the left of the graphical editor you can see the Project view, to the right - the Palette view, and at the bottom - the Properties view.
1992-2007 XJ Technologies
http://www.xjtek.com
1992-2007 XJ Technologies
http://www.xjtek.com
3. Once you have placed the element onto the diagram, it becomes selected and its properties are displayed in the Properties view. You can adjust element properties here as your model requires. Please note that the Properties view is a context-sensitive view and it displays the properties of the currently selected element of the model. To adjust properties at a later time, first select the element (e.g. by clicking on the element in the graphical editor) and then modify the required properties.
Properties view . At the moment view displays the properties of the currently selected stock variable.
4. Change the name of the stock. On the General page of the Properties view, type PotentialAdopters in the Name edit box.
1992-2007 XJ Technologies
http://www.xjtek.com
Add a stock to model adopter population 1. Add another stock in the same way. Place it to the right of the PotentialAdopters stock as shown in the figure below.
2. Name this stock Adopters. 3. Move text labels of the stocks above stocks' icons. Do it in the following way: first select a variable by clicking on it (if selected, it is drawn in a blue outline and its label is underlined) and then drag the label wherever you like. Place labels as on the figure below:
We need this since otherwise later these labels will be painted over with arrows pointing from one stock to other. At this point, the stocks are not defined properly. We have not defined integral functions and initial values for our stocks yet. But we will create the adoption flow first.
1992-2007 XJ Technologies
http://www.xjtek.com
4. You can have a look at stock properties now. AnyLogic automatically adjusts formulas for stocks. The value of inflows i.e. flows that increase stock value, are added and the value of outflows, i.e. flows that decrease stock are subtracted from the current value of the stock. In our case we should have the following formulas defined:
10
1992-2007 XJ Technologies
http://www.xjtek.com
We will define the formula calculating the value of the flow a little bit later.
1992-2007 XJ Technologies
http://www.xjtek.com
11
The rate, with which potential adopters come into contact with adopters, is assumed to be constant. So, we will define a constant to represent contact rate. Define the ContactRate constant 1. Define the constant in the same way. Enter the Name: ContactRate. 2. Assume a contact rate of 100 per person per year. In the Default Value, type 100.
In this model the volume of advertising and the probability that a potential adopter will adopt as the result of exposure to a given amount of advertising are assumed to be constant each period. So, we will add a constant to model the advertising effectivenessthe fractional adoption rate from advertising.
12
1992-2007 XJ Technologies
http://www.xjtek.com
Define a constant representing advertising effectiveness 1. Define a constant in the similar way. Name it AdEffectiveness. 2. Set the value to 0.011.
Define one more constant to specify the adoption fractionthe proportion of contacts that are sufficiently persuasive to induce the potential adopter to purchase the product. Define the AdoptionFraction constant 1. Name the constant AdoptionFraction. 2. Set the value to 0.015.
1992-2007 XJ Technologies
http://www.xjtek.com
13
The wizard listing model variables and functions appears. Scroll to the name you want to add, or type the first letters of the name until it becomes visible in the list. Finally, press Enter to insert the name. We do not need to set up the initial value for the Adopters stock explicitly since there are no adopters initially and the stock is already initialized with zero by default.
14
1992-2007 XJ Technologies
http://www.xjtek.com
Create the AdoptionFromWOM auxiliary 1. Do it in the same way except name the auxiliary AdoptionFromWOM and specify the following formula: ContactRate*AdoptionFraction*PotentialAdopters*Adopters/TotalPo pulation
Now we can formulate the adoption flow using just defined auxiliares. The two sources of adoption are assumed to be independent. Thus, the total adoption rate is the sum of adoptions resulting from word of mouth driven by the population of adopters and adoptions resulting from advertising. Define the formula for the adoption rate 1. Click the just created flow variable on the diagram.
1992-2007 XJ Technologies
http://www.xjtek.com
15
2. Go to the General page of the Properties view. 3. Change the variable name to AdoptionRate. 4. Specify the formula expression in the AdoptionRate= field: AdoptionFromAd+AdoptionFromWOM
Now we have completely defined our model. The stock and flow diagram of the model should look like as on the figure below.
You may examine the causal dependencies between stocks, flows and auxiliaries in your model. They are denoted with arrows as in standard SD notation. A thick arrow going from flow to stock means that this flow acts as inflow for this stock. A thick arrow going from stock to flow means that this flow acts as outflow. A thin arrow going from A variable to B means that A causes to change B.
You can see that our model has one balancing and one reinforcing feedback loop.
16
1992-2007 XJ Technologies
http://www.xjtek.com
A balancing feedback loop affects the adoption rate due to advertising. The adoption rate reduces the pool of the potential adopters, which in turn decreases the adoption rate. A reinforcing loop affects the adoption rate due to word of mouth. The adoption rate increases the adopter population, resulting in an increase of word of mouth, and thus the increase of the adoption rate.
1992-2007 XJ Technologies
http://www.xjtek.com
17
It is a simulation experiment, enabling model simulation with customized parameter values. There are also other types of experiments (optimization, risk assessment, parameter variations experiment), used when the model parameters play a significant role and you need to analyze how they affect the model behavior, or when you want to find optimal parameters of your model. If we start the model, it will work 100 time units and then will stop. Since we want to observe only how the model behaves when the adoption process takes place, we need to stop the model when the system comes to equilibrium. The adoption process in this model lasts something over 10 years. Set the model to stop at time 10 1. In the Project view, click the Simulation:Main experiment item. 2. On the Model Time tab of the Properties window, select the Stop model at specified time check box. In the edit box on the right, type 10. The model will stop after 10 model time units elapse.
Before running the model, we will set the real time mode to control the execution speed and, consequently, animation speed. In real time mode, the model is executed regarding the physical time. Set the real time execution mode
18
1992-2007 XJ Technologies
http://www.xjtek.com
1. In the Project view, click the Simulation experiment. 2. On the Presentation page of the Properties view, go to the Simulation Speed section and choose the Real time with scale option. 3. Specify the model execution speed, i.e., how many model time units will be executed in one second. In the edit box to the right, type 2.
1992-2007 XJ Technologies
http://www.xjtek.com
19
Problems view
After the model is successfully built, you can start it. Running the simulation, you automatically bring the current model up to date. Start the model 1. Click the Run toolbar button and choose the experiment you want to run from the drop-down list. Your simulation experiment is called Bass Diffusion/Simulation.
In the case this model is the only one opened in the workspace at the moment you will be prompted to run this particular experiment. Later on this button will start the previously run experiment. To run any other experiment, right-click the experiment in the Project view and choose Run from the context menu. Having started the model, you will see the presentation window. It displays the presentation designed for your simulation experiment. AnyLogic automatically places the show-bench title and the button enabling running your model and switching to the presentation designed for the Main class.
20
1992-2007 XJ Technologies
http://www.xjtek.com
You can see animated stock-and-flow diagram. Elements of the diagram match the system dynamics notation. The actual values of variables are displayed as well. You can adjust the execution speed to your needs using Slow down and Speed up toolbar buttons.
1992-2007 XJ Technologies
http://www.xjtek.com
21
AnyLogic supports various tools for collecting, displaying, and analyzing data during model execution. The simpliest way to examine current state and history of a parameter or a variable during model simulation is to use inspect window. We want to inspect our variables AdoptionFromAd and AdoptionFromWOM to view the contribution of different adoption sources. Inspect adoption sources 1. Click the AdoptionFromAd variable in the presentation. The yellow popup box will be shown. If needed, move it by dragging the toolbar of the window and resize it to the desired size by dragging the lower right corner of the window.. 2. By default the window is in inspect mode - it displays the current value of the variable. You can switch it to the plot mode by clicking the "rectangle" button in the upper right corner of the window. Now it shows the time plot showing the trend for AdoptionFromAd variable. 3. In the same way, open inspect window for AdoptionFromWOM and switch it to the plot mode.
22
1992-2007 XJ Technologies
http://www.xjtek.com
"Inspect" charts change scales automatically to embrace the plots, displaying the variables changing from the beginning to the end of simulation. We can easily see that when an innovation is introduced and the adopter population is zero, the only source of adoption will be advertising. The advertising effect is largest at the start of the diffusion process and steadily diminishes as the pool of potential adopters is depleted.
1992-2007 XJ Technologies
http://www.xjtek.com
23
2. Go to the General page of the Properties view. 3. Specify the data set title in the Title edit box: # of potential adopters. It will be displayed in the legend displayed for this data item in the chart. 4. Clear the Show at Runtime check box to prevent showing the data set icon in the presentation window at model runtime. Create one more data set for Adopters 1. Create data set for the Adopters variable in the same way and set up its title: # of adopters. Draw a time plot displaying adopter and potential adopter population pools 1. Choose the Time Plot element from the Analysis page of the Palette view.
2. Click the place in the graphical editor where you want to place the chart and resize as shown on the figure.
24
1992-2007 XJ Technologies
http://www.xjtek.com
3. Go to the General page of the Properties view. 4. Set up the charts time diapason. In the Time Window edit box, type: 8 (so the chart will display all the simulation run). 5. Specify data sets to be displayed on the time plot. 6. Add PotentialAdoptersDS data set to be visualized on this plot by clicking the Add Data Set button and defining settings for the data set in the property section above. Choose PotentialAdoptersDS data set from the Data Set dropdown list. Choose the first option from the Point Style drop-down list to turn off indicating data set values with a marker. 7. Add AdoptersDS data set in the same way. 8. Define how the plot will be updated with new data set values. At the botom of the properties page, choose Update automatically option and specify the update rate in the Recurrence (in time units) edit box to the right: 0.1.
Now you can run the model and examine the trend of potential adopter and adopter populations over time. You will see classic S-shaped diffusion curves.
1992-2007 XJ Technologies
http://www.xjtek.com
25