Search

Search papers and lessons

Multi-Agent Consensus

Level 3 · 11 min read

Consensus is a rule that lets many agents, each talking only to its neighbours, drive their values to a common number, and the graph Laplacian's spectrum decides how fast they get there.

On this page

  • Colour = topic mix
  • Probability
  • Linear algebra
  • Calculus
  • Discrete math
  • Control systems
  • Motion planning
  • Sign in to see your progress

TL;DR

A group of agents each holds a number, such as a heading, a height or a temperature reading. Each agent can only talk to its neighbours in a communication graph. Consensus is a simple local rule: every agent nudges its value toward the values of the neighbours it can hear. If the graph is connected, all values converge to one common number, and with the simplest rule that number is the average of the starting values.

The speed of convergence is set by the graph itself. It is read from the eigenvalues of the graph Laplacian, and the second-smallest one tells you how quickly the group agrees.

Where you'll see it: in flocking and formation control, where a swarm of drones aligns its headings without a leader, in distributed sensor networks that average their readings, and in distributed optimization, where machines agree on a shared estimate.

Intuition

Agreeing by talking to neighbours

Picture five people standing in a line, each holding a card with a number on it. Nobody can see the whole room. Each person can only hear the two people beside them. The group wants everyone to end up holding the same number, but there is no chair in charge of collecting the cards.

The rule is simple. Each person looks at the neighbours' numbers, and moves their own number a little toward them. If your number is higher than your neighbour's, you lower yours; if it is lower, you raise yours. Repeat this for everyone at once, and the differences between neighbours shrink. Keep going and the whole line flattens to one value.

This is the core idea of consensus. No agent knows the global state. Each agent uses only local information, and agreement emerges from the repeated local moves.

flowchart LR
  A1((agent 1)) --- A2((agent 2))
  A2 --- A3((agent 3))
  A3 --- A4((agent 4))
  A4 --- A5((agent 5))

Why this model exists: real multi-agent systems rarely have a central computer. A robot swarm, a set of wireless sensors or a fleet of satellites has to coordinate over links that are local, slow and sometimes broken. Consensus gives a way to reach a shared value, with no leader and no full picture, using only messages between neighbours.

The math

Setup

Let there be nn agents, and let agent ii hold a scalar state xi(t)x_i(t) at time tt. Stack the states into one vector x(t)∈Rn\mathbf{x}(t) \in \mathbb{R}^n. The agents communicate over an undirected graph G\mathcal{G} with adjacency matrix AA, where aij=1a_{ij} = 1 if agents ii and jj can hear each other and 00 otherwise. Let DD be the diagonal degree matrix, with di=∑jaijd_i = \sum_j a_{ij} on its diagonal, and let L=D−AL = D - A be the graph Laplacian.

The continuous-time consensus protocol is

x˙i(t)=∑jaij(xj(t)−xi(t)),or in stacked formx˙(t)=−L x(t).\dot{x}_i(t) = \sum_{j} a_{ij} \bigl(x_j(t) - x_i(t)\bigr), \qquad \text{or in stacked form} \qquad \dot{\mathbf{x}}(t) = -L\,\mathbf{x}(t).

Each agent's rate of change is the sum of its disagreements with its neighbours, so it moves toward them. This is a linear dynamical system with dynamics matrix −L-L and no input or noise, so its solution is x(t)=e−Ltx(0)\mathbf{x}(t) = e^{-Lt}\mathbf{x}(0).

Two facts about the Laplacian

Two properties of LL do all the work. Both follow from the definition L=D−AL = D - A.

  1. Every row sums to zero. So L1=0L\mathbf{1} = \mathbf{0}, where 1\mathbf{1} is the all-ones vector. This means the constant vector is an eigenvector with eigenvalue zero.
  2. LL is symmetric and positive semidefinite. Its eigenvalues are real and non-negative, and they can be ordered as 0=λ1≤λ2≤⋯≤λn0 = \lambda_1 \le \lambda_2 \le \cdots \le \lambda_n.

The number λ2\lambda_2 is called the algebraic connectivity, or the Fiedler value. It is positive exactly when the graph is connected.

The average is preserved

Because the columns of LL also sum to zero, 1⊤L=0⊤\mathbf{1}^\top L = \mathbf{0}^\top. Differentiate the average xˉ(t)=1n1⊤x(t)\bar{x}(t) = \frac{1}{n}\mathbf{1}^\top \mathbf{x}(t):

xˉ˙(t)=1n1⊤x˙(t)=−1n1⊤L x(t)=0.\dot{\bar{x}}(t) = \frac{1}{n}\mathbf{1}^\top\dot{\mathbf{x}}(t) = -\frac{1}{n}\mathbf{1}^\top L\,\mathbf{x}(t) = 0.

So the average of the states never changes. Whatever the group agrees on, it has to be the initial average.

Convergence

Let L=∑kλkvkvk⊤L = \sum_k \lambda_k \mathbf{v}_k \mathbf{v}_k^\top be the eigen-decomposition, with orthonormal eigenvectors vk\mathbf{v}_k. Then

x(t)=∑k=1ne−λkt (vk⊤x(0)) vk.\mathbf{x}(t) = \sum_{k=1}^{n} e^{-\lambda_k t}\,(\mathbf{v}_k^\top \mathbf{x}(0))\,\mathbf{v}_k.

Each mode decays at rate λk\lambda_k. The mode with λ1=0\lambda_1 = 0 does not decay, and it is the average direction v1=1/n\mathbf{v}_1 = \mathbf{1}/\sqrt{n}. Every other mode decays to zero if λ2>0\lambda_2 \gt 0. So for a connected graph,

x(t)⟶xˉ(0) 1,with the gap closing like e−λ2t.\mathbf{x}(t) \longrightarrow \bar{x}(0)\,\mathbf{1}, \qquad \text{with the gap closing like } e^{-\lambda_2 t}.

The slowest mode is the one with the smallest positive eigenvalue, λ2\lambda_2. A sparse graph has a small λ2\lambda_2 and slow agreement. A well-connected graph has a large λ2\lambda_2 and fast agreement.

Discrete-time version

Real networks often update at discrete times. The rule becomes xk+1=(I−εL)xk\mathbf{x}_{k+1} = (I - \varepsilon L)\mathbf{x}_k for a step size ε\varepsilon. Choosing 0<ε<1/dmax⁡0 \lt \varepsilon \lt 1/d_{\max}, where dmax⁡d_{\max} is the largest degree, keeps every entry of I−εLI - \varepsilon L non-negative, so each agent's new value is a weighted average of its own value and its neighbours' values. The average is still preserved, because 1⊤(I−εL)=1⊤\mathbf{1}^\top(I - \varepsilon L) = \mathbf{1}^\top.

Worked examples

Example
Three agents in a line

Take three agents in a path, 1−2−31 - 2 - 3. Agent 2 talks to both others, and agents 1 and 3 talk only to agent 2. The adjacency and degree matrices are

A=(010101010),D=(100020001),L=D−A=(1−10−12−10−11).A = \begin{pmatrix} 0 & 1 & 0 \\ 1 & 0 & 1 \\ 0 & 1 & 0 \end{pmatrix}, \qquad D = \begin{pmatrix} 1 & 0 & 0 \\ 0 & 2 & 0 \\ 0 & 0 & 1 \end{pmatrix}, \qquad L = D - A = \begin{pmatrix} 1 & -1 & 0 \\ -1 & 2 & -1 \\ 0 & -1 & 1 \end{pmatrix}.
  1. The eigenvectors are (1,1,1)(1,1,1) with eigenvalue 00, (1,0,−1)(1,0,-1) with eigenvalue 11, and (1,−2,1)(1,-2,1) with eigenvalue 33. Check the middle one: L(1,0,−1)⊤=(1,0,−1)⊤L(1,0,-1)^\top = (1, 0, -1)^\top, so its eigenvalue is 11.
  2. Start from x(0)=(0,3,6)\mathbf{x}(0) = (0, 3, 6). Its average is 33. Write x(0)=3 (1,1,1)−3 (1,0,−1)\mathbf{x}(0) = 3\,(1,1,1) - 3\,(1,0,-1). Check: 3(1,1,1)−3(1,0,−1)=(0,3,6)3(1,1,1) - 3(1,0,-1) = (0, 3, 6).
  3. Apply the solution formula. The constant part stays. The (1,0,−1)(1,0,-1) part decays at rate λ=1\lambda = 1. So x(t)=3 (1,1,1)−3e−t (1,0,−1)\mathbf{x}(t) = 3\,(1,1,1) - 3e^{-t}\,(1,0,-1).
  4. Read off each agent: x1(t)=3−3e−tx_1(t) = 3 - 3e^{-t}, x2(t)=3x_2(t) = 3, x3(t)=3+3e−tx_3(t) = 3 + 3e^{-t}.
  5. Check the dynamics for agent 1: x˙1=3e−t\dot{x}_1 = 3e^{-t}, and −(x1−x2)=−(3−3e−t−3)=3e−t-(x_1 - x_2) = -(3 - 3e^{-t} - 3) = 3e^{-t}. They agree.

Numbers: at t=1t = 1, x1≈1.90x_1 \approx 1.90 and x3≈4.10x_3 \approx 4.10. At t=2t = 2, x1≈2.59x_1 \approx 2.59 and x3≈3.41x_3 \approx 3.41. The gap between the outer agents shrinks by the factor e−1e^{-1} per unit time, and the rate is exactly λ2=1\lambda_2 = 1.

Interpretation: the middle agent never moves because it already sits at the average. The ends move inward at the rate the graph allows, and everything lands on 33, the starting average.

01234560246time tstate
  • agent 1
  • agent 2
  • agent 3
The three states under continuous-time consensus from (0, 3, 6). The outer agents approach the average 3 at rate e^(-t), and agent 2 stays put.
Example
One discrete update, step by step

Use the same path graph and start from x0=(0,3,6)\mathbf{x}_0 = (0, 3, 6). Here dmax⁡=2d_{\max} = 2, so choose ε=1/3\varepsilon = 1/3, which is below 1/21/2.

  1. Compute the Laplacian action: Lx0=(0−3,  −0+6−6,  −3+6)=(−3,0,3)L\mathbf{x}_0 = (0 - 3,\; -0 + 6 - 6,\; -3 + 6) = (-3, 0, 3).
  2. Update: x1=x0−13Lx0=(0+1,  3−0,  6−1)=(1,3,5)\mathbf{x}_1 = \mathbf{x}_0 - \tfrac{1}{3}L\mathbf{x}_0 = (0 + 1,\; 3 - 0,\; 6 - 1) = (1, 3, 5).
  3. Check the average: (1+3+5)/3=3(1 + 3 + 5)/3 = 3. It is unchanged, as the theory says.
  4. Repeat. Lx1=(1−3,  −1+6−5,  −3+5)=(−2,0,2)L\mathbf{x}_1 = (1 - 3,\; -1 + 6 - 5,\; -3 + 5) = (-2, 0, 2), so x2=(1+23,  3,  5−23)≈(1.67,3,4.33)\mathbf{x}_2 = (1 + \tfrac{2}{3},\; 3,\; 5 - \tfrac{2}{3}) \approx (1.67, 3, 4.33).

Interpretation: each step pulls the outer agents inward by a third of the disagreement with their neighbours. The spread shrinks from 66 to 44 to about 2.672.67, and the average stays at 33. Each new value is a weighted average of the agent's own value and its neighbours', so the states never leave the range of the starting values.

Example
A disconnected network agrees in two groups

Take four agents with only two links, 1−21 - 2 and 3−43 - 4. This graph has two components. Its Laplacian has eigenvalues 0,0,2,20, 0, 2, 2, so λ2=0\lambda_2 = 0. Start from x(0)=(0,4,10,6)\mathbf{x}(0) = (0, 4, 10, 6).

  1. The first component, agents 1 and 2, has average (0+4)/2=2(0 + 4)/2 = 2. Within it, both agents move to 22.
  2. The second component, agents 3 and 4, has average (10+6)/2=8(10 + 6)/2 = 8, and both move to 88.
  3. The limit is (2,2,8,8)(2, 2, 8, 8). No single value is reached.

Interpretation: consensus needs a connected graph. With two components, each group agrees internally and the groups never talk, so the global average is not the target. The condition λ2>0\lambda_2 \gt 0 tells you this in advance.

Tradeoffs and failure modes

The linear averaging protocol is simple and robust, but it has limits.

SituationWhat goes wrongBetter choice
The communication graph is sparse, such as a long chainλ2\lambda_2 is small, so agreement is slowDenser links, or a graph with better connectivity
The graph is disconnected, or links drop oftenThe group splits into groups that never agree globallyEnsure connectivity over time, or add relays
Messages arrive lateDelayed information can make the protocol oscillate or diverge if the step size is too largeSmaller step size, or delay-aware protocols
The agents need the exact average, not just agreementOn an undirected graph the protocol gives the exact average, but on a directed graph, or with unbalanced weights, it converges to a weighted average of the starting valuesUse symmetric weights, or add a correction step such as push-sum
Agents are heterogeneous, or the network is adversarialA single faulty or malicious agent can pull the group to a wrong valueByzantine-tolerant consensus, which needs many more messages

A common mistake is to assume that more links always help. They do speed up agreement, but a poorly designed update rule can still diverge if the step size is too large. Check the step-size bound ε<1/dmax⁡\varepsilon \lt 1/d_{\max} before running a discrete system.

History

The idea of agents converging to a common opinion by repeatedly averaging their neighbours' views goes back to the statistician Morris DeGroot, who described it in a 1974 paper on reaching consensus among experts. The same averaging update reappeared in control and computer science, where it is now studied as a special case of linear dynamics on graphs.

In the 1980s, researchers in distributed computing and optimization, including John Tsitsiklis and his collaborators, analysed agreement and averaging protocols for networks of processors. Their work showed how convergence depends on the network's connectivity. The graph Laplacian came to be the central object in the mid-1990s and early 2000s, when work on flocking and swarms, notably the Vicsek model of 1995, made coordination of moving agents a research topic. Reza Olfati-Saber and Richard Murray's 2004 paper set out the Laplacian-based consensus framework for switching and delayed networks, and their 2007 survey became a standard reference.

Check yourself

QuestionWhy does the average of the agents' states stay fixed under the consensus rule?Show answer

Every column of the Laplacian sums to zero, so the vector of ones multiplied by LL is zero. The time derivative of the average is therefore −1n1⊤L x-\frac{1}{n}\mathbf{1}^\top L\,\mathbf{x}, which is zero. The protocol moves values around but never changes their total, so the group can only agree on the starting average.

QuestionFor a connected path of four agents, what is the consensus value if the starting states are (2,2,2,10)(2, 2, 2, 10)?Show answer

The average is (2+2+2+10)/4=4(2 + 2 + 2 + 10)/4 = 4. Because the average is preserved and a connected graph converges to a common value, the group converges to (4,4,4,4)(4, 4, 4, 4).

QuestionWhy does the second-smallest Laplacian eigenvalue, not the largest, set the speed of agreement?Show answer

Every mode of the state except the average decays at a rate equal to its eigenvalue. The slowest of these decaying modes has the smallest positive eigenvalue, λ2\lambda_2, so the gap between agents shrinks no faster than e−λ2te^{-\lambda_2 t}. The largest eigenvalue describes the fastest mode, which is already gone by the time the slow one matters.

QuestionA swarm of drones can only hear neighbours within a fixed radius. What would you check before expecting the swarm to agree on one heading?Show answer

Check that the communication graph is connected, meaning there is a path of hearing links between any two drones, or that it stays connected over time as drones move. If the graph splits into groups, each group agrees on its own heading and the groups never coincide. Also check that the update step is small enough for the largest number of neighbours any drone has, so the protocol does not oscillate.

Sources