5D Library › 集群动力学、耦合振子同步与分布式共识的数学模型 · English

第三章 自驱动粒子与三区模型:噪声、对齐与集体记忆

从计算机动画到统计物理

鸟群与鱼群没有指挥,却能整齐地转向。最早的计算模型来自两条线索:青木一郎 1982 年用排斥、平行定向与吸引三种规则模拟鱼群 (Aoki 1982);雷诺兹 1987 年为计算机动画设计的「类鸟群」(boids)用分离、对齐与聚合三条局部规则产生了逼真的群体运动 (Reynolds 1987)。这两条线索后来汇合成本章讨论的两个模型:维切克等人 1995 年的自驱动粒子模型,只保留「对齐」一条规则,用来研究噪声下的有序—无序转变;库赞等人 2002 年的三区模型,保留三条规则,用来研究群体的不同形态。维切克与扎费里斯 2012 年的综述概括了此后的大量工作 (Vicsek and Zafeiris 2012)。

维切克模型

推导

模型。 NN 个粒子在边长为 LL 的周期性方盒中以恒定速率 v0v_0 运动。每一步,粒子 ii 的方向变为半径 1 之内所有粒子(含自身)方向的平均,再加上 [−η/2,η/2][-\eta/2, \eta/2] 上均匀分布的随机扰动: θi(t+1)=arg⁡(∑|xj−xi|<1eiθj(t))+Δθi,xi(t+1)=xi(t)+v0eiθi(t+1).\theta_i(t+1) = \arg\left(\sum_{\lvert x_j – x_i\rvert < 1} e^{i\theta_j(t)}\right) + \Delta\theta_i, \qquad x_i(t+1) = x_i(t) + v_0 e^{i\theta_i(t+1)}. 序参量为平均速度的归一化大小 va=|∑ieiθi|/Nv_a = |\sum_i e^{i\theta_i}|/N。控制参数是噪声 η\eta 与密度 ρ=N/L2\rho = N/L^2 (Vicsek et al. 1995)。

维切克等人发现,噪声小于某个临界值或密度大于某个临界值时,粒子会自发地朝同一方向运动,vav_a 显著大于 0;他们最初把它报告为一个类似平衡态相变的连续转变。这个结论后来有两处重要修正。第一,在二维平衡态的 XY 模型中,连续对称性不能自发破缺(没有真正的长程序);托纳与涂(Yuhai Tu)1995 年用流体力学理论说明,自驱动粒子因为一边对齐一边移动,信息可以随粒子传播,所以二维中也能出现真正的长程有序 (Toner and Tu 1995)。第二,格雷瓜尔与沙泰 2004 年用大得多的系统证明,这一转变在二维中其实是不连续的(一级相变),在接近转变点时会出现密度带,内聚性也会丧失 (Grégoire and Chaté 2004)。所以小系统模拟中看到的平滑曲线,不能用来判断相变的阶数。

程序复现维切克等人的噪声扫描:密度 ρ=4\rho = 4,v0=0.03v_0 = 0.03,比较 N=100N = 100(L=5L = 5)与 N=25N = 25(L=2.5L = 2.5)。用格子链表找邻居,模拟 600 步,对第 300 到 600 步的 vav_a 取平均,每个噪声值用 2 个随机种子。

推导

# Vicsek et al. (1995): N particles, speed v0 = 0.03, periodic box L, radius 1.
#   theta_i(t+1) = arg( sum_{|x_j - x_i| < 1} e^{i theta_j} ) + U(-eta/2, eta/2)
#   x_i(t+1) = x_i(t) + v0 e^{i theta_i(t+1)};   order v_a = |sum_i e^{i theta_i}| / N
# Density rho = N / L^2 = 4 as in the original noise scan; cell lists of side 1.
# v_a is averaged over steps 300..600 and over 2 seeds.
import math, random

def vicsek(N, L, eta, steps=600, burn=300, seed=0, v0=0.03):
    rng = random.Random(seed); nc = int(L)
    x = [rng.uniform(0, L) for _ in range(N)]; y = [rng.uniform(0, L) for _ in range(N)]
    th = [rng.uniform(-math.pi, math.pi) for _ in range(N)]
    acc = 0.0
    for t in range(steps):
        cells = {}
        for i in range(N):
            cells.setdefault((int(x[i]) % nc, int(y[i]) % nc), []).append(i)
        c = [math.cos(a) for a in th]; s = [math.sin(a) for a in th]; new = []
        for i in range(N):
            cx, cy, sc, ss = int(x[i]) % nc, int(y[i]) % nc, 0.0, 0.0
            for dx in (-1, 0, 1):
                for dy in (-1, 0, 1):
                    for j in cells.get(((cx + dx) % nc, (cy + dy) % nc), ()):
                        ex = (x[j] - x[i] + L / 2) % L - L / 2
                        ey = (y[j] - y[i] + L / 2) % L - L / 2
                        if ex * ex + ey * ey < 1.0:
                            sc += c[j]; ss += s[j]
            new.append(math.atan2(ss, sc) + rng.uniform(-eta / 2, eta / 2))
        th = new
        x = [(a + v0 * math.cos(b)) % L for a, b in zip(x, th)]
        y = [(a + v0 * math.sin(b)) % L for a, b in zip(y, th)]
        if t >= burn:
            acc += math.hypot(sum(map(math.cos, th)), sum(map(math.sin, th))) / N
    return acc / (steps - burn)

if __name__ == "__main__":
    print("noise eta   v_a (N = 100, L = 5)   v_a (N = 25, L = 2.5)")
    for eta in (0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 5.0, 6.0):
        a = sum(vicsek(100, 5.0, eta, seed=s) for s in (1, 2)) / 2
        b = sum(vicsek(25, 2.5, eta, seed=s) for s in (1, 2)) / 2
        print(f"   {eta:3.1f}            {a:.3f}                  {b:.3f}")
# noise eta   v_a (N = 100, L = 5)   v_a (N = 25, L = 2.5)
#    0.5            0.988                  0.989
#    1.0            0.952                  0.957
#    1.5            0.894                  0.907
#    2.0            0.815                  0.837
#    2.5            0.719                  0.753
#    3.0            0.594                  0.653
#    3.5            0.476                  0.552
#    4.0            0.326                  0.430
#    5.0            0.127                  0.233
#    6.0            0.093                  0.173

噪声小时两种规模都几乎完全有序(η=0.5\eta = 0.5 时 vav_a 约为 0.99);噪声增大,有序度逐渐下降,N=100N = 100 时 η=4.0\eta = 4.0 为 0.326,η=6.0\eta = 6.0 为 0.093。小系统的曲线更平缓:η=5.0\eta = 5.0 时 N=25N = 25 的 vav_a 为 0.233,N=100N = 100 为 0.127,这部分来自有限人数的涨落(N−1/2N^{-1/2} 分别为 0.20 与 0.10)。在这样小的系统中看到的是平滑过渡,与格雷瓜尔与沙泰在大系统中发现的不连续转变并不矛盾——不连续性只有在足够大的尺度上才显现。

证据

拓扑邻居。 巴莱里尼等人 2008 年用立体摄影重建了罗马上空椋鸟群中每只鸟的三维位置,发现每只鸟的相互作用对象是固定数目的最近邻(约六到七只),而不是一定距离内的所有个体;也就是说,相互作用取决于拓扑距离而不是度量距离。他们认为这使鸟群在密度剧烈变化时(例如遭遇捕食者)仍能保持内聚 (Ballerini et al. 2008)。

这一发现提醒我们,维切克模型的「半径 1 之内」是一个建模选择。第四章的程序用每次随机看几个同伴的方式粗略代替拓扑邻居。

维切克模型也连接着第五章。贾德巴拜、林(Jie Lin)与莫尔斯 2003 年把维切克模型去掉噪声后线性化,证明只要邻居关系构成的图在一段段时间内「联合连通」,所有个体的方向最终会趋于一致;这本质上就是一个邻居关系随时间变化的德格鲁特平均过程 (Jadbabaie et al. 2003)。

库赞的三区模型

库赞、克劳泽、詹姆斯、拉克斯顿与弗兰克斯 2002 年的模型给每个个体三层同心区域 (Couzin et al. 2002):

  • 排斥区(半径 rrr_r):只要有邻居进入,个体就优先远离它们,其他规则暂不起作用;
  • 定向区(宽度 Δro=ro−rr\Delta r_o = r_o – r_r):与其中的邻居对齐方向;
  • 吸引区(宽度 Δra=ra−ro\Delta r_a = r_a – r_o):朝其中的邻居靠拢。

个体身后有一个盲区,每步的转角有上限,方向带有随机误差。在三维中,他们改变 Δro\Delta r_o 与 Δra\Delta r_a,得到四种集体状态:群集(swarm:内聚但方向杂乱,极化度与角动量都低)、环面(torus:个体绕着一个空心的中心旋转,角动量高)、动态平行(dynamic parallel:方向一致,内部位置不断交换)与高度平行(highly parallel:方向高度一致,几乎直线运动)。Δro\Delta r_o 很小时为群集;Δro\Delta r_o 较小而 Δra\Delta r_a 较大时为环面;Δro\Delta r_o 增大则变为平行。两者都很小时群体容易分裂。

框架只列了「虫群、旋转环面、平行巡航」三种,本书按原文补全为四种。更重要的是原文的「集体记忆」:固定 ra=14r_a = 14,逐渐增大 ror_o 时,群体约在 ro≈1.5r_o \approx 1.5 处从群集变为环面,约在 2.5 以上变为平行;但反过来逐渐减小 ror_o 时,群体保持平行,不再回到环面,直到 ror_o 降到约 1.5 以下才回到群集。同样的个体规则可以对应不同的集体状态,取决于群体经历了什么,而个体并不「知道」这段历史。

程序是三区模型的二维简化版:N=40N = 40,rr=1r_r = 1,Δra=10\Delta r_a = 10,盲区为身后 90°90°(视野 ±135°\pm 135°),最大转角每秒 70°70°,速率 3,方向误差标准差 0.05 弧度,时间步 0.1 秒。对每个 Δro\Delta r_o 用 3 个随机初始条件各模拟 1200 步,对最后 300 步计算极化度 pp(平均单位速度的大小)与归一化角动量 mm,把 p>0.65p > 0.65 判为平行,否则 m>0.45m > 0.45 判为环面,其余为群集。最后从 Δro=8\Delta r_o = 8 形成的平行群体出发,检验较小 Δro\Delta r_o 下的状态是否取决于起点。参数是示意值,二维结果不能与原文的三维数值一一对应。

推导

# Two-dimensional simplification of the three-zone model of Couzin et al. (2002).
# Zone of repulsion r_r = 1 (priority); else orientation within r_o = r_r + d_o and
# attraction within r_a = r_o + d_a. Blind angle: neighbours behind (outside +-135 deg of
# the heading) are unseen. Max turn 70 deg/s, speed 3, noise SD 0.05 rad, dt 0.1 s, N 40.
# Measures (last 300 of 1200 steps): polarisation p = |mean unit velocity|,
# rotation m = |mean of (r_i - centroid)/|r_i - c| x v_i|.
import math, random

N, RR, SPEED, DT, TURN, SEE = 40, 1.0, 3.0, 0.1, math.radians(70), math.radians(135)

def step(x, y, h, ro, ra, rng):
    new = []
    for i in range(N):
        rx = ry = ox = oy = ax = ay = 0.0; rep = False
        for j in range(N):
            if j == i: continue
            dx, dy = x[j] - x[i], y[j] - y[i]; d2 = dx * dx + dy * dy
            if d2 >= ra * ra: continue
            d = math.sqrt(d2) or 1e-9
            if d < RR:
                rep = True; rx -= dx / d; ry -= dy / d; continue
            if abs((math.atan2(dy, dx) - h[i] + math.pi) % (2 * math.pi) - math.pi) > SEE:
                continue
            if d < ro: ox += math.cos(h[j]); oy += math.sin(h[j])
            else: ax += dx / d; ay += dy / d
        if rep: dx, dy = rx, ry
        else:
            no, na = math.hypot(ox, oy), math.hypot(ax, ay)
            dx = (ox / no if no else 0) + (ax / na if na else 0)
            dy = (oy / no if no else 0) + (ay / na if na else 0)
        want = math.atan2(dy, dx) if (dx or dy) else h[i]
        want += rng.gauss(0, 0.05)
        turn = (want - h[i] + math.pi) % (2 * math.pi) - math.pi
        new.append(h[i] + max(-TURN * DT, min(TURN * DT, turn)))
    xs = [a + SPEED * DT * math.cos(b) for a, b in zip(x, new)]
    ys = [a + SPEED * DT * math.sin(b) for a, b in zip(y, new)]
    return xs, ys, new

def measures(x, y, h):
    cx, cy = sum(x) / N, sum(y) / N
    p = math.hypot(sum(map(math.cos, h)), sum(map(math.sin, h))) / N
    m = 0.0
    for a, b, t in zip(x, y, h):
        d = math.hypot(a - cx, b - cy) or 1e-9
        m += ((a - cx) * math.sin(t) - (b - cy) * math.cos(t)) / d
    return p, abs(m) / N

def run(d_o, d_a=10.0, seed=3, steps=1200, start=None):
    rng = random.Random(seed)
    if start is None:
        x = [rng.uniform(-4, 4) for _ in range(N)]
        y = [rng.uniform(-4, 4) for _ in range(N)]
        h = [rng.uniform(-math.pi, math.pi) for _ in range(N)]
    else: x, y, h = start
    ro = RR + d_o; ps = ms = 0.0
    for t in range(steps):
        x, y, h = step(x, y, h, ro, ro + d_a, rng)
        if t >= steps - 300:
            p, m = measures(x, y, h); ps += p; ms += m
    return ps / 300, ms / 300, (x, y, h)

def label(p, m):
    return "parallel" if p > 0.65 else ("torus/mill" if m > 0.45 else "swarm")

if __name__ == "__main__":
    print("d_o   (p, m) for 3 random starts (d_a = 10)                 states")
    for d_o in (0.0, 1.0, 2.0, 4.0, 8.0):
        res = [run(d_o, seed=s)[:2] for s in (1, 2, 3)]
        print(f"{d_o:3.0f}   " + "  ".join(f"({p:.2f}, {m:.2f})" for p, m in res)
              + "   " + ", ".join(label(p, m) for p, m in res))
    _, _, pol = run(8.0, seed=1)        # collective memory: start from a parallel group
    for d_o in (4.0, 2.0):
        p, m, _ = run(d_o, seed=1, start=pol)
        print(f"d_o = {d_o:.0f}, started from the parallel group of d_o = 8:"
              f"  p = {p:.2f}, m = {m:.2f} -> {label(p, m)}")
# d_o   (p, m) for 3 random starts (d_a = 10)                 states
#   0   (0.19, 0.15)  (0.17, 0.08)  (0.12, 0.07)   swarm, swarm, swarm
#   1   (0.11, 0.81)  (0.11, 0.85)  (0.09, 0.18)   torus/mill, torus/mill, swarm
#   2   (0.15, 0.70)  (0.68, 0.16)  (0.16, 0.82)   torus/mill, parallel, torus/mill
#   4   (0.33, 0.71)  (0.26, 0.77)  (0.11, 0.84)   torus/mill, torus/mill, torus/mill
#   8   (1.00, 0.01)  (0.96, 0.05)  (0.99, 0.14)   parallel, parallel, parallel
# d_o = 4, started from the parallel group of d_o = 8:  p = 0.84, m = 0.05 -> parallel
# d_o = 2, started from the parallel group of d_o = 8:  p = 0.08, m = 0.86 -> torus/mill

二维简化版复现了原文的定性顺序:Δro=0\Delta r_o = 0 时 3 次都是群集(pp 为 0.12 至 0.19);Δro=4\Delta r_o = 4 时 3 次都是环面(mm 为 0.71 至 0.84);Δro=8\Delta r_o = 8 时 3 次都是平行(pp 为 0.96 至 1.00)。中间区域存在多稳态:Δro=1\Delta r_o = 1 时有 2 次环面、1 次群集,Δro=2\Delta r_o = 2 时有 2 次环面、1 次平行。集体记忆也出现了:Δro=4\Delta r_o = 4 时随机起点 3 次都形成环面,但从平行群体出发则保持平行(p=0.84p = 0.84,m=0.05m = 0.05);到 Δro=2\Delta r_o = 2 时记忆消失,平行群体转为环面(p=0.08p = 0.08,m=0.86m = 0.86)。这一部分只用了一个种子;核查时换用种子 2 与 3 重跑:种子 2 的平行群体在 Δro=4\Delta r_o = 4 与 2 时都保持平行,种子 3 的平行群体在 Δro=4\Delta r_o = 4 时散成群集(同一种子的随机起点形成环面)。所以「从平行出发的终态与随机起点不同」(历史起作用)在三个种子中都成立,但平行状态能否保持、记忆在哪个 Δro\Delta r_o 消失,取决于随机性,不能从一次模拟读出。

左:维切克模型的有序度 v_a 随噪声 \eta 的变化(密度 4,N = 100 与 N = 25,单个种子)。右:二维三区模型中极化度 p 与角动量 m 随定向区宽度 \Delta r_o 的变化(单个种子):\Delta r_o 很小时为群集,中等时角动量高(环面),较大时极化度高(平行)。

证据

真实鱼群中的三种状态。 通斯特罗姆等人 2013 年分析了 30 到 300 条金体美鳊(golden shiner)组成的鱼群,至少识别出三种动态稳定的集体状态:群集、旋转(milling)与极化;鱼游得慢时多为密集而无序的群集,游速增大时则进入旋转或高度机动的极化状态。旋转与极化在一个参数区间内双稳共存,两者之间的转换主要由扰动触发;各状态的稳定性还取决于鱼群的规模 (Tunstrøm et al. 2013)。

假说 · 尚未验证 · 改变集体状态需要越过记忆区

三区模型与鱼群数据都显示,在一段参数区间内两种集体状态共存,群体处于哪一种取决于历史。作者的推测是:在需要协调移动的人群(例如第四章戴尔等人范式中的步行人群)中,如果逐步改变「与邻近者保持方向一致」的指令强度,群体由松散转为整齐与由整齐转回松散的转折点不同(存在滞后)。可以用双向扫描的人群步行实验检验:若两个方向上的转折点在统计上没有差别,这个推测就是错的。这是从动物群体模型到人群的类比,不涉及任何组织管理建议。

本章小结

维切克模型只用「对齐加噪声」就产生了集体有序;托纳与涂解释了二维中长程序的来源,格雷瓜尔与沙泰证明大系统中的转变是不连续的,小系统的平滑曲线不能判断相变阶数。库赞的三区模型给出群集、环面、动态平行与高度平行四种状态,并且存在滞后的「集体记忆」;二维简化版复现了这些定性结论,真实鱼群也有多稳态。下一章讨论这样的群体怎样被少数知情者带往某个方向。

参考文献

Aoki, Ichiro. 1982. “A Simulation Study on the Schooling Mechanism in Fish.” Bulletin of the Japanese Society of Scientific Fisheries 48 (8): 1081–88. https://doi.org/10.2331/suisan.48.1081.
Ballerini, Michele, Nicola Cabibbo, Raphael Candelier, et al. 2008. “Interaction Ruling Animal Collective Behavior Depends on Topological Rather Than Metric Distance: Evidence from a Field Study.” Proceedings of the National Academy of Sciences 105 (4): 1232–37. https://doi.org/10.1073/pnas.0711437105.
Couzin, Iain D., Jens Krause, Richard James, Graeme D. Ruxton, and Nigel R. Franks. 2002. “Collective Memory and Spatial Sorting in Animal Groups.” Journal of Theoretical Biology 218 (1): 1–11.
Grégoire, Guillaume, and Hugues Chaté. 2004. “Onset of Collective and Cohesive Motion.” Physical Review Letters 92 (2): 025702. https://doi.org/10.1103/PhysRevLett.92.025702.
Jadbabaie, Ali, Jie Lin, and A. Stephen Morse. 2003. “Coordination of Groups of Mobile Autonomous Agents Using Nearest Neighbor Rules.” IEEE Transactions on Automatic Control 48 (6): 988–1001.
Reynolds, Craig W. 1987. “Flocks, Herds and Schools: A Distributed Behavioral Model.” Computer Graphics (SIGGRAPH ’87 Proceedings) 21 (4): 25–34.
Toner, John, and Yuhai Tu. 1995. “Long-Range Order in a Two-Dimensional Dynamical XY Model: How Birds Fly Together.” Physical Review Letters 75 (23): 4326–29. https://doi.org/10.1103/PhysRevLett.75.4326.
Tunstrøm, Kolbjørn, Yael Katz, Christos C. Ioannou, Cristián Huepe, Matthew J. Lutz, and Iain D. Couzin. 2013. “Collective States, Multistability and Transitional Behavior in Schooling Fish.” PLoS Computational Biology 9 (2): e1002915. https://doi.org/10.1371/journal.pcbi.1002915.
Vicsek, Tamás, András Czirók, Eshel Ben-Jacob, Inon Cohen, and Ofer Shochet. 1995. “Novel Type of Phase Transition in a System of Self-Driven Particles.” Physical Review Letters 75 (6): 1226–29. https://doi.org/10.1103/PhysRevLett.75.1226.
Vicsek, Tamás, and Anna Zafeiris. 2012. “Collective Motion.” Physics Reports 517 (3): 71–140. https://doi.org/10.1016/j.physrep.2012.03.004.

Fan, Y. (2026). Collective Dynamics, Coupled-Oscillator Synchrony and Distributed Consensus: From the Kuramoto Phase Transition and Vicsek Flocking to DeGroot Spectral Convergence, Read Beside Classical Chinese Thought on Harmony and Conformity [集群动力学、耦合振子同步与分布式共识的数学模型] (Version 1.0.0). 5D Library. https://doi.org/10.5281/zenodo.23828063 · Licensed under Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0).