Examples

On this page we provide various examples of models built using repast.

-->

Basic Grid Examples


A translation of the Swarm example simulation Heat Bugs. The heat bugs simulation consists of heat bugs - simple agents that absorb and expel heat and a heatspace which diffuses this heat into the area surrounding the bug. Heat bugs have an ideal temperature and will move about the space in attempt to achieve this idea temperature.

A translation of the Swarm example simulation Heat Bugs. The heat bugs simulation consists of heat bugs - simple agents that absorb and expel heat and a heatspace which diffuses this heat into the area surrounding the bug. Heat bugs have an ideal temperature and will move about the space in attempt to achieve this idea temperature. Unlike the traditional heat bugs this takes place on a hexagonal grid space.

An implementation of the simulation described in John Padgett's "The Emergence of Simple Ecologies of Skill: A Hypercycle Approach to Economic Organization" in _The Economy as an Evolving Complex System II_, Eds. Arthur, Durlauf, and Lane. SFI Studies in the Sciences of Complexity, Vol. XXVII, Addison-Wesley, 1997, pp. 199-221. Thanks to John Padgett for allowing us to include it here. jpadgett@midway.uchicago.edu

Graphically the display shows cells activating each other, and displays existing hypercycles when stopped or paused.

This is an implementation of John Conway's game of life. Life is typically played on an "infinite" square grid. Each cell can be either live or dead. A cell comes to life if it has three neighboring live cells, and will die of "loneliness" if it has less than two neighbors, and will die of overcrowding if it has more than three neighbors.


A port of the mousetrap simulation from the Swarm simulation toolkit. This is a good example of dynamic scheduling and how to do discrete-event simulations using Schedule objects. The simulation is as follows. A torus is populated with "mousetraps." These traps each contain some n number of balls. A ball is thrown from the "outside" onto the center mousetrap. This trap triggers and throws its n number of balls into the air. These balls then trigger other traps and so on and so on.

An partial implementation of the Sugar Scape simulation from _Growing Artificial Societies_ by Epstein, Joshua M and Axtell, Robert. This implements rules G, R, and M from chapter II. The source code is heavily annotated as example of a simulation built using the Repast toolkit. See the html API documentation for the details of the framework objects.

This demo illustrates the use of the genetic algorithm package in an agent. The premise of this model is that there is a simple competition where the competitors must make a particular amount of change with the least amount of coins possible. Each step a judge will judge the competitors based on the number of coins they used and the total change they have. For example, if the goal amount is $0.79, an agent should have 3 quarters and 4 pennies. The number of coins the competitor has is determined by a genetic algorithm. This is a simple example, but shows the way in which the GA can be incorporated into an agent, and the procedures neccessary to have the GA work. Even with a small initial genetic pool the GA finds the correct solution usually in the first few ticks. When a competitor performs the correct action she moves towards the center of the display.

This demo illustrates the use of the neural network package in an agent. The premise of this model is that there is an office with numerous employees and two bosses. Every tick of the model the bosses may or may not tell each employee to do something. Each employee then is to either perform some task or not depending on the tasks given to them by the bosses. After that the actions of the employee are judged by a consultant. When an employee performs the correct action she moves towards the center of the display.

This demo illustrates the use of the regression package in an agent. The premise of this model is that there is an office with numerous employees and two bosses. Every tick of the model the bosses may or may not tell each employee to do something. Each employee then is to either perform some task or not depending on the tasks given to them by the bosses. After that the actions of the employee are judged by a consultant. When an employee performs the correct action she moves towards the center of the display.

Network Examples


A simple example model that illustrates how to create and display a non-grid network. The JiggleModel creates two networks of oval and rectangular agents where each agent is linked to every other node in its network. These agents then randomly pick another member of the network and if the two agents do not overlap, the first agent moves towards the second. If they do overlap the first moves away.

This is an implementation of the second model (model II) described in Jin, Girvan, and Newman, "The Structure of Growing Social Networks." Santa Fe Institute 2001 working paper. This paper can be found on-line at http://www.santafe.edu/research/publications/workingpapers/01-06-032.pdf

Geographic Information Systems (GIS) Examples


A simple example featuring Repast's GIS capabilities.

Systems Dynamics Examples


This is an example model demonstrating how to use the CEquation and CEquationFactory classes to create system dynamics type models. This particular simple model of a rabbit population is based on that described in http://sysdyn.clexchange.org/sdep/Roadmaps/RM5/D-4432-2.pdf. The general idea here is to link the CEquations together so that the variables in one equation are the results of another. For example, population = population + (births - deaths) * dt. When this equation is evaluated the value of births and deaths are the results of a previous evalutation of the births and deaths equations.