Getting Started

The example models can be downloaded from here.

Each example model resides in its own subdirectory, e.g., examples/rumor for the Rumor Network model. Each subdirectory contains the python source for the model, an html file with additional information about the model, and a yaml format file containing the input parameters for that model.

To run the model,

$ cd examples/<model_dir>
$ mpirun -n 4 python <model.py> <input_params.yaml>

Replace <model_dir>,<model.py>, <input_params.yaml> with the relevant model directory, python file, and yaml input file. For example,

$ cd examples/rndwalk
$ mpirun -n 4 python rndwalk.py random_walk.yaml

Example Models

Random Walk

Location: examples/rndwalk
Key Concepts: movement, grid API

The Random Walk model is simple model intended as introduction to coding a Repast4Py simulation. The model consists of a number of agents moving at random around a two-dimensional grid and logging the aggregate and agent-level colocation counts. Each iteration of the model:

  1. All the agents (walkers) choose a random direction and move one unit in that direction.

  2. All the agents count the number of other agents they meet at their current location by determining the number of colocated agents at their grid locations.

  3. The sum, minimum, and maxiumum number of agents met are calculated across all process ranks, and these values are logged as the total, minimum, and maximum meet values.

See Tutorial 1 in the Repast4Py User’s Guide for a complete explanation of the Random Walk model.

Rumor Spreading

Location: examples/rumor
Key Concepts: networks, network neighbors, network API

The Rumor model is a simple network model that illustrates repast4py’s network agent-based model features. The simulation models the spread of a rumor through a networked population. During initialization some number of agents (network nodes) are marked as rumor spreaders. Then at each iteration of the model:

  1. A random draw is made to determine if the network neighbors of any rumor-spreading nodes have received the rumor. This draw is performed once for each neighbor.

  2. After all of the neighbors that can receive the rumor have been processed, the collection of rumor spreaders is updated to include those nodes that received the rumor.

  3. The total number of rumor spreaders and the number of new rumor spreaders are logged.

See Tutorial 2 in the Repast4Py User’s Guide for a complete explanation of the Rumor model.

Zombies

Location: examples/zombies
Key Concepts: movement, neighborhood search, continuous space API, grid API

The Zombies model is a predator-prey type model that illustrates the use of a continous space for movement and a discrete grid for neighborhood searches. In the Zombies model, human agents are pursued by zombie agents, and once caught become zombies themselves. Each timestep, the following occurs:

  1. All the Zombies:

    1. Query their immediate neighborhood to determine the adjacent grid location with the most number of Humans

    2. Move towards that location, assuming any Humans are found

    3. Infect the Humans at that location, also assuming any Humans are found

  2. All the Humans:

    1. Become a Zombie, after being infected for more than 9 timesteps, else

    2. Query their immediate neighborhood to determine the adjacent grid location with the fewest number of Zombies

    3. Move to that location at twice the speed of a Zombie.

See Tutorial 3 in the Repast4Py User’s Guide for a complete explanation of the Zombies model.