135
Introduction to Computing for Complex Systems (Bonus Online Content) Daniel Martin Katz Michigan State University

ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

Introduction to Computing !for Complex Systems!

!

(Bonus Online Content)!

Daniel Martin Katz!Michigan State University!

Page 2: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

System Dynamics Modeling!

Page 3: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

System Dynamics!

Just want to give you a quick taste !of the ideas !

Page 4: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

System Dynamics!

System Dynamics has a long history !

In 1950‘s Jay Forester of MIT Business School applied ideas in engineering to study business dynamics!

Professor Forester also responsible for inventing random-access magnetic-core memory (RAM)!

Page 5: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

Feedback Effects!

System Dynamics is interested in !systems that feature feedback effects!

Feedback = the return to the input of a part of the output (can be +, - or 0 )!

Page 6: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

negative feedback !

negative feedback --> negative if the resulting action opposes the condition that triggers it!

This class of feedback is often described as auto-regulating in so much as deviations from the equilbriua are dragged back !

Page 7: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

positive --> if the resulting action builds upon the condition that triggers it!

These are the more interesting class of effects !

Perturbations to the system can generate a novel set of outcomes!

Positive feedback !

Page 8: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

An Example of Feedback !

A positive connection: !”!

For Full Example: http://serc.carleton.edu/introgeo/models/loops.html

!“The positive connection for a cooling coffee cup implies that the hotter the coffee is the faster it cools. The variables Tc and Tr are coffee and room temperature respectively.

Page 9: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

a negative connection:!!

“the negative connection in the figure

below for a cooling coffee cup implies a

positive cooling rate makes the coffee

temperature drop.” !

For Full Example: http://serc.carleton.edu/introgeo/models/loops.html

An Example of Feedback !

Page 10: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

An Example of Feedback !

the two connect i ons are combined yield a !negative feedback loop !!

coffee temperature approaches the stable

equilibrium of the room temperature.!

going around the loop the positive connection

times the negative connection gives a negative

loop feedback effect. !

Page 11: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

System Dynamics!System Dynamics Models are typically represented by stocks and flows!

http://www.systemdynamics.org!

Page 12: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

System Dynamics!

Page 13: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

Exponential Growth!When you open exponential growth!

two windows will open!

Page 14: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

Exponential Growth!

If you double click these variable windows will open !

Page 15: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

System Dynamics!

Page 16: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

System Dynamics Version !of the Wolf Sheep Model!

You can explore the netlogo version of system dynamics !

However, if you are really interested in system dynamics you f i nd a lternat i ve s o f t w a r e t o b e easier !

Page 17: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

Some of the Alternative Software Platforms !

http://www.iseesystems.com/softwares/Education/StellaSoftware.aspx

http://www.vensim.com/software.html

http://www.berkeleymadonna.com/

Page 18: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

Vensim !

You can start with the free download: !

If this works well you can by an academic license for $89!

http://www.vensim.com/download.html

http://www.vensim.com/cgi-bin/ecom.exe

Page 19: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

To Learn More about !System Dynamics !

http://www.shodor.org/tutorials/vensim/

http://www.shodor.org/talks/ncsi/vensim/

Shodor also has a useful collection of sample models: !

Shodor is a national resource for computational science educat ion . The Shodor Website has a really nice Vensim tutorial:!

Page 20: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

The Advanced SIR Model !

http://www.shodor.org/talks/ncsi/vensim/

To Run !the Model !

You can overwrite the file if you like !

Page 21: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

The Advanced SIR Model !

http://www.shodor.org/talks/ncsi/vensim/

Move Around these Sliders !

Page 22: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

The Advanced SIR Model !

http://www.shodor.org/talks/ncsi/vensim/

You can Right Click !!(ctrl+click for mac) !! !

Page 23: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

To Learn More about !System Dynamics !

http://sysdyn.clexchange.org/road-maps/home.html

http://projects.ischool.washington.edu/ jscholl/Papers/DTABS01.PDF

Page 24: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

!Nova: A Platform

for System Dynamics!

!

Page 25: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

http://www.novamodeler.com/

Page 26: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

http://www.novamodeler.com/

Page 27: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

!Modifying the

Population Model!!

Page 28: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

Modifying the !Population Model!

• Before we build more models, let’s take a quick look at the model we created in Session XIV.!

•  If you no longer have access to that model, these slides should be sufficient to show you how you could go about modifying the model we built in class.!

Page 29: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

Modifying the !Population Model!

!

• Our old model displayed a graph that showed exponential growth in one population and had sliders that gave users the chance to select the growth rate and initial population.!

Page 30: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

Sub-Model!

Page 31: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

Main Level!

Page 32: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

Modifying the !Population Model!

!

• What if we wanted to compare populations with different initial populations and growth rates?!

• Would we have to create a whole new sub-model?!

Page 33: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

Adding Another Population!

• Thanks to NOVA’s hierarchical modeling structure, we can simply ‘drag-and-drop’ another population, and connect that population to new sliders that will supply the values for that population’s growth rate and initial population.!

Page 34: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

Adding Another Population!

• In fact, it’s a bit easier than that.!

• We can simply copy the sliders we already built as well as the population sub-model chip, and paste them below.!

Page 35: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

Adding Another Population!

• In order to copy and paste, we would go to the select, resize, and move arrow, located above the modeling canvas.!

Page 36: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

Adding Another Population!

• Then we would use the move arrow to select an area of the canvas fully encompassing the population chip model as well as the two sliders.!

• This will allow us to copy or move them.!

Page 37: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

Copying the Old Population and Sliders!

Page 38: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

Adding Another Population!

• After we copied the population sub-model chip and the sliders, we would simply paste the new population and sliders below.!

Page 39: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

Pasting the New Population and Sliders!

Page 40: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

Adding Another Population!

• As you can see, the new population sub-model chip was automatically named ‘Simple Population Growth Model 1’ to indicate that it is the second sub-model chip (the first was Model 0) to be calling upon the sub-model ‘Simple Population Growth’.!

Page 41: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

Adding Another Population!

• Similarly, the rate slider and initial population slider also have a 1 next to their titles to indicate that they will be used for the second population sub-model.!

Page 42: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

Adding Another Population!

• Still, we should check to see if the new sliders are connected to the new sub-model chip.!

• In order to see what is connected to a sub-model chip, we right-click the chip.!

Page 43: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

Adding Another Population!

Page 44: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

Adding Another Population!

• Our input data pins are already connected to rate_1 and Initial_Population_1, so we now have a working second population model.!

Page 45: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

Adding Another Population!

• We could also switch the sliders that send information to the input data pins in the sub-model chips, so that rate_1 supplied information to the first population chip, while the first rate slider supplied information to our second population chip.!

Page 46: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

The Graph!

• The only thing we need to do now is to connect the second population chip to the graph.!

• To do that, we would right-click on the bottom right edge of the graph. This will bring up the graph interface.!

Page 47: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

The Graph Interface!

Page 48: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

The Graph!

• We now see that there is something new located in the left-hand “Select Contents” box entitled ‘Simple Population Growth_1.pop’ !

Page 49: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

The Graph!

• As we saw in class, this stands for the sub-model name, as well as a ‘_1’ to indicate that it is the second sub-model chip on the canvas, and that the information from that chip is being supplied to the graph through the data output pin located within the sub-model named “pop”.!

Page 50: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

The Graph!

!

• Now we just need to select the second population’s name in the ‘Select Contents’ on the left hand side and use the arrows pointing to the right to bring it over to the right hand side.!

Page 51: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz
Page 52: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

The Graph!!

• We can also give the second population an alias by using the ‘Alias’ box below the “Select Contents’ box on the right. !

• I will call the second population “Population Model 1” and set that alias so it shows up on the graph with that name.!

Page 53: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz
Page 54: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

The Graph!

• Now we have two populations on the graph.!

• We can run the simulator with different values for each population and see them graphed next to each other. !

Page 55: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz
Page 56: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz
Page 57: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

!Building the !

Forest Fire Model!!

Page 58: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

Forest Fire Model!

• Now we are going to move onto something you will be familiar with if you looked at the other Netlogo focused sessions.!

!

• The forest fire model in Netlogo was a fairly short and simple program with one variable (forest density). !

Page 59: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz
Page 60: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

Forest Fire Model!

• In NOVA, we will create a forest fire model using system dynamics principles and hierarchical modeling.!

!

Page 61: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

Forest Fire Model!

• This model will show some of the interesting features available with NOVA’s plugins. !

• For example, we will give users the ability to select the initial state of every tree in the model by interacting directly with the GUI.!

Page 62: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

Forest Fire Model!

!

• In the model we will build, each tree will be modeled through its own system dynamics process that will be located within a sub-model, similar to how the population chips were sub-models in our population model.!

Page 63: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

Forest Fire Model!!

!

•  The state of a given tree in each time step will be determined by the state of a tree’s neighbors.!

Page 64: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

Forest Fire Model!!

• In NOVA, these types of models are called ‘cellular’ models, because each tree will be located within a grid, like patches in Netlogo, and each of the trees, or cells, in the grid will be allowed to interact with its neighbors.!

Page 65: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

Forest Fire Model!

• Let’s go ahead and open up a new NOVA window so we can build the forest fire model.!

Page 66: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

Building the Model!

• In a forest fire model, trees change between states such as unburned, burning, and burned.!

• The tree is therefore the thing that is changed over time and its state could be measured at any given point in time. Thus, it is our stock.!

Page 67: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

Building the Model!

• Go to components and select stock.!

• Name the stock Tree.!

Page 68: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

Modifying Our Tree!

• Now right-click on the stock “Tree” to get the stock interface.!

• Once there, check the discrete box and then press OK.!

Page 69: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

Building the Model!

• Now we need something to change its state. This will be our flow.!

• Go back to the components menu and select the flow button. Place a flow somewhere to the left of the stock and name it “Change.” !

Page 70: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

Building the Model!

• Once you have placed the flow down, connect the right-hand cloud to our stock.!

Page 71: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

Building the Model!

• The next thing we will need is to give the model the probability of burning and give each tree its initial state.!

Page 72: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

Building the Model!

• Select two data inputs and place them to the left of the flow. Name one “Prob of Burning” and the second one “Init” for initial state.!

Page 73: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

Building the Model!

• We will also want to output the state of the tree to the main level of the model.!

•  To do that, select a data output from the components menu and place it to right of the stock. Name the data output “state”.!

Page 74: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

How It Should Look So Far…!

Page 75: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

Building the Model!!

• Now we will want to wire them up.!

• Select the red arrow button from the components menu and connect an arrow running from “Prob of Burning” to the yellow valve on the flow “Change”.!

Page 76: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

Building the Model!

• After that, use another red arrow to connect the stock “Tree” to the yellow valve on the flow “Change”.!

Page 77: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

Building the Model!

!

• Use another red arrow to connect “Init” to the stock “Tree”.!

• Finally, use another red arrow to connect the stock “Tree” to the data output “state.” !

Page 78: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

How It Should Look So Far…!

Page 79: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

What The Red Arrows Tell Us!

•  As you can see, Init will tell the tree what its state is in the first time step of the model, while Prob of Burning and the current state of the tree will be needed by the flow in order to tell the tree what state it should be in (for example, a burned out tree should never have the option of catching on fire again.)!

Page 80: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

What The Red Arrows Tell Us!

!

• Just by looking at the diagram, we can clearly see that the new state of our tree will depend upon some function involving the probability of burning and the current state of the tree.!

Page 81: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

Defining the States!

• Our model will be working with states that could simply be labeled with numbers such as 0,1,2, etc.!

• However, if we gave them labels, they would be much more easy to work with.!

Page 82: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

Defining the States!

• Press on the lambda symbol located on the top left above the canvas.!

• You will get a blank space that will allow you to write some code.!

Page 83: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

Defining the States!

• In that space type the following:!

(define unburned 0)!

(define burning 1)!

(define burned 2)!

(define state 2)!

Page 84: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

It Should Look Like This!

Page 85: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

Defining the States!

• Now when we need to refer to these states later on, we will be able to use these words rather than some numerical value.!

• It is important to note that these states will be available under the lambda symbol within the sub-model, not within the main model.!

Page 86: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

Writing the Burn Procedure!

• The states that we just defined allow a tree to be either unburned, burning, or burned.!

• In our model, there will be some function that looks at the state of a cell’s neighbors and determine what state the cell should be in.!

Page 87: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

Writing the Burn Procedure!

• Our trees will burn for one time step and then become burned.!

• A burned tree does not transform into an unburned tree, and only unburned trees can burn.!

Page 88: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

Writing the Burn Procedure!

!

• Let’s go back to the canvas and right-click on the flow. The flow interface will pop up and allow us to write the procedure that will govern when a tree should change its state.!

Page 89: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

Writing the Burn Procedure!

!

• Write the following code into the large top middle box:!

Page 90: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

The Burn Procedure!

if Tree == unburned then!

"if NEIGHBORS(state, $==burning) > 0 then !

"if RANDOM(0,1) < Prob_of_Burning then!

" " Burning!

" "else unburned endif!

"else unburned endif!

else burned endif!

Page 91: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

It Should Look Like This!

Page 92: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

Dissecting The Code!

• The code you wrote contained some code that is native to the NOVA environment, like “primitives” in Netlogo, such as NEIGHBORS, RANDOM, and $.!

• These and other code native to NOVA are available in the bottom left of the interface.!

Page 93: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

Dissecting The Code!

•  In each time step the flow will ask if the current state of a tree is ‘unburned.’ If it is not unburned, the code will jump to the ‘else’ part of the if-else and make the state of the tree ‘burned.’ !

•  Therefore a tree that is burning will only burn for one time step before becoming burned.!

Page 94: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

Dissecting The Code!

• A burned tree will jump straight to the ‘else’ portion and remain burned.!

• An unburned tree must go through the rest of the procedure to determine its next state.!

Page 95: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

Dissecting The Code!

• Once it is determined that a tree is unburned, it will take a look at its neighbors and report back if it is true that there are any neighboring cells that are in a state of ‘burning.’ ($ represents state.)!

Page 96: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

Dissecting The Code!

• If it is true that there is at least one ‘burning’ neighbor, the unburned tree must continue on to the next ifelse conditional.!

• Otherwise it will remain unburned.!

Page 97: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

Dissecting The Code!

•  If there is at least one burning neighbor, then the procedure will flip a coin.!

•  If the random number generator produces a number between 0 and 1 that is less than the probability of burning, then the tree will enter a state of “burning.” Otherwise it will not burn.!

Page 98: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

Final Steps Of !The Sub-Model!

• Now we need to just add some finishing touches.!

• Right-click on the data output state and write “Tree” into it’s ‘state =’ box!

Page 99: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

Final Steps Of !The Sub-Model!

• Then right-click on the stock “Tree” and write “Init” into its ‘Initial_Tree =’ box.!

Page 100: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

Final Steps Of !The Sub-Model!

• Now we are done with the sub-model.!

• Let’s go to the main level and name our sub-model by pressing the yellow paper icon near the top left of the screen. When it asks what to name the sub-model, call it “Tree”.!

Page 101: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

Building the Main Model!

• Like in the population model, we will drag-and-drop the sub-model into the main level’s canvas.!

• But we want to have more than one tree, so before you drag out the sub-model go to the components menu and find the button called “Cell Grid.” !

Page 102: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

Building the Main Model!

• Go ahead and place the cell grid onto the canvas and call it “Forest.” !

Page 103: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

Building the Main Model!

• Now we will drag-and-drop the sub-model into the cell grid.!

• Go ahead and click-and-hold on the sub-model title “Tree” and drag-and-drop it on top of the cell grid “Forest.” !

• Our cell grid is now a sub-model chip.!

Page 104: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

The Cell Grid: Forest!

Page 105: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

Building the Main Model!

• Right now, our forest has 9 trees in it, or 3 rows by 3 columns of trees.!

• We can change that to make it a much larger forest. Go ahead and right-click the lower right edge of the cell grid to bring up the cell grid interface.!

Page 106: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

The Cell Grid Interface!

Page 107: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

Building the Main Model!

• Let’s make a forest of 2500 trees. Change the rows and columns to 50.!

Page 108: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

Building the Main Model!

• Now we need to build a slider to tell our model what the probability of burning is.!

• Select a slider from the components menu and give it the name, “Prob of Burning”. Make sure to right-click on it and change the range of values to between 0 and 1.!

Page 109: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

Building the Main Model!

!

• Next, we need to connect our slider to the cell grid. Right-click on the lower right edge of the cell grid and select “Prob of Burning” from the menu for the first input.!

• Remember, since sliders don’t have pins, they do not need red arrow connections.!

Page 110: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

The Cell Grid Interface!

Page 111: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

Building the Main Model!

• Now we will want to select a GUI so that we can display our forest. Go to the Plugin menu and select the button on the bottom middle called Raster.!

Page 112: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

Adding The GUI!

• Place the raster to the right of the cell grid and call it “Forest Display.” !

Page 113: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

Adding The GUI!

• Right now our forest GUI is geared to display a 3x3 forest.!

• Right-click on the bottom right edge of the raster and then click “Properties” so we can access the raster interface.!

Page 114: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

Adding The GUI!

!

• The raster interface will allow you to change the row and column numbers.!

• Change these to 50.!

Page 115: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

Adding The GUI!

Page 116: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

Adding The GUI!

• Next we have to program the colors for each state.!

• Change the number of colors to 3 and make the range go between 0.0 and 2.0!

Page 117: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

Adding The GUI!

• Remember that in our states, 0 = unburned, 1 = burning, and 2 = burned.!

• So change the colors to match these numbers in the colors displayed on the right-hand side.!

• Do this by right-clicking on the colors.!

Page 118: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

Changing The Colors!

Page 119: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

Adding The GUI!

• Click OK to get out of the raster interface. You will now see that the display became green.!

Page 120: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz
Page 121: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

Adding The GUI!

• Right now, rasters cannot be ‘wirelessly’ connected to cell grids so we will need red arrows to connect them.!

• Select the red arrow from the components menu and bring your mouse to the cell grid’s output pin located on the right. !

Page 122: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

Adding The GUI!

• Connect the red arrow from the cell grid’s output pin on the right to the raster’s input pin on the left.!

Page 123: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

User Selected Fires!

• You may have noticed earlier that we did not add a slider for the data input “Init”.!

• That is because while it is something we want the user to input on the main level of the model, we do not want the user to select these values from a slider.!

Page 124: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

User Selected Fires!!

• Instead, the user will click on the forest GUI and select which trees will be either burning, burned, or unburned, by clicking individually on them once, twice, or three times (or leaving them in the default unburned state).!

Page 125: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

User Selected Fires!

• We now need this user selected data to be feed back into our model.!

• Go and right-click on the cell grid and go to the “Init” pull down menu and select “Forest_Display.Out” !

Page 126: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

User Selected Fires!

Page 127: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

User Selected Fires!

• Now the user can select any initial pattern of initial burning trees they want, as well as create “walls” of unburned trees.!

Page 128: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

Running the Model!

• Now we can run our model. Go to the simulator menu and in Off mode have the model go between 0 and 100 time steps, so the model will run long enough for the fire to move across the forest.!

Page 129: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

Running the Model!

• Since this is a discrete model, go to the simulator menu and select for the Integration Method Euler. Also set Dt equal to 1.0.!

Page 130: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz

Running the Model!

• You can now select a few trees to set to “burning” and run your fire using Clock.!

• Remember not to fuss with the GUI too much while it is running.!

Page 131: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz
Page 132: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz
Page 133: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz
Page 134: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz
Page 135: ICPSR - Complex Systems Models in the Social Sciences - Bonus System Dynamics Lab - Professor Daniel Martin Katz