This project implements a biological simulation of self-organization in decentralized systems, based on the Mirollo-Strogatz model (1990). It demonstrates how a population of coupled oscillators (agents) can achieve global phase synchronization through local interactions, mimicking the behavior of Pteroptyx malaccae fireflies.
The simulation utilizes a Toroidal topology to approximate an infinite medium and eliminate boundary effects, ensuring mathematically accurate convergence.
Each agent
When oscillator
To ensure biological plausibility and system stability, a refractory period is implemented. Agents are insensitive to external stimuli immediately after firing (
- Topology: Toroidal Manifold (Periodic Boundary Conditions). Distance is calculated as the shortest path on a torus surface: $$ d(x, y) = \min(|x_1 - x_2|, W - |x_1 - x_2|) $$
- Synchronization Logic: Synchronous update loop with an event stack to handle intra-frame signal propagation.
-
Heterogeneity: Agents have variance in their natural frequencies (
$\omega \pm \delta$ ), making exact synchronization non-trivial and robust.
| Parameter | Description | Value in Code |
|---|---|---|
NUM_AGENTS |
Population size | 200 |
COUPLING_STRENGTH |
Phase jump magnitude ( |
0.01 |
VIEW_RADIUS |
Interaction range | 150 px |
REFRACTORY_PERIOD |
Insensitivity duration | 0.2 |
- Mirollo, R. E., & Strogatz, S. H. (1990). Synchronization of Pulse-Coupled Biological Oscillators. SIAM Journal on Applied Mathematics, 50(6), 1645–1662.
- Buck, J. (1988). Synchronous rhythmic flashing of fireflies. The Quarterly Review of Biology, 63(3), 265-289.
- Kuramoto, Y. (1984). Chemical Oscillations, Waves, and Turbulence. Springer-Verlag.
Requires Python 3.x and Pygame.
pip install pygame
python main.pyClick anywhere in the window to randomize phases and restart the synchronization process.
If you use this code in your research or project, please cite it as:
@software{firefly_sync_sim,
author = {lrdcxdes},
title = {Pulse-Coupled Oscillators: Firefly Synchronization Simulation},
year = {2025},
publisher = {GitHub},
journal = {GitHub repository},
url = {https://github.com/lrdcxdes/PCO}
}