Skip to content

Latest commit

 

History

History
111 lines (82 loc) · 6.77 KB

README.md

File metadata and controls

111 lines (82 loc) · 6.77 KB

Active Inferants

CI License: MIT

Code for the computational model in Active Inferants: An Active Inference Framework for Ant Colony Behavior by Daniel Ari Friedman, Alec Tschantz, Maxwell J. D. Ramstead, Karl Friston, and Axel Constant.

The simulation models ant-colony foraging in a 40 × 40 T-maze. Individual simulated ants use a Markov decision process (MDP) to infer local pheromone observations, move through the environment, and deposit trail pheromone while returning from food. The repository contains the implementation used for the paper's in-silico experiments.

Documentation

Quick start

The project requires Python 3.12 or later. From the repository root:

python3 -m venv .venv
.venv/bin/python -m pip install -e .
.venv/bin/python figure_1.py

With uv, the same setup is uv sync --extra dev followed by uv run figure_1.py.

The figure scripts create an imgs/ directory containing PNG snapshots, GIFs, NumPy arrays, text summaries, and (for figure_1.py) path plots. Generated output is ignored by Git. The default experiments are intentionally larger runs; see Running the simulations for the smaller API smoke test and experiment details.

Tests

The test suite lives in tests/ and runs under pytest with a 90% coverage floor:

.venv/bin/python -m pip install -e ".[dev]"
.venv/bin/python scripts/gate.py fast   # default arm: lint + docs + fast tests
.venv/bin/python scripts/gate.py all    # every arm, including the full suite

With uv, uv sync --extra dev followed by uv run python scripts/gate.py all. The arms are lint, test-fast, test, docs, and gnn; test runs the full suite under the 90% coverage floor and gnn re-validates the specification against the pinned parser. The arm table, measured timings, and the CI job mapping are in docs/RUN_GUIDE.md and docs/_generated/gate-metrics.md.

Continuous integration runs the same gate arms on every push and pull request (see .github/workflows/ci.yml).

Model specification (GNN)

The ant-colony foraging MDP is specified in gnn/ant_colony_foraging.gnn.md in Generalized Notation Notation (GNN): the 9 focal-cell states, 10 pheromone-level observations, 9 actions, the environment-driven likelihood, the deterministic transition tensor, the log-preference vector, and the habit prior.

The specification is validated against the GNN revision pinned in gnn/upstream.json, read from that pinned commit rather than from the GNN checkout's working tree. The pin itself is read by gnn.importers, the reader shipped in that revision — this repository carries no pin reader of its own:

uv run python scripts/gate.py gnn           # reader check + strict validator + conformance tests
uv run pytest tests/test_gnn_conformance.py # specification sections and dimensions under pytest

The arm first runs python -m gnn.importers check --repo . from the pinned environment, which reads the pin and validates the specification with the pinned parser; the gate then parses the specification with the pinned GNN extractor and checks the extracted matrices against ants.py. The test module runs the same model checks under pytest and skips only the pinned-parser half when the GNN checkout is unavailable. When editing the specification, start from GNN's Start Here, framework integration guide, and syntax reference. For the wider picture (the adoption patterns sibling repositories use, pin discipline, and the drift guard these checks implement), see GNN's downstream adoption guide.

Related repositories

  • Active_InferAnts — the multi-language Active Inference framework that grew out of this model. Its framework agent is specified separately, in that repository's gnn/ directory.
  • Active_Skillference — the Active Inference / Free Energy Principle micro-learning platform; its discrete active-inference agent kernel is specified in that repository's gnn/ directory.

Each concept has one canonical home: this repository owns the 2021 ant-colony foraging MDP; the other two specify their own models.

Citation

For the published article:

Friedman DA, Tschantz A, Ramstead MJD, Friston K, Constant A (2021). Active Inferants: An Active Inference Framework for Ant Colony Behavior. Frontiers in Behavioral Neuroscience, 15, 647732. https://doi.org/10.3389/fnbeh.2021.647732

Machine-readable citation metadata is provided in CITATION.cff. The repository's source code is released under the MIT License. See LICENSE. The article is open access under the license specified by its publisher; consult the publication for the article's reuse terms.

InstituteOS sidecar

This repository carries a committed .aii/ sidecar with curated InstituteOS metadata (aii-sidecar/v1): category, maturity, ecosystem relations, key artifacts, provenance, and portable tasks. It is read by InstituteOS tooling and does not affect the project's build or runtime.