3.2 An Outline of Repast Concepts 85
• Contexts provide the way to group agents without regard to any spatial or struc-
tural arrangement between them. A context is used, therefore, to indicate that a
set of agents are related in some way. Neither agents nor projections have any
useful existence outside of contexts within Repast.
• Projections are subordinate to contexts. They impose a spatial or structural ar-
rangement on the agents within a given context.
Once an agent has been created, it must be added to a context. The projection ap-
plied to that context then describes the relationships of the agents to each other
within the context. For instance, at the start of a mosquito simulation we might
create all the mosquito and human agents we require and place them together in a
single context because we want them to be aware of each other and to be able to
interact. In order to impose a geographical structure on them we would create and
add a projection to the context. For instance, it could be a two-dimensional discrete
grid projection, or a two-dimensional continuous projection. The chosen projection
would determine aspects such as the physical area occupied by the agents. The scale
of the projection used for the mosquitoes and humans would be related to the sizes
of the agents’ movements. A wide range of projection types is available within the
Repast API: N-dimensional continuous (floating-point coordinate) spaces; single-
and multi-occupancy N-dimensional cellular grids; GIS Geospacial coordinate sys-
tems; and network/graph relationships.
There is always a root context, which is a top-level context to which all agents
belong by default. In many models, this single context will be sufficient but contexts
also can be organized in a nested, hierarchical structure to fit the needs of a model.
A second-level of multiple contexts might be nested within the root context, there-
fore. Such an arrangement would be an ideal way of partitioning bacteria between
different hosts in a model of fimbriation (see Chap. 2), for instance. An individual
bacterium would be placed in a single sub-context but the model might permit it to
move to a different one over the course of the simulation. In other types of models,
a single agent might exist simultaneously in multiple contexts. In addition, contexts
may be nested to any level in order to provide different sub-groupings of agents
within an overall root context For instance, individual people are often members of
family groupings, work groupings, and other social groupings. Each such grouping
could be represented as a different context in Repast.
Note that grouping in a context tells us nothing about physical location or con-
nectedness of the agents, only that some form of relationship between the contained
agents exists. Each context will have its own projection to provide the structuring. It
follows that a single agent may be related in many ways to other agents through dif-
ferent projections simultaneously if they exist in multiple contexts. Think, for exam-
ple, of work relationships. While at their workplace an individual will be physically
located in a particular geographical location, with work connections to co-located
colleagues; yet they may also be in phone or email contact with other colleagues
who are geographically much more widely separated. This connectivity might be
represented by a network projection applied to that individual’s work context in
Repast. A network projection does not necessarily imply a bounded physical space.