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

Abstract GridDF #41

Closed
Tracked by #6
adamamer20 opened this issue Jul 24, 2024 · 0 comments · Fixed by #32
Closed
Tracked by #6

Abstract GridDF #41

adamamer20 opened this issue Jul 24, 2024 · 0 comments · Fixed by #32
Assignees
Labels
enhancement Improvements to existing features or performance.

Comments

@adamamer20
Copy link
Collaborator

adamamer20 commented Jul 24, 2024

The GridDF class has been implemented as an abstract base class that extends DiscreteSpaceDF, specifically designed for grid-based spatial representations in mesa_frames. Key features and methods include:

  1. Initialization with model object, dimensions, torus property, capacity, and neighborhood type
  2. Grid-specific spatial operations:
    • get_directions: Calculate directions between grid positions or agents
    • get_distances: Calculate distances between grid positions or agents
    • get_neighbors: Find neighboring agents within a given radius on the grid
    • get_cells: Retrieve cell properties and agents for specified grid cells
    • move_agents: Place agents at specific grid positions
    • remove_agents: Remove agents from the grid
  3. Grid-specific utilities:
    • out_of_bounds: Check if positions are outside the grid boundaries (for non-toroidal grids)
    • torus_adj: Adjust coordinates for toroidal grids
  4. Internal grid management:
    • _calculate_differences: Calculate coordinate differences between positions or agents
    • _compute_offsets: Generate neighborhood offsets based on the specified type (Moore, von Neumann, or hexagonal)
    • _get_df_coords: Convert various input formats to a DataFrame of coordinates
    • _generate_empty_grid: Abstract method to create an empty grid with specified dimensions and capacity
    • _place_agents_df: Abstract method to place agents in the grid
  5. Properties:
    • dimensions: Get the grid dimensions
    • neighborhood_type: Get the type of neighborhood used
    • torus: Check if the grid is toroidal

This implementation provides a comprehensive framework for grid-based spatial environments in agent-based models. It handles various grid types (rectangular, toroidal) and neighborhood configurations (Moore, von Neumann, hexagonal). The class manages grid coordinates, agent positions, and cell properties efficiently using DataFrames.

GridDF builds upon the DiscreteSpaceDF class, adding grid-specific functionality while maintaining compatibility with the overall mesa_frames structure. It offers methods for common grid operations like calculating distances and directions, finding neighbors, and handling boundary conditions (toroidal or non-toroidal).

The abstract methods (_generate_empty_grid and _place_agents_df) allow for customization in concrete subclasses, potentially accommodating different backend implementations or optimizations for specific use cases.

This GridDF class provides a robust foundation for implementing various types of grid-based simulations within the mesa_frames library, offering flexibility and efficiency in managing spatial aspects of agent-based models.

@adamamer20 adamamer20 mentioned this issue Jul 24, 2024
9 tasks
@adamamer20 adamamer20 self-assigned this Jul 24, 2024
@adamamer20 adamamer20 added the enhancement Improvements to existing features or performance. label Jul 24, 2024
@adamamer20 adamamer20 moved this to Ready in mesa-frames Jul 24, 2024
@adamamer20 adamamer20 added this to the 1.0.0 Alpha Release milestone Jul 24, 2024
@adamamer20 adamamer20 linked a pull request Jul 24, 2024 that will close this issue
@github-project-automation github-project-automation bot moved this from Ready to Done in mesa-frames Jul 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improvements to existing features or performance.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant