Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

paper: Rewrite Spaces section #2573

Merged
merged 6 commits into from
Dec 29, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 21 additions & 18 deletions paper/paper.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,40 +70,43 @@ for species, agents in grouped:
```

### Spaces
Mesa 3 provides multiple types of spaces for agent interactions, broadly categorized into discrete (cell-based) and continuous spaces. Each type serves different modeling needs while maintaining a consistent API.
Mesa 3 provides multiple spatial environments where agents interact, offering both discrete (cell-based) and continuous space implementations:
EwoutH marked this conversation as resolved.
Show resolved Hide resolved

#### Discrete Spaces
EwoutH marked this conversation as resolved.
Show resolved Hide resolved
In discrete spaces, agents occupy specific cells or nodes. Mesa offers several implementations:
In discrete spaces, agents occupy distinct cells or nodes. Mesa implements these using a doubly-linked structure where each cell maintains connections to its neighbors. The framework includes several discrete space variants with a consistent API:
EwoutH marked this conversation as resolved.
Show resolved Hide resolved

- Grid-based spaces (OrthogonalMooreGrid, OrthogonalVonNeumannGrid, Hexgrid)
- Network spaces where agents occupy nodes
- Voronoi meshes for irregular cell patterns
- Grid-based: `OrthogonalMooreGrid`, `OrthogonalVonNeumanGrid`, and `HexGrid`
- Network-based: `Network` for graph-based topologies
- Voronoi-based: `VoronoiMesh` for irregular tessellations

These spaces use a doubly-linked structure where cells maintain connections to their neighbors. A key feature is the PropertyLayer system, which enables efficient storage and manipulation of environmental data across the space:
Example grid creation:
```python
grid = OrthogonalVonNeumannGrid(
(width, height), torus=False, random=model.random
)
```

All discrete spaces support PropertyLayers - efficient numpy-based arrays for storing environmental data:
EwoutH marked this conversation as resolved.
Show resolved Hide resolved
```python
# Create a grid with an elevation layer
grid = OrthogonalMooreGrid((width, height), torus=False)
grid.create_property_layer("elevation", default_value=10)

# Select cells above a threshold
high_ground = grid.elevation.select_cells(lambda x: x > 50)
```

To facilitate agent-space interactions, Mesa provides specialized agent classes:
- FixedAgent: Remains at its assigned cell
- CellAgent: Can move between cells
- Grid2DMovingAgent: Adds directional movement shortcuts

#### Continuous Space
EwoutH marked this conversation as resolved.
Show resolved Hide resolved
For models requiring precise positioning, continuous space allows agents to have any coordinate location:

For models requiring precise positioning, `ContinuousSpace` allows agents to occupy any coordinate within defined boundaries:
EwoutH marked this conversation as resolved.
Show resolved Hide resolved
```python
space = ContinuousSpace(x_max, y_max, torus=True)
space.move_agent(agent, (new_x, new_y))
```

All space types can be configured as toroidal (wrapping at edges) or bounded.
#### Agent Types for Spaces
EwoutH marked this conversation as resolved.
Show resolved Hide resolved
Mesa provides specialized agent classes for spatial interactions:

- `FixedAgent`: Remains at its assigned cell
- `CellAgent`: Can move between cells and access its current location
- `Grid2DMovingAgent`: Extends `CellAgent` with directional movement methods

These agent types interface with Mesa's spaces while enforcing appropriate movement constraints and cell access patterns.

### Time advancement
Typically, agent-based models rely on incremental time progression or ticks. For each tick, the step method of the model is called. This activates the agents in some way. The most frequently implemented approach is shown below, which runs a model for 100 ticks.
Expand Down
Loading