---
abstract: 'The proposed distributed dynamic clustering algorithm enables to group agents based on their pre-selected feature states. The clusters are determined by comparing the distance of the agents’ current feature states with average estimates of the states in all clusters. The algorithm also provides average estimates of pre-selected auxiliary states that can be utilized for control purposes. Two example applications of the algorithm are introduced. In the first application, the algorithm is applied to a microgrid with distributed batteries that are controlled to achieve a common state of charge within a group. However, a random selection of the batteries’ groups results in additional power losses during operation. The algorithm reduces the power losses by clustering the batteries based on the selected feature states: local loads and battery capacities, while the state of charges and output voltages are selected as auxiliary states for control purposes. In the second application, the algorithm is used to form a virtual energy storage from batteries distributed in a microgrid.'
author:
- 'Runfan Zhang, Branislav Hredzak, [^1]'
title: 'A Novel Dynamic Peer-to-Peer Clustering Algorithm and Its Application to Aggregate Energy Storage Systems'
---

Distributed clustering, multi-agent, cluster, microgrid, battery energy storage, state of charge balancing, power loss reduction, voltage restoration.

Introduction
============

is a division of data into groups with similar properties [@Clustring_Df]. Various centralized clustering algorithms have been researched, such as k-means [@KmeanC], hierarchical clustering [@HierarchicalC], self-organization map [@SOM] or expectation maximization clustering algorithms [@EMA]. Besides, distributed clustering algorithm have been proposed for distributed data environment [@DisCluster]. However, although the data is distributed, these algorithms require a main site for global clustering, with each data storage communicating with the main site through a centralized network [@DisClstrRv]. In addition, all before-mentioned algorithms are clustering based on previously collected data and not on real-time system states. Therefore, these algorithms are inadequate for clustering multi-agent based systems communicating via a distributed network.

Microgrids are small-scale power networks that supply local loads in small geographical areas. The microgrid enables penetration of renewable energy sources, such as photovoltaic (PV) and wind generation, and energy storage [@CoopMG_bk]. To control the microgrid, the traditional hierarchical power systems control architecture can be applied [@BMG_RV]: primary, secondary and tertiary control levels. The primary control level applies droop control to provide proportional power sharing. Then, the secondary control eliminates the voltage and/or frequency deviations caused by the droop control and, at the same time, provides accurate power sharing. Power flow objectives objectives are realized at the tertiary control level.

To improve the power quality and reliability in microgrids, a state of charge (SoC) balancing control strategy at the secondary control level was proposed for distributed energy storages (ESs) [@BMG_RV]. Not only the strategy maintains the SoCs of all ESs at the same level, but it can also provide a proportional power sharing between ESs after a balanced SoC is achieved. However, for a microgrid with a large number of heterogeneous ESs and different local loads, maintaining all ESs SoCs at the same level is not always the best option. This is because during and after the SoC balancing, the power network line currents inevitably result in power losses.

Literature on application of clustering algorithms in microgrids can be broadly divided into three categories. In the first category, power systems are clustered based on previous data profiles, such as 24 hour data profiles of loads and renewable energy generation [@clstrLoad; @clstrMG2; @ClstringWindfarm]. The purpose of clustering is to achieve economical operation. The second category is based on stochastic modeling utilizing a one year data profile (365 days) and dividing the data into different probabilistic scenarios to deal with uncertainties [@clsterTime; @ClstrsStochastic]. The last one defines a set of power systems in a geographical area without using any clustering algorithm [@clsterMG; @VBES; @clusterPS]. Besides, clustering methods were used for partitioning a central network based on voltage source converter sensitivity matrices, voltage influence factors and merge matrices [@Netclustering], and by finding a critical load [@CLoadClstr]. However, all above clustering algorithms require past data and are run off-line, i.e. the clustering is determined before the system operation.

Motivated by the above discussion, this paper proposes a novel, fully distributed dynamic on-line clustering algorithm based on dynamic states of multi-agents communicating through a distributed communication network. The clustering algorithm dynamically aggregated ESs into clusters with selected similar features and maintains a balanced SoC within each cluster. The proposed algorithm is applied (i) to mitigate power losses associated with the traditional SoC balancing of fixed ES clusters distributed in a microgrid and (ii) to form a virtual energy storage . The salient novel features of this paper are:

1.  The clustering algorithm is fully distributed and can be implemented with any existed distributed control method.

2.  The clustering is done on-line, i.e. the clustering can dynamically adjust to variation in multi-agent states and does not require previously collected data.

3.  The proposed algorithm is applied to a microgrid (i) to reduce power losses associated with SoC balancing of batteries in fixed clusters and (ii) to form a virtual energy storage.

4.  The clustering algorithm is robust to multi-agents’ state variation. As a result, frequent cluster changes, caused by fast state variations, can be eliminated.

The rest of this paper is organized as follows. Section \[sec\_DCA\] presents the proposed algorithm. Implementation of the algorithm to a microgrid with distributed batteries is discussed in Section \[sec\_ClstrMG\]. Section \[sec\_Conclusion\] concludes the paper.

Distributed Clustering Algorithm {#sec_DCA}
================================

This section introduces the proposed distributed clustering algorithm for multi-agents. The clustering problem can be defined as: cluster $N$ agents into $M$ groups based on some selected features propagated through a distributed network. Also assume that the estimations of average states inside of a cluster can be obtained by each agent through the distributed network.

Next, the concept of a distributed network is introduced and then the proposed algorithm is presented.

Distributed Communication Network
---------------------------------

Multi-agents communicate with neighbours through a network represented by a sparse graph $\mathcal{G}\left(\mathcal{V},\mathcal{E}\right)$, with nodes $\mathcal{V}=\{1,\cdots,N\}$ and edges $\mathcal{E}$ [@coopCtrl]. Each graph node represents an agent. Elements of $\mathcal{E}$ are denoted as $\left( {i,\;j} \right)$, where $\left( {i,\;j} \right) \in \mathcal{E}$ if there is a link allowing information to flow from node $i$ to node $j$. The neighbours of node $i$ are given by $\mathcal{N}_{i}$, where $j \in {{\mathcal{N}}_i}$, if $\left( {i,\;j} \right) \in \mathcal{E}$. The graph adjacency matrix is given by $$\label{Adj}
{\mathcal{A}} = \left[ {{a_{ij}}} \right] \in {\mathbb{R} ^{N \times N}}, {a_{ij}} = \left\{ {\begin{array}{*{20}{c}}
    {\alpha,\;\left( {j,\;i} \right) \in \mathcal{E} }\\
    {0,\;otherwise}
    \end{array}}, \right.$$ where $\alpha$ is the coupling strength. Then, the graph Laplacian matrix is $L=\mathcal{D}-\mathcal{A}$, where $\mathcal{D}=diag\{d_i\}$, and ${d_i} = \sum\nolimits_{j = 1}^N {a_{ij}}$ is the in-degree of the communication network.

Dynamic Clustering Algorithm
----------------------------

![Distributed clustering algorithm for the $i$-th agent. The double line arrows represent distributed communication.[]{data-label="fig_Agrm"}](Algorithm_blocks_1.pdf){width="3.5in"}

![Illustration of the proposed clustering algorithm. Nine agent nodes are clustered into three groups. The black lines represent the distributed communication network between agent nodes. The colored dash lines indicate virtual communications within a cluster. One color represents one cluster.[]{data-label="fig_AgrmSMP"}](ALG_case.pdf){width="3in"}

The feature states of an agent, used to determine the clusters, are defined as ${x_i} \in {\Re ^n}$. The proposed algorithm dynamically clusters $N$ agents into $M$ clusters based on the feature states. Estimates of the average of the states ${x_i}$ in the $j$-th cluster are $\bar x_i^{cstrj}$, where $i = 1,\; \cdots ,\;N$ and $j = 1,\; \cdots ,\;M$. Each $i$-th agent has continuous access to the latest average states $\bar x_i^{cstrj}$ of all clusters through the communication network.

First, select (arbitrary) initial estimates of $\bar x_i^{cstrj}$. Then, in order to decide/update to which cluster the $i$-th agent belongs, its current state $x_i$ is compared with all current estimates of $\bar x_i^{cstrj}, j = 1,\; \cdots ,\;M$. The $k$-th estimate $\bar x_i^{cstrk}$ which has the smallest distance from the current state ${x_i}$, as given by , denotes that the $i$-th agent is allocated to the $k$-th cluster. Once all clusters are determined, each $i$-th agent estimates the average of the states of the $k$-th cluster to which it belongs based on its current state ${x_i}$ and the $k$-th cluster agents’ estimates passed through the network, as given by . Neighbours’ estimates that do not belong to the $k$-th cluster, $j \in \left\{ {1,\; \cdots ,\;M} \right\},j \ne k$, are passed through, as given by .

$$\begin{aligned}
&\dot {\bar {x}}_i^{cstrk} = {{\dot x}_i} + \sum\limits_{l \in {\mathcal N_i}} {{a_{il}}\left( {\bar x_l^{cstrk} - \bar x_i^{cstrk}} \right)}, \label{eq_avg_xk} \\
&\dot {\bar {x}}_i^{cstrj} = \frac{1}{\left| {\mathcal N_i} \right|}\sum\limits_{l \in {\mathcal N_i}} {\dot {\bar {x}}_l^{cstrj}}  + \sum\limits_{l \in {\mathcal N_i}} {{a_{il}}\left( {\bar x_l^{cstrj} - \bar x_i^{cstrj}} \right)} ,\;j \ne k,\label{eq_avg_xj}\end{aligned}$$

where ${\left| {\mathcal N_i} \right|}$ denotes the number of neighbours of the $i$-th agent.

$$\label{eq_DCA}
{x_i} \in \left\{ {k \text{-th cluster}\left| {\bar x_i^{cstrk} = \mathop {\arg \min }\limits_{k \in \left\{ {1,\; \cdots ,\;M} \right\}} \left( {\left\| {{x_i} - \bar x_i^{cstrj}} \right\|} \right),\;j = 1,\; \cdots ,\;M} \right.} \right\}.$$

Each $i$-th agent has always access to two results:

1.  $clstr\_rslt\_a$: information to which $k$-th cluster it belongs;

2.  $clstr\_rslt\_b$: estimates of the average of the feature states $\bar x_i^{cstrj}$ in the $j$-th cluster, $j = 1,\; \cdots ,\;M$.

The algorithm is illustrated in Fig. \[fig\_Agrm\] and can be summarized as **Algorithm \[alg\_ddyc\]**.

\[1\][ \#1]{}

design $\mathcal{G}\left(\mathcal{V},\mathcal{E}\right)$ and $M$ initialize $\bar x_i^{cstrj}, j = 1,\; \cdots ,\;M$ measure $x_i$ receive ${\bar {x}}_l^{cstrj}, {l \in {\mathcal N_i}}, j = 1,\; \cdots ,\;M$ from neighbours $k \gets$ label of the cluster with the smallest distance between $x_i$ and $\bar x_i^{cstrj}, j = 1,\; \cdots ,\;M$, where $k \in \left\{ {1,\; \cdots ,\;M} \right\}$ Eq. Eq. send $\bar x_i^{cstrj}, j = 1,\; \cdots ,\;M$ to neighbours Each local agent $i$ implements the same algorithm.

*Example*: To further clarify the algorithm, consider the communication network structure in Fig. \[fig\_AgrmSMP\]. In the figure, nine agent nodes are clustered into three groups. In each cluster, the average estimations are calculated based on the agents in the group, i.e. only the agents in the same cluster communicate with each other to obtain the average estimates through virtual communication lines shown as colored dash lines. The agents which are not in the cluster simply pass trough estimates of the other clusters to its neighbours. Assume the red dashed line connecting nodes 1, 5 and 9 denote the $k$-th cluster. Nodes 1, 5, and 9 obtain the average estimate of the cluster $\bar x_i^{cstrk}$ using . However, for the other two clusters’ estimates $\bar x_i^{cstrj}, j \ne k$, nodes 1, 5, and 9 apply to estimate the averages. Similarly, the other six agents ($i \ne 1,\;5,\; \text{and}\;9$) obtain the average estimates of the red line cluster $k$, $\bar x_i^{cstrk}, i \ne 1,\;5,\; \text{and}\;9$, by applying . As a result, the nodes 1, 5, and 9 in the red line cluster $k$ directly communicate with each other through the virtual red color line links. The other agents just transmit the estimations $\bar x_i^{cstrk}, i=1,\;5,\; \text{and}\;9$.

Utilization of Clusters
-----------------------

![The average estimations of the auxiliary state $z_i$ for the $i$-th agent. The double line arrows represent distributed communication.[]{data-label="fig_Agrmz"}](Algorithm_blocks_2.pdf){width="3.5in"}

In some cases, other states than the feature states may be required for control, optimization and analysis within the cluster or between the clusters. These states are defined as the auxiliary states, ${z_i} \in {\Re ^m}$, and are only used to calculate average of the states within a cluster. For example, in a microgrid, local loads and battery sizes are selected as feature states to determine clusters, whereas the SoCs are selected as auxiliary states for the average estimates of SoCs and the SoC balancing control within a cluster.

Hence, similar to feature states, the estimates of the auxiliary states ${z_i}$ are $\bar z_i^{cstrj}$, where $i = 1,\; \cdots ,\;N$ and $j = 1,\; \cdots ,\;M$. The estimates of the average states of the $i$-th agent in the $j$-th cluster can be obtained using the $clstr\_rslt\_a$ result and following the same procedure as for the estimates $\bar x_i^{cstrj}$, $$\begin{aligned}
&\dot {\bar {z}}_i^{cstrk} = {{\dot z}_i} + \sum\limits_{l \in {\mathcal N_i}} {{a_{il}}\left( {\bar z_l^{cstrk} - \bar z_i^{cstrk}} \right)}, \label{eq_avg_zk}\\
&\dot {\bar {z}}_i^{cstrj} = \frac{1}{\left| {\mathcal N_i} \right|}\sum\limits_{l \in {\mathcal N_i}} {\dot {\bar {z}}_l^{cstrj}}  + \sum\limits_{l \in {N_i}} {{a_{il}}\left( {\bar z_l^{cstrj} - \bar z_i^{cstrj}} \right)} ,\;j \ne k. \label{eq_avg_zj}\end{aligned}$$ Hence, each $i$-th agent has always access to $clstr\_rslt\_c$ result: estimates of the average of the auxiliary states $\bar z_i^{cstrj}, j = 1,\; \cdots ,\;M$. The algorithm is illustrated in Fig. \[fig\_Agrmz\].

Including the auxiliary states into the **Algorithm \[alg\_ddyc\]** gives **Algorithm \[alg\_ddycAE\]**.

\[1\][ \#1]{}

design $\mathcal{G}\left(\mathcal{V},\mathcal{E}\right)$ and $M$ initialize $\bar x_i^{cstrj}, j = 1,\; \cdots ,\;M$ measure $x_i$ and $z_i$ receive ${\bar {x}}_l^{cstrj}, {l \in {\mathcal N_i}}, j = 1,\; \cdots ,\;M$ from neighbours receive ${\bar {z}}_l^{cstrj}, {l \in {\mathcal N_i}}, j = 1,\; \cdots ,\;M$ from neighbours $k \gets$ label of the cluster with the smallest distance between $x_i$ and $\bar x_i^{cstrj}, j = 1,\; \cdots ,\;M$, where $k \in \left\{ {1,\; \cdots ,\;M} \right\}$ Eq. and Eq. and send $\bar x_i^{cstrj}, j = 1,\; \cdots ,\;M$ to neighbours send $\bar z_i^{cstrj}, j = 1,\; \cdots ,\;M$ to neighbours Each local agent $i$ implements the same algorithm.

Applications of Algorithm to Cluster Batteries in Microgrid {#sec_ClstrMG}
===========================================================

This section introduces two example applications of the proposed algorithm to cluster batteries distributed in a microgrid in order (i) to reduce the power losses and (ii) to form a virtual energy storage.

A battery energy storage system (BESS) includes a battery, a bidirectional DC-DC converter interfacing the battery with the microgrid and a local load.

Power Loss Reduction
--------------------

Balancing SoC of batteries distributed in a microgrid can improve stability and reliability of the power system by making full use of energy stored in batteries and lengthening the battery lifetime [@BMG_RV]. However, if the batteries are randomly clustered into fixed groups, it can result in power losses even though their SOCs are balanced. The additional power losses are caused by different local loads and different battery capacities, as explained next.

### Local Loads

Assume that all batteries have the same capacity. The power losses, after a balanced SoC has been achieved, can be reduced by clustering the battery systems with similar local loads. This is because if each battery in a cluster has the same load, there will be no line currents flowing between the batteries.

### Battery Capacity

Assume that all batteries have equal local loads. After a balanced SoC has been reached, larger capacity batteries have to provide more power than smaller capacity batteries to maintain the balanced SoC. This results in additional line currents and hence power losses. Therefore, clustering batteries with similar capacity can reduce the power losses.

Based on the above discussion, two feature states: local load and battery capacity are selected to cluster the batteries using the proposed distributed clustering algorithm and hence minimize the power losses.

Virtual Energy Storage
----------------------

In this application, the batteries are clustered into virtual energy storage(s) to sell power to the main grid or to absorb the power from renewable energy sources.

It is assumed that the utility company provides required energy storage capacity (virtual energy storage) and its price to be formed from distributed BESSs. At the same time, all prosumers decide how much of their battery capacity will be made available to form the virtual energy storage and at what price. Then, the utility company pins (broadcasts) its virtual energy storage requirements to at least one prosumer in an area where prosumers can exchange information through a neighbour-to-neighbour distributed communication network. The requirements are the initial values for the clusters. Two feature states, price and battery capacity, are applied in the algorithm. The algorithm finds the clusters of batteries that are close to the feature states’ average estimations. All prosumers in a cluster can sell their available battery capacity at the average price. Subsequently, the company receives all information from the pining prosumers and selects clusters with sufficient energy capacity and at acceptable price to form the virtual energy storage. The SoC balancing control algorithm maintains the same SoC level in all batteries in the virtual energy storage by ensuring that batteries provide power in proportion to their own energy capacity.

It should be noted that the selected feature states are not restricted to the price and energy capacity only, additional feature states, such as distance or geographical location, can be added to form virtual energy storage(s).

Distributed Control for Microgrid with Clustered Batteries
----------------------------------------------------------

![Control system together with the proposed distributed clustering algorithm, for the $i$-th BESS.[]{data-label="fig_CtrlB"}](./fig/Control_blocks.pdf){width="3.2in"}

The proposed clustering algorithm is combined with primary and secondary control levels in order to achieve SoC balancing within a cluster and voltage restoration in the microgrid, as shown in Fig. \[fig\_CtrlB\].

![image](./Fig/BenchmarkMGDC9.PDF){width="7in"}

![image](./fig/RTDS_setup.pdf){width="7in"}

### Clustering of Batteries

The local load $y_i$ and battery capacity $E_i$ are selected as the feature states for the clustering of batteries. Normalizing the load and capacity gives $y_i^*$ and $E_i^*$. i.e., $x_i={\left[ {y_i^*,\;E_i^*} \right]^T}$. Once the batteries are clustered, the main goal is to maintain a balanced SoC inside each cluster. Therefore, $z_i={\left[ {{s_i},\;s_i^d} \right]^T}$, where $s_i$ is the SoC of the $i$-th battery and $s_i^d$ is its derivative respectively, are selected as the auxilliary states. Then, by applying the proposed algorithm -, ${\bar {z}}_i^{cstrj}$ for $i=1,\; \cdots,\;N,\;j=1,\; \cdots,\;M$ are obtained and used for the SoC balancing.

### Primary Control

Each battery interfaces with the microgrid through a bidirectional DC-DC converter. Outer voltage and inner current PI control loops generate the duty cycle for the converter [@DCCnvrtrCtrL]. Above this control level, V-I droop control regulates BESS to provide proportional power sharing. Then, at the secondary control level, the SoC balancing control based on the proposed algorithm and voltage restoration are proposed.

### SoC Balancing

To maintain a balanced SoC of batteries clustered in a group, a distributed sliding mode control from [@FixedTD], based on the SoC and its derivative states, is implemented to generate the control input $u_i^s$. The errors $e_i={\left[ {e_i^s,\;e_i^{ds}} \right]^T}$ required for the SoC balancing strategy are obtained as $$\label{es}
{e_i} = {z_i} - \bar z_i^{cstrk}.$$ The local sliding mode control regulates the errors $e_i$ to zero. Hence, after a period of time, $ {z_i}= \bar z_i^{cstrk}$ and the SoC balance is achieved in each cluster.

### Voltage Restoration

The main difference between the voltage restoration control and the SoC balancing is that the voltage control requires a reference. The voltage restoration control proposed in this paper regulates the average voltage of the whole microgrid to the rated microgrid voltage reference, $v_{mg}$.

Because the clustering algorithm is dynamically changing based on the feature states $x_i$, the voltages of all BESSs distributed in the microgrid are governed together. This guarantees that every BESS can access the voltage reference. Thus, at least one BESS should be pinned by the rated microgrid voltage reference following the Assumption 1:

\[A1\] The communication graph for the voltage regulation, $\mathcal{G}_v$, is undirected and connected, and at least one agent can access the reference $v_{mg}$.

To maintain the average voltage at the rated value, firstly, inspired by the fixed-time stability theorem [@FTT1], the observer is proposed to obtain the average voltages in the distributed network as $$\begin{aligned}
\label{obs}
{{\dot {\bar v}}_i} &= {{\dot v}_i} + {c_1}{\sum\nolimits_{j = 1}^N {{a_{ij}}sig\left( {{{\bar v}_j} - {{\bar v}_i}} \right)} ^{{\kappa _1}}} \nonumber \\
&\quad  + {c_2}{\sum\nolimits_{j = 1}^N {{a_{ij}}sig\left( {{{\bar v}_j} - {{\bar v}_i}} \right)} ^{{\kappa _2}}},\end{aligned}$$ where $v_i$ and ${\bar v}_i$ are the output voltage and its estimation based on neighbours of the $i-th$ BESS respectively; $c_1, c_2>0$, ${\kappa _1} = 2{\kappa '_1} - 1,\;{\kappa '_1} = 1 - (1/\mu )$, ${\kappa _2} = 2{\kappa '_2} - 1,\;{\kappa '_2} = 1 + (1/\mu )$ and $\mu \ge 2$ are the control parameters of the observer; $sig{(x)^k} = {\left| x \right|^k}sign\left( x \right)$, $sign\left( x \right)$ is the sign function and $k$ is a real number.

Then, the control signal for voltage regulation $u_i^v$, using measurements from converters neighbouring on the communication graph, is given by $$\begin{aligned}
\label{u_v}
u_i^v & = \int{ {\alpha _v}\left( {\sum\limits_{j = 1}^N {{a_{ij}}sig{{\left( {\bar v _j - \bar v_i} \right)}^{{p_v}}} - {g_i}sig{{\left( {e_i^{\bar v}} \right)}^{{p_v}}}} } \right)} \nonumber \\
& \quad+ {\beta _v }\left( {\sum\limits_{j = 1}^N {{a_{ij}}sig{{\left( {\bar v _j - \bar v_j} \right)}^{{q_v}}} - {g_i}sig{{\left( {e_i^{\bar v}} \right)}^{{q_v}}}} } \right)dt,\end{aligned}$$ where $\alpha _v, \beta _v>0$, ${p_v} = 2{p'_v} - 1,\;{p'_v} = 1 - (1/{\mu _v})$, ${q_v} = 2{q'_v} - 1,\;{q'_v} = 1 + (1/{\mu _v})$ and $\mu_v \ge 2$ are the control parameters of the fixed-time control; $e _i^{\bar v}$ is the error defined as $e _i^{\bar v}=v_{mg}-\bar v_i$.

Results {#sec_Reslut}
=======

  ------------ --------------------- ----------- ------------------------ ------- -----
  $m_1$        5                     $n_1$       3                        $m_2$   7
  $n_2$        5                     $m_3$       7                        $n_3$   3
  $\alpha_1$   $4.8\times 10^{-3}$   $\beta_1$   $2.9426\times 10^{-8}$   $r$     0.9
  $k_1$        1.0431                $k_2$       $5.1879\times 10^{-7}$   $p_1$   3
  $q_1$        5                                                                  
  ------------ --------------------- ----------- ------------------------ ------- -----

  : Sliding Mode Control Parameters[]{data-label="tab_smc"}

  ------------ ------- ------------ -------------------- ------------ ---------------------
  $p_v$        $0.6$   $q_v$        $1.4$                $\alpha_v$   25
  $\beta_v$    $95$    $c_1$        $9.5\times10^{-7}$   $c_2$        $1.85\times10^{-6}$
  $\kappa_1$   0.75    $\kappa_2$   1.25                              
  ------------ ------- ------------ -------------------- ------------ ---------------------

  : Voltage Restoration Control Parameters[]{data-label="tab_vctrl"}

![Illustration of the battery clusters obtained for Case A. Local load and battery capacity feature states are normalized. ‘Clstr x’ indicates the average states of the BESSs in the corresponding cluster.[]{data-label="fig_ClusterMG"}](./fig/ClsterMap.eps){width="3.5in"}

![Case Study A: SoCs.[]{data-label="fig_soc"}](./fig/soc.eps){width="3.5in"}

![Case Study A: DC-DC converter output voltages.[]{data-label="fig_v"}](./fig/v.eps){width="3.5in"}

![Case Study A: DC-DC converter output powers.[]{data-label="fig_p"}](./fig/p.eps){width="3.5in"}

A European benchmark microgrid with three feeders, shown in Fig. \[fig\_MG\], was used to verify the proposed clustering algorithm. The microgrid comprises nine BESSs, three PV sources and an industrial load. Each BESS has a different local load and battery size as specified in Fig. \[fig\_MG\]. The rated microgrid voltage is 0.38kV. The PV generation sources maximum power point was calculated based on irradiance and temperature data with one-minute resolution from the NREL Baseline Measurement Station in Colorado. Data was taken from 11:50am to 3:50pm for July 1st to July 5th, 2015. The rated PV power is 8kW. The circuit breaker is always closed, connecting the industrial load to the microgrid. Coupling strength $\alpha=10$.

The microgrid together with the switching models of the DC-DC converters, nonlinear battery models, control systems and clustering algorithm is implemented on RTDS real-time digital simulator shown in Fig. \[fig\_RTDSsp\]. The control parameters for the sliding mode control and voltage control are shown in TABLE \[tab\_smc\] and \[tab\_vctrl\] respectively.

As shown in Fig. \[fig\_ClusterMG\], the proposed distributed clustering algorithm clustered the BESSs into three clusters with similar local loads and battery capacities:

1.  Cluster 1: BESS 4, BESS 7, BESS 8;

2.  Cluster 2: BESS 2, BESS 3, BESS 6;

3.  Cluster 3: BESS 1, BESS 5, BESS 9,

Figs. \[fig\_soc\] to \[fig\_p\] show the SoCs of batteries, the output voltages of DC-DC converters and the DC-DC converter output powers respectively. As shown in Fig. \[fig\_soc\], all three clusters achieve their own balanced SoC after about 50min. Fig. \[fig\_v\] confirms that all DC-DC converter output voltages are regulated at around the rated microgrid voltage, i.e. the average microgrid voltages is restored to the rated value.

Conclusion {#sec_Conclusion}
==========

This paper proposed a distributed dynamic clustering algorithm for clustering agents based on pre-selected feature states. The clustering algorithm was applied (i) to cluster batteries with a similar load and energy capacity to reduce the power losses and (ii) to form a virtual energy storage based on price and energy capacity. The proposed algorithm can be applied to any other systems which require dynamic, on-line clustering based on pre-selected feature states, while using auxiliary states for any required control, optimization or analysis purposes.

Acknowledgment {#acknowledgment .unnumbered}
==============

R. Zhang would like to gratefully thank for a scholarship from the China Scholarship Council.

[10]{} \[1\][\#1]{} url@samestyle \[2\][\#2]{} \[2\][[ l@\#1 =l@\#1 \#2]{}]{}

J. Han, M. Kamber, and J. Pei, *Data Mining: Concepts and Techniques*.1em plus 0.5em minus 0.4emWaltham: Morgan Kaufmann Publishers, 2001.

S.-S. Yu, S.-W. Chu, C.-M. Wang, Y.-K. Chan, and T.-C. Chang, “Two improved k-means algorithms,” *Applied Soft Computing*, vol. 68, pp. 747–755, 2018.

A. B. Geva, “Hierarchical unsupervised fuzzy clustering,” *IEEE Transactions on Fuzzy Systems*, vol. 7, no. 6, pp. 723–733, Dec 1999.

J. A. Flanagan, “Self-organisation in kohonen’s som,” *Neural networks*, vol. 9, no. 7, pp. 1185–1197, 1996.

M. Aci and M. Avci, “K nearest neighbor reinforced expectation maximization method,” *Expert Systems with Applications*, vol. 38, no. 10, pp. 12585–12591, 2011.

K. Thangavel, J. Kacprzyk, A. Abraham, A.-E. Hassanien, A. P. de Leon F de Carvalho, and V. Sn谩拧el, *Distributed Data Clustering: A Comparative Analysis*, ser. Foundations of Computational, IntelligenceVolume 6.1em plus 0.5em minus 0.4emBerlin, Heidelberg: Springer Berlin Heidelberg, 2009, vol. 206.

M. Hai, S. Zhang, L. Zhu, and Y. Wang, “A survey of distributed clustering algorithms,” in *2012 International Conference on Industrial Control and Electronics Engineering*, Aug 2012, pp. 1142–1145.

A. Bidram, V. Nasirian, A. Davoudi, and F. L. Lewis, *Cooperative Synchronization in Distributed Microgrid Control*.1em plus 0.5em minus 0.4emSpringer, 2017.

T. Morstyn, B. Hredzak, and V. G. Agelidis, “Control strategies for microgrids with distributed energy storage systems: An overview,” *IEEE Transactions on Smart Grid*, vol. 9, no. 4, pp. 3652–3666, July 2018.

K. Li, J. Che, B. Wang, J. Zhang, F. Wang, and Z. Mi, “A meta-heuristic optimization based residential load pattern clustering approach using improved gravitational search algorithm,” in *2018 IEEE Power Energy Society Innovative Smart Grid Technologies Conference (ISGT)*, Feb 2018, pp. 1–5.

H. Ryu, Y. Jung, and J. Park, “Energy storage control based on user clustering and battery capacity allocation,” in *2017 IEEE Power Energy Society General Meeting*, July 2017, pp. 1–5.

H. Kim and C. Singh, “Three dimensional clustering in wind farms with storage for reliability analysis,” in *2013 IEEE Grenoble Conference*, June 2013, pp. 1–6.

D. Thomas, O. Deblecker, K. Genikomsakis, and C. S. Ioakimidis, “Smart house operation under pv and load demand uncertainty considering ev and storage utilization,” in *IECON 2017 - 43rd Annual Conference of the IEEE Industrial Electronics Society*, Oct 2017, pp. 3644–3649.

C. Yao, M. Chen, and Y. Hong, “Novel adaptive multi-clustering algorithm-based optimal ess sizing in ship power system considering uncertainty,” *IEEE Transactions on Power Systems*, vol. 33, no. 1, pp. 307–316, Jan 2018.

M. He and M. Giesselmann, “Reliability-constrained self-organization and energy management towards a resilient microgrid cluster,” in *2015 IEEE Power Energy Society Innovative Smart Grid Technologies Conference (ISGT)*, Feb 2015, pp. 1–5.

J. Schlund, D. Steber, P. Bazan, and R. German, “Increasing the efficiency of a virtual battery storage providing frequency containment reserve power by applying a clustering algorithm,” in *2017 IEEE Innovative Smart Grid Technologies - Asia (ISGT-Asia)*, Dec 2017, pp. 1–8.

K. Shi, C. Gao, J. Li, J. Fan, and G. Cui, “The establishment of energy storage model and its application in secondary frequency regulation of air conditioning load,” in *2017 4th International Conference on Systems and Informatics (ICSAI)*, Nov 2017, pp. 363–368.

M. Bahramipanah, M. Nick, R. Cherkaoui, and M. Paolone, “Network clustering for voltage control in active distribution network including energy storage systems,” in *2015 IEEE Power Energy Society Innovative Smart Grid Technologies Conference (ISGT)*, Feb 2015, pp. 1–5.

D. D. Sharma, S. N. Singh, B. S. Rajpurohit, and F. G. Longatt, “Critical load profile estimation for sizing of battery storage system,” in *2015 IEEE Power Energy Society General Meeting*, July 2015, pp. 1–5.

F. L. Lewis, H. Zhang, K. Hengster-Movric, and A. Das, *Cooperative Control of Multi-Agent Systems*.1em plus 0.5em minus 0.4em London: Springer-Verlag, 2014.

[^1]: Runfan Zhang and Branislav Hredzak are with the School of Electrical Engineering and Telecommunications, University of New South Wales, Sydney, NSW 2052 Australia (email: runfan.zhang@student.unsw.edu.au; b.hredzak@unsw.edu.au;).
