# Distributed Data Clustering via Opinion Dynamics

Authors: Gabriele Oliva; Damiano La Manna; Adriano Fagiolini; Roberto Setola
Journal: International Journal of Distributed Sensor Networks
 (2015)

---

## Abstract

We provide a distributed method
to partition a large set of data in clusters, characterized by
small in-group and large out-group distances. We assume a
wireless sensors network in which each sensor is given a large
set of data and the objective is to provide a way to group
the sensors in homogeneous clusters by information type. In
previous literature, the desired number of clusters must be
specified a priori by the user. In our approach, the clusters are
constrained to have centroids with a distance at leastε between
them and the number of desired clusters is not specified.
Although traditional algorithms fail to solve the problem with
this constraint, it can help obtain a better clustering.
In this paper, a solution based on the Hegselmann-Krause
opinion dynamics model is proposed to find an admissible,
although suboptimal, solution. The Hegselmann-Krause model
is a centralized algorithm; here we provide a distributed implementation,
based on a combination of distributed consensus
algorithms. A comparison with k-means algorithm concludes
the paper.


---

## Body

## 1. Introduction

The problem of grouping large amounts of data into a small number of subsets with some common features among the elements (often referred to as thedata clustering problem) has attracted the work of several researchers in different fields, ranging from statistics to imagine analysis and bioinformatics [1–3].Data clustering techniques are developed to partition an initial set of observation data into collections with small in-group distances and big out-group distances.Among the existing techniques, one of the most used is thek-means algorithm or its successive extensions (e.g., fuzzy c-means [4], mixture of Gaussians algorithms [5]). Given a set of initial observation data and a number k of desired clusters, the k-means algorithm computes a suboptimal placement of k cluster centroids and assigns the observations to such centroids, alternating between an assignment phase, where each observation point is assigned to its nearest centroid, and refinement phase, where each centroid position is updated as the center of mass of all observations belonging to that centroid.A well-known limitation of data clustering algorithms, such as thek-means algorithm, is that the number of clusters has to be specified beforehand, based for example, on subjective evaluations or a priori analysis. Since this assumption is typically not feasible in practice, a typical solution consists of running several times the algorithm with a different number of clusters and then deciding the best obtained solution based on a posteriori evaluation [6]. Another issue of traditional algorithms is that there is no guarantee that the clusters are sufficiently far from each other. To this respect, distance-constrained data clustering approaches have been devised in the literature: in [7, 8] the considered constraints are the so-calledmust-links (i.e., an observation i must belong to a cluster j) andcannot-link (i.e., an observation i can not belong to a cluster j); in [9] the feasibility of a constrained problem involving the so-called δ-constraints (i.e., any two observations must have a distance greater than δ) and the ε-constraints (i.e., for any observation i in cluster j there must be at least another observation h in cluster j such that the distance between i and j is less than ε) is given. To the best of our knowledge, nowadays, there is no methodology to specify a constraint on the distance between cluster centroids, while this class of constraints might help finding a choice for the number k when such value is a priori unknown.This problem has a particular relevance in a distributed setting, where a network of sensors has to classify information provided by several sensors without a central authority but using only local data exchange among neighbors in the network. Differently from community clustering in wireless networks (e.g., see [10]), here the nodes are clustered depending on the data they sense, with no particular dependency on the network topology.In this paper, based on the preliminary results in [11], a novel approach to solve the data clustering problem with a distance constraint among cluster centroids is provided that does not require the specification of the initial number k of clusters and that is based on an extension of the Hegselmann-Krause (HK) opinion dynamics model [12, 13], which handles scalar data, in order to handle data in Rd. Such a model, similar to consensus [14, 15], represents how a set of agents interacts in order to reach a local agreement, but the agents may split in several clusters depending on their “opinions.”Within the proposed approach, rather than striving for a complete agreement among the agents, we exploit the peculiarity of HK model to generate several clusters, with the aim to map a large set of measurement data into few values (i.e, the opinion clusters). In this view, as it will be discussed in the following, HK models can be seen as a powerful methodology to determine the number of clusters while respecting the constraints on the distance among cluster centroids. The HK model, in its original setting, is a centralized algorithm [13]; hence we devise a distributed implementation based on a combination of consensus algorithms, which are an effective way to distribute complex operations, for example, time synchronization [16].The outline of the paper is as follows: after some preliminaries, in Section2, we provide a formulation of the problem at hand and in Section 3 we analyze the formulation of the standard data clustering problem and the k-means algorithm; then in Section 4 the HK opinion dynamics model is reviewed, while in Section 5 the distributed consensus algorithms are examined; Section 6 is devoted to outline the proposed approach to solve the distance-constrained clustering problem, while Section 7 addresses the distributed implementation of the HK opinion dynamics model; Section 8 contains some numeric examples to show the potentialities of this method, while Section 9 contains some conclusive remarks.Preliminaries. Let G={V,E} be agraph with n nodes vi∈V and ei edges (vi,vj)∈E.A graph is said to beundirected if (vi,vj)∈E whenever (vj,vi)∈E and is said to bedirected otherwise. Let the neighborhood Ni of a node i be the set of nodes vj such that (vj,vi)∈E, and let thedegreedi=|Ni|. A graph G isconnected if for any vi,vj∈V there is a path whose endpoints are in vi and vj.


## 2. Problem Statement

Consider a collection ofn sensors, each equipped with a d-dimensional measurement or piece of information x1,…,xn, with xi∈Rd. We want to select a number k of groups orclusters, C1,…,Ck, k≤n. Every cluster Cj is assigned to a cluster centroid cj∈Rd, which represents the centroid of the observations allocated to that cluster. A data point xi∈Rd is said to belong to cluster Cj if its distance from the centroid ch, with h≠j, of every other cluster Ch is larger than its distance from cj. If xi belongs to Cj we can set a binary assignment variable rij∈B to 1 and to 0 otherwise. The solution of a data clustering problem with distance constraints involves the computation of the optimal choice of cluster centroids cj, for j=1,…,k, that minimizes the distance of every measurement data point xi from the cluster it belongs to. More formally, we need to solve the following.Problem 1 (distance-constrained data clustering).
We want to find the number of clustersk, the cluster centroids, cj∈Rd, and measurement data assignments, rij∈R that minimize the index (1)D=∑i=1n‍∑j=1k‍rijxi-cj2,subject to the constraints (2)(I)∑j=1k‍rij=1∀i=1,…,n(II)ch-cj2≥ε∀i,j=1,…,k;h≠j(III)rij∈B∀i=1,…,n;∀j=1,…,k.
The first set of constraints (I) along with the third one implies that each observation is assigned exactly to one cluster; the constraints (II) imply thatε is a lower bound for the distance between any pair of centroids; finally constraints (III) imply that rij are binary decision variables.This problem is novel, since in the literature, the set of constraints (II) is typically not considered. Including such constraints, however, is quite useful, since it may improve the algorithm’s ability to detect homogeneous clusters. The problem is very hard to solve exactly and traditional methods as thek-means algorithm [17] may fail even at finding an admissible solution, as it will be shown in the next section.On the other side, the proposed algorithm uses an algorithm based on the Hegselmann-Krause model to choose an admissible, although suboptimal, solution, and it has a modest increase in computational complexity with respect to thek-means algorithm, while allowing several advantages (further discussed later in the paper):(i)
the algorithm provided in this paper always finds an admissible, although suboptimal, solution to the problem by means of the HK model, while thek-means algorithm may fail;(ii)
the proposed approach does not require the user to define a priori the number of clusters, but it finds automatically a suitable number of clusters based on the parameterε;(iii)
outliers can be automatically isolated, without any a priori data processing; this feature can be obtained by dropping out the clusters whose cardinality is significantly less than the others;(iv)
the solution provided in this paper is deterministic, that is, for fixedε and fixed observations, the result is always the same, while the k-means algorithm depends on the initial random choice of the centroids;(v)
while traditional approaches are very computationally expensive when applied in a decentralized and distributed setting [18] (i.e., for a sensors network), this method can be distributed with a modest increase in computational complexity [19].


### 2.1. Distributed Setting

In this paper we want to provide a solution to Problem1, where a set of n agents solves the above problem in a distributed fashion, that is, by means of local information exchange among the agents instead of resorting to a centralized processing unit. Let G={V,E} be a graph involving all the agents and without any loss of generality; suppose G is connected, undirected, and fixed. Moreover, it is assumed that each agent i in the network(1)
has an associated observationxi∈Rd;(2)
knowsε∈[0,1] which is the same for all agents;(3)
has a unique identifier;(4)
can exchange directly information only with neighbors overG;(5)
can act synchronously.In the next section we briefly review the traditional data clustering problem and thek-means algorithm.


## 2.1. Distributed Setting

In this paper we want to provide a solution to Problem1, where a set of n agents solves the above problem in a distributed fashion, that is, by means of local information exchange among the agents instead of resorting to a centralized processing unit. Let G={V,E} be a graph involving all the agents and without any loss of generality; suppose G is connected, undirected, and fixed. Moreover, it is assumed that each agent i in the network(1)
has an associated observationxi∈Rd;(2)
knowsε∈[0,1] which is the same for all agents;(3)
has a unique identifier;(4)
can exchange directly information only with neighbors overG;(5)
can act synchronously.In the next section we briefly review the traditional data clustering problem and thek-means algorithm.


## 3. Data Clustering

Let us discuss the following problem.Problem 2 (standard data clustering problem).
Givenk≤n, the data clustering problem consists in finding rij∈B, cj∈Rd, i,j=1,…,n, that minimize (3)D=∑i=1n‍∑j=1k‍rijxi-cj2Subjectto(I)∑j=1n‍rij=1∀i=1,…,n(II)rij∈{0,1}∀i=1,…,n;∀j=1,…,k.Problem (3) is hard to solve, and in the literature, several iterative algorithms have been devised. Among the others, the k-means algorithm [17] proved its effectiveness.Specifically, starting with a random set ofk centroids c1(0),…,ck(0), the algorithm alternates for each step anassignment and arefinement phase.During the assignment phase, each observationxi is assigned to the set characterized by the nearest centroid, that is, (4)rih(t)=1,ifh=argminj⁡xi-cj(t),0,else.Within the refinement phase each centroidcj is updated as the centroid of the observations associated with the cluster Cj(t), that is, (5)cjt+1=∑i=1n‍rijtxi∑i=1n‍rijt.The two steps are iterated until convergence or up to a maximum of M iterations.Figure1 reports a simulation run of the algorithm for a set of n=12 observations in R2 and for k=3. Specifically Figure 1(a) shows with circles the initial centroids, Figures 1(b) and 1(c) report the assignment and refinement phases for the first step, while Figure 1(d) depicts the assignment phase for the second step.Figure 1
Example of execution ofk-means algorithm (source: Wikimedia Commons available under GNU Free Documentation License v. 1.2).
(a)
(b)
(c)
(d)Thek-means algorithm is granted to converge to a local optimum value, while there is no guarantee to converge to the global optimum [17, 20].Since there is a strong dependency on the initial choice of the centroids, a common practice is to execute the algorithm several times and select the best solution. The algorithm, moreover, is extremely sensitive to outliers, which can significantly alter the results; to cope with this issue, the outliers have to be identified and excluded prior to the execution of the algorithm.Note that, for each step, each of then observations and for each of the d components of the observations, the algorithm calculates the difference with each of the k centers; hence the computational complexity is O(dknM), where M are the total number of iterations [20]. Notice that in [18] a distributed implementation of the k-means algorithm has been provided, with a computational complexity of O(dkn2M) for each agent.Note further that, unfortunately, thek-means algorithm is not able to solve Problem 1; hence we need to seek for other solutions.In the following we discuss an alternative method based on the HK opinion dynamics model, which is granted to provide an admissible solution to Problem1. One of the peculiar characteristics of this algorithm is that the number of clusters k has not to be imposed a priori but becomes an output of the algorithm. The HK opinion dynamics model is reviewed in the next section, while the proposed approach is outlined in Section 6.


## 4. Hegselmann-Krause Opinion Dynamics Model

In this section we recall the so-called HK opinion dynamics model and revise some of the main theoretical results. Consider a group ofn agents, each characterized by a discrete time dynamic equation. The opinions, represented by the state associated with each agent.Specifically, each agent is provided with a scalar initial opinionxi(0)∈R, and the opinion of each agent varies depending on the opinion of the others.The key idea of the HK model is that agents with completely different opinions do not influence each other, while some sort of mediation occurs among agents whose opinions are close enough.Letxi(t)∈R be the opinion of ith agent at time step t and let x(t)=[x1(t),…,xn(t)]T be the vector of the opinions of all the agents. The ith agent is influenced by opinions that differ from his own less than a given confidence level ε≥0. Hence theneighborhood of an agent for each time step t can be defined as(6)Nixit=j∈1,…,n:xit-xjt≤ε.Note that, at each step t, Ni(xi(t)) contains the ith agent itself. This models the fact that each agent takes into account also its current opinion to form a new one.The HK dynamic model is in the form(7)xt+1=Axt,εxt,x0=x0,where A(x(t),ε) is the time-varying (actually state-dependent) n×n adjacency matrix whose entries are in the form (8)A(x(t),ε)ij=1cardNixit,ifj∈Nixit,0,otherwise,where card(Ni(xi(t))) is the cardinality of Ni(xi(t)). Note that A is a stochastic matrix, and all its elements belong to the interval [0,1/n].Several works can be found in the literature which attempt to characterize the properties of the HK model. Given the complexity of the above model, most of the studies consider simpleinitial opinion profiles (i.e., the initial condition x(0)). Two different classes are considered in the literature [13, 21]:(i)
theequidistant profile, where xi(0)=(i-1)/(n-1) hence xi(0)∈[0,1];(ii)
therandom profile, where the opinions are uniformly distributed within [0,1].In [13] it is conjectured that for every confidence level ε there must be a number of agents n subject to the equidistant profile for which a consensus is obtained (i.e., a single shared opinion for all the agents), while in [21] it is conjectured that, for any initial opinion profile, there exists a finite time after which the topology underlying the matrix A(x(t),ε) (i.e., the structure of the mutual influence among agents) remains fixed. Recently this claim proved true, as in [22] it is proved that the convergence time is O(n2). In [23] it is proven that, during the evolution of the system, the order of the opinions is preserved, that is, (9)xi(0)≤xj(0)⟹xi(t)≤xj(t),∀t.Moreover it is proved that, if the initial opinion profile is sorted, the evolutions of the smallest opinion x1(t) and of the largest opinion xn(t) are nondecreasing and nonincreasing, respectively. Clearly, at any step t, if |xi(t)-xi+1(t)|>ε, this remains true for any subsequent step, and the system splits into two independent subsystems. In [23–25] the stability of the dynamical model is investigated. In particular, the fact that the system converges to a steady opinion profile in finite time is proved in [23]. However, the fact that the system might converge to a common opinion or split into clusters is still under investigation. Besides, evaluating a lower bound on the intercluster distance, some interesting conditions for the study of the equilibrium stability are established. Figure 2 shows an example of result of the HK model with n=100 agents, equidistantly distributed within [0,1], for different values of the parameter ε. It is noteworthy that the number of clusters decreases when ε grows.Figure 2
Simulation of opinion dynamics forn=100 agents and for different values of ε.Let us discuss the following property that will be used to solve the clustering problem with distance constraints.Property 1.
ε is a lower bound for the intercluster distance; in fact, when a steady state is reached, any two clusters have a distance which is necessarily greater than or equal to ε, otherwise they would have merged during the evolution of the model.The above property justifies the adoption of the HK model to solve the data clustering problem with distance constraints.Regarding the computational complexity, at each step of the algorithm the distance among the opinion of all agents is calculated. Thus the computational complexity isO(n2M), where M is the maximum number of iterations.


## 5. Consensus Algorithms

In order to provide a distributed implementation of the HK model, let us discuss distributed consensus algorithms with reference to connected, fixed, and undirected graphs.Suppose each node in a graphG represents an agent with an initial condition xi(0)∈R; at each iteration t each node i updates its state as(10)xit+1=Uixjt:vj∈Niin∪i,where Ui is a function of the current state of the node vi and his in-neighborhood.Letχ(x1(0),…,xn(0))∈R be any function of the initial conditions of all the nodes the χ-consensus problem consists of to find a function Ui(·), such that (11)limt→∞xi(t)=χ(x1(0),…,xn(0))∀i=1,…,n.Let us now discuss themax⁡-consensus problem, where the nodes have to converge to the maximum of the initial conditions; that is, χ(·) is the maximum of its arguments.


### 5.1. Max-Consensus

Assuming the graph is connected and undirected, the problem is known to have a solution in finite time [15] (and specifically in no more than n steps) choosing(12)Ui(·)=max⁡h∈Niin∪{i}xh(t).In the following we will denote by(13)x¯i=max-consensusi(xi0,xj0∣j≠i,G,tmax⁡)the execution of tmax⁡ iterations of the max-consensus procedure by the ith agent in a network G, starting from its own initial condition xi(0) and the “unknown” initial conditions of the other agents, while x¯i is the state of the ith agent at iteration tmax⁡. Such a formalism just represents the execution of the max-consensus or min-consensus by the ith agent, and we assume that all other agents are executing the same algorithm in a synchronous manner, each with its own initial condition.


### 5.2. Average-Consensus

In theaverage-consensus problem the nodes are required to converge to the average of their initial conditions, that is, (14)χ·=cTx10⋯xn0T,where cT=1/n1nT and 1n is a vector with n components all equal to 1.Let each node choose(15)Ui·=wiixit+∑j=1n‍wijxjt,where wij=0 if (vi,vj)∉E. The update strategy for the entire system can be represented as (16)x(t+1)=Wx(t),where the n×n matrix W contains the terms wij.According to [26], this choice of Ui(·) yields an asymptotical solution if and only if (I) W has a simple eigenvalue at 1 and all other eigenvalues have magnitude strictly less than 1; (II) the left and right eigenvectors of W corresponding to eigenvalue 1 are 1n and cT, respectively.The above condition implies that, if the underlying graph is undirected, it needs to be connected.A possible choice forW, assuming that each node knows n (or an upper bound for n), is that each node i chooses independently the terms wij as (17)wij=1n,ifvj∈Niin,0,ifvj∉Niin,1-∑l∈Nlin‍wil,ifi=j,resulting in a matrix W that satisfies the conditions in [26]. Several other choices that yield to asymptotic consensus are possible (e.g., see [27]).As for the complexity, note that at each time stept each agent i calculates the contribution of each neighbor to the next state; hence we have O(dntmax⁡). Notice that, however, the algorithm in its basic setting has asymptotic convergence, hence typically tmax⁡≫1 in order to obtain a good approximation of the asymptotic result. An alternative is to resort to finite-time average-consensus algorithms like the one in [28], but we choose to omit the discussion for the sake of clarity.In the following we will denote by(18)x¯i=average-consensusi(xi0,xj0∣j≠i,G,tmax⁡)the execution of tmax⁡ iterations of the average-consensus procedure by the ith agent in a network G, starting from its own initial condition xi(0) and the “unknown” initial conditions of the other agents, while x¯i is the state of the ith agent at iteration tmax⁡. Again, such a formalism just represents the execution of the max-consensus or min-consensus by the ith agent, and we assume that all other agents are executing the same algorithm in a synchronous manner, each with its own initial condition.


### 5.3. Network Size Calculation

Combining the max-consensus and the average-consensus algorithms, it is possible to calculate the number of agentsn in the network in a distributed way [29].Specifically, suppose aleader is elected via max-consensus over G (e.g., the nodes, each, have a unique identifier and the node with maximum identifier is elected as leader via max-consensus). Now, let the nodes execute an average-consensus algorithm with x-i(0)=1 if node vi is the leader and x-i(0)=0 otherwise: the average-consensus yields (19)limt→∞x-it=1n;hence n can be calculated in a distributed way.


## 5.1. Max-Consensus

Assuming the graph is connected and undirected, the problem is known to have a solution in finite time [15] (and specifically in no more than n steps) choosing(12)Ui(·)=max⁡h∈Niin∪{i}xh(t).In the following we will denote by(13)x¯i=max-consensusi(xi0,xj0∣j≠i,G,tmax⁡)the execution of tmax⁡ iterations of the max-consensus procedure by the ith agent in a network G, starting from its own initial condition xi(0) and the “unknown” initial conditions of the other agents, while x¯i is the state of the ith agent at iteration tmax⁡. Such a formalism just represents the execution of the max-consensus or min-consensus by the ith agent, and we assume that all other agents are executing the same algorithm in a synchronous manner, each with its own initial condition.


## 5.2. Average-Consensus

In theaverage-consensus problem the nodes are required to converge to the average of their initial conditions, that is, (14)χ·=cTx10⋯xn0T,where cT=1/n1nT and 1n is a vector with n components all equal to 1.Let each node choose(15)Ui·=wiixit+∑j=1n‍wijxjt,where wij=0 if (vi,vj)∉E. The update strategy for the entire system can be represented as (16)x(t+1)=Wx(t),where the n×n matrix W contains the terms wij.According to [26], this choice of Ui(·) yields an asymptotical solution if and only if (I) W has a simple eigenvalue at 1 and all other eigenvalues have magnitude strictly less than 1; (II) the left and right eigenvectors of W corresponding to eigenvalue 1 are 1n and cT, respectively.The above condition implies that, if the underlying graph is undirected, it needs to be connected.A possible choice forW, assuming that each node knows n (or an upper bound for n), is that each node i chooses independently the terms wij as (17)wij=1n,ifvj∈Niin,0,ifvj∉Niin,1-∑l∈Nlin‍wil,ifi=j,resulting in a matrix W that satisfies the conditions in [26]. Several other choices that yield to asymptotic consensus are possible (e.g., see [27]).As for the complexity, note that at each time stept each agent i calculates the contribution of each neighbor to the next state; hence we have O(dntmax⁡). Notice that, however, the algorithm in its basic setting has asymptotic convergence, hence typically tmax⁡≫1 in order to obtain a good approximation of the asymptotic result. An alternative is to resort to finite-time average-consensus algorithms like the one in [28], but we choose to omit the discussion for the sake of clarity.In the following we will denote by(18)x¯i=average-consensusi(xi0,xj0∣j≠i,G,tmax⁡)the execution of tmax⁡ iterations of the average-consensus procedure by the ith agent in a network G, starting from its own initial condition xi(0) and the “unknown” initial conditions of the other agents, while x¯i is the state of the ith agent at iteration tmax⁡. Again, such a formalism just represents the execution of the max-consensus or min-consensus by the ith agent, and we assume that all other agents are executing the same algorithm in a synchronous manner, each with its own initial condition.


## 5.3. Network Size Calculation

Combining the max-consensus and the average-consensus algorithms, it is possible to calculate the number of agentsn in the network in a distributed way [29].Specifically, suppose aleader is elected via max-consensus over G (e.g., the nodes, each, have a unique identifier and the node with maximum identifier is elected as leader via max-consensus). Now, let the nodes execute an average-consensus algorithm with x-i(0)=1 if node vi is the leader and x-i(0)=0 otherwise: the average-consensus yields (19)limt→∞x-it=1n;hence n can be calculated in a distributed way.


## 6. Data Clustering with Distance Constraints via Opinion Dynamics andk-Means

In this section we propose an algorithm for data clustering with measurement distance constraints, based on a generalization of the HK model.Specifically, measurement data is processed by an HK-like opinion dynamics “filter,” which eventually segments the data intoκ clusters. Moreover, based on the weight of each cluster (namely, represented by the amount of measurement data that has converged to that cluster), data outliers can be filtered out from the original set. More precisely, we assume that each agent i is provided with an initial measurement represented by a vector xi∈Rd. Every agent has an initial state xi(0)∈Rd, which is updated according to the following set of iterative rules: (20)x1,i(t+1)⋮xn,i(t+1)=A(x(t),ε)x1,i(t)⋮xn,i(t),for i=1,…,d, where the adjacency matrix A(x(t),ε) is computed based on the following definition of neighborhood:(21)Ni*(t)=j∈1,…,ns.t.xit-xjt≤ε,where · is the Euclidean norm. Note that for d=1 the standard HK model is obtained.In [22] the HK model with vectorial opinions (i.e., d≥2) is shown to converge in polynomial time.In order to give an idea of the actual time required for convergence, we provide the simulation results of Figure3, where the average instant in which a steady state is reached and the number of clusters obtained are reported in the case d=2 for several choices of n=50,100,200 agents and ε∈[0.1,0.5]; for each choice of n,ε, the average of 100 runs with random initial opinions in [0,1] is reported. Notice that all the executions reached an exact agreement in finite time.Figure 3
Average instant in which a steady state is reached and the number of clusters obtained is reported for several choices ofn=50,100,200 agents and ε∈[0.1,0.5]; for each choice of n,ε, the average of 100 runs with random initial opinions in [0,1] is reported.The proposed approach, as discussed before, does not require the user to specify a value for the parameterk, but it finds a suitable number of clusters based on the parameter ε.A high value ofε means very large and sparse clusters (eventually also very few of them) while a small value of ε means very compact and small clusters (eventually, many of them).Note that, as said before, one of the biggest problems of thek-means-like algorithms is that the outliers have to be preprocessed and excluded; otherwise they would influence considerably the quality of the clustering. In the proposed approach, depending on the choice of ε, very far observation is not influenced by the others and is assigned to a singleton (or more in general to a cluster composed of very few elements).Notice that it is always possible to execute ak-means algorithm with k equal to the number of clusters obtained via HK, in order to attempt to refine the solution found, but this can be done only if the solution of the k-means algorithm does not violate the constraints on the distance among cluster centroids.The proposed algorithm, appears as a good candidate to allow the clustering of a set of sensors or mobile robots, based on perceived information such as position or other sensorial information (temperature, humidity, etc.).As for the computational complexity of the extension of the HK model to opinions inRd, it can be noted that such complexity is the same as executing d scalar HK models; hence it is O(dn2M); since the complexity of the centralized k-means algorithm is O(dknM) [17], the proposed approach determines an increase in computational complexity with respect to the k-means algorithm of a factor n/k≥1.


## 7. Distributed HK Opinion Dynamics

As shown in the previous section, the HK opinion dynamics model can be used to provide an admissible, although suboptimal, solution to the distance-constrained data clustering problem. However, since the topology underlying the HK model is indeed a state-dependent topology, theoretically each agent may exchange information with another agent, depending just on the difference in their opinions.In order to adopt the HK model in a distributed perspective, we need to provide a different implementation, as provided in Algorithm1.Algorithm 1:Distributed HK opinion dynamics algorithm.
for  t=1,…,M  do
for  h=1,…,n  do
/*Transmit the state of agent h to each other*/
δhi=xh(t)ifi=h0else;
δh=max⁡-consensusiδhi,δhj∣j≠i,Gc,n;
/*Calculate xi(t+1)*/
ehi=1ifxi(t)-δh≤ε0else;
zhi=xi(t)ifxi(t)-δh≤ε0else
eh=n·average-consensusehi,ehj∣j≠i,G,tmax⁡
zh=n·average-consensuszhi,zhj∣j≠i,G,tmax⁡
xhit+1=zheh
if  i==h  then
xi(t+1)=xhi(t+1);
end if
end for
end forSince the agents have a unique identifierh=1,…,n, for each time step and for each agent h a distributed procedure is executed by all agents in order to calculate xh(t+1). Specifically, for a specific agent h, each agent i selects δki=xh(t) if i=j and δki=0 otherwise. Then the agents execute a max-consensus procedure using δki as initial condition; as a result of such an operation, each agent i knows xh(t) and is able to determine wether xh(t)-xi(t)≤ε or not. Such knowledge is stored in a variable ehi for each agent, while a variable zhi is equal to one if xht-xit≤ε and zero otherwise.Using average-consensus, multiplied byn, in order to obtain(22)zh=∑h=1nzhi,eh=∑h=1nehithe value xhi(t+1) is obtained as(23)xhit+1=zheh.As for the computational complexity of the distributed version, note that, for each stept=1,…,M and for each agent h=1,…,n, the agents execute a max-consensus (O(dn) steps) and two average-consensus algorithms (O(dtmax⁡) steps), both with initial conditions in Rd, and the complexity is O(dnMmax⁡{tmax⁡,n}) where tmax⁡ is the number of iterations of the average- consensus algorithm. Since, typically, tmax⁡>n, the distributed setting has tmax⁡/n times the complexity of the centralized algorithm. Moreover, since the computational complexity of the distributed k-means algorithm is O(dknM) the proposed distributed algorithm has tmax⁡/kn times the complexity of the distributed k-means algorithm.


## 8. Numeric Examples

As discussed above, thek-means algorithm is generally unable to solve the data clustering problem with distance constraints. In this section, some examples are reported in order to show the effectiveness of the proposed approach. A comparative simulation between the HK model and k-means algorithm is first addressed. Afterwards the potentiality of the proposed mixed approach is showed; then the distributed implementation is discussed.Figure4 shows an example in R2 with ε=0.6 and n=200 observations. The application of the HK opinion dynamics model yields k=63 clusters and D≈0.35. Unfortunately, the k-means algorithm finds a solution for k=63 which, although having D≈0.29, is not feasible for Problem 1 (violations of the constraints are shown with red lines).Figure 4
Clustering forn=200 observations that are uniformly distributed in the interval [0,1] and ε=0.06: the HK opinion dynamics model finds k=63 clusters and D≈0.35. The solution of the k-means algorithm for k=63 is better in terms of the objective function (D≈0.29), but it does not respect the distance constraints (red thick lines represent violations).Figure5 shows a case where n=200, ε=0.18 and the HK opinion dynamics model gives k=5 clusters. Using the k-means algorithm for k=5 a better solution is obtained, and the constraints are not violated; hence in this case postprocessing the result of the HK model via k-means algorithm yields a better result.Figure 5
Clustering forn=200 observations that are uniformly distributed in the interval [0,1] and ε=0.18: the HK opinion dynamics model finds k=5 clusters. The solution of the k-means algorithm for k=5 is better in terms of the objective function D without violating the distance constraints.Figure6 shows the ability of the proposed methodology to isolate the outliers. For n=200 and ε=0.1 the HK opinion dynamics model finds k=7 clusters, of which 2 are singletons each containing an outlier. Executing a k-means algorithm for k=7 gives worse results in terms of the objective function with respect to the HK approach. If, conversely, the two outliers are removed (k becomes equal to 5), then the k-means algorithm has better results in terms of the objective function.Figure 6
Clustering forn=200 observations with ε=0.1. The HK opinion dynamics model finds k=7 clusters, of which 2 are singleton clusters containing one outlier each. The solution of the k-means algorithm for k=7 is worse than the one found by HK model. If, however, the 2 outliers are removed (thus k=5), the k-means algorithm has better results in terms of the objective function.Figure7, eventually, shows an example of application of the distributed HK model provided in Algorithm 1, in a case where n=40 agents, each with a random position in [0,1]2, having to be clustered depending on their positions in a way that the centroids are not closer than ε=0.1. The simulation was executed for M=15 iterations, and the average-consensus algorithms were executed each tmax⁡=100 steps. The topology of the network of agents is given in the upper left plot, while the middle plots show the results of the distributed HK model for the x and y coordinates. The consensus steps performed by each agent during one iteration of the distribute HK algorithm are reported in the upper central plot, where “AVG” stands for average-consensus and “MAX” stands for max-consensus, while the distribution of max-consensus and average-consensus steps over the entire execution of the algorithm is reported in the upper rightmost plot. The lower plots, eventually, show the results of the distributed HK model in terms of the clustering in [0,1]2: the agents are divided in k=20 groups, and the objective function has a value D≈0.06. Notice that, in this case, the k-means algorithm with k=20 yields a worst solution both in terms of the objective function D≈0.12 and in terms of violation of the constraints (5 constraints are violated and are highlighted with red thick segments).Figure 7
Distributed clustering on the positions ofn=40 agents with ε=0.1: the distributed HK opinion dynamics model finds k=21 clusters. The distributed implementation of the algorithm requires alternation between max-consensus algorithms and average-consensus algorithms, as shown by the upper rightmost figure. The solution of the k-means algorithm for k=21 is worse in terms of the objective function D and does not respect the distance constraints (red thick lines in the lower rightmost figure represent violations).


## 9. Conclusions and Future Work

In this paper a distributed algorithm for a sensors network to solve a data clustering problem is provided, with the constraint that the centroids of the clusters must be withinε.The proposed approach is based on the HK opinion dynamics model, which finds admissible, although suboptimal, solutions without requiring a user-specified number of desired clusters and applies thek-means algorithm to find a better solution.In its original application, the HK opinion dynamics model is a centralized algorithm. In this paper, a distributed implementation is provided instead, based on a combination of consensus algorithms.Future work will focus on providing a bound for convergence time in high-dimensional spaces and testing the algorithm in a real world scenario, including noise and packet loss.



---

*Source: 753102-2015-03-08.xml*