# Averaging Algorithms and Consensus

**DOI:**https://doi.org/10.1007/978-1-4471-5102-9_214-1

- 1 Citations
- 753 Downloads

## Abstract

In this article, we overview averaging algorithms and consensus in the context of distributed coordination and control of networked systems. The two subjects are closely related but not identical. Distributed consensus means that a team of agents reaches an agreement on certain variables of interest by interacting with their neighbors. Distributed averaging aims at computing the average of certain variables of interest among multiple agents by local communication. Hence averaging can be treated as a special case of consensus – average consensus. For distributed consensus, we introduce distributed algorithms for agents with single-integrator, general linear, and nonlinear dynamics. For distributed averaging, we introduce static and dynamic averaging algorithms. The former is useful for computing the average of initial conditions (or constant signals), while the latter is useful for computing the average of time-varying signals. Future research directions are also discussed.

## Keywords

Multi-agent systems Distributed control Networked systems Coordination Cooperative control## Introduction

In the area of control of networked systems, low cost, high adaptivity and scalability, great robustness, and easy maintenance are critical factors. To achieve these factors, distributed coordination and control algorithms that rely on only local interaction between neighboring agents to achieve collective group behavior are more favorable than centralized ones. In this article, we overview averaging algorithms and consensus in the context of distributed coordination and control of networked systems.

Distributed consensus means that a team of agents reaches an agreement on certain variables of interest by interacting with their neighbors. A consensus algorithm is an update law that drives the variables of interest of all agents in the network to converge to a common value (Jadbabaie et al. 2003; Olfati-Saber et al. 2007; Ren and Beard 2008). Examples of the variables of interest include a local representation of the center and shape of a formation, the rendezvous time, the length of a perimeter being monitored, the direction of motion for a multi-vehicle swarm, and the probability that a target has been identified. Consensus algorithms have applications in rendezvous, formation control, flocking, attitude alignment, and sensor networks (Bullo et al. 2009; Qu 2009; Mesbahi and Egerstedt 2010; Ren and Cao 2011; Bai et al. 2011a). Distributed averaging algorithms aim at computing the average of certain variables of interest among multiple agents by local communication. Distributed averaging finds applications in distributed computing, distributed signal processing, and distributed optimization (Tsitsiklis et al. 1986). Hence the variables of interest are dependent on the applications (e.g., a sensor measurement or a network quantity). Consensus and averaging algorithms are closely connected and yet nonidentical. When all agents are able to compute the average, they essentially reach a consensus, the so-called average consensus. On the other hand, when the agents reach a consensus, the consensus value might or might not be the average value.

**Graph Theory Notations.**Suppose that there are

*n*agents in a network. A

*network topology*(equivalently,

*graph*) \(\mathcal{G}\) consisting of a node set \(\mathcal{V} =\{ 1,\ldots ,n\}\) and an edge set \(\mathcal{E}\subseteq \mathcal{V}\times \mathcal{V}\) will be used to model

*interaction*(communication or sensing) between the

*n*agents. An

*edge*(

*i*,

*j*) in a

*directed graph*denotes that agent

*j*can obtain information from agent

*i*, but not necessarily vice versa. In contrast, an edge (

*i*,

*j*) in an

*undirected graph*denotes that agents

*i*and

*j*can obtain information from each other. Agent

*j*is a

*(in-) neighbor*of agent

*i*if \((j,i) \in \mathcal{E}\). Let \(\mathcal{N}_{i}\) denote the neighbor set of agent

*i*. We assume that \(i \in \mathcal{N}_{i}\). A

*directed path*is a sequence of edges in a directed graph of the form (

*i*

_{1},

*i*

_{2}), (

*i*

_{2},

*i*

_{3}),

*…*, where \(i_{j} \in \mathcal{V}\). An

*undirected path*in an undirected graph is defined analogously. A directed graph is

*strongly connected*if there is a directed path from every agent to every other agent. An undirected graph is

*connected*if there is an undirected path between every pair of distinct agents. A directed graph

*has a directed spanning tree*if there exists at least one agent that has directed paths to all other agents. For example, Fig. 1 shows a directed graph that has a directed spanning but is not strongly connected. The

*adjacency matrix*\(\mathcal{A} = [a_{ij}] \in {\mathbb{R}}^{n\times n}\) associated with \(\mathcal{G}\) is defined such that

*a*

_{ ij }(the weight of edge (

*j*,

*i*)) is positive if agent

*j*is a neighbor of agent

*i*while

*a*

_{ ij }= 0 otherwise. The (nonsymmetric)

*Laplacian matrix*(Agaev and Chebotarev 2005) \(\mathcal{L} = [\ell_{ij}] \in {\mathbb{R}}^{n\times n}\) associated with \(\mathcal{A}\) and hence \(\mathcal{G}\) is defined as \(\ell_{ii} =\sum _{j\neq i}a_{ij}\) and \(\ell_{ij} = -a_{ij}\) for all

*i*≠

*j*. For an undirected graph, we assume that

*a*

_{ ij }=

*a*

_{ ji }. A graph is

*balanced*if for every agent the total edge weights of its incoming links is equal to the total edge weights of its outgoing links (\(\sum _{j=1}^{n}a_{ij} =\sum _{ j=1}^{n}a_{ji}\) for all

*i*).

## Consensus

Consensus has a long history in management science, statistical physics, and distributed computing and finds recent interests in distributed control. While in the area of distributed control of networked systems the term *consensus* was initially more or less dominantly referred to the case of a continuous-time version of a distributed linear averaging algorithm, such a term has been broadened to a great extent later on. Related problems to consensus include synchronization, agreement, and rendezvous. The study of consensus can be categorized in various manners. For example, in terms of the final consensus value, the agents could reach a consensus on the average, a weighted average, the maximum value, the minimum value, or a general function of their initial conditions, or even a (changing) state that serves as a reference. A consensus algorithm could be linear or nonlinear. Consensus algorithms can be designed for agents with linear or nonlinear dynamics. As the agent dynamics become more complicated, so do the algorithm design and analysis. Numerous issues are also involved in consensus such as network topologies (fixed vs. switching, deterministic vs. random, directed vs. undirected, asynchronous vs. synchronous), time delay, quantization, optimality, sampling effects, and convergence speed. For example, in real applications, due to nonuniform communication/sensing ranges or limited field of view of sensors, the network topology could be directed rather than undirected. Also due to unreliable communication/sensing and limited communication/sensing ranges, the network topology could be switching rather than fixed.

### Consensus for Agents with Single-Integrator Dynamics

*x*

_{ i }is the state and

*u*

_{ i }is the control input. A common consensus algorithm for (1) is

*i*at time t and

*a*

_{ ij }(

*t*) is the (

*i*,

*j*) entry of the adjacency matrix \(\mathcal{A}\) of the graph \(\mathcal{G}\) at time

*t*. A consequence of (2) is that the state

*x*

_{ i }(

*t*) of agent

*i*is driven toward the states of its neighbors or equivalently toward the weighted average of its neighbors’ states. The closed-loop system of (1) using (2) can be written in matrix form as

*x*is a column stack vector of all

*x*

_{ i }and \(\mathcal{L}\) is the Laplacian matrix. Consensus is

*reached*if for all initial states, the agents’ states eventually become identical. That is, for all

*x*

_{ i }(0), \(\left \|x_{i}(t) - x_{j}(t)\right \|\) approaches zero eventually.

When the graph \(\mathcal{G}(t)\) is switching at time instants *t* _{0}, *t* _{1}, *…*, the solution to the closed-loop system (3) is given by *x*(*t*) = *Φ*(*t*, 0)*x*(0), where *Φ*(*t*, 0) is the transition matrix corresponding to \(-\mathcal{L}(t)\). Consensus is reached if *Φ*(*t*, 0) eventually converges to a matrix with identical rows. Here \(\Phi (t,0) = \Phi (t,t_{k})\Phi (t_{k},t_{k-1})\cdots \Phi (t_{1},0)\), where *Φ*(*t* _{ k }, *t* _{ k − 1}) is the transition matrix corresponding to \(\mathcal{L}(t)\) at time interval [*t* _{ k − 1}, *t* _{ k }]. It turns out that each transition matrix is a *row-stochastic* matrix with positive diagonal entries. A square matrix is row stochastic if all its entries are nonnegative and all of its row sums are one. The consensus convergence can be analyzed by studying the product of row-stochastic matrices. Another analysis technique is a Lyapunov approach (e.g., max*x* _{ i } − min*x* _{ i }). It can be shown that the agents’ states reach a consensus if there exists an infinite sequence of contiguous, uniformly bounded time intervals, with the property that across each such interval, the union of the graphs \(\mathcal{G}(t)\) has a directed spanning tree. That is, across each such interval, there exists at least one agent that can directly or indirectly influence all other agents. It is also possible to achieve certain nice features by designing nonlinear consensus algorithms of the form \(u_{i}(t) =\sum _{j\in \mathcal{N}_{i}(t)}a_{ij}(t)\psi [x_{j}(t) - x_{i}(t)]\), where *ψ*( ⋅) is a nonlinear function satisfying certain properties. One example is a continuous nondecreasing odd function. For example, a saturation type function could be introduced to account for actuator saturation and a signum type function could be introduced to achieve finite-time convergence.

As shown above, for single-integrator dynamics, the consensus convergence is determined entirely by the network topologies. The primary reason is that the single-integrator dynamics are internally stable. However, when more complicated agent dynamics are involved, the consensus algorithm design and analysis become more complicated. On one hand, whether the graph is undirected (respectively, switching) or not has significant influence on the complexity of the consensus analysis. On the other hand, not only the network topology but also the agent dynamics themselves and the parameters in the consensus algorithm play important roles. Next we introduce consensus for agents with general linear and nonlinear dynamics.

### Consensus for Agents with General Linear Dynamics

*i*and

*A*,

*B*,

*C*are constant matrices with compatible dimensions.

*c*> 0 is a coupling gain, \(K \in {\mathbb{R}}^{p\times m}\) is the feedback gain matrix, and \(\mathcal{N}_{i}\) and

*a*

_{ ij }are defined as in (2). It can be shown that if the graph \(\mathcal{G}\) has a directed spanning tree, consensus is reached using (5) for (4) if and only if all the matrices \(A + c\lambda _{i}(\mathcal{L})BK\), where \(\lambda _{i}(\mathcal{L})\neq 0\) are Hurwitz. Here \(\lambda _{i}(\mathcal{L})\) denotes the

*i*th eigenvalue of the Laplacian matrix \(\mathcal{L}\). A necessary condition for reaching a consensus is that the pair (

*A*,

*B*) is stabilizable. The consensus algorithm (5) can be designed via two steps:

- (a)
Solve the linear matrix inequality \({A}^{T}P + PA - 2B{B}^{T} < 0\) to get a positive-definite solution

*P*. Then let the feedback gain matrix \(K = -{B}^{T}{P}^{-1}\). - (b)
Select the coupling strength

*c*larger than the threshold value \(1/\mathop{\min }\limits_{\lambda _{i}(\mathcal{L})\neq 0}\mathrm{Re}[\lambda _{i}(\mathcal{L})]\), where Re( ⋅) denotes the real part.

Note that here the threshold value depends on the eigenvalues of the Laplacian matrix, which is in some sense global information. To overcome such a limitation, it is possible to introduce adaptive gains in the algorithm design. The gains could be updated dynamically using local information.

*c*> 0 is a coupling gain. Here the algorithm (6) uses not only the relative outputs between each agent and its neighbors but also its own and neighbors’ observer states. While relative outputs could be obtained through local measurements, the neighbors’ observer states can only be obtained via communication. It can be shown that if the graph \(\mathcal{G}\) has a directed spanning tree, consensus is reached using (6) for (4) if the matrices

*A*+

*BF*and \(A + c\lambda _{i}(\mathcal{L})LC\), where \(\lambda _{i}(\mathcal{L})\neq 0\), are Hurwitz. The observer-type consensus algorithm (6) can be seen as an extension of the single-system observer design to multi-agent systems. Here the

*separation principle*of the traditional observer design still holds in the multi-agent setting in the sense that the feedback gain matrices

*F*and

*L*can be designed separately.

### Consensus for Agents with Nonlinear Dynamics

In multi-agent applications, agents usually represent physical vehicles with special dynamics, especially nonlinear dynamics for the most part. Examples include Lagrangian systems for robotic manipulators and autonomous robots, nonholonomic systems for unicycles, attitude dynamics for rigid bodies, and general nonlinear systems. Similar to the consensus algorithms for linear multi-agent systems, the consensus algorithms used for these nonlinear agents are often designed based on state differences between each agent and its neighbors. But due to the inherent nonlinearity, the problem is more complicated and additional terms might be required in the algorithm design. The main techniques used in the consensus analysis for nonlinear multi-agent systems are often Lyapunov-based techniques (Lyapunov functions, passivity theory, nonlinear contraction analysis, and potential functions).

*i*th agent. The sliding surface can be designed as

*α*is a positive scalar. Note that when

*s*

_{ i }= 0, (8) is actually the closed-loop system of a consensus algorithm for single integrators. Then if the control torque

*τ*

_{ i }can be designed using only local information from neighbors to drive

*s*

_{ i }to zero, consensus will be reached as

*s*

_{ i }can be treated as a vanishing disturbance to a system that reaches consensus exponentially.

It is generally very challenging to deal with general directed or switching graphs for agents with more complicated dynamics other than single-integrator dynamics. In some cases, the challenge could be overcome by introducing and updating additional auxiliary variables (often observer-based algorithms) and exchanging these variables between neighbors (see, e.g., (6)). In the algorithm design, the agents might use not only relative physical states between neighbors but also local auxiliary variables from neighbors. While relative physical states could be obtained through sensing, the exchange of auxiliary variables can only be achieved by communication. Hence such generalization is obtained at the price of increased communication between the neighboring agents. Unlike some other algorithms, it is generally impossible to implement the algorithm relying on purely relative sensing between neighbors without the need for communication.

## Averaging Algorithms

Existing distributed averaging algorithms are primarily static averaging algorithms based on linear local average iterations or gossip iterations. These algorithms are capable of computing the average of the initial conditions of all agents (or constant signals) in a network. In particular, the linear local-average-iteration algorithms are usually synchronous, where at each iteration each agent repeatedly updates its state to be the average of those of its neighbors. The gossip algorithms are asynchronous, where at each iteration a random pair of agents are selected to exchange their states and update them to be the average of the two. Dynamic averaging algorithms are of significance when there exist time-varying signals. The objective is to compute the average of these time-varying signals in a distributed manner.

### Static Averaging

*x*

_{ i }be the information state of agent

*i*. A linear local-average-iteration-type algorithm has the form

*k*denotes a communication event, \(\mathcal{N}_{i}[k]\) denotes the neighbor set of agent

*i*, and

*a*

_{ ij }[

*k*] is the (

*i*,

*j*) entry of the adjacency matrix \(\mathcal{A}\) of the graph \(\mathcal{G}\) that represents the communication topology at time

*k*, with the additional assumption that \(\mathcal{A}\) is row stochastic and

*a*

_{ ii }[

*k*] > 0 for all \(i = 1,\ldots ,n\). Intuitively, the information state of each agent is updated as the weighted average of its current state and the current states of its neighbors at each iteration. Note that an agent maintains its current state if it does not exchange information with other agents at that event instant. In fact, a discretized version of the closed-loop system of (1) using (2) (with a sufficiently small sampling period) takes in the form of (9). The objective here is for all agents to compute the average of their initial states by communicating with only their neighbors. That is, each

*x*

_{ i }[

*k*] approaches \(\frac{1} {n}\sum _{j=1}^{n}x_{ j}[0]\) eventually. To compute the average of multiple constant signals

*c*

_{ i }, we could simply set

*x*

_{ i }[0] =

*c*

_{ i }. The algorithm (9) can be written in matrix form as \(x[k + 1] = \mathcal{A}[k]x[k]\), where

*x*is a column stack vector of all

*x*

_{ i }and \(\mathcal{A}[k] = [a_{ij}[k]]\) is a row-stochastic matrix.

When the graph \(\mathcal{G}\) (and hence the matrix \(\mathcal{A}\)) is fixed, the convergence of the algorithm (9) can be analyzed by studying the eigenvalues and eigenvectors of the row-stochastic matrix \(\mathcal{A}\). Because all diagonal entries of \(\mathcal{A}\) are positive, Gershgorin’s disc theorem implies that all eigenvalues of \(\mathcal{A}\) are either within the open unit disk or at one. When the graph \(\mathcal{G}\) is strongly connected, the Perron-Frobenius theorem implies that \(\mathcal{A}\) has a simple eigenvalue at one with an associated right eigenvector \(\mathbf{1}\) and an associated positive left eigenvector. Hence when \(\mathcal{G}\) is strongly connected, it turns out that \(\lim _{k\rightarrow \infty }{\mathcal{A}}^{k} ={ \mathbf{1}\nu }^{T}\), where \({\nu }^{T}\) is a positive left eigenvector of \(\mathcal{A}\) associated with the eigenvalue one and satisfies \({\nu }^{T}\mathbf{1} = 1\). Note that \(x[k] = {\mathcal{A}}^{k}x[0]\). Hence, each agent’s state *x* _{ i }[*k*] approaches *ν* ^{ T } *x*[0] eventually. If it can be further ensured that \(\nu = \frac{1} {n}\mathbf{1}\), then averaging is achieved. It can be shown that the agents’ states converge to the average of their initial values if and only if the directed graph \(\mathcal{G}\) is both strongly connected and balanced or the undirected graph \(\mathcal{G}\) is connected. When the graph is switching, the convergence of the algorithm (9) can be analyzed by studying the product of row-stochastic matrices. Such analysis is closely related to Markov chains. It can be shown that the agents’ states converge to the average of their initial values if the directed graph \(\mathcal{G}\) is balanced at each communication event and strongly connected in a joint manner or the undirected graph \(\mathcal{G}\) is jointly connected.

### Dynamic Averaging

In a more general setting, there exist *n* time-varying signals, *r* _{ i }(*t*), *i* = 1, *…*, *n*, which could be an external signal or an output from a dynamical system. Here *r* _{ i }(*t*) is available to only agent *i* and each agent can exchange information with only its neighbors. Each agent maintains a local estimate, denoted by *x* _{ i }(*t*), of the average of all the signals \(\bar{r}(t)\stackrel{\bigtriangleup }{=} \frac{1} {n}\sum _{k=1}^{n}r_{ k}(t)\). The objective is to design a distributed algorithm for agent *i* based on *r* _{ i }(*t*) and *x* _{ j }(*t*), \(j \in \mathcal{N}_{i}(t)\), such that all agents will finally track the average that changes over time. That is, \(\|x_{i}(t) -\bar{ r}(t)\|\), *i* = 1, *…*, *n*, approaches zero eventually. Such a dynamic averaging idea finds applications in distributed sensor fusion with time-varying measurements (Spanos and Murray 2005; Bai et al. 2011b) and distributed estimation and tracking (Yang et al. 2008).

*r*

_{ i }(

*t*) can be arbitrary but its derivative exists and is bounded almost everywhere, a distributed nonlinear nonsmooth algorithm is designed in Chen et al. (2012) as

*α*is a positive scalar, \(\mathcal{N}_{i}\) denotes the neighbor set of agent

*i*, sgn( ⋅) is the signum function defined componentwise,

*ϕ*

_{ i }is the internal state of the estimator with

*ϕ*

_{ i }(0) = 0, and

*x*

_{ i }is the estimate of the average \(\bar{r}(t)\). Due to the existence of the discontinuous signum function, the solution of (10) is understood in the Filippov sense (Cortes 2008).

The idea behind the algorithm (10) is as follows. First, (10) is designed to ensure that \(\sum _{i=1}^{n}x_{i}(t) =\sum _{ i=1}^{n}r_{i}(t)\) holds for all time. Note that \(\sum _{i=1}^{n}x_{i}(t) =\sum _{ i=1}^{n}\phi _{i}(t) +\sum _{ i=1}^{n}r_{i}(t)\). When the graph \(\mathcal{G}\) is undirected and *ϕ* _{ i }(0) = 0, it follows that \(\sum _{i=1}^{n}\phi _{i}(t) =\sum _{ i=1}^{n}\phi _{i}(0) +\alpha \sum _{ i=1}^{n}\sum _{j\in \mathcal{N}_{i}}\int _{0}^{t}\text{sgn}[x_{j}(\tau ) - x_{i}(\tau )]d\tau = 0\). As a result, \(\sum _{i=1}^{n}x_{i}(t) =\sum _{ i=1}^{n}r_{i}(t)\) holds for all time. Second, when \(\mathcal{G}\) is connected, if the algorithm (10) guarantees that all estimates *x* _{ i } approach the same value in *finite time*, then it can be guaranteed that each estimate approaches the average of all signals in finite time.

## Summary and Future Research Directions

Averaging algorithms and consensus play an important role in distributed control of networked systems. While there is significant progress in this direction, there are still numerous open problems. For example, it is challenging to achieve averaging when the graph is not balanced. It is generally not clear how to deal with a general directed or switching graph for nonlinear agents or nonlinear algorithms when the algorithms are based on only interagent physical state coupling without the need for communicating additional auxiliary variables between neighbors. The study of consensus for multiple underactuated agents remains a challenge. Furthermore, when the agents’ dynamics are heterogeneous, it is challenging to design consensus algorithms. In addition, in the existing study, it is often assumed that the agents are cooperative. When there exist faulty or malicious agents, the problem becomes more involved.

## Cross-References

## Bibliography

- Agaev R, Chebotarev P (2000) The matrix of maximum out forests of a digraph and its applications. Autom Remote Control 61(9):1424–1450zbMATHMathSciNetGoogle Scholar
- Agaev R, Chebotarev P (2005) On the spectra of nonsymmetric Laplacian matrices. Linear Algebra Appl 399:157–178CrossRefzbMATHMathSciNetGoogle Scholar
- Bai H, Arcak M, Wen J (2011a) Cooperative control design: a systematic, passivity-based approach. Springer, New YorkCrossRefGoogle Scholar
- Bai H, Freeman RA, Lynch KM (2011b) Distributed Kalman filtering using the internal model average consensus estimator. In: Proceedings of the American control conference, San Francisco, pp 1500–1505Google Scholar
- Bullo F, Cortes J, Martinez S (2009) Distributed control of robotic networks. Princeton University Press, PrincetonzbMATHGoogle Scholar
- Chen F, Cao Y, Ren W (2012) Distributed average tracking of multiple time-varying reference signals with bounded derivatives. IEEE Trans Autom Control 57(12):3169–3174CrossRefMathSciNetGoogle Scholar
- Cortes J (2008) Discontinuous dynamical systems. IEEE Control Syst Mag 28(3):36–73CrossRefMathSciNetGoogle Scholar
- Jadbabaie A, Lin J, Morse AS (2003) Coordination of groups of mobile autonomous agents using nearest neighbor rules. IEEE Trans Autom Control 48(6):988–1001CrossRefMathSciNetGoogle Scholar
- Li Z, Duan Z, Chen G, Huang L (2010) Consensus of multiagent systems and synchronization of complex networks: a unified viewpoint. IEEE Trans Circuits Syst I Regul Pap 57(1):213–224CrossRefMathSciNetGoogle Scholar
- Mesbahi M, Egerstedt M (2010) Graph theoretic methods for multiagent networks. Princeton University Press, PrincetonGoogle Scholar
- Moreau L (2005) Stability of multi-agent systems with time-dependent communication links. IEEE Trans Autom Control 50(2):169–182CrossRefMathSciNetGoogle Scholar
- Olfati-Saber R, Fax JA, Murray RM (2007) Consensus and cooperation in networked multi-agent systems. Proc IEEE 95(1):215–233CrossRefGoogle Scholar
- Qu Z (2009) Cooperative control of dynamical systems: applications to autonomous vehicles. Springer, LondonGoogle Scholar
- Ren W, Beard RW (2008) Distributed consensus in multi-vehicle cooperative control. Springer, LondonzbMATHGoogle Scholar
- Ren W, Cao Y (2011) Distributed coordination of multi-agent networks. Springer, LondonCrossRefzbMATHGoogle Scholar
- Spanos DP, Murray RM (2005) Distributed sensor fusion using dynamic consensus. In: Proceedings of the IFAC world congress, PragueGoogle Scholar
- Tsitsiklis JN, Bertsekas DP, Athans M (1986) Distributed asynchronous deterministic and stochastic gradient optimization algorithms. IEEE Trans Autom Control 31(9):803–812CrossRefzbMATHMathSciNetGoogle Scholar
- Yang P, Freeman RA, Lynch KM (2008) Multi-agent coordination by decentralized estimation and control. IEEE Trans Autom Control 53(11):2480–2496CrossRefMathSciNetGoogle Scholar