World2 model, from DYNAMO to R. The first doomsday computer model... | by Arnaud M. | Towards Data Science

“In 1972 a small paperbound book called ‘The Limits to Growth’ was published with much fanfare [...] the book warned that the world was steering a course for disaster. Without a drastic change in direction, the human population would run out of food and natural resources, or else would choke on its own pollution, within 50 or 100 years” (Hayes, 1993).
Jay Wright Forrester (1918–2016) was an American computer engineer and systems scientist, credited as the “founding father” of system dynamics. Although less known by the general public than the Meadows couple who wrote ‘The Limits to Growth’ (Meadows et al., 1972), Forrester’s world dynamics model World2 (Forrester, 1971) was the basis of all subsequent models predicting a collapse of our socio-technological-natural system by the mid 21st century. This article revisits this seminal work from a programming perspective, by rewriting the outdated DYNAMO code into R. It will provide a fresh look at this model of world dynamics and could later be used as input model for machine learning exercises.
The transcript of a talk given by Forrester at the System Dynamics Society, Stuttgart, Germany, in 1989, provides us with a first-hand account of the media’s reaction to the bombshell that was the publication of his doomsday computer model:
“‘World Dynamics’ came out the first week of June, 1971. The last week of June it was reviewed on the front page of the London Observer. I received a letter from a university professor in New York asking for more information because he had been reading about the book in the Singapore Times. In August the book had the full front page of the second section of the Christian Science Monitor, in September a page and a half in Fortune, and in October a column in the Wall Street Journal. It was running through editorial columns of mid-America newspapers, it was the subject of prime time documentary television in Europe, it was debated in the environmental press, the zero population growth press, and the anti- establishment underground student press. And, if you don’t like your literature on either the establishment right or the establishment left, then right in the middle of the political spectrum, it had a full-length article in Playboy [...] Nine months after ‘World Dynamics’, ‘Limits to Growth’ was published. The message was essentially the same, although much more work had been done and the book was more popularly written...” — Jay W. Forrester, 1989
System dynamics is an approach to understanding the nonlinear behaviour of complex systems over time using stocks, flows, internal feedback loops, table functions and time delays (Wikipedia). It in fact derives from earlier works on cybernetics.
World2 was not Forrester’s first major work in system dynamics, as he had already applied the method to factory planning in ‘Industrial Dynamics’ ((Forrester, 1961), and then to city planning in ‘Urban Dynamics’ (Forrester, 1969; which, fun fact, would later be influential in the creation of the video game SimCity; Lobo, 2007). Forrester’s work on urban dynamics was noticed by the Club of Rome which led to discussions on global sustainability and the book ‘World Dynamics’ in 1971 where the World2 model was presented. Meadows’ team developed an extension of the model in parallel, leading to the World3 version (Meadows et al., 1972; Meadows, 1974; updated in Meadows et al., 2004; see also Randers, 2012). Interestingly, Forrester had sketched out a preliminary version of the model, called World1, on his flight home from his meeting with the Club of Rome in Switzerland (Hayes, 1993).
“In 1971 ‘World Dynamics’ seemed to have everything necessary to guarantee no public notice. First, it had forty pages of equations in the middle of the book, that should be sufficient to squelch public interest. Second, the interesting messages were in the form of computer output graphs, and most of the public do not understand such presentations.” — Jay W. Forrester, 1989
Reading about a model’s characteristics and outputs on paper is not sufficient to fully grasp the underlying mechanisms and assumptions. Due to the historical importance of the World2 and World3 models in system dynamics and to the 50-year debate that ensued, it is worthwhile to revisit the source codes.
While I thought it would be easy to find modern versions of those models, I had in fact to dig deep to find some open source codes, and finally decided to redo the World2 model from scratch in R, based on the reading of Forrester (1971). Here is a summary of my journey leading to the Rworld2 project:
No code found in R;
Mentions of a Python code created by a French team in 2018 (PDF1, PDF2) but apparently not directly accessible;
Things are getting more concrete: a Javascript dashboard exists that allows the user to try out different parameterisations of the World3 model and plot the results. However, a disclaimer states that “this is a work in progress and may well have serious bugs.” This is linked to a very nice article by the author of the tool, Brian Hayes, who wrote several pieces about ‘The Limits to Growth’ in American Scientist (Hayes, 1993; 2012). Here is a nugget from that article: “The original World3 model ran on mainframe hardware — IBM 360 and 370 machines.” Other nuggets on DYNAMO programming follow, four bullet-points below.
Hayes mentions “that there are several more versatile and more trustworthy implementations out there” and provides the following link which is unfortunately broken, as of 2020.
A trustworthy implementation of World3 is provided by Scott Fortmann-Roe via Insightmaker (Fortmann-Roe, 2014)—However, use of a general-purpose tool for web-based graphical model construction is at odds with the flexibility of the simple script I originally had in mind.
The most reliable and best documented open source versions of World2 and World3 are the ones programmed in Modelica by François E. Cellier (Cellier, 2007; 2008; Castro et al., 2014). The documentation on World3 provides some valuable historical information: “Whereas Jay Forrester listed his entire model in his book ‘World Dynamics’, Dennis Meadows only talked in ‘Limits to Growth’ about the results obtained using his model. The model itself is not listed. [...] Yet, Meadows never tried to hide his model from public scrutiny. In fact, he wrote an internal report of 637 pages that describes all facets of his model. He published that internal report as a separate book in 1974: ‘Dynamics of Growth in a Finite World’.” Cellier (2008) adds: “Although the work of Forrester and Meadows caused quite a stir in the early 70s when their books first appeared, world modeling became unfashionable fairly quickly, because essentially all sources of funding dried out for political reasons. Only very recently, in the context of the looming Peak Oil event and because of the ongoing discussions concerning Global Warming, has world modeling become respectable again.” This makes Rworld2 a timely project, especially since the Modelica codes, although available, are very unlikely to be directly used in any modern data science project.
Back to square 1! Why translate the Modelica program when it is itself translated from the original DYNAMO code provided in Forrester (1971)? DYNAMO (DYNAmic MOdels) was initially developed by Forrester’s MIT team in the late 1950s for system dynamics computation. Both World2 and World3 were originally written in DYNAMO. The language has, since the publication of ‘Limits to Growth’, fallen into disuse. Hayes describes it nicely: “In lexical and syntactic structure DYNAMO is what you’d expect of a language from the punch-card era — six-letter variable names and ALL CAPS — but in other respects it’s an interesting early experiment, with a programming style that falls somewhere between procedural and declarative.” Here is an excerpt from Appendix B ‘Equations of the World Model’ from Forrester (1971:136), showing some lines of code in DYNAMO:
* WORLD DYNAMICS W5L P.K=P.J+(DT)(BR.JK-DR.JK)N P=PIC PI=1.65E9R BR.KL=(P.K)(CLIP(BRN,BRN1,SWT1,TIME.K))(BRFM.K)(BRMM.K)(BRCM.K)X (BRPM.K)C BRN=.04C BRN1=.04C SWT1=1970A BRMM.K=TABHL(BRMMT,MSL.K,0,5,1)T BRMMT=1.2/1/.85/.75/.7/.7A MSL.K=ECIR.K/(ECIRN)
Let us now have a look at the structure of the model, which may look overwhelming at first glimpse. I recommend looking at the structure of World3 first to make the complexity of World2 all the more relative (43 governing equations in World2 versus 150 in World3).
I found the DYNAMO scripts provided throughout chapter 3 of Forrester (1971) far more digestible than the full code given in its Appendix B. I identified the different “equations” (i.e. assignment statements) by following the same numbering system as in the book for direct match. Similarly, I kept the same variable and function names. Order does not count in DYNAMO so the most tedious step in R was the reordering of the World2 set of 43 equations and so-called multipliers (see below) so that all variables were defined and updated correctly (I hence manually did the job of the DYNAMO compiler. It would be challenging, although tempting, to code World2 in R as a graph and then apply topological sorting).
An example of equation is given below in R:
# logical function used as time switch to change parameter valueCLIP <- function(FUNCT1, FUNCT2, THRESH.K, VAL) if(THRESH.K >= VAL) return(FUNCT1) else return(FUNCT2)DT <- .2TIME <- seq(1900, 2100, DT)   # CALENDAR TIME (YEARS)n <- length(TIME)# (...)## (2) Birth rate BR ### BR.KL = P.K CLIP(BRN, BRN1, SWT1, TIME.K) BRFM.K BRMM.K BRCM.K BRPM.K# BRFM = BIRTH-RATE-FROM-FOOD MULTIPLIER ()# BRMM = BIRTH-RATE-FROM-MATERIAL MULTIPLIER ()# BRCM = BIRTH-RATE-FROM-CROWDING MULTIPLIER ()# BRPM = BIRTH-RATE-FROM-POLLUTION MULTIPLIER ()BR <- numeric(n)    # BIRTH RATE (PEOPLE/YEAR)BRN <- .04          # BIRTH RATE NORMAL (FRACTION/YEAR)BRN1 <- .04         # BIRTH RATE NORMAL no. 1 (FRACTION/YEAR)SWT1 <- 1970        # SWITCH TIME no. 1 FOR BRN (YEARS)# (...)for(K in 2:n){  J <- K - 1  # (...)  BR[K] <- P[J] * CLIP(BRN, BRN1, SWT1, TIME[J]) * BRMM(MSL[J]) * BRCM(CR[J]) * BRFM(FR[J]) * BRPM(POLR[J])  # (2-3,16-18)  # (...)
BR is the birth rate, a function of population P, material standard of living MSL, crowding CR, food FR and pollution POL (POLR is the pollution ratio). BR grows proportional with P and depends on the other variables via single-valued functions called multipliers (BR.variable.M). And now an example of multiplier, based on a look-up table defined by Forrester:
library(signal)  # interp1()## (3) Birth-rate-from-material multiplier BRMM ##BRMM = function(MSL.K){  # MSL   = MATERIAL STANDARD OF LIVING ()  # BRMMT = BIRTH-RATE-FROM-MATERIAL MULTIPLIER TABLE  lookup.table <- data.frame(MSL = seq(0, 5, 1),                              BRMMT = c(1.2, 1., .85, .75, .7, .7))  return(interp1(lookup.table$MSL, lookup.table$BRMMT, MSL.K))}
For an articulate explanation of Forrester’s approach to build World2, I recommend this 2016 presentation by Castro and Cellier. Since the Rworld2 code is ~500 lines long (including numerous comments for a direct match to chapter 3 of Forrester, 1971), it is not given here in full but can be found on my GitHub repo hist_gc_sysdyn (short for History_GlobalCatastrophes_ SystemDynamics). Finally, let us plot the results.
# basic plots with same y-range as in Fig. 4-1 of Forrester (1971)plot(TIME, P, type = 'l', ylim = c(0, 8e9))plot(TIME, POLR, type = 'l', ylim = c(0, 40))plot(TIME, CI, type = 'l', ylim = c(0, 20e9))plot(TIME, QL, type = 'l', ylim = c(0, 2))plot(TIME, NR, type = 'l', ylim = c(0, 1000e9))
It was easy to verify that the R code is correct by comparing the results to Fig. 4–1 of Forrester (1971) — see figure on GitHub. The Rworld2 is crude but I wanted to keep the 1970’s essence of Forrester’s original work. Future works will include an interactive dashboard, as already offered in javascript and Insight Maker. Another step will be to write World3 in R (if Rworld2 took me one full day of work, Rworld3 should take about half-a-week). A longer-term project would be to define the model as a graph.
The purpose of this Medium post was to present the World2 model from a programming perspective and provide a R version, which was previously lacking. The debate surrounding the various doomsday scenarios is not the subject of this article but the reader may ask if there is any use in running World2 in 2020. So let me just quote Cellier (2008) in regard to the usefulness of such outdated model: “It turned out that Forrester and Meadows were essentially correct in their assessment, in spite of the fact that their models were very crude in comparison with real world dynamics.” The validity of these “simple” models has been confirmed in recent studies comparing past predictions to observations (Turner, 2008; 2014).
Castro R, Fritzson P, Cellier F, Motesharrei S, Rivas J (2014), Human-Nature Interaction in World Modeling with Modelica. Proc. 10th International Modelica Conference, Lund, Sweden, 477–488.Cellier FE (2007), Ecological Footprint, Energy Consumption, and the Looming Collapse. The Oil Drum.Cellier FE (2008), World3 in Modelica: Creating System Dynamics Models in the Modelica Framework. Proc. Modelica’08, 2, 393–400.Forrester JW (1961), Industrial Dynamics. M.I.T. Press, Cambridge, 464 pp.Forrester JW (1969), Urban Dynamics. Pegasus Communications, Inc., Waltham, 285 pp.Forrester JW (1971), World Dynamics. Wright-Allen Press, Inc., Cambridge, 144 pp.Fortmann-Roe S (2014), Insight Maker: A general-purpose tool for web-based modeling & simulation. Simulation Modelling Practice and Theory, 47, 28–45.Hayes B (1993), Computing Science: Balanced on a Pencil Point. American Scientist, 81(6), 510–516.Hayes B (2012), Computing Science: Computation and the Human Predicament, The Limits to Growth and the limits to computer modeling. American Scientist, 100(3), 186–191.Lobo DG (2007), Playing with Urban Life. In von Borries et al. (eds), Space time play computer games, architecture and urbanism : the next level. Birkhauser, 495 pp.Meadows DH, Meadows DL, Randers J, Behrens III WW (1972), The Limits to Growth. Universe Books, New York, 205 pp.Meadows DL (1974), Dynamics of Growth in a Finite World. Wright-Allen Press, Cambridge, 637 pp.Meadows D, Meadows D, Randers J (1992), Beyond the Limits. Chelsea Green Publishing, 300 pp.Meadows D, Randers J, Meadows D (2004), Limits to Growth: The 30-Year Update. Chelsea Green Publishing, 338 pp.Randers J (2012), 2052: A Global Forecast for the Next Forty Years. Chelsea Green Publishing, 416 pp.Sterman JD (2001), System Dynamics Modeling: Tools for learning in a complex world. California Management Review, 43(4), 8–25Turner GM (2008), A comparison of The Limits to Growth with 30 years of reality. Global Environmental Change, 18, 397–411.Turner GM (2014), Is Global Collapse Imminent? An Updated Comparison of The Limits to Growth with Historical Data. MSSI Research Paper No4, Melbourne Sustainable Society Institute, The University of Melbourne, 21 pp.