SWARMICA Documentation

Technical Documentation · API Reference · Variational & Continuum Mechanics Framework for Collective Stability

94.7%
Mean CSI
88.3%
Mean ERI
2.3 τ_A
Convergence Time
64
N_basis
3×K_c
Kuramoto Coupling

📖 Overview

"The swarm is not a collection of agents. It is a single thought, distributed across a thousand bodies, moving through the geometry of its own potential. SWARMICA gives that thought a direction — and proves, mathematically, that it will arrive."

SWARMICA is a Variational and Continuum Mechanics framework for collective swarm stability that treats the swarm not as a collection of discrete reactive agents but as a continuous active matter field evolving on a Physical Coupling Manifold under the Principle of Least Action. Built on three orthogonal constructs spanning variational mechanics, SOS potential optimization, and Kuramoto phase synchronization, SWARMICA achieves certified collective stability across four canonical swarm scenarios.

94.7%
Mean CSI · 4 scenarios
88.3%
Mean ERI
<1%
Collapse Rate

🏗️ 3-Core Architecture

SWARMICA operates on the Physical Coupling Manifold M through three synergistic constructs:

CLO — Collective Lagrangian Operator

Derives swarm trajectory equations from a variational action functional over the generalized coordinate space of the continuum density field. The Euler-Lagrange equations have the same mathematical form regardless of N — all N-dependence is absorbed into the metric G(Q).

python — CLO initialization
from swarmica import SwarmEngine, SwarmConfig

clo = CollectiveLagrangian(
    n_basis=64,
    mu_dissipation=0.02,
    alpha=0.15
)

EPFE — Effective Potential Field Engine

Engineers V_eff(Q) as a Sum-of-Squares polynomial with a guaranteed unique global attractor at Q*. Eliminates all local minima by construction — the SOS parameterization ensures global convexity.

KPSL — Kuramoto Phase Synchronization Layer

Drives inter-agent phase alignment above the critical coupling threshold K_c = 2Δ. At K = 3K_c, the swarm becomes a mechanically rigid collective body whose effective degrees of freedom collapse from 6N to 6.

📐 Core Equations (Eq. 1-8)

Eq. 1 — PCM State Vector
p(t) = (ρ(x,t), v(x,t)) ∈ M
Eq. 2 — Collective Lagrangian
L[Q, Q̇] = T[Q̇] − V_eff[Q] = ½∫ρ|v|²dx − ∫ρ(x)V(x)dx
Eq. 3 — Euler-Lagrange Field Equations
G(Q)Q̈ + C(Q,Q̇)Q̇ + ∇_Q V_eff(Q) = F_ctrl
Eq. 4 — SOS Potential Field
V_eff(Q) = p(Q)ᵀ P p(Q) + α‖Q − Q*‖²_G
Eq. 5 — Kuramoto Phase Dynamics
dθᵢ/dt = ωᵢ + (K/N)Σⱼ sin(θⱼ − θᵢ) + F_ext,i(t)
Eq. 6 — Critical Coupling
K_c = 2Δ, r_∞ = √(1 − K_c/K) for K > K_c
Eq. 7 — Jacobian Stability Certificate
Re(λᵢ) < −σ_min < 0 ∀i = 1…2N_basis
Eq. 8 — Convergence Bound
‖Q(t)−Q*‖ ≤ C e^{−σ_min t} ‖Q(0)−Q*‖

📦 Installation

bash — pip install
# From PyPI (stable)
pip install swarmica-engine

# From source
git clone https://github.com/gitedeeper12/SWARMICA.git
cd SWARMICA && pip install -e .

# Quick test
python -c "from swarmica import SwarmEngine, SwarmConfig; print('SWARMICA ready')"

🔧 API Reference

SwarmEngine

python — main interface
from swarmica import SwarmEngine, SwarmConfig

# Configure swarm
cfg = SwarmConfig(
    n_agents=500,
    modality='aerial',
    n_basis=64,
    k_coupling=3.0,
    mu_dissipation=0.02,
    target_config='diamond_V'
)

engine = SwarmEngine(cfg)
engine.load_weights('experiments/weights/swarmica_v1.0.0_aerial.pt')

# Real-time control loop (1 kHz)
for obs in sensor_stream:
    ctrl = engine.step(dt=1e-3, obs=obs)
    csi = engine.get_csi()
    r = engine.get_order_parameter()
    S_s = engine.get_structural_entropy()

SwarmConfig Parameters

ParameterDescriptionDefaultDomain
n_agentsNumber of agents5001–10,000
modalitySwarm type'aerial'aerial/ground/underwater/mixed
n_basisBasis dimension6416–256
k_couplingKuramoto coupling (K=3K_c)3.02.0–6.0
mu_dissipationDrag coefficient0.020.01–0.5
target_configFormation type'diamond_V'diamond_V/convoy_line/school_sphere/mixed_cluster
sos_degreeSOS polynomial degree42–6

🧩 Core Modules

ModuleDescription
manifold/Physical Coupling Manifold · metric G(Q) · Christoffel connection
field/CLO + EPFE · Euler-Lagrange integrator · SOS optimization
synchronization/KPSL · Kuramoto order parameter · critical coupling K_c
stability/Jacobian eigenvalue analysis · basin estimation · convergence monitor
control/SwarmEngine · formation controller · CSI monitor
interface/SwarmConfig · ROS2 bridge · TensorRT export

📊 Validation Summary

ScenarioModalityN AgentsCSIERIConvergence
S1 — Aerial FormationAerial50–5,00096.2%91.4%1.8 τ_A
S2 — Ground ConvoyGround10–50094.1%87.9%2.4 τ_A
S3 — Underwater SchoolUnderwater20–1,00093.8%86.2%2.6 τ_A
S4 — Mixed ModalityMixed30–30094.7%88.1%2.3 τ_A
Mean94.7%88.3%2.3 τ_A

📈 N-Independence Certificate

Key Theoretical Result: SWARMICA's stability certificate is N-independent — no performance degradation from N=50 to N=5,000 across all four scenarios. This is a direct consequence of the continuum mechanics formulation: the CLO's Euler-Lagrange equations are defined over the continuum density field ρ(x,t) — they have the same mathematical form regardless of N.

Number of Agents (N)Mean CSIDegradation
5094.9%
20094.5%-0.4 pp
1,00094.3%-0.6 pp
5,00094.1%-0.8 pp

👤 Author

🐝
Samir Baladi
Principal Investigator — Collective Swarm Intelligence
Samir Baladi is an independent interdisciplinary researcher affiliated with the Ronin Institute, developing the Rite of Renaissance research program. SWARMICA is a Variational and Continuum Mechanics framework for collective stability in autonomous swarm systems, building on the mathematical foundations of Lagrangian mechanics, Kuramoto synchronization, and SOS polynomial optimization.
No conflicts of interest declared. All code and data are open-source under MIT License with full reproducibility via Zenodo.

📝 Citation

@software{baladi2026swarmica, author = {Samir Baladi}, title = {SWARMICA: A Variational and Continuum Mechanics Framework for Collective Stability in Autonomous Swarm Systems}, year = {2026}, version = {1.0.0}, publisher = {Zenodo}, doi = {10.5281/zenodo.20168278}, url = {https://doi.org/10.5281/zenodo.20168278}, note = {PyPI: pip install swarmica-engine} }

"The swarm is not a collection of agents. It is a single thought, distributed across a thousand bodies, moving through the geometry of its own potential. SWARMICA gives that thought a direction — and proves, mathematically, that it will arrive." — SWARMICA v1.0.0 Manifesto