The OPTIMAES project started with a simple "seed" program written in Python (WhyPythonForOptimaes
?) and we (and we hope others) will continue to extend this code to address different questions we'd like to answer. Although this is the basis of our experiments, you don't have to use our code to contribute to the project. If you're using Swarm, Sugarscape, Repast etc. we're still interested.
If you unpack the current version of the code you see it's divided into 5 subdirectories.
This provides the basic network code and infrastructure. We wrote it ourselves, though there are probably better libraries out there. If you think there's a good reason to port to one of these libraries, tell us. Or even better, do the port :-)
We use a generic network (rather than, for example, a grid or a space within which agents are mobile) to represent the topology of economies. This allows us to experiment with different social structures : fully connected networks, locally connected ones, and randomly connected ones. In future we'll also do SmallWorlds, ScaleFreeNetworks and later, more complex models will explore allowing the network to be rewired by the economic activity.
Networks contains the following classes
- Matrix : a simple two dimensional array of Object. This is used by the Network to hold a matrix of arcs.
- Node : A node
- Arc : Arcs are always between two nodes.
- Network : Holds lists of networks and arcs, and a matrix of arcs.
- NetworkFactory? : Creates and wires networks together. Can create different structures.
As of version 0.1.2 statistics has more classes
- Table : derived from Matrix, this is a 2D array that assumes it contains numbers, and produces : totals, means and standard deviations of all columns.
- EconomyReport? : contains a Table summarizing the state of an economy
- EconomyAccountant? : takes an Economy and produces an EconomyReport?
- ExperimentReport? : contains information summarizing an Experiment
- ExperimentAccountant? : Does all necessary statistics to create and fill an ExperimentReport?
This directory contains all the classes necessary to model economies. Before trying to understand this code, make sure you've read and understood OverviewOfTheFirstModel.
Now, here are the core classes :
- RRMap : contains one agent's characteristic about one resource. It contains the name, rgc, rcr, need and current.
- Agent : contains a number of RRMaps, one for each resource. Also links to the node in the social network where the agent lives. And has methods for assessing the status of the agent, behaving during one time step (in this case, ignoring other agents in the population) etc.
- Neighbourhood : holds the list of agents that are connected to a particular agent
- Economy : Holds a number of Agents, and a Network to define the social topology within which they live.
- EconomyFactory? : Creates an economy. Different types of economies contain different types of agents, and the main method of this factory object takes the agent type as parameter for constructing an economy.
- the name of a resource is used as it's unique id in all dictionaries of RRMaps and representations of resources.
This directory also contains subclasses which represent different agent and economy types :
- GiftAgent : these are the basic agents in a gift economy. They subclass Agent, and override it's "oneStep" method. Each time-step, each gift agent identifies it's surplus for each resource type, looks around it's neighbourhood for someone most in need of this resource, and donates it's surplus to that agent.
- BarterAgent : another subclass of Agent. This one, for each surplus, offers to barter it for it's shortfall in another resource
- ProfitSeekingBarterAgent : a subclass of BarterAgent. Unlike BarterAgent which barters "fairly", this agent tries to extract a profit by exagerating it's stated needs.
- MoneyAgent : this subclass of agent has a variable, purse, to hold it's money (another RRMap). It auctions it's surplus to it's neighbourhood for money.
This directory contains the outer framework for running experiments on economies and collecting statistics on them.
- Run (REMOVED IN VERSION 0.1.2) : This class represents one run through a number of steps with a particular economy. It creates the economy internally and steps through it a requisite number of times, it then creates a Table of the state of each agent at the end of the run.
- Experiment : This class can execute a number of runs of an economy with the same parameters.
- ExperimentFactory? : assembles all the parameters necessary to run an experiment
Experiments are objects which hold one set of runs with the same parameters. One Experiment maps to one data-point.
The next level of organization up from Experiments are Questions. A question considers a comparison between different types of economy or different parameters for the purposes of testing a hypothesis. At the moment there's no Question class in the object model. Instead, a question can be represented by putting a question data file or script in the questions sub-directory.
At the moment contains :
- defaultExperiment which is exactly that. To test that it's working and to give you a chance of doing "real useful science in just five minutes" (tm).
- batchExperiment which allows you to run a file containing a number of data points (See BatchMode)
- config.py : used by all top level programs to set the library directories