Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

45 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

E.L.B.E.R.R. β€” Swarm Intelligence Warehouse Exploration

Efficient Logistics by Exploration with Robotic Retrieval

A real-time multi-agent simulation framework where autonomous agents explore warehouse environments, discover objects, and optimize retrieval through swarm intelligence principles. Built with Python (Streamlit) backend for interactive visualization and benchmarking.

Repository: SwarmLab

Live demo: swarm-lab.streamlit.app


πŸš€ Quick Start β€” Run with Streamlit

Prerequisites

  • Python 3.9+
  • Virtual environment (optional but recommended)

Setup & Run (3 steps)

# 1. Activate your virtual environment (if you have one)
# Windows PowerShell:
.\.venv\Scripts\Activate.ps1
# macOS / Linux:
source .venv/bin/activate

# 2. Install dependencies
pip install -r requirements.txt
# or with uv (recommended)
uv pip install -r requirements.txt

# 3. Launch the app
streamlit run app.py

Open your browser at http://localhost:8501 β€” you'll see the interactive dashboard with:

  • Live grid visualization
  • Agent configuration panel
  • Real-time metrics & battery monitoring
  • Preset save/load
  • Benchmark mode for batch testing

Note: this project uses pygame-ce (drop-in compatible with import pygame) to ensure reliable wheel installs on modern Windows/Python setups.


Features

Exploration Strategies (5 Usable + 1 Prototype)

Strategy Colour Approach
Frontier Blue Frontier-based systematic exploration with target lock
Greedy Orange Warehouse-centric greedy search
Sector Green Grid-partitioning with assigned sectors per agent
Repulsion Red Emergent dispersion based on inter-agent repulsion
Smart Random Purple Information-gain guided random walk with stale avoidance
Ant-Colony Teal Experimental prototype (currently not usable)

Real-time interactive UI

  • Live grid visualization with Pygame offscreen rendering β€” fog-of-war, agent vision radius, communication range
  • Three-column layout: agent configuration | simulation grid | live metrics & battery bars
  • Preset system β€” save/load agent configurations as JSON for reproducible runs
  • Battery monitoring β€” real-time per-agent energy consumption tracking
  • Run history β€” compare multiple simulation runs side-by-side
  • Full-screen benchmarking β€” automated batch testing of strategy combinations

Comprehensive benchmarking

  • Random preset generation β€” vary usable strategies, vision radius, communication radius independently
  • Exhaustive or sampled search β€” generate unique presets up to the full combinatorial space
  • Multi-run execution with configurable random seeds
  • Delivery curves β€” cumulative object retrieval over time (per preset)
  • CSV export β€” download full results for external analysis
  • Top-10 rankings β€” filters by tick count, completion rate, energy consumption
  • Ant-Colony excluded β€” currently treated as a prototype and not used in benchmark runs

Configurable environments

  • Two provided warehouse instances (A.json, B.json) with identical structure:
    • Grid size: 25Γ—25 cells
    • 4 warehouses with entrance/exit per warehouse
    • 10 objects to retrieve per instance
  • Easy JSON format for custom scenarios

Architecture

β”œβ”€β”€ πŸ“„ README.md                    (this file)
β”œβ”€β”€ πŸ“„ requirements.txt             (Python dependencies)
β”œβ”€β”€ πŸ“„ app.py                       (Streamlit entry point)
β”œβ”€β”€ 🐍 benchmark_strategies.py      (CLI benchmarking script)
β”‚
β”œβ”€β”€ πŸ“ assets/                      (Images: logo, icons)
β”‚   β”œβ”€β”€ 2.png
β”‚   β”œβ”€β”€ agent.png
β”‚   └── package.png
β”‚
β”œβ”€β”€ πŸ“ ui/                          (Streamlit UI modules)
β”‚   β”œβ”€β”€ πŸ“„ __init__.py
β”‚   └── (future: component split)
β”‚
β”œβ”€β”€ πŸ“ src/
β”‚   β”œβ”€β”€ πŸ“ agents/
β”‚   β”‚   β”œβ”€β”€ 🐍 agent.py             (Core Agent class)
β”‚   β”‚   β”œβ”€β”€ 🐍 sensors.py           (Perception: visibility, communication)
β”‚   β”‚   └── πŸ“ strategies/
β”‚   β”‚       β”œβ”€β”€ 🐍 base.py          (Strategy interface)
β”‚   β”‚       β”œβ”€β”€ 🐍 frontier.py      (Frontier exploration)
β”‚   β”‚       β”œβ”€β”€ 🐍 greedy.py        (Warehouse-centric greedy)
β”‚   β”‚       β”œβ”€β”€ 🐍 sector.py        (Sector partitioning)
β”‚   β”‚       β”œβ”€β”€ 🐍 Repulsion.py     (Emergent repulsion)
β”‚   β”‚       β”œβ”€β”€ 🐍 random_walk.py   (Info-gain random walk)
β”‚   β”‚       └── 🐍 ant_colony_lite.py (Pheromone-based)
β”‚   β”‚
β”‚   β”œβ”€β”€ πŸ“ environment/
β”‚   β”‚   β”œβ”€β”€ 🐍 environment.py       (Simulator state & logic)
β”‚   β”‚   β”œβ”€β”€ 🐍 grid.py              (Cell types, grid data)
β”‚   β”‚   └── 🐍 __init__.py
β”‚   β”‚
β”‚   β”œβ”€β”€ πŸ“ simulation/
β”‚   β”‚   β”œβ”€β”€ 🐍 simulator.py         (Tick loop & step generator)
β”‚   β”‚   β”œβ”€β”€ 🐍 metrics.py           (Statistics collection)
β”‚   β”‚   └── 🐍 __init__.py
β”‚   β”‚
β”‚   β”œβ”€β”€ πŸ“ pathfinding/
β”‚   β”‚   β”œβ”€β”€ 🐍 pathfinder.py        (A* navigation)
β”‚   β”‚   └── 🐍 __init__.py
β”‚   β”‚
β”‚   β”œβ”€β”€ πŸ“ communication/
β”‚   β”‚   β”œβ”€β”€ 🐍 protocol.py          (Inter-agent messaging)
β”‚   β”‚   └── 🐍 __init__.py
β”‚   β”‚
β”‚   β”œβ”€β”€ πŸ“ visualization/
β”‚   β”‚   β”œβ”€β”€ 🐍 base.py              (Abstract visualizer)
β”‚   β”‚   β”œβ”€β”€ 🐍 matplotlib_viz.py    (Matplotlib rendering)
β”‚   β”‚   β”œβ”€β”€ 🐍 pygame_viz.py        (Pygame rendering)
β”‚   β”‚   └── 🐍 __init__.py
β”‚   β”‚
β”‚   └── πŸ“„ __init__.py
β”‚
└── πŸ“ __pycache__/                 (Python cache)

Configuration & Parameters

Agent Capabilities

Parameter Min Max Default Notes
Vision radius 1 3 2 Cells visible in Manhattan distance (orthogonal)
Comm radius 1 2 2 Max distance for inter-agent message exchange
Initial battery β€” β€” 500 Energy units; βˆ’1 per step; agent stops at 0
Grid size β€” β€” 25Γ—25 Environment dimensions (fixed per instance)
Num agents 1 10 5 Team size; configurable per run
Max ticks 100 750 500 Simulation duration limit

Warehouse Geometry

Both instances (A.json, B.json) contain:

  • 4 warehouses β€” rectangular regions marked WAREHOUSE (value 2)
  • 4 entrances β€” one per warehouse, marked ENTRANCE (value 3)
  • 4 exits β€” one per warehouse, marked EXIT (value 4)
  • Corridors β€” EMPTY cells (value 0) connecting warehouses
  • Obstacles β€” WALL cells (value 1) representing shelves
  • 10 objects β€” coordinates in separate objects array (not grid-embedded)

Cell type values:

Value Type Walkable Role
0 EMPTY βœ“ Corridor, general space
1 WALL βœ— Obstacle, shelf
2 WAREHOUSE βœ“ Interior; delivery target
3 ENTRANCE βœ“ Gateway into warehouse
4 EXIT βœ“ Gateway out of warehouse

Simulation Flow

  1. Initialization

    • Load environment from JSON
    • Create N agents with assigned strategies
    • Reset batteries, local maps, object tracking
  2. Per-tick loop (up to max_ticks)

    • Each agent perceives surroundings (vision + communication)
    • Each agent executes strategy logic (navigation, exploration)
    • Local maps (agent knowledge) are updated
    • Metrics are collected (ticks, objects delivered, energy)
    • Stop if all objects are delivered
  3. Metrics & reporting

    • Total ticks: simulation duration
    • Objects delivered: count of objects successfully carried to warehouse
    • Completion rate: delivered / total objects (0–1)
    • Average energy consumed: sum of energy spent / num agents
    • First pickup tick: when first object was picked up
    • First delivery tick: when first object was delivered

Benchmarking Modes

Interactive Benchmarking (UI)

Run from the πŸ”¬ Benchmark tab in Streamlit:

  1. Select parametrization mode:

    • Random: vary each parameter independently across a range
    • Fixed: lock each parameter to a single value
  2. Configure ranges:

  • Strategy pool (subset of usable strategies; Ant-Colony excluded)
  • Vision radius range (1–5, or fixed)
  • Communication radius range (1–2, or fixed)
  1. Generate presets:

    • Displayed: max unique combinations
    • Input: number of presets to test (sampled or exhaustive)
  2. Execute & analyze:

    • Run all presets with progress bar
    • Download CSV with all results
    • View delivery curves (cumulative objects/tick)
    • Rank by efficiency (ticks, energy, completion)

Exploration Strategies

Frontier

Explores based on "frontier" cells β€” boundaries between known and unknown areas. Prioritizes distant frontiers and locks on selected targets to avoid oscillation. Weights frontier distance sub-linearly to prefer nearby exploration while still reaching far areas.

Greedy

Performs warehouse-centric search: prioritizes cells closest to known warehouse locations, exploring warehouse interiors first. Simpler but may miss distributed objects.

Sector

Divides the grid into equal sectors and assigns each agent a sector. Agents explore only their assigned area to minimize overlap and ensure uniform coverage.

Repulsion

Agents repel each other based on proximity, creating emergent separation. No explicit coordination; behavior emerges from local repulsion forces.

Smart Random

Enhances random walk with:

  • Information gain β€” prefers cells that reveal more unknown area
  • Stale avoidance β€” deprioritizes recently visited cells
  • Separation β€” avoids crowding with nearby agents

Ant-Colony

Prototype: Pheromone-inspired strategy where agents should lay virtual pheromones and bias motion toward low-pheromone cells. This strategy is not fully implemented yet, so it is documented for completeness only. Do not use in production runs or benchmark comparisons.


Author

Daniele Barabagallo β€” GitHub


About

A real-time multi-agent simulation framework where autonomous agents explore warehouse environments, discover objects, and optimize retrieval through swarm intelligence principles.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages