Metadata-Version: 2.1
Name: phyelds-mesa
Version: 8.2.0
Summary: Mesa integration for phyelds: aggregate programs on the agents of a Mesa model
Home-page: https://github.com/phyelds/phyelds
License: Apache-2.0
Author: Davide Domini
Author-email: davide.domini@unibo.it
Requires-Python: >=3.12,<3.14
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Dist: mesa[network] (>=3.5.1,<4.0.0)
Requires-Dist: phyelds (>=8.0.0,<9.0.0)
Project-URL: Repository, https://github.com/phyelds/phyelds
Description-Content-Type: text/markdown

# phyelds-mesa

[Mesa](https://mesa.readthedocs.io) integration for [phyelds](https://pypi.org/project/phyelds/):
run aggregate programs on the agents of a Mesa model.

## Installation

```bash
pip install phyelds-mesa
```

`phyelds-mesa` installs a compatible `phyelds` release and Mesa.

## Usage

```python
from phyelds.calculus import aggregate
from phyelds.libraries.device import sense
from phyelds.libraries.distances import hops_distance
from phyelds.libraries.spreading import distance_to
from phyelds.mesa import AggregateRuntime, within


@aggregate
def hops_to_source():
    return distance_to(sense("source"), hops_distance())


runtime = AggregateRuntime(
    hops_to_source,
    neighbors=within(1.5),                                 # or cell_neighbors in a grid
    sensors=lambda agent: {"source": agent.unique_id == 1},
)
# In Model.step(): one synchronous round on every agent.
hops = runtime.run_round(model.agents)                     # {unique_id: result}
```

See the [documentation](https://phyelds.github.io/phyelds/integration/mesa/).

