The example models can be downloaded from here.
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>
<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
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:
All the agents (walkers) choose a random direction and move one unit in that direction.
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.
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
See Tutorial 1 in the Repast4Py User’s Guide for a complete explanation of the Random Walk model.
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:
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.
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.
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.
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:
All the Zombies:
Query their immediate neighborhood to determine the adjacent grid location with the most number of Humans
Move towards that location, assuming any Humans are found
Infect the Humans at that location, also assuming any Humans are found
All the Humans:
Become a Zombie, after being infected for more than 9 timesteps, else
Query their immediate neighborhood to determine the adjacent grid location with the fewest number of Zombies
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.