# The Bees Buzz to St. Wasserstein

The bees have made a startling discovery. Rather than choosing among discrete options $\{A,B\}$, they have discovered they actually live a continuous universe $\mathbb{R}^d$. Accordingly, we extend the gradient flow perspective to the continuous space setting. They move according to individual dynamics
$$\dot{x} = u(t,x)$$ where the dynamics $u(t,x)$ was decided 5000 years ago by an all-seeing overlord. Our goal as out-of-control chimps is to reverse engineer these dynamics. Note that here each agent is evolving according to this ODE, in constrast to the discrete setting, where each agent evolved according to a Markov chain.
Once again, we are interested in the *mean-field* perspective. In this perspective, the bee colony is a yellow blob. The blob or density $\rho(t,x)$ is governed by the [continuity equation](https://hackmd.io/@clopenloop/H1Dxxcpzbx).
$$\partial_t \rho + \nabla \cdot (u\, \rho) = 0$$
This is a partial differential equation. It governs how a ensemble of initial conditions evolve under the above ODE dynamics.
Given this objective the collective decisition making problem in its feedback stabilization formulation is the following.
**Objective**: Given a potential $V(x)$, the collective decision-making problem is to design a **mean-field feedback law** $u = u(\rho, V)$ so that the swarm converges to the minimizer of $V$.
As in the last note, we take a *gradient flow* approach. Since $\rho(t,x)$ is a function (or a measure), we will use a *infinite dimensional gradient flow*. A natural energy functional on the space of probabilities is
$$\mathcal{F}[\rho] = \int_{\mathbb{R}^d} V(x)\,\rho(x)\,dx + \frac{\lambda}{2}\iint_{\mathbb{R}^d \times \mathbb{R}^d} |x-y|^2\,\rho(x)\,\rho(y)\,dx\,dy$$
The first term drives the swarm toward regions where $V$ is small, while the second penalizes spread, encouraging consensus. The appropriate notion of a gradient flow in this context is the [*Wasserstein gradient flow*](https://abdulfatir.com/blog/2020/Gradient-Flows/) of $\mathcal{F}$, which is formally given by
$$\partial_t \rho = \nabla \cdot \left(\rho\, \nabla \frac{\delta \mathcal{F}}{\delta \rho}\right)$$
The first variation of $\mathcal{F}$ is
$$\frac{\delta \mathcal{F}}{\delta \rho}(x) = V(x) + \lambda \int_{\mathbb{R}^d} |x - y|^2\,\rho(y)\,dy$$
so that
$$\nabla_x \frac{\delta \mathcal{F}}{\delta \rho}(x) = \nabla V(x) + 2\lambda(x - \bar{m}_\rho)$$
where $\bar{m}_\rho = \int y\,\rho(y)\,dy$ is the mean of the swarm. The resulting velocity field is purely a function of $V$ and the mean-field $\rho$
$$u(x) = -\nabla V(x) - 2\lambda(x - \bar{m}_\rho)$$
Each agent is driven by two forces: the quality gradient $-\nabla V$ pulling it toward nearby minima of $V$, and a consensus term $-2\lambda(x - \bar{m}_\rho)$ pulling it toward the current swarm mean.
## Equilibria: Where Society gets Stuck
We immediately see a lots of differences from the discrete case. For any critical point $x^*$ of $V$, i.e. $\nabla V(x^*) = 0$, the point mass $\rho = \delta_{x^*}$ is an equilibrium. the consensus term vanishes since $\bar{m}_\rho = x^*$, and the gradient vanishes by assumption. This holds for all values of $\lambda$. So sub-optimal choices are also equilibria.
But are these the only equilibria?
At equilibrium, the velocity must vanish on the support of $\rho$ so that the continuity equation is at steady state:
$$\nabla V(x) + 2\lambda(x - \bar{m}_\rho) = 0 \qquad \text{for all } x \in \mathrm{supp}(\rho)$$ where $\mathrm{supp}(\rho)$, loosely speaking denotes the set of points where the density (or measure) is positive.
Rearranging, this says
$$\nabla V(x) + 2\lambda x = 2\lambda \bar{m}_\rho \qquad \text{for all } x \in \mathrm{supp}(\rho)$$
The mean of the swarm is a constant, so the support of any equilibrium must be contained in a level set of the map $x \mapsto \nabla V(x) + 2\lambda x$.
Lets consider an example. Take $d = 1$ with the symmetric double well $V(x) = (x^2 - 1)^2$. Our one-dimensional bees face the following fixed points.
**Three single-Dirac equilibria.** The critical points $V'(x) = 4x^3 - 4x = 0$ give $x^* \in \{-1, 0, 1\}$, so we have $\delta_{-1}$, $\delta_0$, and $\delta_1$.
**A fourth equilibrium.** By symmetry, we attempt to find a solution of the form $$\rho = \frac{1}{2}\delta_{-s} + \frac{1}{2}\delta_s$$ so that the mean $\bar{m} = 0$. The equilibrium condition at $x = s$ becomes
$$V'(s) = -2\lambda(s - 0) \implies 4s^3 - 4s = -2\lambda s$$
Dividing by $s > 0$: $$4s^2 - 4 = -2\lambda \implies s = \sqrt{1 - \frac{\lambda}{2}}$$
This exists whenever $\lambda < 2$. So we have a symmetric two-Dirac equilibrium with support points at $\pm\sqrt{1 - \lambda/2}$, shifted inward from the wells by the consensus pull.
**Summary.** For $\lambda < 2$, the system has at least four equilibria:
| Equilibrium | Type |
|---|---|
| $\delta_{-1}$, $\delta_1$ | Single Diracs at wells |
| $\delta_0$ | Single Dirac at saddle |
| $\frac{1}{2}\delta_{-s} + \frac{1}{2}\delta_s$ | Split equilibrium, $s = \sqrt{1 - \lambda/2}$ |
As $\lambda \to 0$, $s \to 1$ and the split equilibrium approaches $\frac{1}{2}\delta_{-1} + \frac{1}{2}\delta_1$ — an even split across both wells. As $\lambda \to 2$, $s \to 0$ and the two support points collide at the origin, merging with $\delta_0$.
## But Wait, There Are More!
Our initial menu identified three single-Dirac equilibria ($\delta_{-1}$, $\delta_0$, $\delta_1$) and one symmetric two-Dirac equilibrium. But sadly this equilbria cafe serves a lot more. *The bees collectively stare at the waiter in confusion*.
Recall that every support point of an equilibrium must satisfy the same equation:
$$V'(x_i) + 2\lambda(x_i - \bar{m}) = 0$$
For $V(x) = (x^2 - 1)^2$, this gives
$$4x^3 + (2\lambda - 4)x = 2\lambda\bar{m}$$
The right-hand side is a constant $c = 2\lambda\bar{m}$, independent of $i$. So every support point is a root of the cubic
$$p(x) = 4x^3 + (2\lambda - 4)x - c$$
The derivative $p'(x) = 12x^2 + (2\lambda - 4)$ has real roots only when $\lambda < 2$, and in this regime $p$ can have up to three real roots. When $\lambda \geq 2$, $p$ is strictly monotone and admits only one real root — only single-Dirac equilibria are possible. *We have proved*: **all you need is love. [This has been long suspected.](https://www.youtube.com/watch?v=4EGczv7iiEk&list=RD4EGczv7iiEk&start_radio=1))**
### Other Two-Dirac equilibria: It's not just all about
### "Do you want Pizza or -Pizza?"
The symmetric split $\frac{1}{2}\delta_{-s} + \frac{1}{2}\delta_s$ is not the only two-point equilibrium. Lets see if there are other equilibria of the form $\alpha\delta_{x_1} + (1-\alpha)\delta_{x_2}$. If $x_1 \neq x_2$ are both roots of $p$, subtracting the equilibrium conditions and dividing by $x_1 - x_2$ gives
$$x_1^2 + x_1 x_2 + x_2^2 = 1 - \frac{\lambda}{2}$$
This is an ellipse in the $(x_1, x_2)$ plane. The mean of $\rho = \alpha\delta_{x_1} + (1-\alpha)\delta_{x_2}$ is
$$\bar{m} = \alpha x_1 + (1-\alpha)x_2$$
Solving for $\alpha$:
$$\bar{m} = \alpha x_1 + x_2 - \alpha x_2 = x_2 + \alpha(x_1 - x_2)$$
$$\alpha = \frac{\bar{m} - x_2}{x_1 - x_2}$$
Now, $\alpha \in (0,1)$ requires $\bar{m} - x_2$ to be strictly between $0$ and $x_1 - x_2$, which is exactly the statement that $\bar{m}$ lies strictly between $x_1$ and $x_2$. This is simply the fact that a convex combination of two distinct points lies in their interior, the mean of a two-point measure cannot fall outside its support.
The constraint $x_1^2 + x_1 x_2 + x_2^2 = 1 - \lambda/2$ defines an ellipse in the $(x_1, x_2)$ plane, rotated $45°$ from the standard axes. As $\lambda$ increases toward $2$, the ellipse shrinks and collapses to the origin. The symmetric split sits where the ellipse crosses the anti-diagonal $x_1 = -x_2$, but the full ellipse parametrizes a continuous family. Not every point on the ellipse corresponds to a valid equilibrium though. The weight $\alpha$ must lie in $(0,1)$, which restricts the admissible arc. The following plot shows the ellipse for several values of $\lambda$, with the valid arc highlighted.

### Three-Dirac equilibria
When $\lambda < 2$ and $c$ lies between the local maximum and minimum of $p$, all three roots $x_1 < x_2 < x_3$ are real. Any convex combination $\rho = \sum_i \alpha_i \delta_{x_i}$ with $\bar{m} = \sum_i \alpha_i x_i = c/(2\lambda)$ is an equilibrium. This is one linear constraint on the 2-simplex, leaving a one-parameter family of valid weight vectors for each such triple of support points.
For $\lambda < 2$, the equilibrium set is considerably larger. The single Diracs at critical points of $V$ and the symmetric two-Dirac split are isolated members of continuous families of multi-Dirac equilibria. Most of these are expected to be unstable. But one needs a careful Hessian analysis to characterize the stability.
These are some very cool visualizations made by Claude. We have not verified the stability of these equilibria but one can visualize the evolution of the dynamics of different parameter values for the double.


The following example is interesting as the bees not only show bistability. But they end up converging to the wrong points.

In this example, we consider the double well when one minima is striclty better than the other.

## The Convex Case
We have not yet considered the simplest setting when $V$ is strictly convex with a unique minimum $x^*$. Here the quality gradient and the consensus force are cooperative. Both terms drive the swarm toward $x^*$. The only equilibrium is $\rho = \delta_{x^*}$, and it is globally attracting. This can be shown using the notion of *displacement convexity*.
