ModEco (NetLogo Version)
My purpose on this page is to briefly describe my experience working with NetLogo, constructing an agent based model which replicates one of the ModEco C++ model scenarios described elsewhere on this site.
(I AM EXCITED ABOUT THIS STUFF. PLEASE READ THE 'BRIEF DESCRIPTION' OF THE PANELS BELOW TO SEE HOW A GROWTH ECONOMY TRANSITIONS THROUGH THREE PHASES TO A STATIONARY ECONOMY [figures 5 through 8].)
This spring (2014) I took a couple of courses from Santa Fe Instutute (SFI). They were Massive Open Online Courses (MOOCs). In the second course, Introduction To Complexity, there was an opportunity to learn how to program in the language which can be downloaded for free here (NetLogo). I decided to give it a try. NetLogo is both a language and an application development environment (ADE). It seems to be designed for use by naive programmers who want to develop agent based models. It was, of course, my interest in agent based models (ABMs) that got me interested. I discovered that it was very easy to use, but slightly limited in the number of things you can do, when compared with C++.
Figure 1 - Evidently, I passed. :-)
I also found that there was a lack of style guidance on how to write good code. There is, of course, a language manual, like an automated dictionary, that is really very good. But that is not a style guide.
Having developed my own (somewhat peculiar) coding style over the years, I decided to find what guidance I could and write my own personal style guide while learning the language. This has two purposes for me. It helps me get a handle on the language itself. And, if I am away from the language for a while, it is a good tool to help me get back into the language later. My style guide has no NetLogo coding idioms, so it is not great, but it is what it is. If interested, you can download it from here (NetLogo Coding Standards for Orrery Software).
ModEco (NetLogo) Downloads
This is the closest I have to user documentation. This was written for the C++ version of ModEco, but, since my goal in NetLogo was to reproduce the C++ application in as much detail as possible, it is mostly applicable to the NetLogo version as well.
ModEco (NL) Brief Description
My approach was to focus on the PMM (Perpetual Motion Machine), a scenario in ModEco (C++) which runs forever, but is a tightly managed economy with fixed prices. My goal was to recreate that scenario as accurately as possible, but in NetLogo instead of C++, to see whether that scenario was reproducible.
Having worked on the ModEco application for several years now, I was very familiar with the code. So, in spite of the size (about 70 pages of NetLogo Code) it only took me about 2-3 weeks to learn the language and write a simplified version of the ModEco application in NetLogo. I was surprised and pleased with the ease of use. Ultimately, I completed the project in June, but returned to it in September, at which time I added many graphs and data collection and export facilities.
Figure 3 - The main interface tab for my NetLogo application called 'ModEco (NL)'.
Figure 3 shows the main 'panel' of the application, which is just large enough to hold a few controls and displays. Thankfully, the view can be extended to the right automatically if you place a control on the right edge. I did this, as an experiment as much as anything, and you can see that in the following figures. Each "panel" is actually just more real estate of the one single view, scrolled to the right. Note the horizontal scroll bar at the bottom which appeared as soon as I added stuff on the right.
Figure 4 - The Interface tab scrolled to the right to shows the additional real estate.
To the left is the set of controls and instructions for debugging the code, and for data collection in CSV files for analysis using MS Excel post-run. To the right is the set of parameter sliders to be used when exploring the so-called 'behavior space' of the model, a NetLogo feature worth understanding.
Figure 5 - Showing histograms of wealth and age for wrkrs and frmrs.
Now, this where is starts to get really interesting. In figure 5 the top two graphs are histograms of wealth distribution at about 8,000 ticks into the 'GROWTH' scenario. Here are the same characteristic Maxwell-Boltzmann distributions for wealth that appeared in the C++ version. This is clear evidence that some sort of entropy is being produced in these logical ABMs, just as it is in real-world systems of gas molecules. (See the graph of entropic indices in figure 7.) The bottom two graphs are different in shape. Agents are mature enough to reproduce by fission at age 800 (middle of the domain) but many live longer and die of old age. An agent that is unhealthy cannot reproduce until its energy level climbs sufficiently. All those agents still alive after age 800 (ticks) are therefore poor and unhealthy. In a steady-state economy, the population throbs, and you can see here that the frmrs are not well, compared to the wrkrs. A large part of the population of frmrs are unhealthy.
Figure 6 - Showing time series graphs for values of asset classes, wrkrs and frmrs.
I like these graphs. In the early ticks of a run, before some kind of stationary state is achieved, the behaviour of the economy goes through three phase shifts, two of which are clearly visible here. They are most easily distinguished in these charts that cover the first 8000 ticks (10 generations). In this 'GROWTH' scenario, the raw resources are absorbed by the economy as quickly as they can be taken up. This happens in two distinct phases causing huge perturbations in the relative sizes of classes. In phase I, during the first ~1600 ticks (2 generations), there is a small population, well below carrying capacity, enjoying great wealth, as free raw resources are sopped up by the wrkr population. All offspring have a great opportunity to not only live, but prosper. During phase II, for the next ~4000 ticks (5 generations) the wealth equillibrates within the classes with huge fast movements, while at the same time the remaining raw resources are sopped up more slowly. During phases I and II population growth is exponential. Phase III starts when the population reaches carrying capacity and all resources must now be recycled. When those fast movements of value from class to class have exhausted their fuel of new resources, then the more ponderous transformations of wealth from form to form are able to continue the process of equillibration. The shift to phase IV, the stationary 'sustainable' state, happens at about 24,000 ticks.
I see this as similar to the transformation of energy within a plant, e.g., as free energy is first captured as sugars, via photosynthesis, then moved and stored as starches, and finally converted to cellulose and other needed compounds.
Figure 7 - Showing the panel of economic indicators
Look for the two phase shifts in these graphs. At the beginning, the EMgr has a large endowment of cash and energy to give away, and the wrkrs are the primary recipients of these gifts. In the usage rates of labour, find the shift from abundant free resources to earned resources, at about 1600 ticks. In phase II the EMgr is still giving away its endowment, but the frmrs are sopping up the mass endowment more slowly. During this phase, the existing wealth shifts from asset class to asset class. Find the second shift at the point where massive wealth movements give way to smaller wealth movements.
Also, look for the throbbing background pattern as generations of agents reproduce about every 800 ticks.
Finally, note the responses of the three entropic indices as the economy shifts from phase to phase. Note how cash flows are stable for the first two phases, but highly volatile as the economy approaches its phase III almost stationary state.
I am still working out the details of how to properly calculate entropic indices for ABMs (see my page on this topic), but the bottom right graphs display the results of an implementation of my current thinking (as of 150103). Note how the plateauing of the entropic index for the wrkrs happens at the shift from phase I to phase II, and note how the plateauing of the entropic index for all agents combined happens at the shift from phase II to phase III behaviour. I don't entirely understand why (I am working on that), but I think it is really cool, and possibly significant.
Figure 8 - Sector sizes
Look for the phase changes in these graphs. Sector size is measured in dollars. During phase I the EMgr pours free resources into the economy as quickly as the wrkrs can sop them up. Wrkrs form the majority of the population, becoming very wealthy very quickly. During phase II, when there are massive fast movements of value from asset class to asset class, the remaining free resources of the EMgr are absorbed more slowly, with the wrkrs making few gains, and the frmrs (corporations) making much larger gains. During all of this time we have exponential growth of numbers of wrkrs, and almost linear growth of numbers of frmrs. But, when the free resources of the EMgr bottom-out, the population hits carrying capacity, all resources must now be recycled, and phase III begins. Phase IV, stationary state, during which all asset classes are stable, does not appear until about 24,000 ticks (30 generations of agents). That's the 'SUSTAINABLE' economy.
Last updated: 03 January 2015.