# Distributed finite-time termination for consensus algorithm in switching topologies

In this article, we present a finite time stopping criterion for consensus algorithms in networks with dynamic communication topology. Recent results provide asymptotic convergence to the consensus algorithm. However, the asymptotic convergence of these algorithms pose a challenge in the practical settings where the response from agents is required in finite time. To this end, we propose a Maximum-Minimum protocol which propagates the global maximum and minimum values of agent states (while running consensus algorithm) in the network. We establish that global maximum and minimum values are strictly monotonic even for a dynamic topology and can be utilized to distributively ascertain the closeness to convergence in finite time. We show that each node can have access to the global maximum and minimum by running the proposed Maximum-Minimum protocol and use it as a finite time stopping criterion for the otherwise asymptotic consensus algorithm. The practical utility of the algorithm is illustrated through experiments where each agent is instantiated by a NodeJS socket.io server.

## Authors

• 3 publications
• 3 publications
• 3 publications
• 6 publications
10/31/2018

### On finite-time and fixed-time consensus algorithms for dynamic networks switching among disconnected digraphs

The aim of this paper is to analyze a class of consensus algorithms with...
01/01/2020

### Single-Bit Consensus with Finite-Time Convergence: Theory and Applications

In this brief paper, a new consensus protocol based on the sign of innov...
07/26/2020

### Convex Decreasing Algorithms: Distributed Synthesis and Finite-time Termination in Higher Dimension

We introduce a general mathematical framework for distributed algorithms...
04/29/2018

### Randomization and quantization for average consensus

A variety of problems in distributed control involve a networked system ...
07/18/2017

### Coresets for Triangulation

Multiple-view triangulation by ℓ_∞ minimisation has become established i...
06/21/2019

### MinMax Algorithms for Stabilizing Consensus

In the stabilizing consensus problem, each agent of a networked system h...
08/27/2021

### A Bisection Method Like Algorithm for Approximating Extrema of a Continuous Function

For a continuous function f defined on a closed and bounded domain, ther...
##### This week in AI

Get the week's most popular data science and artificial intelligence research sent straight to your inbox every Saturday.

## 1 Introduction

Above results do not provide any finite time stopping criterion for the consensus protocol. As multi-agent systems with real-time applications, require the consensus value to be used by each agent for a subsequent task or action, a finite-time distributed stopping criterion is imperative. Moreover, if the agents can distributedly detect the convergence within a pre-specified tolerance of the consensus value, they will avoid running the algorithm longer than necessary and save scarce power and computational resources. The authors in [sundaram2007finite] have presented a method to achieve the consensus value in a finite number of iterations. Here, each node can calculate the final consensus value using the minimal polynomial associated with the weight matrix in the state update iterations. However, to calculate the coefficients of the minimal polynomial each node has to run (total number of agents) different linear iterations each for at least time-steps. Also, every node should have enough storage and computation abilities to handle matrix inversions and rank calculations which makes it unsuitable for applications like ad hoc sensor networks.

To this end, authors in [ratio_consensus_lab],[yadav2007distributed],[prakash2019distributed] established that the sequence of global maximum (or minimum) state value of the agents following a consensus algorithm is a monotonic sequence converging to the consensus when network topology is fixed. A distributed maximum (and minimum) protocol was proposed to propagate these global maximum (and minimum) state values to achieve finite-time consensus within a pre-specified tolerance margin. Having additional states corresponding to the global maximum and minimum values help each node to detect the progress toward consensus. Each node is able to simultaneously detect the convergence in finite time thus the consensus protocol is terminated by each node at the same iteration. Moreover the above methodology guarantees that each node will have access to the consensus value at the same time.

In this article, we show that the above approach is not directly applicable when the network topology is dynamic. Here, we propose an extension of this approach which can be applied to networks with dynamic topology. We introduce the concept of a "time-path" to incorporate the effect of current state value of an agent on other agents at the following time instants. We establish the existence of time-paths of finite length for all pairs of agents in the network. Leveraging the existence of time-paths, we propose a new Maximum-Minimum protocol to propagate the global maximum and minimum state values. Now, we briefly describe some of the applications of the proposed protocol.

Ad hoc cognitive radio networks. In cognitive radio networks, secondary users can sense the spectrum to detect the presence of primary users. In a spectrum-sensing consensus algorithm [li2009distributed], secondary users mutually transmit and receive their states according to the real-time (dynamic) network topology, regardless of whether primary users are present. The topology is created when secondary users establish communication links with their own neighbors to locally exchange information among them. The algorithm iterations are repeatedly done until all the individual states converge toward the average of the initial value of states to make a local decision.

Control of autonomous agents. It is often necessary to coordinate a collection of autonomous agents (e.g., cars or unmanned aerial vehicles). For example, consider a fleet of self-driving cars where each car can communicate with its neighboring cars. One may wish for the cars to meet a global objective such as maintaining a particular formation where the neighbors of a car can change in real-time. A distributed decision is usually needed in such situations. All the cars can distributively agree on a direction or an average speed (or both). Such a coordination model was investigated in [fax2002information].

#### Statement of contribution:

1. This article presents an algorithm with a distributed stopping criterion for ratio consensus in the presence of directed switching topologies. We augment the ratio consensus algorithm with two additional states: global maximum and global minimum of the values held by agents. We show that these values are monotonic in nature and converge to the consensus value even when the network is dynamic. The stopping criterion can be set such that if the criterion is met by an agent then it has access to the consensus value within any prespecified tolerance margin. Here, the maximum and minimum consensus based distributed stopping approach [ratio_consensus_lab],[yadav2007distributed] is extended to the case of time varying topologies.

2. We provide an upper bound on the number of iterations required for a node in the network to influence all other nodes. In order to achieve this, we introduce a novel concept of time-path. We prove the existence of finite-length time-paths for every pair of nodes and present the Maximum-Minimum protocol to propagate the global maximum and minimum state values in the network.

3. The scheme proposed here is shown to be scalable for implementation as it only requires each agent to have access to an upper bound on the number of nodes. The performance of the proposed algorithm is illustrated by experimentally realizing a network with dynamic topology created using a NodeJS framework. Here each node is implemented as a socket.io [mulder2016node] server. This validates the distributed stopping criterion experimentally in the presence of switching topologies, thus providing evidence that our algorithm is indeed applicable for real-time applications.

The rest of the paper is organized as follows. In Section 2, the basic definitions needed for subsequent development are presented. The setup for distributed averaging using ratio consensus is presented in Section 3. In Section 4, analytical results for distributed finite-time termination of ratio consensus in switching topology using maximum and minimum consensus algorithms have been discussed. Theoretical findings are validated with experiments presented in Section 5 followed by conclusions in Section 6.

## 2 Definitions

In this section we present basic notions of graph theory and linear algebra which are essential for the subsequent developments. Detailed description of graph theory and linear algebra notions are available in [Die06] and [horn2012matrix] respectively.

###### Definition 1.

(Cardinality of a set) Let be a set. The cardinality of a set denoted by is a measure of the number of elements of the set .

###### Definition 2.

(Directed Graph) A directed graph (denoted as digraph) is a pair where is a set of vertices or nodes and is a set of edges, which are ordered subsets of two distinct elements of . If an edge from to exists then it is denoted as .

###### Definition 3.

(Path) In a directed graph, a directed path from node to exists if there is a sequence of distinct directed edges of of the form

###### Definition 4.

(Strongly Connected Graph) A directed graph is strongly connected if it has a directed path between each pair of distinct nodes and .

###### Definition 5.

(Column Stochastic Matrix) A real

matrix is called a column stochastic matrix if for and for

###### Definition 6.

(Irreducible Matrix) A matrix is said to be irreducible if for any , there exist such that , that is, it is possible to reach any state from any other state in a finite number of hops.

###### Definition 7.

(Primitive Matrix) A non negative matrix

is primitive if it is irreducible and has only one eigenvalue of maximum modulus.

## 3 Average Consensus in switching topology

In this section, the key result from [dominguez2010coordination], which enables reaching average consensus in the presence of dynamic topology is summarized. Consider a scenario where the network topology is dynamic but with a fixed set of nodes () i.e. at any given instant , the network is described by a digraph . Let be the weighted adjacency matrix associated with the digraph . Here is the set of all possible digraphs for a given set of nodes . Here we assume that a node always has access to its own information, i.e. for any node for all . Now we present a few definitions related to dynamic topology.

###### Definition 8.

(Union of digraphs) Given a collection of digraphs (for some ) of the form , , the union of digraphs is defined as .

###### Definition 9.

(In-Neighborhood at instant k) The set of in-neighbors of node at instant is denoted by

###### Definition 10.

(Out-Neighborhood at instant k) The set of out-neighbors of node at instant is denoted by

Each node maintains two states at time , denoted by (referred as numerator state of node ) and (referred as denominator state of node ). Node updates its state at the iteration according to the following policy:

 xi(k+1)=pii(k)xi(k)+∑j∈N−(i,k)∖{i}pij(k)xj(k) (1)
 yi(k+1)=pii(k)yi(k)+∑j∈N−(i,k)∖{i}pij(k)yj(k), (2)

where for all .

We consider the network with dynamic topology to satisfy the following assumptions throughout the rest of the paper.

###### Assumption 1.

For a sequence of digraphs , there exists an infinite sequence of time instants where , , , with the property that for any the union of digraphs is strongly connected.

###### Assumption 2.

for all is a column-stochastic, primitive and irreducible matrix.

###### Theorem 1.

Consider a sequence of digraphs of the form , satisfying Assumption 1 and Assumption 2. With the update rule (1) and (2), the ratio asymptotically converges to for all , that is, the ratio of the numerator and denominator states converge to the average of the initial conditions of variables (referred to as ratio consensus).

Proof. See [dominguez2010coordination] for proof. ∎

## 4 Distributed Finite-Time Termination

In this section, the definitions and convergence of maximum and minimum consensus algorithms are established. Subsequently, a finite-time termination criterion for average consensus in the case of switching topology is developed based on these algorithms. Let us consider the maximum and minimum value of the ratio of consensus protocols given by (1) and (2) over all nodes at any time instant be given by,

 M(k):=maxi∈Vxi(k)yi(k),yj(k)≠0,j∈V, (3)
 m(k):=mini∈Vxi(k)yi(k),yj(k)≠0,j∈V (4)

The following Lemma shows that the ratio of states at each node stays within the maximum and minimum for subsequent iterations.

###### Lemma 1.

Consider the ratio consensus protocol of (1) and (2). Let Assumption 1 and Assumption 2 hold. Then for all time instants and for all

 m(k)≤xi(k′)yi(k′)≤M(k).

Proof. We first prove the inequality for using induction. By definition of for the proof is trivial. Suppose it is asserted that for , for all Then we have,

 xi(k+l+1)yi(k+l+1)=∑j∈N−(i,k+l)pij(k+l)xj(k+l)∑j∈N−(i,k+l)pij(k+l)yj(k+l)
 =pii(k+l)xi(k+l)yi(k+l)+∑j∈N−(i,k+l)∖{i}pij(k+l)xj(k+l)yi(k+l)pii(k+l)+∑j∈N−(i,k+l)∖{i}pij(k+l)yj(k+l)yi(k+l).

It follows from the inductive assumption that,

 xi(k+l+1)yi(k+l+1)≤pii(k+l)M(k)+∑j∈N−(i,k+l)∖{i}pij(k+l)M(k)yj(k+l)yi(k+l)pii(k+l)+∑j∈N−(i,k+l)∖{i}pij(k+l)yj(k+l)yi(k+l)=M(k).

Therefore, for all Other inequality is similar and is left to the reader. ∎

Next Lemma strengthens the result of Lemma 1 to a strict inequality.

###### Lemma 2.

Consider the ratio consensus protocol of (1) and (2) where the initial time instant is . Let Assumption 1 and Assumption 2 hold. Let and be as in (3) and (4). Let be a node such that and let be a node such that for some time instant . Then for all time instants and

Proof. The proof is based on induction and follows similarly to the proof of Lemma 1 and is left to the reader. ∎

The following definition and Lemmas introduce the concept of a time-path and derive a bound on number of iterations required for one node to access information of any other node in the network.

###### Definition 11.

(Time-path) In the case of switching topology, a time-path of length at time from node to is a sequence of nodes such that . In other words, node has access to node ’s information after time steps through the nodes starting at time .

###### Lemma 3.

Consider a network where Assumption 1 and Assumption 2 hold along with added constraint that digraphs for all are strongly connected. Then for any node , let

 Ri(k,t):=⋃m∈Ri(k,t−1){l:l∈N+(m,k+t−1)},

with, and is the out-neighborhood of node at instant . The following hold:

1. for all

Proof. Here, is the union of out-neighborhoods of all the elements of at instant . Clearly, . Indeed, implies which in turn implies, .

Now for ,

 Ri(k,1)={m1:m1∈N+(i,k)}=N+(i,k).

If , the claim is proven. Suppose . Note that at time instant , the graph is strongly connected. Thus, there exists an outgoing edge between the set of nodes and . That is there exists such that for some . Thus, It follows that which implies that

 |Ri(k,2)∖Ri(k,1)|≥1.

Now, as we have,

 |Ri(k,2)|=|Ri(k,1)|+|Ri(k,2)∖Ri(k,1)|

which implies Note here is a proper subset of Following in the same manner we get,

 |Ri(k,t)|≥|Ri(k,t−1)|+1≥|Ri(k,t−2)|+2≥⋯≥|Ri(k,0)|+t,

and thus For , . However and thus for all . Thus, implying . Therefore, the claim is true. ∎

###### Lemma 4.

Consider the assumptions of Lemma 3. Then for any two nodes and at any time instant , there exist a time-path of length from to with . In other words, has access to information of in number of time steps.

Proof. It is to be noted here that is the set of nodes influenced by node ’s current state within next time steps. Now, we show the existence of a time-path. We have . Let be the smallest time step such that . From Lemma 3, . As, there exists such that As it follows that there exists such that Choosing ’s in this manner we get , … such that . Therefore, there exists a time-path with . ∎

Using Lemma 3 and Lemma 4, we next provide a sampling of the and such that the resulting sub-sequences are strictly monotonic and converge to the average of the initial conditions of variables.

###### Lemma 5.

Consider the ratio consensus protocol of (1) and (2) with the assumptions of Lemma 3. Let and be as in (3) and (4) such that where initial time instant is . Then for all and for all

 m(k)

where is an upper bound on .

Proof. As it follows that there exists a node such that Let be an arbitrary node, then from Lemma 4 there exist a time-path of length from node to node at instant where . Let this path be denoted as Then,

 xm1(k+1)ym1(k+1)=pm1i(k)xi(k)+∑u∈N−(m1,k)∖{i}pm1u(k)xu(k)pm1i(k)yi(k)+∑u∈N−(m1,k)∖{i}pm1u(k)yu(k)
 =pm1i(k)xi(k)yi(k)+∑u∈N−(m1,k)∖{i}pm1u(k)xu(k)yi(k)pm1i(k)+∑u∈N−(m1,k)∖{i}pm1u(k)yu(k)yi(k)


By definition of for all , thus It follows that,

 xm1(k+1)ym1(k+1)

Thus, Therefore, from Lemma 2 it follows that for all , Similarly, if , then and that for all Note that since it follows that The condition is independent of the index and where the node was chosen arbitrarily. Thus, it can be concluded that for all and for all This completes the proof for The other inequality for can be proven similarly and is left to the reader. ∎

###### Remark 1.1.

Note that from Lemma 5, after a finite number of iterations given by , all ratios of the nodal states under (1) and (2) become strictly less than the maximum value of the ratio in network in the past and strictly greater than the minimum value of the ratio in the network in the past.

The following theorem shows that after a finite time, the maximum value of the ratio in the network decreases and the minimum value of the ratio in the network increases.

###### Theorem 2.

Consider the ratio consensus protocol of (1) and (2) with the assumptions of Lemma 3

and the initial ratio vector being

 r(un′):=[x1(un′)y1(un′) x2(un′)y2(un′)…xN(un′)yN(un′)]

such that , where, . Then, and

Proof. Let , then using Lemma 5, it follows that for for all Hence, This completes the proof of the inequality involving . The other inequality involving can be proved similarly and is left to the reader. ∎

###### Theorem 3.

Consider the ratio consensus protocol of (1) and (2) with the assumptions of Lemma 3. Then,

 limu→∞M(un′) =∑nj=1xj(0)n  and limu→∞m(un′) =∑nj=1xj(0)n.

Proof. This result follows directly from Theorem 1 and Theorem 2 and is left to the reader. ∎

###### Corollary 3.1.

Consider the ratio consensus protocol of (1) and (2) with the assumptions of Lemma 3. Then,

 limu→∞M(un′)−m(un′)=0.

Proof. The proof follows from Theorem 3 and is left to the reader. ∎

We next present Maximum-Minimum consensus protocol in the case of dynamic topology and use the preceding theorems to design a finite time termination criterion.

### 4.1 Maximum-Minimum Consensus Protocol

The Maximum and Minimum Consensus Protocol denoted by MXP and MNP computes the maximum and minimum of the given initial node conditions

 z(0)=[z1(0) z2(0) ... zn(0)]T, w(0)=[w1(0) w2(0) ... wn(0)]T

in a distributed manner respectively. It takes and as an input and generates a sequence of node values based on the following update rules for node ,

 zi(k+1) =maxj∈N−(i,k)zj(k), (6) wi(k+1) =minj∈N−(i,k)wj(k). (7)
###### Proposition 1.

MXP protocol given by (6) converges to in finite time for any

Proof. Let be a node with state value at . Then at , all nodes connected to at instant will have the maximum value . Then, from the definition of in Lemma 4, if then Similarly, at , all the nodes connected to the elements of the set at instant will have the maximum value, that is, if then and so on. At , if then . As , we have for all , Thus, at instant all nodes will have the maximum value. As , converges to in finite time

###### Proposition 2.

MNP protocol given by (7) converges to in finite time for any

Proof. Similar to the proof of Proposition 1

### 4.2 Distributed Finite-Time Termination Algorithm for Ratio Consensus

Here, we propose an algorithm using the above MXP-MNP protocol which allows each node to simultaneously detect the convergence of the ratio consensus within a pre-specified threshold . In the proposed algorithm, the initial conditions for the MXP-MNP protocol are set as ratio of the initial values held by the nodes.

###### Definition 12.

(Epoch)

epoch is defined as the state update iteration at the instant for any positive integer .

The MXP-MNP protocol is re-initialized at every epoch that is , where , with and respectively. We define , and . Each node compares with at every epoch and if then it terminates the consensus protocol. Details of this scheme are given in Algorithm 1.

###### Theorem 4.

Algorithm 1 converges in finite-time simultaneously at each node.

Proof. From Corollary 3.1, it follows that as Thus, for any given there exists an integer such that for all for all nodes in the network. As each node has access to and , convergence is detected simultaneously by each node at the same iteration. ∎

###### Remark 4.1.

Notice that using the above protocol, the global maximum and minimum values at any instant are available to each node at instant . Further, the only global parameter needed for Algorithm 1 is the knowledge of number of nodes of the network. However, it should be noted that each node does not need to know the actual number of nodes but some upper bound. In most applications, an upper bound on the number of nodes is readily available.

This result is a non trivial extension of [ratio_consensus_lab],[yadav2007distributed] as these considered only static network where the finite time consensus is based on knowledge of upper bound on graph diameter. There it was derived that within iterations every node has access to global maximum and minimum where is an upper bound on the graph diameter. This is not applicable to a network with dynamic topology. The following counter example highlights the case where an upper bound on maximum diameter ( where is diameter of graph ) does not provide access to global maximum and minimum to all the nodes of the network. Let us consider a network of 6 nodes where the network topology can be either of undirected graphs or (see Figure 1), that is , with switching as described in Table 1. Here the diameter of both graphs . Range (as defined in Lemma 3) of node 1 starting from any instant is also shown in Table 1. It can be clearly observed that it takes iterations for range to contain all the nodes which is more than the bound on maximum diameter (). In other words, it requires at least iterations for any node to receive information from node which follows directly from Lemma 4. Therefore, if is set as in Proposition 1 and Proposition 2, and for a node will not converge to global maximum and minimum respectively and rather converge to local maximum and minimum of the neighborhood defined by . This will lead to two problems:

• Theorem 2 gives strict monotonicity of global maximum/minimum and does not extend to local maximum/minimum. Thus, the resulting sequences may not be monotonic.

• Some nodes in Algorithm 1 can detect local convergence (when the maximum and minimum of the neighborhood defined by are within tolerance) and terminate well before actual global convergence.

Above analysis is further bolstered by experimental results in Section 5.

## 5 Experimental Results

Consider a network of agents with switching topology represented by a digraph chosen at random from a set of 100 strongly connected digraphs for every time instant. Three instances of these digraphs are shown in Figure 2. Here, each agent running the consensus Algorithm is implemented using a NodeJS socket.io server. Initial condition of the numerator states are chosen at random from . With and , Algorithm results in distributed finite-time termination of computations performed by the agents in iterations as shown in Figure 3.

Observe that the ratio of the nodal states are close to the average of the numerator initial conditions (consensus value). The consensus value for this instance is . This experiment was repeated multiple times by randomly choosing digraphs for each iteration as well as the initial values of the agents. The proposed MXP-MNP protocol was able to distributively terminate the algorithm each time. As noted in Remark 4.1, the global maximum and minimum state values at are available at . This is shown in Figure 3 where shifting the MXP and MNP plots left by time instants we get the MXP and MNP plots which coincide with global maximum and minimum.

###### Remark 4.2.

It is worth noting that while running MXP-MNP protocol, global maximum and minimum are available to each agent after every iterations. It entails that if all the node states were within tolerance margin at any epoch , algorithm will terminate at the next epoch resulting in a delay of iterations in detection of convergence. This delay in detection scales linearly with the number of nodes making the algorithm suitable for large networks.

We next present the specific example discussed in Section 4 where it was shown analytically that some of the nodes will not have access to global maximum and minimum within iterations. We consider a node network where the topology is given by the sequence with and as defined in Figure 1. Initial state value of the nodes is chosen as leading to a consensus value equal to . As earlier, each node is implemented using a NodeJS socket.io server. We use to reset