ModEco - Version 1.XX - C++ Implementation

Towards an understanding of sustainable economics

Version 1.XX was the basis of my studies with gifted high school students, and my presentation to MABS 2013.  It is here for historical reasons, because I have a lot of analytical material drawn from it.

Design Documentation To Download

ODD specification of the PMM - The only sustainable complete economy achieved to date has been called the 'Perpetual Motion Machine', or PMM.  The Open Agent-Based Modeling Consortium (OpenABM) has proposed that standards be established for documentating agent-based models in such a way that they can be easily replicated by other researchers on different platforms.  Those standards are called the 'Overview, Design concepts, Details' protocol, or ODD protocol.  I have used the ODD protocol to document the PMM.  This document does not cover those parts of the ModEco application that are outside of the ODD protocol standard scope,

To download a copy of the ODD specification of the PMM  click here.

To access the website of OpenABM click here.

To access the description of the ODD protocol on the OpenABM website click here.

To access my submission of the PMM to OpenABM, for a copy of the ModEco C++ code, click here.

The Economic Engine - This document contains a easily readable extract of the C++ code modified to become pseudo-code.  That is to say, it will not execute, but a lot of technical stuff that is not relevant to understanding the basic functioning of the model is removed so that you can see the important part that remains.  For example, I have removed error checking and correction, real-time data update and display, real-time data collection and insertion to CSV file.

To download a copy of this document click here.
A Sustainable Model Economy - In this unpublished paper I describe the PMM as the only complete economic model that is sustainable, argue that it is a good testbed for research into the dynamics of sustainable economic systems, and propose a number of testable hypotheses.

To download this paper click here.
The ModEco Report - This is the report written by my students and I presenting our findings at the end of the 2010/2011 session of the IDC4U CAS course for gifted students.  We started the program in early October 2010.  We had ModEco running by November 2010, but none of the models were stable or sustainable.  By early February of 2011 we had discovered how to make the PMM sustainable by fixing prices, a technique that was admittedly less than realistic.  By March 2011 we had a first draft of a mathematical model of the PMM ready for presentation.  Our program came to its intended conclusion in April, when we made presentations, and we did not have time to test the mathematical model against ModEco output.

To download this report click here.

Three graphics from the report are replicated below.  Cash, mass (resource-based materiel units, or RbMus) and energy (work-based materiel units, or WbMus) are all conserved, and all flow in cycles through the system.  These diagrams epitomize the cyclic economic engine of V1.XXX.  The PMM has run for an amazing 20 million ticks without gain or loss of these quantities.  For a complete description of the diagrams, download and read the report.

I understand that energy does not cycle in an economy.  It was implemented in this fashion as I knew this should lead to a sustainable and stable dynamic.  Luckily it did.  A more realistic implementation is undertaken in the linear engine in V2.XX, as per Herman Daly's concept of a steady-state economy.  

Model Economy Design Document V1.19a - This is a relatively detailed description of the design of the ModEco application as of release V1.19 alpha, the most recent of the V1.XX series.  I will not be doing any more work on this series, as it has been incorporated into the V2.XX series.  However, this design document is the best description of the cyclic engine ported from V1.XX to the V2.XX series of releases.

To download a copy of this document click here.
The Phase Space - An unpublished paper, this is a draft of an exploration into the size of the ModEco application's parameter space, and the phase space of a typical model such as the PMM.  There is also an associated PowerPoint slide showing the structure of the phase space.  Some parameters are fixed at the beginning of a run for a given model, so the parameter space of the application is significantly larger than the phase space of a modelled economy.  Nevertheless, the phase space of a modelled economy is still immense.  This draft was worked out quickly with some of my students, and, in retrospect contains some errors which I have not yet addressed.  The work, did, however, provide me with some substantial insight into the size of the phase space of an economy, as well as of a simple model economy.  So, I share it, defective though it be.

To download a copy of this document  click here.
To download a PowerPoint graphic of the phase space structure  click here.

Analytical Documentation to Download

The Distribution of Wealth - In this unpublished paper, I examined the peculiar shape of the distribution of wealth that was discovered to be characteristic of the PMM.  The diagrams below show the distributions for corporations and persons tested against a best fit for four types of curve.  The Burr or Fisk distributions can replicate the data most favourably.  However, the Maxwell-Boltzmann distribution for speeds in an ideal gas provides the most sound theoretical description that we could find that might give rise to such a distribution.  It seems that a one-to-one capital exchange in an economy is similar to a one-to-one exchange of energy in an ideal gas.  This discovery by me and my students lead us to the work of Econophysicists like Yakovenko.  

To download this paper click here
To download the NTF in which these analyses are described, click here.
To access Dr Victor Yakovenko's website presenting his work in Econophysics, click here.

About Steady-State Economics and Carrying Capacity

When you think about deep long-term sustainability, you are talking about a global economy that has reached steady-state in some fashion.  Herman Daly and the Ecological Economists have championed this idea.  This means that the global human population has reached the global carrying capacity.  And this means that every reproductive pair of people can produce exactly two offspring.  Any reproduction in excess of that results in death of the excess by starvation, old age, war or disease or other means.  Admittedly, the PMM is not a very realistic economic model, but, since it is the only model of a sustainable biophysically complete economic system in existence, one has to ask oneself, "Just what does this sustainable economic system looks like?"

NTF - Transient vs Steady State - This is the first of a series of 'notes to file' (i.e. diary entries) in which I logged the steps I used to create and analyse data.  ModEco has the ability to create a wide variety of data files with both microeconomic data and macroeconomic data.  This data may be generated on a per transaction basis, on a per tick basis, or on a per generation basis.  A generation is by default 800 ticks.  The output data files are in 'comma separated value' (CSV) file format, as described in the appropriate design document.  In these diary notes I somewhat meticulously recorded the steps I undertook in the analysis to ensure that it was repeatable and comparable.  I share them here as a guide for those who might wish to undertake similar studies or challenge my results.  Below I share one or two graphics from among several for each NTF.

In this NTF  and the following, I study the PMM, the only sustainable model economy found so far within ModEco.  Like all models that achieve a kind of steady-state mode of operation, there are transient changes that eventually die out before steady state is finally achieved.  For example, population rises until it reaches carrying capacity.  Such changes are easy to see.  I determined that most transients die out by 16,000 ticks, or approximately 20 generations of ModEco agents.

What I discovered is that some kinds of transient behaviour have short lapse times, while others have long lapse times.  You can see in the following figure that even in the extremely long time scale of 1 million ticks there is a small but relentlessly positive slope on the average net worth per agent.  Since number of mass and energy units (having value), and prices are all fixed, the change must be ascribed to a long-term decline of the carrying capacity of the economy over time as it becomes more and more mature.  I speculate that the extreme wealth of a small dynasty of agents increasing over many generations would account for this drift.

To download a copy of this document click here.

The Beating Heart of a Sustainable Economy

The following graphic represents life in a sustainable economy over a period of time covering 1.290 generations of agents.  There are four times as many persons and corporations (workers vs farmers) by design.  Focus on the workers (brown line).  There are short-time-scale ups and downs that make the line look thick.  I realize that the time scale is difficult to read, but it is marked off about every 19,000 ticks, or about every 24 generations.  So, every 10-12 generations the populations grows, then collapses.  There are medium-time-scale ups and downs.  On a varying cycle that may last barely 50 generations, or may stretch to several hundred generations, the population rises and falls.  On a very very long time scale, there is a steady decline in the average number of agents.  Note that there is a correlation between the rises and falls in the two lines, easily detectable by inspection.

This cyclic economic growth and collapse is an emergent phenomenon, as is the long-term decline in carrying capacity of the economy.


Farmers (corporations) and workers (persons) hold their wealth in assets classes.  The following graphic displays the asset classes of each type of agent, on a real-time basis as the model runs.  This data can also be collected in CSV files for later analysis using MS Excel.  The asset classes for corporations are Cash on Hand, Raw grain in the field, infrastructure, inventory for sale, supplies for self-consumption, and waste.  The asset classes for persons are Cash on Hand, ability to perform hours of work, supplies for self-consumption and waste.

NTF - Partition of Wealth Based on Macro-Economic Data - In this note I use the macro-economic data to explore the way wealth is divided between the public, corporate and private sectors in the economy.  The total value of all cash, goods and services is conserved and constant.  This is why I call the PMM a conservative economy.  I realize this is NOT realistic, but it is the only economy that is stable and sustainable, so I study it to understand why. 

To download a copy of this document click here.

In the graphic that follows, we see a truly bizarre phenomenon.  In this graph we are looking at the corporate sector, but the consumer sector looks similar.  The graph needs some explanation.  Note that both axes are net worth.   The corporations hold their assets in six asset classes.   Suppose the agents have a combined net worth of $210K held in six asset classes of values $10K through $60K.  Then the data for that generation of corporations would be plotted at the six points (210 K ,10 K ), (210 K ,20 K ), (210 K ,30 K ), (210 K ,40 K ), (210 K ,50 K ), and (210 K ,60 K ).  So, the combined net worth of a single generation of corporations is plotted as six points in a vertical line, such that the sum of the y values is equal to the x value.

Over a thousand generations in a sustainable economy, the total net worth of the corporations as a sector waxes and wanes like the beating heart of a living organism, as seen above.  The size of some asset classes also waxes and wanes, while others do not.  So, two asset classes form stable lines near the bottom of the graph (green and red).  Two form sloped lines that define a kind of line of symmetry (light blue and very dark blue).  And two lie above and below those lines of symmetry (dark blue and dark brown).  These are the cash holdings and the value of the corporate infrastructure.  For a given level of net worth (a vertical line), when cash is down, the value of infrastructure is up.  The economy goes through periods of expansion and collapse.  During expansion, corporate net worth climbs and these two asset classes each draw an arcing line on the graph.  During collapse, both lines terminate and reappear a little down and to the left.  Over a thousand+ generations many cycles of growth and collapse follow one another until they paint this rather abstract representation of life in a sustainable world.

This is an emergent phenomenon.
NTF - Partition of Wealth Based on Micro-Economic Data - Whereas the study of macro data looks at the dynamics of each economic sector, this study looks at the distribution of wealth in asset classes for individual agents.

To download a copy of this document click here.

As the graph below shows, micro-economic data paints a totally different kind of picture.  This time we look at persons rather than corporations, though the graph for corporations is, again, similar.  Persons (workers) hold their assets in four classes.  They use business factors to decide into which asset class value should be placed at each tick of the model.  For each agent, a vertical line at the net worth goes through four dots, one for each asset class.   So, for example, you see that one extremely wealthy agent with a net worth of 23-24 thousand dollars is represent by four dots at the far right of the graph.  When you plot the asset class values for all agents, we get a range of net worth values, and a variety of distributions of that net worth among the available asset classes.   Waste is sold off immediately, so the value stays close to zero at all times.  Cash is blue.  Food stocks are green.  The value stored as health/personal infrastructure varies greatly between the very wealthy and very poor.  The poor agents are living on the edge of starvation at all times, so money is spent on food and usually eaten almost immediately.  This mean they are ill-prepared to participate in economic opportunities that arise that require cash.  On the other hand, the very wealthy retain most of their wealth in cash and in food stocks.  They are fully enfranchised to participate in the economy whenever they can and wish, and are never in danger of starvation.

NTF - Agent Deaths - In the PMM, a sustainable steady-state economy, 50% of every generation die of starvation or old age having failed to reproduce.  All agents that succeed in reproducing in this model are removed from the population (die) to make room for the two offspring.  Even so, on average, one must die.  This graph shows the probability of death vs age.  Another graph in this NTF (not shown here) shows the probability of death vs net worth.  Sadly, in the PMM the offspring of the poor are likely to have a short miserable life of partial or total economic disenfranchisement ending in starvation,  On the other hand, the offspring of the wealthy are likely to have a life of partial or total economic enfranchisement, ending in reproduction.  As you can see from the following graph, a small few avoid starvation and die of old age, having failed to achieve enough health to reproduce at any time in their long lives,

To download a copy of this document click here.

NTF - Agent Births - In ModEco, when agents reproduce they have two offspring and are then removed from the population.  This primitive approach to reproduction (essentially fission) allows for easier analysis than sexual serial reproduction of multiple litters, as demonstrated in PSoup.  When we plot the probability of death by reproduction (i.e. giving birth) vs the net worth of the mother, we get this outstanding graph.  It is well modelled by a Burr distribution, but the right-hand tail is slightly fatter than a Burr distribution around net worth 109, and slightly thinner than a Burr distribution around net worth 160.  We draw the conclusion that the poor agents are not only the most common (as seen in the graphs respecting distribution of wealth), but also the most prolific reproducers.  This is, perhaps, not a surprise, but it does again bring us face to face with the fact that the offspring of the poor have the shortest lives, are most vulnerable, and rarely survive to reproduce.

NTF - Grants - When an agent dies, its assets are transferred to the care of the Estate Manager (EMgr) in the form of mass, energy and cash.  The system is closed with respect to these three types of materiel.  If such assets are not returned to the economy the EMgr eventually has most or all of the assets and the economy collapses.  It is a necessary part of the PMM that the EMgr donates these assets to the living agents.  In ModEco, needy but deserving agents apply for and receive grants.  If they have opportunity to sell or buy, but have insufficient assets to meet quota for the deal, they can apply to the EMgr for a grant sufficient to meet quota.  This document analyses the grant-related statistics.

To download a copy of this document click here.

ModEco keeps track, for each agent, of the number of opportunities to participate in an economic transaction, and the number of times it successfully completes a transaction.  This provides an indication of how fully enfranchised an economic agent is.  On its death, the statistics for the agent are written to a CSV file for analysis, as part of the grant statistics.  The following graphic is a remarkable graph for a variety of reasons.  I cannot say I understand it.  But I can explain what it means.

The x axis is for the number of possible transactions in which an agent may participate.  The y axis is for the number of actual transactions in which the agent did participate.  Each point represents the statistics for one agent.  The graph represents data for about 100,000 agents.  Many points overlay each other, and that depth of layers is not visible here.  The least squares line is shown through the middle of the cloud of points, but I am not sure what it means.  The other two lines are drawn in by hand.  Points near the upper line indicate maximal economic enfranchisement.  Points near the lower line indicate minimal economic enfranchisement.  Points to the left of the cloud indicate less opportunity, possibly due to short lives due to poverty.  Points to the right of the cloud indicate more opportunity, possibly due to long lives due to wealth.  I have not investigated these hypotheses.  Note the vertical bars at the left and right edges of the cloud.  Very curious!

NTF - Redistribution of Wealth - In this note I attempted to find a mathematical formula similar to the Boltzmann equation for equilibrium.  The idea is the distribution of wealth is stable tick after tick, as is the distribution of energy in the atoms of an ideal gas.  If you divide the domain of wealth into equal small intervals, then on each tick the number of agents entering an interval must equal the number exiting that interval.  For a given interval, entries and exits might come from births, deaths, deals, and grants.  If there is a formula for each of these, it should be possible to come up with a combined equation.  Such a combined equation would define sustainability in a way that might be applied to more complex economies, as is done for complex gases.

Regretfully, I failed.  The mathematics was beyond me.

To download a copy of this document click here.

Technical Stuff

To download a software package with the most current release of ModEco V1.XX, click here (2.8 Mb).

Release Status:  Version 1.244, Alpha release.  Only the cyclic economic engine is found in this build.  I.e. it is a closed system with respect to mass, energy and cash.

System Requirements:  Tested on Windows 95, Windows XP, Windows 7.  Not tested on Windows 8.  Will not work on Windows Vista.  Requires screen resolution of 1024 x 768 or higher.

Installation: This package of software does not install itself.  Copy it to a suitable directory.  I suggest you make a new directory in your "My Documents" directory called "OrrerySW\ModEco\" and place it there.  Then use WinZip or a similar utility to decompress it in place.  There are three files, only one of which is functional, but the three are needed in place.  Copy the exe file and place a short cut on your desk top.

Startup and operation:  Double left-click on the exe file, or on the desk-top icon, click once on the splash screen, and close the welcome screen.  Use the Menu command "Models" to select a startup scenario from the list.  There is a toolbar with icons for most of the commands you will need.  E.g. there is an IWiz button to call up the initiation wizard which lets you change parameters before a run.  A restricted version of this, the EWiz button, will let you change a subset of those parameters later, during a run.  There are also buttons for causing the economy to advance by 1 function (1Fn), by 1 tick (1Tic), in slow mode (SloMo), in fast mode (Go) or to stop (Stop).  There are also toolbar buttons to toggle the display areas: left (L), right (R), status (S) or notes (N).  Finally, you should know that a wide variety of data output files can be generated using the menu command "Excel Export".

Documentation: To download documentation about the software, see  the section above.

The Cyclic Engine:  V1.XX is a closed system in which energy and mass flow in a cycle.  While this is consistent with the laws of conservation of mass and energy, it is not consistent with the second law of thermodynamics which implies that energy becomes degraded on use and cannot be used again.

NOTE: ModEco is a work in progress!

Last updated: September 2014