Skip to content

Commit

Permalink
paper: Update space section - adding clarity.
Browse files Browse the repository at this point in the history
  • Loading branch information
jackiekazil committed Jan 5, 2025
1 parent 4dddba6 commit 4136b1e
Showing 1 changed file with 22 additions and 8 deletions.
30 changes: 22 additions & 8 deletions paper/paper.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,36 +94,50 @@ One significant advancement of Mesa 3+ is expanded functionality around agent ma
### Spaces
Mesa 3 provides both discrete (cell-based) and continuous space implementations. In discrete spaces, an agent occupies a cell. Mesa implements discrete spaces using a doubly-linked structure where each cell maintains connections to its neighbors. The framework includes several discrete space variants with a consistent API:


- Grid-based: `OrthogonalMooreGrid`, `OrthogonalVonNeumanGrid`, and `HexGrid`
- Network-based: `Network` for graph-based topologies
- Voronoi-based: `VoronoiMesh` for irregular tessellations


Example grid creation:


```python
grid = OrthogonalVonNeumannGrid((width, height), torus=False, random=model.random)
grid = OrthogonalVonNeumannGrid((width, height), torus=False, random=model.random)
```

Mesa provides specialized agent classes for spatial interactions in the discrete spaces:

In Mesa 3, specialized agent classes for spatial interactions in discrete spaces were added:


- `FixedAgent`: Is assigned to a cell, can access this cell, but cannot move to another cell.
- `CellAgent`: Can move between cells
- `Grid2DMovingAgent`: Extends `CellAgent` with directional movement methods

All discrete spaces support PropertyLayers - efficient numpy-based arrays for storing cell-level properties:

All discrete spaces support PropertyLayers - efficient numpy-based arrays for storing cell-level properties. This newly added feature allows for agents to interact with spatial properties of the cell more easily:


```python
grid.create_property_layer("elevation", default_value=10)
high_ground = grid.elevation.select_cells(lambda x: x > 50)
grid.create_property_layer("elevation", default_value=10)
high_ground = grid.elevation.select_cells(lambda x: x > 50)
```


For models where agents need to move continuously through space rather than between discrete locations, `ContinuousSpace` allows agents to occupy any coordinate within defined boundaries:


```python
space = ContinuousSpace(x_max, y_max, torus=True)
space.move_agent(agent, (new_x, new_y))
```
The space module is stable but under active development. The new cell-based spaces in Mesa 3 are currently being tested and considered feature-complete. The code snippets reflected in this paper are the future expected state of Mesa. Features not yet merged into core are imported from experimental:


```python
space = ContinuousSpace(x_max, y_max, torus=True)
space.move_agent(agent, (new_x, new_y))
from mesa.experimental.cell_space ...
```
The new cell-based spaces are feature complete but still in experimental state. A new ContinuousSpace implementation is in active development.

### Time advancement
Typically, ABMs 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

0 comments on commit 4136b1e

Please sign in to comment.