|
| 1 | +# Sugarscape Constant Growback Model with Traders |
| 2 | + |
| 3 | +## Summary |
| 4 | + |
| 5 | +This is Epstein & Axtell's Sugarscape model with Traders, a detailed description is in Chapter four of |
| 6 | +*Growing Artificial Societies: Social Science from the Bottom Up.* (1996) |
| 7 | + |
| 8 | +This code generally matches the code in the Complexity Explorer Tutorial, but in `.py` instead of `.ipynb` format. |
| 9 | + |
| 10 | +### Agents: |
| 11 | + |
| 12 | +- **Sugar**: Sugar agents grow back at one unit per time step and can be harvested and traded by the trader agents. Sugar |
| 13 | +is unequally distributed across the landscape with sugar hills in the upper left and lower right of the space. |
| 14 | + (green if you do the interactive run) |
| 15 | +- **Spice**: Spice agents grow back at one unit per time step and can be harvested and traded by the trader agents. Spice |
| 16 | +is unequally distributed across the landscape with spice hills in the upper right and lower left of the space. |
| 17 | +(yellow if you do the interactive run) |
| 18 | +- **Traders**: Trader agents have the following attributes: (1) metabolism for sugar, (2) metabolism for spice, (3) vision, |
| 19 | + (4) initial sugar endowment and (5) initial spice endowment. The traverse the landscape harvesting sugar and spice and |
| 20 | +trading with other agents. If they run out of sugar or spice then they are removed from the model. |
| 21 | + |
| 22 | +The trader agents traverse the landscape according to rule **M**: |
| 23 | +- Look out as far as vision permits in the four principal lattice directions and identify the unoccupied site(s). |
| 24 | +- Considering only unoccupied sites find the nearest position that produces the most welfare using the Cobb-Douglas function. |
| 25 | +- Move to the new position |
| 26 | +- Collect all the resources (sugar and spice) at that location |
| 27 | +(Epstein and Axtell, 1996, p. 99) |
| 28 | + |
| 29 | +The traders trade according to rule **T**: |
| 30 | +- Agents and potential trade partner compute their marginal rates of substitution (MRS), if they are equal *end*. |
| 31 | +- Exchange resources, with spice flowing from the agent with the higher MRS to the agent with the lower MRS and sugar |
| 32 | +flowing the opposite direction. |
| 33 | +- The price (p) is calculated by taking the geometric mean of the agents' MRS. |
| 34 | +- If p > 1 then p units of spice are traded for 1 unit of sugar; if p < 1 then 1/p units of sugar for 1 unit of spice |
| 35 | +- The trade occurs if it will (a) make both agent better off (increases MRS) and (b) does not cause the agents' MRS to |
| 36 | +cross over one another otherwise *end*. |
| 37 | +- This process then repeats until an *end* condition is met. |
| 38 | +(Epstein and Axtell, 1996, p. 105) |
| 39 | + |
| 40 | +The model demonstrates several Mesa concepts and features: |
| 41 | + - MultiGrid |
| 42 | + - Multiple agent types (traders, sugar, spice) |
| 43 | + - Dynamically removing agents from the grid and schedule when they die |
| 44 | + - Data Collection at the model and agent level |
| 45 | + - Batchrunner (i.e. parameter sweeps) |
| 46 | + |
| 47 | +## Installation |
| 48 | + |
| 49 | +To install the dependencies use pip and the requirements.txt in this directory. e.g. |
| 50 | + |
| 51 | +``` |
| 52 | + $ pip install -r requirements.txt |
| 53 | +``` |
| 54 | + |
| 55 | +## How to Run |
| 56 | + |
| 57 | +To run the model a single instance of the model: |
| 58 | + |
| 59 | +``` |
| 60 | + $ python run.py -s |
| 61 | +``` |
| 62 | + |
| 63 | +To run the model with BatchRunner: |
| 64 | + |
| 65 | +``` |
| 66 | + $ python run.py |
| 67 | +``` |
| 68 | + |
| 69 | +To run the model interactively: |
| 70 | + |
| 71 | +``` |
| 72 | + $ mesa runserver |
| 73 | +``` |
| 74 | + |
| 75 | +Then open your browser to [http://127.0.0.1:8521/](http://127.0.0.1:8521/) and press Reset, then Run. |
| 76 | + |
| 77 | +## Files |
| 78 | + |
| 79 | +* ``sugarscape_g1mt/trader_agents.py``: Defines the Trader agent class. |
| 80 | +* ``sugarscape_g1mt/resource_agents.py``: Defines the Sugar and Spice agent classes. |
| 81 | +* ``sugarscape_g1mt/model.py``: Manages the Sugarscape Constant Growback with Traders model. |
| 82 | +* ``sugarscape_g1mt/sugar_map.txt``: Provides sugar and spice landscape in raster type format. |
| 83 | +* ``server.py``: Sets up and launches and interactive visualization server. |
| 84 | +* ``run.py``: Runs Server, Single Run or Batch Run with data collection and basic analysis. |
| 85 | + |
| 86 | +## Additional Resources |
| 87 | + |
| 88 | +- [Growing Artificial Societies](https://mitpress.mit.edu/9780262550253/growing-artificial-societies/) |
| 89 | +- [Complexity Explorer Sugarscape with Traders Tutorial](https://www.complexityexplorer.org/courses/172-agent-based-models-with-python-an-introduction-to-mesa) |
0 commit comments