In this section, Nick Louca shares his step-by-step process
of building a System Dynamic model of the Milk Glass Game.
His narrative can give you pretty good sense
of how to go about building a model.
Note: If you find any "typos" or sections difficult to read,
please send your feedback to FAQ.
|
Modelling the Milk Glass Game My Process by Nick Louca, July, 2009
In this project, I model the Milk Glass Game in the iThink programming language. You can find the Milk Glass Game in the EcoNowMics pages. See the link, above.
I go through 3 challenges and lots of confusion while I develop the Milk Glass Game in iTHink. I also have a number of AHA’s and key lessons about model building and system dynamics principles during the process. I share my insights here for the reader as my process evolves. |
||||||||||||||||||||||||||
|
First Challenge – Positive or Negative Feedback Loop?
I face the first challenge before
I even start building the model in iThink while I go through the
EcoNowMics
pages.
I look at the model and see a target so I think that it is a negative
feedback system. I know from reading
Road Maps
materials that filling a level to a target implies a goal and a gap, two of the
basic components that make up a negative feedback loop. I take another look at the system
structure. There is a milk flow rate
into the level and the milk flow rate is increasing the level. This seems positive so I start to feel some
confusion. Throughout my studies I do not recall a negative feedback system
structure with a rate inflow into the level.
I am under the impression that negative feedback systems only contain
rate outflows from the level. I carry on. I experiment with
filling the glass with milk on Ed’s Milk Glass Game on the
EcoNowMics
pages. As I fill the glass to the target line I notice that I act to minimize the discrepancy between
the level and the target line. This is
negative feedback - however I am still not clear on how I can have negative
feedback with the level increasing. I
recall that positive feedback has exponential growth in which the rate
increases the level. I find that I do not really know the difference between positive feedback and negative feedback. I decide to do some research to resolve this question.
The
Milk Glass Game System Structure
I go to the Road Map papers and find a negative feedback model with a rate inflow into the level. I read through it carefully in order to better understand how the system structure behaves. The model I find (the Widgets Model, below) has a rate inflow into the level and exhibits asymptotic growth as its approaches its target. I have my first insight. A system with a rate inflow into the level, a goal and a gap can also be a negative feedback system.
. The Widgets Model
Clip: Road Maps, Beginner Modeling Exercises, Section 3,
Mental Simulation of Simple Negative Feedback, Pg 15 I notice in Chapter 3, ‘Negative Feedback Structure’ of Study Notes in System Dynamics by Michael R. Goodman, another system structure with a rate inflow into the level that looks similar to the Milk Model structure. The chapter outlines the basic elements of negative feedback systems. These are: the target (goal), the discrepancy (gap), the action (rate) and the system state (level). While I feel that I am getting more understanding on negative feedback loops, I also notice that I am still not clear on the difference between positive and negative feedback loops.
Negative
Feedback Structure Study Notes in System Dynamics, Michael R. Goodman, Chapter 3, Pg 38
Ed senses my confusion about the difference between positive and negative feedback loops. We have a discussion about the difference between the two. I describe negative feedback systems to Ed as systems that have a goal and a gap in their system structure. I also mention that the behavior negative feedback systems exhibit is either asymptotic growth or exponential decay. I describe positive feedback system structure as a structure that consists of a level, a rate and a constant and that positive feedback exhibits exponential growth.
Positive
Feedback Structure
Study Notes in System Dynamics,
Michael R. Goodman, Chapter 3, Pg 40 Ed tells me that both positive and negative feedback loops have a level, a reference level (target, goal) and a delta (gap) that results from comparing the level and the reference level. This is new to me.
System
Structure – Showing Policy
I do not recall thinking about positive and negative feedback systems in
this way before. Ed tells me that the
main difference between positive and negative feedback systems is that negative
feedback systems act to decrease the delta while positive feedback systems act
to increase the delta. Key Lesson 1 Negative feedback loops act to decrease the delta and positive feedback loops act to increase the delta.
|
||||||||||||||||||||||||||
|
Second Challenge – Units of Measure
I am now clear on the difference between positive and negative feedback loops so I decide to build the Milk Glass Game (Version 1, below) in iThink as per the format of the Widgets Model in Road Maps. I make sure to include the basic elements of negative feedback systems in my model. I run the system and get the asymptotic behaviour I see in the Excel spreadsheet.
I choose a dt value of 0.1 seconds. Note: Dt (delta time) is the time interval between calculations. This is the same value as in the Excel simulation of the Milk Glass Game. Thus, I re-compute all the system variables every 0.1 seconds. A small dt generates a more accurate simulation and it also requires more computations. A dt value of about 1/5 of the shortest "time constant" in the system is generally small enough. In real-life, everything influences everything else continually, in the ever-evolving moment of now; in real-life dt becomes the zero-width moment of now. Choosing a very very small dt for a model can make a model very very accurate and never exactly accurate. I mention "time constant" later in this article: 1 2.
Notes:
1. Dt is the delta time between simulation computations; the other "delta" in this model is the gap between the target (goal) and the actual milk level.
2. "Cause and Effect" models generally attempt to link events that have very long time intervals between them. Such linkages do not and cannot actually exist. We cannot model them with system dynamics. In System Dynamics, we do not attempt to make "Cause and Effect" claims such as "Since the empty glass occurs first, the empty glass obviously causes the full glass." You can find more on "Cause and Effect" in the EcoNowMics pages.
I present the model to Ed and we review it together. Ed questions me on what the Milk Inflow
Fraction represents. Is it a fraction of
time? Is it a fraction of milk pouring
into the rate which then pours into the level?
Is this how filling a glass of milk works in reality? I conclude that the Milk Inflow Fraction
{cc/sec} does not represent anything real even though I get the desired
asymptotic behaviour. Also I realize
that the units do not match.
Ed and I have a discussion about the importance of unit consistency in
model building. Ed tells me that if the units
of measurement are inconsistent then the whole model is inconsistent. Ed also tells me that unit inconsistency is a
vital clue that something in the model is not right. Ed advises me to take another look at the Milk
Glass Game on the
EcoNowMics
page and rearrange the model according to what I see. Key Lesson 2 Always make sure that units of measure in the model are consistent
and make sense. I review the Milk Glass Game and the system structure again. I also go through the Milk Model in the Excel spreadsheet to get a better understanding of the units of measure. The Excel spreadsheet has a Time Constant instead of Milk Inflow Fraction that I use in my first version of the Milk Glass Game. The Time Constant represents the time it takes to fill the milk glass to the target level in a system where there is no feedback. In this system the Time Constant and the delta (gap) both determine the flow rate. The unit of measure for the Time Constant in the Milk Glass Game is seconds.
I revise the model (version 2, below), replace the Milk Inflow Fraction
with a Time Constant and make the necessary adjustments to the model
equations. I run the model again and get
the same behavior as I get in the previous model which also reconciles with the
Excel simulation of the Milk Glass Game. In
addition, all the units of measure make sense and are consistent with each
other.
The
Milk Glass Game System Structure Version 2
I notice that something is still missing from my structure when I
compare it to Ed’s structure on the
EcoNowMics
page. I do not have a “Policy” in my
model. I am not clear about the meaning
of the word Policy in a System Dynamics context. |
||||||||||||||||||||||||||
|
Third Challenge – Define the Policy
I present the model to Ed and we discuss the second version of my iThink Model. Ed asks me if I really use a Time
Constant when I fill a glass of milk.
The answer is No. Ed asks me to
define the location and operation of the Policy in this model. I draw a blank. I realize I am not clear on the word Policy. Ed asks me to go back to the Milk Glass Game and simulate filling the
glass. As I start to fill the glass Ed asks
me what I notice about what I am doing as I fill the glass. I notice that as I see the milk flowing into
the glass I use this information to regulate the position of the button. As the milk glass fills up and approaches the white target line I
gradually release the button to reduce the flow of milk into the glass. I have an AHA. My hand and eyes are part of the system and
part of the feedback loop for filling the glass! My Policy for managing the valve completes and closes the feedback
loop. Ed explains the meaning of Policy
and how to use it in a System Dynamics context.
The policy acts as a transducer that receives information about the
level and controls the rate. Key Lesson 4 A policy is a plan
of action that receives information from a level and controls a rate. Complex
policies may receive information from many levels and control many rates. During the process of my discussion with Ed I have another AHA for model
building. Key Lesson 5 Be sure to locate
and define model policies. Make sure
that polices correspond to reality. The sixth key lesson I receive comes from Thinking in Systems by
Donella H. Meadows. Key Lesson 6 The least obvious
part of the system, its function or purpose is often the most crucial
determinant of system behaviour. In the case of the Milk Glass Game the least obvious parts of the system, my
nervous system, eyes and muscles are all part of my policy. Success I make my third attempt to build the model (version 3, below) as per my
previous discussion with Ed on the meaning of “Policy”. I am now clear on the term Policy and the
role it plays in the feedback loop. Ed
also demonstrates how a valve works by filling a glass of water from a water
faucet. As the valve handle rotates, the
flow rate into the glass increases or decreases accordingly. The valve handle position (degrees)
associates with the flow (cc/sec) so the valve transfer function (TF) is in
cc/sec/degree.
I use millimeters (mm) of
milk to represent the level and mm to represent the button position
in version 3 of the Milk Glass Game model. I use millimetres instead cubic centimetres as this
is what I see on my 17" monitor as I fill the milk glass. I respond to the height of the milk in the
milk glass while I fill the glass (mm) by controlling the button position (mm). The TF for the Policy
has units of mm/mm = 1. The TF unit for the button itself is in mm/sec ÷ mm or 1/sec. Note: The
total control path from the level to the rate has a TF with
units of 1 * 1/sec = 1/sec where the number of seconds represents the “Time
Constant.” I figure out how to implement the Policy function in iThink and include the details about what actually takes place within the Policy. I run the model and notice that the behavior I see is the same as that in the Excel model.
The Milk Glass Game System Structure Version 3 Showing Policy as a Block
The Milk Glass Game System Structure Version 3
Showing Policy Detail
Note: Some system builders who are familiar with this type of structure may condense the policy and valve function into one shorthand variable, the Time Constant.
Model System Structure in “Time Constant” Formulation
|
||||||||||||||||||||||||||
|
Verify the Model
During further discussion and review with Ed on my model, he suggests that I verify my model. My task when I verify the model is to make sure that: 1) the model structure corresponds to the physical reality of the Milk Glass Game and 2) the model behaviour corresponds to the behavior I observe in the Milk Glass Game.
To verify the structure I measure the Milk Glass (85mm tall), the Target Line (65mm from the bottom) and the Button (10mm tall) on a 17” monitor. The button still protrudes by 2mm in the full down position, 10mm - 2mm = 8mm. I use various policies to fill the milk glass. I vary my policies from the Slam Shut policy, where I start the flow at the maximum to a Slow Fill policy, where I press the button down approximately 2mm and release it as soon as the level reaches the Target Line.
I find that the transfer function remains constant at 8.125mm/sec/mm so
I can use 8.125 as a “constant” in the model. I run the iThink model with this transfer function and compare the
behaviour against the data from the Milk Glass Game. I try various values of responsiveness until
I get my best fit to the Milk Glass Game at 0.2 mm/mm. I notice that the only thing actually under my control is my own
responsiveness. The more responsive I
am, the faster I fill the glass. When I
am too responsive however, I overshoot.
We explore gain, delay and overshoot in the next section.
Milk
Glass Game Behavior - The Actual Game
Milk
Glass Game Version 3 Behaviour With Responsiveness at 0.2 mm/mm
Model
Development Checklist I notice that during my work to develop the Milk
Glass Game in iThink I achieve several milestones which I highlight below. 1. Positive and Negative Feedback are clear;
2.
Units of measure
are consistent;
3. Policy function is
defined; and
4. The structure and
behavior of version 3 of my model agrees with the Milk Glass Game.
I also find that I would like to research System
Dynamics in greater detail. The next model I intend to develop in iThink is the
Tracker
model on the
EcoNowMics
page. To simulate the Milk Glass Game in iThink, follow this link:
http://forio.com/service/netsims/nowsystems/milkglassgame/index.html Note: Excel Spreadsheet
Next Section: Cause and Effect |