Exploring an Edgeworth Box in the Indra agent-based modeling system.


In [12]:
from IPython.display import Image
Image(filename='Contract-curve-on-edgeworth-box.svg.png')


Out[12]:

"In economics, an Edgeworth box, named after Francis Ysidro Edgeworth, is a way of representing various distributions of resources. Edgeworth made his presentation in his book Mathematical Psychics: An Essay on the Application of Mathematics to the Moral Sciences, 1881. Edgeworth's original two-axis depiction was developed into the now familiar box diagram by Pareto in his book "Manual of Political Economy", 1906 and was popularized in a later exposition by Bowley. The modern version of the diagram is commonly referred to as the Edgeworth–Bowley box." -- Wikipedia

In our agent-based model, we endow our two traders with a certain amount of two goods, and then allow them to make any trades that result in increased utility for the trader. Neither trader knows the other's utility functions, and must make offers and see if they are accepted. Let's look at the properties we are using in our first run. Multiple sets of properties can be stored to disk, so interesting parameters sets can be saved:


In [16]:
!cat edgebox.props


{
    "bea_cheese": 0, 
    "al_cheese": 20, 
    "al_cutil": "10 - .5 * qty", 
    "al_wine": 0, 
    "log_fmode": "w", 
    "bea_wutil": "10 - .5 * qty", 
    "log_level": 20, 
    "user_type": "iPython Notebook", 
    "al_wutil": "10 - .25 * qty", 
    "bea_wine": 20, 
    "log_format": "%(levelname)s:%(message)s", 
    "bea_cutil": "10 - .25 * qty", 
    "log_fname": "edgebox_model.txt", 
    "user_name": "gcallah"
}

These properties endow Albert with 20 cheeses and 0 bottles of wine, and Beatrice with 0 cheeses and 20 bottles of wine.


In [15]:
Image(filename='Graphics/AlAndBea.jpg')


Out[15]:

(Image from Zo by Arnold H.Q.M. Merkies.)

We can also set separate utility functions for each trader-good combo: here, for instance, we set Beatrice's cheese utility function to 10 - .25 * qty, and Al's to 10 - .5 * qty. And now we'll run with those properties, stepping through a series of "periods" where each trader is allowed to make an offer to the other:


In [1]:
run edgebox_run.py


/Users/gcallah/anaconda/envs/py33/lib/python3.3/site-packages/matplotlib/mathtext.py:46: UserWarning: Due to a bug in pyparsing <= 2.0.0 on Python 3.x, packrat parsing has been disabled.  Mathtext rendering will be much slower as a result.  Install pyparsing 2.0.0 or later to improve performance.
  warn("Due to a bug in pyparsing <= 2.0.0 on Python 3.x, packrat parsing "
Welcome, gcallah
Running in An Edgeworth Box
File: (w)rite properties | e(x)amine log file | (q)uit
Edit: (c)ode
View: (l)ist agents | (v)isualize | (i)nspect agent | (p)lot agents
Tools: (s)tep (default) | (r)un | (d)ebug
Choose one of the above and press Enter:s
Trades this period: 2
Albert has gained 18.75 utils and now has: wine: 2, cheese: 18,
Beatrice has gained 18.75 utils and now has: wine: 18, cheese: 2,
File: (w)rite properties | e(x)amine log file | (q)uit
Edit: (c)ode
View: (l)ist agents | (v)isualize | (i)nspect agent | (p)lot agents
Tools: (s)tep (default) | (r)un | (d)ebug
Choose one of the above and press Enter:s
Trades this period: 2
Albert has gained 34.5 utils and now has: wine: 4, cheese: 16,
Beatrice has gained 34.5 utils and now has: wine: 16, cheese: 4,
File: (w)rite properties | e(x)amine log file | (q)uit
Edit: (c)ode
View: (l)ist agents | (v)isualize | (i)nspect agent | (p)lot agents
Tools: (s)tep (default) | (r)un | (d)ebug
Choose one of the above and press Enter:s
Trades this period: 2
Albert has gained 47.25 utils and now has: wine: 6, cheese: 14,
Beatrice has gained 47.25 utils and now has: wine: 14, cheese: 6,
File: (w)rite properties | e(x)amine log file | (q)uit
Edit: (c)ode
View: (l)ist agents | (v)isualize | (i)nspect agent | (p)lot agents
Tools: (s)tep (default) | (r)un | (d)ebug
Choose one of the above and press Enter:s
Trades this period: 2
Albert has gained 57.0 utils and now has: wine: 8, cheese: 12,
Beatrice has gained 57.0 utils and now has: wine: 12, cheese: 8,
File: (w)rite properties | e(x)amine log file | (q)uit
Edit: (c)ode
View: (l)ist agents | (v)isualize | (i)nspect agent | (p)lot agents
Tools: (s)tep (default) | (r)un | (d)ebug
Choose one of the above and press Enter:s
Trades this period: 2
Albert has gained 63.75 utils and now has: wine: 10, cheese: 10,
Beatrice has gained 63.75 utils and now has: wine: 10, cheese: 10,
File: (w)rite properties | e(x)amine log file | (q)uit
Edit: (c)ode
View: (l)ist agents | (v)isualize | (i)nspect agent | (p)lot agents
Tools: (s)tep (default) | (r)un | (d)ebug
Choose one of the above and press Enter:s
Trades this period: 2
Albert has gained 67.5 utils and now has: wine: 12, cheese: 8,
Beatrice has gained 67.5 utils and now has: wine: 8, cheese: 12,
File: (w)rite properties | e(x)amine log file | (q)uit
Edit: (c)ode
View: (l)ist agents | (v)isualize | (i)nspect agent | (p)lot agents
Tools: (s)tep (default) | (r)un | (d)ebug
Choose one of the above and press Enter:s
Trades this period: 1
Albert has gained 68.25 utils and now has: wine: 13, cheese: 7,
Beatrice has gained 68.25 utils and now has: wine: 7, cheese: 13,
File: (w)rite properties | e(x)amine log file | (q)uit
Edit: (c)ode
View: (l)ist agents | (v)isualize | (i)nspect agent | (p)lot agents
Tools: (s)tep (default) | (r)un | (d)ebug
Choose one of the above and press Enter:s
Trades this period: 0
Albert has gained 68.25 utils and now has: wine: 13, cheese: 7,
Beatrice has gained 68.25 utils and now has: wine: 7, cheese: 13,
We've reached equilibrium.
Returning to run-time environment

We end the run by reaching equilibrium (no more mutually beneficial trades) with Albert having 7 cheese and 13 wine, and Beatrice having 13 cheese and 7 wine. Now let's change the utility functions. We'll set them to:

pa.set("al_cutil", "10 - .5 * qty")

pa.set("al_wutil", "10 - .75 * qty")

pa.set("bea_wutil", "10 - .5 * qty")

pa.set("bea_cutil", "10 - .75 * qty")

In [2]:
run edgebox_run.py


Welcome, gcallah
Running in An Edgeworth Box
File: (w)rite properties | e(x)amine log file | (q)uit
Edit: (c)ode
View: (l)ist agents | (v)isualize | (i)nspect agent | (p)lot agents
Tools: (s)tep (default) | (r)un | (d)ebug
Choose one of the above and press Enter:s
Trades this period: 2
Albert has gained 17.25 utils and now has: wine: 2, cheese: 18,
Beatrice has gained 17.25 utils and now has: wine: 18, cheese: 2,
File: (w)rite properties | e(x)amine log file | (q)uit
Edit: (c)ode
View: (l)ist agents | (v)isualize | (i)nspect agent | (p)lot agents
Tools: (s)tep (default) | (r)un | (d)ebug
Choose one of the above and press Enter:s
Trades this period: 2
Albert has gained 29.5 utils and now has: wine: 4, cheese: 16,
Beatrice has gained 29.5 utils and now has: wine: 16, cheese: 4,
File: (w)rite properties | e(x)amine log file | (q)uit
Edit: (c)ode
View: (l)ist agents | (v)isualize | (i)nspect agent | (p)lot agents
Tools: (s)tep (default) | (r)un | (d)ebug
Choose one of the above and press Enter:s
Trades this period: 2
Albert has gained 36.75 utils and now has: wine: 6, cheese: 14,
Beatrice has gained 36.75 utils and now has: wine: 14, cheese: 6,
File: (w)rite properties | e(x)amine log file | (q)uit
Edit: (c)ode
View: (l)ist agents | (v)isualize | (i)nspect agent | (p)lot agents
Tools: (s)tep (default) | (r)un | (d)ebug
Choose one of the above and press Enter:s
Trades this period: 2
Albert has gained 39.0 utils and now has: wine: 8, cheese: 12,
Beatrice has gained 39.0 utils and now has: wine: 12, cheese: 8,
File: (w)rite properties | e(x)amine log file | (q)uit
Edit: (c)ode
View: (l)ist agents | (v)isualize | (i)nspect agent | (p)lot agents
Tools: (s)tep (default) | (r)un | (d)ebug
Choose one of the above and press Enter:s
Trades this period: 0
Albert has gained 39.0 utils and now has: wine: 8, cheese: 12,
Beatrice has gained 39.0 utils and now has: wine: 12, cheese: 8,
We've reached equilibrium.
Returning to run-time environment

We now reach equilibrium sooner, and with different final holdings. Our changed utility functions make each trader "like" their initial good better, and so they wind up with more of it in equilibrium.


In [ ]: