<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.cas-group.net/index.php?action=history&amp;feed=atom&amp;title=Distributed_Aggregation_Algorithm</id>
	<title>Distributed Aggregation Algorithm - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.cas-group.net/index.php?action=history&amp;feed=atom&amp;title=Distributed_Aggregation_Algorithm"/>
	<link rel="alternate" type="text/html" href="https://wiki.cas-group.net/index.php?title=Distributed_Aggregation_Algorithm&amp;action=history"/>
	<updated>2026-07-19T18:07:13Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.8</generator>
	<entry>
		<id>https://wiki.cas-group.net/index.php?title=Distributed_Aggregation_Algorithm&amp;diff=162&amp;oldid=prev</id>
		<title>Jfromm: New page: &#039;&#039;&#039;Distributed aggreation algorithms&#039;&#039;&#039; belong to a special class of  distributed algorithms for mathematical operations.  At each node in the distributed system,...</title>
		<link rel="alternate" type="text/html" href="https://wiki.cas-group.net/index.php?title=Distributed_Aggregation_Algorithm&amp;diff=162&amp;oldid=prev"/>
		<updated>2008-10-02T19:55:48Z</updated>

		<summary type="html">&lt;p&gt;New page: &amp;#039;&amp;#039;&amp;#039;Distributed aggreation algorithms&amp;#039;&amp;#039;&amp;#039; belong to a special class of  &lt;a href=&quot;/index.php?title=Distributed_Algorithm&quot; title=&quot;Distributed Algorithm&quot;&gt;distributed algorithms&lt;/a&gt; for mathematical operations.  At each node in the distributed system,...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;#039;&amp;#039;&amp;#039;Distributed aggreation algorithms&amp;#039;&amp;#039;&amp;#039; belong to a special class of &lt;br /&gt;
[[Distributed Algorithm|distributed algorithms]] for mathematical operations. &lt;br /&gt;
At each node in the distributed system, one or more values are stored, the &lt;br /&gt;
nodes can communicate with each other, and are allowed to perform certain&lt;br /&gt;
mathematical operations. The distributed algorithm now has to &lt;br /&gt;
determine the exact sequence of operations that each node &lt;br /&gt;
has to follow in order to achieve a global goal (for instance &lt;br /&gt;
find the max, min, gcd or average value for all nodes).&lt;br /&gt;
&lt;br /&gt;
== Simple Operations ==&lt;br /&gt;
&lt;br /&gt;
=== Invariants involving one node ===&lt;br /&gt;
&lt;br /&gt;
It is always important to identify invariants in distributed algorithms,&lt;br /&gt;
especially to prove safety and liveness properties in order to verify the&lt;br /&gt;
[[Distributed Algorithm|distributed algorithm]]. Invariants remain constant&lt;br /&gt;
and unchanged during all operations at the node.&lt;br /&gt;
For simple mathematical operations such as maximum (Max), minimum (Min), and &lt;br /&gt;
greatest common divisor (GCD) it is easy to find invariants.&lt;br /&gt;
&lt;br /&gt;
If one node with value z receives a message from another node with value e,&lt;br /&gt;
the overall value of Max, Min and GCD for all nodes is invariant (or constant)&lt;br /&gt;
if the value at one node is replaced by the Max, Min, or GCD of both&lt;br /&gt;
nodes, that is if the following operations are executed:&lt;br /&gt;
&lt;br /&gt;
 If node has value z and receives message from node with value e:&lt;br /&gt;
 GCD: if (e &amp;lt; z) { z = ((z-1)%e)+1); }&lt;br /&gt;
 MAX: if (z &amp;lt; e) { z = Max(z,e); }&lt;br /&gt;
 MIN: if (e &amp;lt; z) { z = Min(z,e); }&lt;br /&gt;
&lt;br /&gt;
If an invariant has been found, and a corresponding operation has been identified&lt;br /&gt;
that satisfies both safety (the goal is never violated) and liveness (there is&lt;br /&gt;
progress towards the goal) properties it is therefore quite easy &lt;br /&gt;
to construct a distributed algorithm, see &lt;br /&gt;
for instance the [[Distributed_GCD_Algorithm|distributed gcd algorithm]]:&lt;br /&gt;
&lt;br /&gt;
 &amp;#039;&amp;#039;On receiving a message from a neighbor:&amp;#039;&amp;#039;&lt;br /&gt;
 Receive (int e)&lt;br /&gt;
 { &lt;br /&gt;
   if (Condition) &lt;br /&gt;
   {&lt;br /&gt;
     z = InvariantOp(z,e)&lt;br /&gt;
     Send(z, all Neighbors)&lt;br /&gt;
   }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=== Invariants involving two nodes ===&lt;br /&gt;
&lt;br /&gt;
The situation for operations such as sum, average, variance and&lt;br /&gt;
standard deviation is a bit more complicated. If a value of one&lt;br /&gt;
node is replaced by the sum or average of two nodes, the overall&lt;br /&gt;
value of the sum or average obviously changes and is no longer &lt;br /&gt;
invariant.&lt;br /&gt;
Nevertheless, an invariant to calculate the average is possible,&lt;br /&gt;
if we always consider a pair of nodes. If the values at both&lt;br /&gt;
nodes are replaced by the average value, the overall average for&lt;br /&gt;
all nodes is invariant.&lt;br /&gt;
&lt;br /&gt;
 If a pair of node communicates, and one node has value z and the node has value e:&lt;br /&gt;
 AVG: z = e = Avg(z,e)&lt;br /&gt;
&lt;br /&gt;
Therefore the reciple to construct a distributed algorithm in&lt;br /&gt;
this case is: select two neighbor nodes, exchange values and &lt;br /&gt;
perform operations which live the desired value invariant.&lt;br /&gt;
&lt;br /&gt;
 &amp;#039;&amp;#039;At each node execute the following:&amp;#039;&amp;#039;&lt;br /&gt;
 OnTimer()&lt;br /&gt;
 {&lt;br /&gt;
      NeighborNode = PickRandomNeighbor();&lt;br /&gt;
      Send(z, NeighborNode)&lt;br /&gt;
      WaitForResponse(MeighborNode);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &amp;#039;&amp;#039;On receiving a message from a neighbor:&amp;#039;&amp;#039;&lt;br /&gt;
 Receive (int e)&lt;br /&gt;
 { &lt;br /&gt;
   if (Condition) &lt;br /&gt;
   {&lt;br /&gt;
     Send(z, NeighborNode)&lt;br /&gt;
     z = InvariantOp(z,e)&lt;br /&gt;
   }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
== Complex Operations ==&lt;br /&gt;
&lt;br /&gt;
Complex mathematical operations such variance or standard deviation&lt;br /&gt;
are of course as the name says more complicated to implement as a&lt;br /&gt;
distributed algorithm. They require the storage of more than one &lt;br /&gt;
parameter, register or value at each node.&lt;br /&gt;
&lt;br /&gt;
To calcute the [http://en.wikipedia.org/wiki/Variance variance]&lt;br /&gt;
of n numbers distributed at an equal number of nodes, one can &lt;br /&gt;
use the following distributed algorithm, according to the equation Var(x) = E((x-E(x))^2)&lt;br /&gt;
&lt;br /&gt;
 &amp;#039;&amp;#039;Store four values/parameters at each node&amp;#039;&amp;#039;: x, E(x), (x-E(x))^2, E((x-E(x))^2)&lt;br /&gt;
  1.Param: local value (remains unchanged)&lt;br /&gt;
  2.Param: average of 2.Param and local value&lt;br /&gt;
           (copy every time from 1. Param if 1. Param has changed)&lt;br /&gt;
  3.Param: (Value of 1.Param - Value of 2.Param)^2&lt;br /&gt;
           (calculate every time if 2. Param has changed)&lt;br /&gt;
  4.Param: average of 4.Param&lt;br /&gt;
           (copy every time from 3. Param if 3. Param has changed)&lt;br /&gt;
 &amp;#039;&amp;#039;At each step&amp;#039;&amp;#039;&lt;br /&gt;
 -Select pair of nodes&lt;br /&gt;
 -Exchange value of 2 parameters (parameters 2 and 4)&lt;br /&gt;
 -Calculate values of parameters 2-4 at both nodes, replace&lt;br /&gt;
  for average values (parameters 2 and 4) the previous values at &lt;br /&gt;
  both nodes with the average of both nodes, calculate&lt;br /&gt;
  3. parameter if 2. parameter has changed&lt;br /&gt;
&lt;br /&gt;
Alternative, there is the following faster version which&lt;br /&gt;
requires one more parameter at each node. It works according to &lt;br /&gt;
the equation Var(x) = E(x^2)-(E(x))^2&lt;br /&gt;
&lt;br /&gt;
 &amp;#039;&amp;#039;Store five values/parameters at each node&amp;#039;&amp;#039;: x, E(x), x^2, E(x^2), E(x^2)-(E(x))^2&lt;br /&gt;
  1.Param: local value (remains unchanged)&lt;br /&gt;
  2.Param: average of 2.Param and local value&lt;br /&gt;
           (copy every time from 1.Param if 1.Param has changed)&lt;br /&gt;
  3.Param: square of local value&lt;br /&gt;
           (calculate every time if 1.Param has changed)&lt;br /&gt;
  4.Param: average of 4.Param and square&lt;br /&gt;
           (copy every time from 3.Param if 3.Param has changed)&lt;br /&gt;
  5.Param: 4.Param-(2.Param)^2&lt;br /&gt;
           (copy every time from 3. Param if 3. Param has changed)&lt;br /&gt;
 &amp;#039;&amp;#039;At each step&amp;#039;&amp;#039;&lt;br /&gt;
 -Select pair of nodes&lt;br /&gt;
 -Exchange value of 2 parameters (parameters 2 and 4)&lt;br /&gt;
 -Calculate values of params 2-5 at both nodes, replace&lt;br /&gt;
  for average values (parameters 2 and 4) the previous values at &lt;br /&gt;
  both nodes with the average of both nodes, calculate&lt;br /&gt;
  the others&lt;br /&gt;
&lt;br /&gt;
To calculate the [http://en.wikipedia.org/wiki/Standard_deviation standard deviation], &lt;br /&gt;
one has to add another parameter at each node, since the standard deviation can be defined &lt;br /&gt;
as the square root of the variance.&lt;br /&gt;
&lt;br /&gt;
== Literature ==&lt;br /&gt;
&lt;br /&gt;
Mark Jelasity, Alberto Montresor, and Ozalp Babaoglu,&lt;br /&gt;
&amp;#039;&amp;#039;Gossip-Based Aggregation in Large Dynamic Networks&amp;#039;&amp;#039;,&lt;br /&gt;
ACM Transactions on Computer Systems, Vol. 23, No. 3, August (2005) 219–252&lt;/div&gt;</summary>
		<author><name>Jfromm</name></author>
	</entry>
</feed>