polybee

User Guide

This guide covers how to configure and run PolyBee, in both its normal (single simulation) mode and its evolve (optimization) mode, and describes the output files each mode produces.

Building and running

PolyBee is built with CMake and Ninja:

./make-debug     # configures and builds a debug binary at build/bin/debug/polybee
./run-debug      # runs it, passing through any command-line arguments

(./make-release / ./run-release build and run an optimized -O3 build instead.) run-debug/run-release are thin wrappers that just invoke the built polybee binary, so any command-line arguments described below can be passed straight through, e.g. ./run-debug --num-bees 20.

polybee --help lists every available parameter with its description and default value.

Configuring PolyBee

Parameters can be set in a config file, on the command line, or both:

A config file is a plain list of key=value lines; # starts a comment.

Parameter groups

The parameters registered in Params (see polybee --help for the authoritative, up-to-date list with defaults) fall into these groups:

Group Example parameters Purpose
Simulation control num-iterations, rng-seed How long to run, and RNG seeding
Environment env-width, env-height Overall environment size
Tunnel tunnel-width, tunnel-height, tunnel-x, tunnel-y, tunnel-entrance Polytunnel geometry and entrances
Tunnel exit nets net-antibird-exit-prob, net-antihail-exit-prob, net-antibird-max-exit-attempts, net-antihail-max-exit-attempts Per-attempt exit probability and attempt limits for bees passing through netted entrances (see PARAM-NOTES.md for how the defaults were derived from the literature)
Barriers barrier, barrier-pass-prob Obstacles that block or partially block bee movement
Plant patches / flowers patch, plant-default-spacing, plant-default-jitter, flower-initial-nectar, min-visit-count-success, max-visit-count-success Where flowers are placed and what counts as a “successful” visit
Bees num-bees, bee-max-dir-delta, bee-step-length, bee-visual-range, bee-visit-memory-length, bee-prob-visit-nearest-flower, bee-in-hive-duration, bee-initial-energy, bee-energy-* , bee-on-flower-duration, bee-path-record-len Bee movement, sensing, and energy/foraging-bout behaviour
Hives hive Hive location(s) and exit direction
Evolve/optimization evolve, evolve-objective, evolve-spec, target-heatmap-filename, num-trials-per-config, num-configs-per-gen, num-generations, num-islands, migration-*, use-diverse-algorithms, bridge-overlaps-allowed See Running in evolve mode
Logging/output logging, log-dir, log-filename-prefix, heatmap-cell-size, flowmap-cell-size, flowmap-update-period Where and whether output files are written, and their resolution
Visualisation visualise, vis-cell-size, vis-delay-per-step, vis-bee-path-draw-len Real-time graphical display

Multi-value parameters

A few parameters describe things placed in the environment and can be repeated on the command line or in the config file (one per occurrence) to add multiple instances. Each uses a compact positional string format:

See polybee.cfg and the files under config-files/ for worked examples.

Running a normal simulation

With evolve=false (the default), PolyBee runs a single simulation for num-iterations steps using whatever hives, tunnel, barriers and patches are configured, then (if logging=true) writes the output files described below.

If visualise=true, a Raylib window opens showing bees, their trails, and the environment in real time. Controls in the visualisation window:

Key Action
? Toggle the help overlay
P Pause/unpause the simulation
H Cycle display mode (bees, heatmap, or both)
T Toggle bee trails on/off
E Toggle EMD-to-target display on/off
S Toggle successful-visit-fraction display on/off
F Toggle flowmap overlay on/off
1 / 2 Colour bee trails randomly / by entrance used
+ / - Speed up / slow down the simulation
Mouse wheel Zoom in/out
Arrow keys Pan the camera
R Reset camera zoom and position
Esc / close button Exit

Running in evolve mode

Set evolve=true to run genetic optimization (via the Pagmo library) instead of a single simulation. Evolve mode repeatedly places elements of the environment according to a candidate configuration, runs one or more simulation trials, scores the result, and evolves the population of candidates over a number of generations.

Key parameters:

See config-files/evolve-*.cfg for complete worked examples, and ANALYSIS_WORKFLOW.md plus tools.md for how to run and analyse many replicate evolve runs (e.g. on a Slurm cluster via tools/gen_slurm_file.py).

Output files

If logging=true, files are written to log-dir (default .), named <log-filename-prefix-> (if set) followed by a file-type tag and a per-run timestamp string, e.g. evolve-4-entrance-1o-hive-positions-flowmap-<timestamp>.csv.

Normal-mode output

Written once, at the end of the run:

File Format
config-<ts>.cfg The full effective configuration for the run, in config-file format (can be reused directly as input via -c).
heatmap-<ts>.csv Raw bee-position heatmap: a 2D grid (one row per line, comma-separated), each cell holding the count of bee positions recorded in that cell, at heatmap-cell-size resolution.
heatmap-normalised-<ts>.csv The same grid, normalised so cell values sum to 1.0.
flowmap-<ts>.csv Bee-movement flowmap: a 2D grid at flowmap-cell-size resolution, one row per line, cells comma-separated. Each cell is encoded axis:strength:count, where axis is the predominant movement axis through that cell in radians (headless, i.e. a direction and its opposite are treated as the same axis), strength is the alignment strength in [0,1], and count is the number of bee movements recorded in the cell. Only written if the flowmap has data (flowmap-update-period != 0).
run-info-<ts>.txt Human-readable run summary: PolyBee version and git commit, EMD to the target heatmap (if one was configured), successful-visit fraction, and tunnel-entrance crossing success rate.

Evolve-mode output