Skip to content
/ PCO Public

Implementation of the Mirollo-Strogatz model for Pulse-Coupled Oscillators in Python. Simulates the emergent synchronization of Pteroptyx malaccae fireflies using a toroidal topology and integrate-and-fire mechanisms.

License

Notifications You must be signed in to change notification settings

lrdcxdes/PCO

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Pulse-Coupled Oscillators: Firefly Synchronization Simulation

Abstract

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.

Theoretical Background

1. Integrate-and-Fire Mechanism

Each agent $i$ is modeled as an oscillator with a phase variable $\theta_i \in [0, 1]$. The phase evolves over time according to a natural frequency $\omega_i$: $$ \frac{d\theta_i}{dt} = \omega_i $$ When $\theta_i$ reaches the threshold ($1.0$), the oscillator "fires" (flashes) and resets $\theta_i$ to $0$.

2. Excitatory Coupling

When oscillator $i$ fires, it sends a pulse to all neighbors $j$ within a radius $R$. The neighbors adjust their phase instantaneously: $$ \theta_j(t^+) = \theta_j(t) + \varepsilon $$ Where $\varepsilon$ is the Coupling Strength. If the adjustment pushes $\theta_j \ge 1.0$, oscillator $j$ also fires immediately, creating an avalanche effect.

3. Refractory Period

To ensure biological plausibility and system stability, a refractory period is implemented. Agents are insensitive to external stimuli immediately after firing ($\theta < \theta_{ref}$), preventing signal feedback loops and chaotic "stuttering."

Implementation Details

  • 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.

Key Parameters

Parameter Description Value in Code
NUM_AGENTS Population size 200
COUPLING_STRENGTH Phase jump magnitude ($\varepsilon$) 0.01
VIEW_RADIUS Interaction range 150 px
REFRACTORY_PERIOD Insensitivity duration 0.2

References

  1. Mirollo, R. E., & Strogatz, S. H. (1990). Synchronization of Pulse-Coupled Biological Oscillators. SIAM Journal on Applied Mathematics, 50(6), 1645–1662.
  2. Buck, J. (1988). Synchronous rhythmic flashing of fireflies. The Quarterly Review of Biology, 63(3), 265-289.
  3. Kuramoto, Y. (1984). Chemical Oscillations, Waves, and Turbulence. Springer-Verlag.

Usage

Requires Python 3.x and Pygame.

pip install pygame
python main.py

Click anywhere in the window to randomize phases and restart the synchronization process.

Citation

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}
}

About

Implementation of the Mirollo-Strogatz model for Pulse-Coupled Oscillators in Python. Simulates the emergent synchronization of Pteroptyx malaccae fireflies using a toroidal topology and integrate-and-fire mechanisms.

Topics

Resources

License

Stars

Watchers

Forks

Languages