© Ed Seykota, 2003 - 2009 ... Write for permission to reprint.

Ed Seykota's FAQ

(formerly: Frequently Appearing Questions)

Home  ...  FAQ Index & Ground Rules  ...  Tribe Directory - How to Join

TTP - The Trading Tribe Process  ...  Rocks  ...  Glossary

  TTP Workshop  ...  Resources  ...  Site Search  ...  The Trading Tribe Book

TSP: Trading System Project  ...  Breathwork ...  Levitator

EcoNowMics  ...  Contact Us  ...  The Whipsaw Song ...  Music

 

 

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 a 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 Video Game

My Process

 

by Nick Louca, July, 2009

Revision: September, 2009

(c) 2009 by Ed Seykota

 

 

 

Clip: http://www.caswells-moms.com/e-shop/index.php?main_page=index&cPath=125

 

 

In this paper, I model the Milk Glass Video Game in the iThink programming language.  You can find the Milk Glass Video Game in the EcoNowMics pages. See the link, above.

 

I go through three challenges and lots of confusion while I develop the Milk Glass Video 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.

 

1.     First Challenge – Positive or Negative Feedback Loop?

 

I face the first challenge before I even start building the model in iThink while I read through the EcoNowMics pages.

 

I look at the Milk Glass Video Game model.  I see a Target so I think that it is a First Order Negative Feedback system. Note that "First Order" denotes a system with one Level.  I know from reading Road Maps that filling a Level to a Target implies a Goal and a Gap, two of the basic components that make up a First Order Negative Feedback loop.  I take another look at the system structure.  There is a milk flow Rate into the Level.  The milk flow Rate is increasing the Level.  This seems like a positive feedback loop.  I start to feel some confusion.

 

Throughout my studies I do not recall a First Order Negative Feedback system structure with a Rate flowing into the Level.  I am under the impression that First Order Negative Feedback systems contain Outflow Rates from the Level only.

 

I carry on.  I experiment with filling the glass with milk on Ed’s Milk Glass Video 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 seems like negative feedback - however I am still not clear on how I can have negative feedback while the Level is increasing.  I recall that positive feedback has exponential growth in which the Inflow Rate increases the Level.

 

I find that I do not really know the difference between First Order Positive Feedback and First Order Negative Feedback.  I decide to do some research to resolve this question.

 

 

The Milk Glass Video Game System Structure

 

 

I research the Road Maps papers and find a negative feedback model with a Rate that flows into the Level.  I read through the paper carefully in order to better understand how this system structure behaves.  The model I find (the Widgets Model, below) has a Rate that flows into the Level and exhibits asymptotic growth as it approaches the Target.  I have my first insight.  A system with an Inflow Rate, a Goal and a Gap can also be a First Order Negative Feedback system.

 

 

The Widgets Model

Clip: Road Maps, Beginner Modeling Exercises, Section 3,

Mental Simulation of Simple Negative Feedback, Pg 15

 

 

I also notice in Chapter 3, ‘Negative Feedback Structure’ of Study Notes in System Dynamics by Michael R. Goodman, another system structure with an Inflow Rate into the Level that looks similar to the Milk Glass Video Game model structure.  The chapter outlines the basic elements of First Order Negative Feedback systems. These are:

 

  1. the Target (Goal);

  2. the Discrepancy (Gap);

  3. the Action (in this particular case, the Inflow Rate); and

  4. the system state (Level).

 

I feel that I am getting more understanding on First Order Negative Feedback systems.  I also notice that I am still not clear on the difference between First Order Positive and First Order Negative Feedback systems.

 

 

 

First Order Negative Feedback Structure

Study Notes in System Dynamics, Michael R. Goodman, Chapter 3, Pg 38

 

 

Ed senses my confusion about the difference between First Order Positive and First Order Negative Feedback loops.  We have a discussion about the difference between the two.  I describe the First Order Negative Feedback system to Ed as  a system that has a Goal and a Gap in its system structure.  I also mention that the behavior we might observe in First Order Negative Feedback systems, either, as asymptotic growth or exponential decay.

 

I describe a First Order Positive Feedback system structure as a structure that consists of a Level, an Inflow Rate and a Constant.  I also mention that First Order Positive Feedback systems exhibit exponential growth.

 

 

 

Positive Feedback Structure

Study Notes in System Dynamics, Michael R. Goodman, Chapter 3, Pg 40

 

 

Ed tells me that both First Order Positive and Negative Feedback loops have a Level, a Reference Level (Target, Goal) and a Delta (Gap or Discrepancy) that results from comparing the Level and the Reference Level.  This is new to me.

 

 

 

System Structure – shows the Policy (see section on Policy below)

Note: other names for Delta is Gap or Discrepancy; and

for the Reference Level is Target or Goal.

 

 

I do not recall thinking about First Order Positive and Negative Feedback systems in this way before.  Ed tells me that the main difference between First Order Positive and First Order 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.

 

 

 

2.     Second Challenge – Units of Measure

 

I am now clear on the difference between First Order Positive and First Order Negative feedback loops.  I decide to build the Milk Glass Video Game (Version 1, below) in iThink as per the structure of the Widgets Model I see in Road Maps.  I make sure to include the basic elements of a First Order Negative Feedback system in my model.  I run the system and get the asymptotic behaviour I see in the Excel spreadsheet in the Building an Excel Model section of the EcoNowMics page.

 

I choose a dt value of 0.1 seconds. Note: Dt (delta time) is the time interval between each calculation.  This is the same value as in the Excel simulation of the Milk Glass Game.  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/5th of the shortest "Time Constant" in the system is generally small enough.  I explore the "Time Constant" later in this article: 1  2.

 

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 but never exactly accurate.

 

 

Notes:

 

1. Dt is the delta time between simulation computations; the other "delta" in this model refers to 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.

 

 

 

The Milk Glass Video Game Model

Version 1 System Structure

 

 

Equations

.

Milk Level Initial Value (cc) = 0 (cc)
Milk Level (cc) = Milk Level (cc) + Milk Inflow Rate (cc/sec) * dt
Milk Inflow Rate (cc/sec) = Milk Inflow Fraction (cc/sec) * Gap (cc)
Milk Inflow Fraction (cc/sec) = 0.5 (cc/sec)
Goal (cc) = 1500 (cc)
Gap (cc) = Goal (cc) - Milk Level (cc)
Solution Interval, dt (secs) = 0.1 (secs)

 

 

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 Inflow 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 in reality even though my model exhibits the right behaviour.  I also realize that the units of measure in my model do not match.

 

 

Milk Inflow Rate (cc/sec) = Milk Inflow Fraction (cc/sec) * Gap (cc)
cc/sec = cc/sec * cc
cc/sec = cc2/sec - MISMATCH

 

 

Ed and I have a discussion about the importance of unit consistency in model building.  Ed tells me that if the units of measure 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 Video 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 Video Game and the system structure again.  I go through the Building an Excel Model section again.  I also review 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 Inflow Rate.  The unit of measure for the Time Constant in the Milk Glass Video Game is seconds.

 

 

Milk Inflow Rate (cc/sec) = Gap (cc) / Time Constant (sec)
cc/sec = cc/sec  - MATCH

 

 

I revise the model (version 2, below).  I 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 version 1 of the model.  This also matches with the Excel simulation of the Milk Glass Game.  In addition, all the units of measure now make sense and are consistent with each other.

 

 

 

The Milk Glass Video Game Model

Version 2 System Structure

 

 

Equations

.

Milk Level Initial Value (cc) = 0 (cc)
Milk Level (cc) = Milk Level (cc) + Milk Inflow Rate (cc/sec) * dt
Milk Inflow Rate (cc/sec) = Gap (cc) / Time Constant (secs)
Time Constant (secs) = 2 (secs)
Goal (cc) = 1500 (cc)
Gap (cc) = Goal (cc) - Milk Level (cc)
Solution Interval, dt (secs) = 0.1 (secs)

 

 

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 notice that I am not clear about the meaning of the word Policy in a System Dynamics context.

 

3.     Third Challenge – Define the Policy

 

I present the model to Ed and we discuss the second version of my 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 Video Game and simulate filling the glass.  As I start to fill the glass, Ed asks me what it is that I notice about my actions while I fill the glass.  I notice that as I see the milk flowing into the glass I use the information about the Level 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 button 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 policies 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 Video Game the least obvious parts of the system, my nervous system, eyes and muscles are all part of my Policy.

 

4.      Success - Developing Version 3 of Milk Glass Game Model

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 rate (cc/sec) so the valve Transfer Function unit of measure is cc/sec/degree.

 

In Version 3 of the Milk Glass Video Game model I use millimeters (mm) of milk to represent the Level and mm to represent the Button position.  I use millimetres instead of 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 as I fill the glass (mm) by controlling the button position (mm).  The Transfer Function for the Policy has units of measure in mm/mm = 1.  The Transfer Function 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 Transfer Function 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 Video Game Model

Version 3 System Structure

Showing Policy as a block

 

 

 

The Milk Glass Video Game

System Structure Version 3

Showing Policy Detail

 

 

Equations

.

Milk Level Initial Value (mm) = 0 (mm)
Milk Level (mm) = Milk Level (mm) + Milk Inflow Rate (mm/sec) * dt
Milk Inflow Rate (mm/sec) = Mouse Position (mm) * Button Function (mm/sec/mm)
Target (mm) = 65 (mm)
Button Function (mm/sec/mm) = 8.125 (mm/sec/mm)
Solution Interval, dt (secs) = 0.1 (secs)

Note: I measure the Milk Glass Video Game on a 17" monitor. See section 5 on verification below.

. .
Policy Equations .
Gap (mm) = Target (mm) - Milk Level (mm)
Mouse Position (mm) = Gap (mm) * Responsiveness (mm/mm)
Responsiveness (mm/mm) = 0.2 (mm/mm)

 

 

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 Only

 

 

 

Note: In this case, the control path from the Level, back to the Inflow Rate includes the button and the user.

 

The control path “Gain” equals my Responsiveness * Button Function.  The “Time Constant” is the reciprocal of the Gain.

 

The Time Constant is also the time it takes the Level to travel about 2/3rds of the way to the Target.  Note: 1 - 1/e = 0.632.

 

 

Equations

.

Responsiveness = 0.2 mm/mm
Button Function = 8.125 mm/sec/mm
Total Path Gain = 1.625 sec
Time Constant = 0.615 sec

 

4.      Verify the Model

 

During further discussion and review of my model with Ed, 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 Video Game; and

                 2.   the model behaviour corresponds to the behavior

                       I observe in the Milk Glass Video Game.

 

 

Model verification includes:

 

1)   Verify that the structure:

      a.   makes sense; and

      b.   has consistent units of measure.

 

2)   Verify that the model behavior:

      a.  matches the real behavior (of the Milk Glass Game);

      b.  has a similar magnitude of variables; and

      c.  has a similar shape of behavior curves.

 

 

To verify the structure I measure the Milk Glass (85mm height), the Target Line (65mm from the bottom) and the Button (10mm height) 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.

 

 

Policy

Button Depression

(mm)

Duration

(secs)

Accumulation

(mm)

Inflow Rate

(mm/sec)

Transfer Function

(mm/sec/mm)

Slam Shut

8

1

65

65

65/8 = 8.125

Steady Fill

4

2

65

32.50

32.50/8 = 8.125

Slow Fill

2

4

65

16.25

16.25/2 = 8.125

 

Table of Button Experiments

 

 

I find that the Transfer Function remains constant at 8.125 mm/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 Video Game.  I try various values of responsiveness until I get my best fit to the Milk Glass Video 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 Video Game Behavior - The Actual Game

 

 

 

Milk Glass Video Game Version 3 Behaviour

With Responsiveness at 0.2 mm/mm

 

 

Point A is 65 * (1-1/e) = 41.08mm.  This is the point to which the original Level climbs at t = 1 Time Constant, B = 0.615 seconds.

 

4.      Conclusion & Model Development Checklist

I notice that during my work to develop the Milk Glass Video 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 Video Game.

 

I also find that I would like to research System Dynamics in greater detail.  The next model I intend to develop is the Tracker model on the EcoNowMics page.

 

To simulate the Milk Glass Video Game in iThink, follow this link:

http://forio.com/service/netsims/nowsystems/milkglassgame/index.html

 

Note: Excel Spreadsheet

 

Next Section: Cause and Effect

 

back to menu

 

Clip: http://www.caswells-moms.com/e-shop/index.php?main_page=index&cPath=125