projectmesa / mesa-frames

Extension of mesa for performance and scalability
https://projectmesa.github.io/mesa-frames
Apache License 2.0
13 stars 4 forks source link

Abstract DiscreteSpaceDF #40

Closed adamamer20 closed 1 month ago

adamamer20 commented 1 month ago

The DiscreteSpaceDF class has been implemented as an abstract base class that extends SpaceDF, specifically designed for discrete space representations such as grids and networks in mesa_frames. Key features and methods include:

  1. Initialization with a model object and optional capacity parameter
  2. Cell management methods:
    • is_available: Check if positions have available capacity
    • is_empty: Check if positions are completely empty
    • is_full: Check if positions are at full capacity
    • move_to_empty: Move agents to completely empty cells
    • move_to_available: Move agents to cells with available capacity
    • sample_cells: Sample cells based on specified criteria (any, empty, available, full)
  3. Enhanced spatial operations:
    • get_neighborhood: Get neighborhood cells for given positions or agents
    • get_cells: Retrieve cell properties and agents for specified cells
    • set_cells: Set properties for specified cells
  4. Property access:
    • cells: Get/set all cell properties
    • empty_cells: Get all empty cells
    • available_cells: Get all cells with available capacity
    • full_cells: Get all cells at full capacity

The class introduces the concept of cell capacity, allowing for multiple agents per cell/position. It also provides methods for checking cell states (empty, available, full) and moving agents based on these states.

This implementation offers a more specialized framework for discrete spatial environments, building upon the general SpaceDF class. It provides additional functionality for managing cell occupancy and capacity, which is particularly useful for grid-based and network-based simulations in agent-based models.

The DiscreteSpaceDF class serves as a bridge between the general SpaceDF and more specific implementations like GridDF, providing a common interface for discrete spatial representations in the mesa_frames library.