You are on page 1of 9

ELECTOR: Deterministic leader election algorithm for modular robots

1st Edy Hourany 2nd Bachir Habib 3rd Abdallah Makhoul


Univ. Bourgogne Franche-Comté Department of computer science Univ. Bourgogne Franche-Comté
FEMTO-ST Institute, CNRS Holy Spirit University of Kaslik FEMTO-ST Institute, CNRS
Montbéliard, France Jounieh, Lebanon Montbéliard, France
edyhourany@gmail.com bachir.habib@uek.edu.lb Abdallah.Makhoul@univ-fcomte.fr

4th Benoit Piranda 5th Julien Bourgeois 6th Pierre-Cyrille Heam


Univ. Bourgogne Franche-Comté Univ. Bourgogne Franche-Comté Univ. Bourgogne Franche-Comté
FEMTO-ST Institute, CNRS FEMTO-ST Institute, CNRS FEMTO-ST Institute, CNRS
Montbéliard, France Montbéliard, France Montbéliard, France
Benoit.Piranda@univ-fcomte.fr Julien.Bourgeois@univ-fcomte.fr PHeam@univ-fcomte.fr

Abstract—A modular robot is an ensemble of programmable proposed an implementation of programmable matter based
robotic modules which are linked together to form a bigger on a huge modular robots composed of spherical elements:
robot. Some applications like programmable matter are using a the 3D Catoms. The Programmable Matter Project1 is con-
huge number of modules, potentially millions of modules, and tinuing this objective.
there are many cases in which electing a leader is needed to op- In modular robots, many algorithms need a leader even
timize distributed algorithms. In these algorithms, modules act though it is just to start a distributed algorithm [2], [3],
in collaboration with the condition, the status, and the decision the distributed leader election algorithm is therefore very
of the leader. The main problem of current leader election algo- important. This algorithm can be simplified in a distributed
rithms is that most of them rely on random number generation consensus algorithm if there are unique identifiers but it
which is difficult to implement in a distributed system. This turns out to be much more difficult with their absence.
paper proposes a new algorithm for electing a leader that does In the literature, leader election algorithms are often
not take into consideration any probability approach such as based on the probability of a coin flipping which will, most
random identifiers or coin flipping. Furthermore, the proposed of the time, lead to the repetition of the algorithm and
algorithm reduces the probability of having a symmetric system an increased complexity of the election [4], [5]. In other
since it uses the connected interfaces’ number to generate approaches [4], [6], [7], the authors used an arbitrary identi-
identifiers. The results show that the proposed algorithm, with fication for the modules, and ran a comparison phase among
a complexity of θ(n), will end up with a leader with high them based on their previously defined identification. In this
probability, and works on all kinds of modular robots, 2D or case, some modules may end up with the same identifier and
3D, despite the particle distribution and/or the system’s graph
risk a failure in the leader election. Furthermore, the usage of
representation.
randomness is very difficult to implement as all modules are
perfectly homogeneous physically and logically, they will
Index Terms—Modular Robot, Distributed Algorithms, Leader end up having the same random values generated.
Election, Programmable Matter, Deterministic Algorithm This paper proposes a new deterministic leader election
algorithm with a complexity of θ(n). The same assumptions
1. Introduction as in [8] are taken, where modules have the following
properties: each module is anonymous, in other words, the
Programmable matter is a term used to define the ability modules do not have a unique identifier or generates one of
of a system to change its physical properties in a pro- any kind. Each module has a set of ports that can be labeled
grammable way based on multiple inputs gathered from by a consecutive integer {0, 1, 2, ..., m}.
its environment. The term programmable matter was first The remainder of the paper is organized as follows.
introduced in 1991 by T. Toffoli and N. Margolus to define Section 2 presents the literature review, followed by a back-
a system that consists of simple computational particles that ground section in which the main definitions of modular
can establish, release bonds, compute, and actively move in robots are recalled. Section 4 is dedicated to the proposed
a self-organized manner [1]. The Claytronics project [1] has leader election algorithm. The termination with no leader
will be discussed in Section 5. In section 6, the results
This work has been supported by the EIPHI Graduate School (contract
”ANR-17-EURE-0002”). 1. https://projects.femto-st.fr/programmable-matter/
are shown, analyzed and the complexity is studied. Finally, a square or king graph representations. To be able to use
Section 7 concludes our work and gives some directions for this method, the graph should not have any holes in it. In
future work. other words, there is only an outer boundary and no inner
boundaries defined on section 3.
2. Existing Leader election algorithms In [6], the authors introduced an approach to the leader
election algorithm and they precisely mentioned that the
Leader election is a fundamental problem in modular algorithm does not work on systems with holes. The system
robots systems. In this context, leader election is essential is divided into multiple spanning trees. Each root of those
and important for various and different applications such trees is a candidate. In order to elect a leader, the candidates
as shape formation [6], [9], self-repair [10], [11], self- scan their respective trees of the spanning forest. In each
assembly algorithms [12], [13], decision making [14], [15], step, the modules of each tree send a constant length code
etc. Leader election is a fairly old problem in distributed to their parent, describing their neighborhood. The message
systems, it consists in electing a unique leader from a fixed is then forwarded all the way to the candidate leader at the
set of nodes [16], [17]. Indeed, several algorithms have been root of the tree. Once all candidate leaders have obtained a
proposed in the literature to solve this problem. However, in code from a particle in their respective tree, they send each
the context of modular robotic systems, multiple challenges other these codes and compare them. If the codes are not
must be taken into account to elect a leader. The first one is all equal, the candidates are able to elect a unique leader.
the homogeneity or uniformity of the system. All particles Otherwise, the election attempt fails, and each candidate
are considered to follow the same program. They are anony- leader asks one of its children for another neighborhood
mous and indistinguishable and do not share any kind of code.
coordinate or positioning system. In such kind of distributed In order to break the symmetry, the solution proposed
systems, it is proven that it is impossible to elect a leader in [20] is based on physically moving the modules when
in a deterministic manner since it is impossible to break a confronted which make the system consumes more time and
possible symmetric system in the initial configuration [18]. energy. This algorithm does not use randomness, does not
A deterministic method is of paramount importance since require the modules to have a common chirality, and does
all modules are identical, therefore, they will be using not take into consideration if the system has holes in it or
the same pseudo random function and the same seed, this not. At the end of its execution, only one leader will be
will end up generating the same number for the modules elected. The execution time complexity of this algorithm is
each time they pick a random number. Therefore, random O(Ln2 ) where L is the size of the outer boundary at the
number generating cannot be used in this case. The second initial state of the algorithm and n is the number of particles
challenge is the low energetic and computation resources of in the system. However, this algorithm is complex and not
the particles. Therefore, the solution must be non-complex suitable for limited resources modular robots.
and suitable for modular robots. Despite all the proposed solutions by the different au-
Although the importance of leader election in modular thors, the leader election algorithm has always a complexity
robots systems, it has received little attention until now. of O(n) except for the algorithm of Emak et al. [20] that has
For instance, the works presented in [4], [5], [7] are fully a complexity of O(Ln2 ). A lot of challenges will be faced
theoretical based on graph theory, probability and random when implementing those solutions. Therefore, this paper
number generation approaches. After implementing these will be proposing an algorithm that does not take any prob-
solutions, the simulation may end up with no leader. ability approach such as random identifiers or coin flipping.
In [4], [6], [7], [19], the authors used an arbitrary The proposed algorithm will end up with a leader with high
identification strategy for the particles. Then, they ran a probability, and will work on all connected systems, despite
comparison phase among the particles based on their pre- the particles’ distribution and/or the system’s graph repre-
viously defined identification. In this case, modules might sentation. In the proposed approach, the port numbering and
end up with the same identification for different particles, orientation as well as the summation of an integer generated
and this might lead to the failure of the leader election. In will be used in order to break the symmetry of the system.
[19], the authors divided their algorithm into six phases. A symmetric system in this approach is defined in 3. The
The system begins by setting up the boundary of the graph, probability of having a symmetric graph is considered to be
then its segments. Next, it identifies each module with a negligible specially with high number of modules.
unique identifier. After that, it starts by comparing those In summary, Table 1 compares six algorithms among
identifiers, and finishes by a ”solitude” verification and a what was studied in the literature with the algorithm pro-
boundary identification. Consequently, this solution is not posed in this paper.
applicable because all the modules needs to finish a step [21] [19] [22] [6] [8] [20] Proposed algorithm
before moving to the other one. This is impossible to do it Multiple Leaders
Random Numbers
Yes
No
No
Yes
No
Yes
Yes
Yes
No
Yes
No
No
No
No
since a module can never know if all other modules in the Holes
Same Chirality
Yes
Yes
Yes
Yes
Yes
Yes
No
No
No
Yes
Yes
No
Yes
No
system finished this step. Implemented No No No No No No Yes
Complexity NA O(L) O(Lmax) O(n) O(2(r + mtree + 1)) O(Ln2 ) O(n)
In [8], the authors introduced a new leader election
algorithm. This algorithm is very easy to implement, but on TABLE 1: Comparison of all leader election algorithms
the other hand, it only works on certain kinds of topologies:
3. Background study concatenating the d bits. Then using the connected interfaces
and its orientation, each module will be generating its weight
This section will be dedicated to basic definitions and w as follows:
terminology in modular robots. A modular robotic system
d−1
is a system that is presented as an undirected graph where X
the vertices are the modules (particles) and the edges are w= 2Ci (1)
i=0
the communication links between neighbouring particles.
All the particles are considered to be uniform. They are Where Ci is the state of the connector i (1 if connected
anonymous and indistinguishable they have the same clock- 0 otherwise), d is the degree of the graph (the number of
wise orientation and execute the same program. The com- connectors).
munication among the modules happens through exchanging Some examples of the number generation are presented
messages. Each particle can communicate with its adjacent in Figure 1 with different kind of robots. Both position and
neighbors only. A particle’s neighbor is defined as being the orientation of the module affect its weight. For example,
module that is directly connected to that particle through if a module in a square lattice has the interfaces 0 and 3
an interface. Modules are only aware of their status and connected, the respective binary number is (1001)bin which
their neighbors’ status only. Definitions and assumptions are gives (9)dec in decimal.
given next, before starting the development of the algorithm. By the end of this step all the modules will have gen-
Definition 1 (Particle/module). A particle, also referred to erated an integer as previously described. This weight will
as module, is defined by being a conceptual model for a be used in the third phase of the algorithm to be able to
computational entity in an infinite regular grid. A module compute the tree value.
can take different forms. In one system, only one type 3 3
of particles is used. Multiple types of modules exist 0001 0 0110 0 110001 011100
leading to different organisations, such as a regular like 2 1 2
6 49 28
1 1
square lattice (Smart Blocks), hexagonal , cubic lattice 2
(Blinky Blocks), FCC lattice (3D Catom), free positions 0101 3 000110 111011 001110
1 5 6 59 14
(Kilobots) [23], and droplet [24]. It is important to note 0
that modules have a constant memory size. 0
4
5
0001 1 110000 0
Definition 2 (Weight). The weight of a robot is defined as an 3
1 3 48
2 2 1
intrinsic value calculated from the list of its connection
to neighbors. This concept is explained in details in Figure 1: Examples of weight generation based on the
subsection 4.1 interfaces connections for two different 2D lattices (cubic
Definition 3 (Symmetrical system). Axial symmetry is usu- on the left and hexagonal on the right). Grey triangles mark
ally defined as the geometrical quality of being made up #0 connectors, others are placed clockwise.
of exactly similar parts facing each other around an axis.
In addition, in the proposed approach, the weight of the
modules was taken into consideration as an added con- 4.2. Recruitment phase
dition to accomplish, a so called, symmetrical system.
In this section, prospective leaders will start competing
by recruiting modules to create their spanning tree. In this
4. Proposed algorithm and contribution scenario, prospective leaders are chosen as follow: if the
module has only one connection, it directly becomes a
This section will be describing the proposed solution in prospective leader. If a module has two connections, it will
details. The algorithm is based on six phases. First, each wait for a T 2 time and after that time if it was not recruited
module generates locally an integer, called weight, based it will become a prospective leader and start the recruitment
on the numbering of their connected interfaces. After that, process. Likewise, modules with 3 connections will wait for
spanning trees will be created using a recruitment method, T 3 time and so on. The delay T i , where i is the number of
then the values of the recruited modules will be calculated, connected interfaces, can be fixed by the user before the
the generated spanning tree will compete and the loosing execution of the algorithm. It can be computed in function
trees are dismantled, this step is repeated until one tree of the diameter of the network and the speed of the message
remains. And finally the leader is elected. propagation.
When an available module receives a recruitment mes-
4.1. Computing the weight parameter sage, it marks the interface from where the message was
received as parent interface, changes the module flag to re-
Considering that each robot is connected to up to d cruited, informs its parent that the recruitment was success-
neighbors, (d is the degree of the associated graph), and ful and starts recruiting its remaining connected modules.
defining Ci the state of the ith connector (setting Ci = 1 if This process will continue until all modules in the system
connected and Ci = 0 elsewise) the weight is encoding by are recruited. When a module has no neighbor to recruit or
all its neighbors are already recruited, it will be depicted as 40 10 23 33
41 34
1 14 10 7 10 1
a leaf of the tree since no more children can be recruited. 41 41 34 34
41 16 34 16
After that, each spanning tree will have two properties, the 23 Message sending the sum of the weights
total number of modules recruited in the tree and the sum 5 10 of the subtree.

41 11 34 6 Message flooding the value of the group.


of the weights (calculated in phase 1) of the modules in the 5
41

same tree. 6 5 6 34
Value of the group computed by the
root node.
41
An illustration example of the recruitment phase is pre-
sented in Figure 2. In this example, two prospective leaders Figure 3: Group value computation: Starting from the leaf
will start recruiting modules until no more modules are of each group, each leaf sends its weight to its parent. The
available. parent adds the received value with its weight and then send
the result backward until it reaches the root of the tree. Once
1 14 10 7 10 1 1 14 10 7 10 1 1 14 10 7 10 1
the sum reaches the root, it will be added to the root’s weight
5 10 5 10 5 10 to define the group value. This group value is then broadcast
1
6 5 6
2
6 5 6
3
6 5 6 to all the modules of the tree.
1 14 10 7 10 1 1 14 10 7 10 1 1 Module with weight
5 10 5 10 1 Root of the green graph
of particles in their tree and the sum of all its integers, and
6 5 6 6 5 6 1 Leaf of the blue graph
4 5 in addition, they have their ”ready to compete” flag set to
Figure 2: 5 steps of the recruitment process: Roots start true. Modules that have neighbors recruited to a different
recruiting modules until no more modules are available. tree, send them a competing message containing the sum
of the tree and the number of modules. The receiving party
then compares those variables with the one stored in their
4.3. Tree value computation memory. The module with the higher sum wins. If both trees
have the same value, then the tree with more modules is the
Once a module appoints itself as leaf, it sends its weight winner. There are rare and negligible cases where both sum
to its parent. And every time a parent receives such a value, and total number of modules are the same for the competing
it will increment the counter that counts the number of trees, this is called symmetry and is discussed in details in
modules, and it will flag the interface from where the value section 5 of this paper.
was received as value sent. Once all the interfaces that
are connected to its children sent their values, the module
computes the sum of all the received values and sends it 4.5. Dismantling trees and more recruitment
to its parent. This process will keep on executing until it
reaches the tree root. In like manner, the root itself will
process the message as previously described and, as a result, As a result of the previous competitions, loosing trees
the final value of that tree and the total number of modules will become dismantled. In this scenario, dismantle is de-
are calculated. Forthwith, the root will then broadcast the fined as breaking into pieces. This means that the modules
tree value and the number of modules in its tree to all its that were the children of the loosing tree will no longer
children. As soon as a module receives this type of message, be related to that tree and they will be restored to their
it will save those variables in its local memory and sets its state before the recruitment. The process operates as follow:
”ready to compete” flag to true. Identically, this module will the leaf that received the loosing message, will send that
forward the same message to its children, that will treat this message back to the tree root. In his turn, the root broadcasts
message in the same fashion, until it reaches the leaves. to all its children the dismantle message. Consequently, the
As previously described, the competition among the trees is particles receiving the dismantle message set the recruited
done through the connected leaves or modules. Therefore, flag to ”false”, the interfaces that are flagged as parent and
the tree root should send the total sum of the tree to all its children are no longer flagged. Furthermore, the variables
children in order to compete with other trees. containing the value of the tree and the number of modules
Figure 3 shows an illustrative example of this phase. are set back to zero. Once the dismantle process reaches the
Starting from the leaf, each module sends its value to its leaf of the loosing tree, it will send a message to the winning
parent. The parent adds it up to its own and - after having tree that the dismantle is finished. As a result, the winning
received all values from its children - sends it backward tree will re-initiate the recruitment and start recruiting the
until the message reaches the root of the tree. Once the sum dismantled modules in the same manner.
reaches the root, it will be added to the root’s value and then Figure 4 presents an example of the dismantling recruit-
the root broadcast it to all the modules in the same tree. ment. In this example the loosing modules send a dismantle
message to their parent until it reaches the root of the loosing
4.4. Competition with other trees tree. In the mean time, the winning tree sends a message to
its parent until it reaches the root to reset the value of the
In this section, all the modules are ready to compete. To tree. Furthermore, the winning modules start recruiting the
put it in other words, all modules received the total number loosing tree.
41>34 Blue wins
1 14 10 7 10 1 1 14 10 7 10 1 1 14 10 7 10 1
you
41 41 41 34 34 34 41 41 41 loose 34 34 34 5 10 5 10 5 10

41 34 41 34 5 6 5 5 6 5 5 6 5
1 2 3
you
41 41 34 41 41 win
34 1 Nodes of the initial tree,
initial PL senders
1 2 1 14 10 7 10 1 1 14 10 7 10 1
1 Wait for PL from all its
children
5 10 5 10 PL message
41 41 41 34 34 34 1 14 10 7 10 1 Leader found message
5 6 5 5 6 5 1 Elected leader
4 5
41 34 5 10
Messages
reset
Figure 5: Leader election: 1) Once a module can not recruit
41 41 34 dismantle 5 6 5 or compete further, it sends a Potential Leader message (PL)
3 4
to its parent. 2)& 3) Each parent that receives PL message
Figure 4: 4 steps of the dismantling recruitment: First step waits for all its children PL message and then sends it
presents the initial state, step 2 shows the competition backward to its parent. 4) So far until the message reaches
between the two groups, the blue group win on the green the root, which becomes the leader and broadcast (5) to all
group, then each leaf of the two groups produces reset and modules in the system that the leader is elected.
dismantle messages. Step 3 shows the broadcasting of reset
and dismantle messages. At the end, step 4, their is only
one group and nodes are reset. will result in having a bigger tree that will win against the
remaining one. Figure 6 shows an example of two cases.
Figure 6a presents a symmetry scenario while in Figure 6b
4.6. Leader election phase there is no symmetry. The aim of this section is to discuss
the probability of symmetry occurrence and show that it
As long as the system contains multiple trees, the com- is very low while following the above proposed for leader
petition will go on and recruitment will be re-initiated until election.
one tree remains. This occurs when all the modules of the
tree are not connected to any other tree.
After the election, the leader will change its leader flag
and leader found flag to true, broadcast a leader found
message to all its neighbors, and restore to its initial state
before the beginning of the algorithm except for the leader
flag and the leader found flag that should remain set to
true. Correspondingly, every module that receives the leader
found message, will restore to its initial state and then sets
the leader found flag to true.
Figure 5 presents an example of the last phase of the (a) Two trees with exactly the (b) Three spanning trees. The
leader election approach. Once a module can not recruit or same number of modules and green and blue trees are iden-
compete further, it will send a ”potential leader” message the same total value. tical.
to its parent. Each parent that receives this type of message, Figure 6: Comparison of two cases, a) and b) has the same
will wait until all its children send him the same message blue and green trees but b) has yellow modules in addition.
then send it backward to its parent. So far until the message In the case b), yellow tree will dramatically change the
reaches the root. If this message reaches the root, the root results. The yellow tree will be loosing against the blue
becomes the leader and broadcasts to all modules in the tree, and it will be then merged into one tree. So in this case
system that it is the leader. having two identical trees is not considered as a conflict.

5. Termination with no Leader As discussed, the proposed algorithm may terminate


without electing a leader. It happens when at the end of
This section will be explaining the conflicts that might a recruiting phase, all trees have both the same number
occur during the leader election algorithm. As mentioned of nodes and the same weight. It would be very hard to
previously in Section 4.4, a symmetry occurs when two, or precisely compute the probability of being in such a situa-
more, competing trees end up with the same total value and tion. However it seems to occur very unlikely: rotating any
the same number of modules. This might happen at the end module on a border (with at least one open connection) will
of the algorithm when only two trees are remaining. break the symmetry and there is no selected orientation of
When the system has three trees where two are having the modules. The ”no leader” situation was never observed
the same values and a third one with a different value, in any of the experiments executed.
this is not called a symmetry because the third tree will Nevertheless, it may be possible to improve the algo-
be loosing or winning against one of the two trees. This rithm to fix this problem with a high probability in the
following way. When a blocking situation with no leader values, computing a sum, etc. Those operations are assumed
is detected (that may be done using a time counter), a new to take linear time O(1).
stage starts. From each leaf a message is sent to the root
with all the information in order to provide to the root the 6.1.1. Upper Bound.
whole structure of the tree. Then, this complete structure is Proposition 4. In the worst case scenario, the leadership
broadcast to the leaves. election algorithm will work in time Θ(n2 ) and Θ(n2 )
Now, a new challenging procedure can start by tree messages will be sent. The total number of elementary
comparisons (rather than just weights and numbers of nodes) operations is also Θ(n2 ).
using any tree order (for instance a lexicographic order).
With this new algorithm, it may also happen that there is As previously discussed, the algorithm will be executing
no leader election: when all the involved trees are exactly in multiple steps. Below is an in-depth explanation of each
the same. Considering that a shape is a connected graph on step, with relation to its complexity:
the grid with an orientation of each node, it is possible to 1) Integer number generation: This Step, done in par-
estimate the probability of non termination on the uniform allel by each module, is done in time O(1) and
distribution over equivalent shapes (two shapes are equiv- requires a total of O(n) operations. No messages
alent if there exists a combination of rotation, translation, are sent in this step, hence the message complexity
reflection or glide reflection transforming one shape to the is null.
other one). 2) Recruitment phase: Each module sends O(1) mes-
Since for large n rotations are very unlikely,n
it might sages: there is a total of O(n) messages sent. Each
be estimated that there are about sn = c (4λ) n different module performs O(1) operations and the broadcast
shapes [25], with c close to 3 and λ close to 4. Now, under ends in time O(n).
these hypotheses, the number of shapes with n nodes that 3) Tree value computation: As in the previous step, the
can be split into k exactly equal trees is less or equal to tree value computation is performed in time O(n),
s nk ( 4n k k
k ) 4 : s k is the number of ways to chose the tree and
n each module performing O(1) operations. There are
4n k also O(n) sent messages.
( k ) an upper bound on how to put the k copies of this
tree together and the 4k is for the possible orientations for 4) Competition and dismantling trees: Similarly to
each tree. steps 2 and 3, this step is performed in O(n) time.
It results that the probability a shape can be divided Each module performs O(1) operations. Further-
s knk 4k more, O(n) messages are sent.
into k equal trees is bounded by n/k sn ≤ n k−1
, which
kk (4λ) k 5) Leader election phase. This phase has an identical
is exponentially small. Since k may vary at most from 2 complexity as the previous phases. Therefore, this
to n/2, one can estimate that the probability that this new phase is done in O(n) since each module is per-
algorithm doesn’t find any leader is exponentially small. forming an O(1) operation. Also this phase has a
The algorithm proposed in the previous paragraph has message complexity of O(n) since each leaf report
not been implemented. It is important to point out that if a back to its parent, until the message reaches the
blocking situation is critical, the algorithm can be modified root.
in order to works with an estimated high probability.
Steps two through four may be repeating. But at each
6. Complexity analysis stage, the number of trees is decreasing. Therefore, since
there are at most n trees, these steps can be repeated at
The purpose of this section is to explore the complexity most n times.
analysis of the algorithm developed in the previous section. In conclusion, the algorithms works in time O(n2 ) and
This section will first explore the theoretical complexity O(n2 ) messages are being sent. Moreover the total number
analysis of the algorithm. It will then go on to explore of performed elementary operations is also O(n2 ).
the empirical study of the complexity of the algorithm.
This section will prove that although the algorithm has a 6.1.2. Lower Bound. For the lower bound analysis, a two-
theoretical complexity O(n2 ) in the worst case, it is actually dimensional configuration is used, but the proof is easily
O(n) in most of the cases. generalized for other contexts. Considering that n = 3m,
each module is identified by an integer from 0 to 3m − 1.
Modules are placed on the grid by blocks of 3 as follows
6.1. Theoretical analysis (note that all blocks are similar except the one on the left
and the one on the right; see Figure 7 for an illustration):
The time complexity of an algorithm is analyzed when
at least one module starts executing the algorithm. The time • Modules of the from 3i with 0 ≤ i ≤ n − 1,
complexity depends on T1 , T2 , . . . , Tn where T is the are placed respectively on positions (2i, 1). They all
execution time in each module and n the total number of have their interface 1 connected.
modules. • Modules of the form 3i + 1, with 0 ≤ i ≤ n − 1,
The analysis is based on counting elementary operations: are placed respectively on positions (2i, 0). Module
sending a message, checking an interface, comparing two 1 has interfaces 3 and 4 connected. Module 3m − 2
1 1 1 1
2 0 4 2 3 4 2 6 4 2 9 4
3 3 3 3

4 2 2 3
1 3 4 2 2 3 4 1 3 5 1 3 7 1 3 8 1 4 10 2 1 11

Figure 7: Example of initial configuration with m = 4.

has interfaces 2, 3 and 4 connected. All others (for (a) Shape 1 (b) Shape 2 (c) Shape 3
1 ≤ i ≤ n−2) have interfaces 1, 2, and 3 connected.
• Modules of the form 3i + 2, with 0 ≤ i ≤ n − 1 are Figure 8: The 3 configurations of Blinky Blocks used in the
placed respectively on positions (2i + 1, 0). Module simulation
2 have interfaces 2 and 4 connected. Modules 3m−1
have interface 1 connected. All others (for 1 ≤ i ≤
n − 2) have interfaces 1, 2, and 3 connected. A series of simulations were executed on VisibleSim [27],
a simulator dedicated to modular robots. The linked video2
It may occure that the recruitment phase ends up with shows a running of the algorithm on a simple configuration
m − 1 three modules trees. Each tree will have the modules recorded from VisibleSim simulator in 3D. In those simula-
{3i, 3i + 1, 3i + 2} where 0 ≤ i ≤ m. Starting from the tions, different modular robots system shapes are considered
left side, the tree {0, 1, 2} has a weight of 23. On the right while varying the number of the modules in the system as
side of the graph, the system might endup with {9, 10} and shown in Figure 8. The shapes were increased in size after
{11}, or {9} and {10, 11}. In either case, the tree containing each simulation to be able to analyze the complexity based
two modules will have a weight of 15. The middle of the on the total number of connected modules. Furthermore,
graph contains the trees with a weight equals to 13. The the following subsection will discuss the time and message
dismanteling process will start from both end of the graph complexity of the proposed algorithm while comparing it
at the same time. In other terms, the tree {0, 1, 2} will take with the existing deterministic algorithm presented by Emek
over {3, 4, 5} and at the same time the tree {9, 10} will take et al in [20] since it is the closest to the proposed algorithm.
over {11} and {6, 7, 8}. The system now has two trees only.
Tree A containing {0, 1, 2, 3, 4, 5} and tree B containing 6.2.1. Time complexity analysis. In this section the time
{6, 7, 8, 9, 10, 11}. A has a weight of 36 and tree B has a complexity of the algorithm is studied. In other words, the
weight of 29. Therefore, A takes over B . In this unlikely execution time needed by the algorithm to find one leader.
context, steps 2 to 4 are repeated m−1 2 times (for large m). Three different shapes are considered (random (shape1),
After the k -th iterations, the depth of the dominating tree is Square (shape2) and line (shape3)) as shown in Figure 8
2k and, therefore, Θ(k) messages and a time in Θ(k) are and it is compared to the work presented in [20]. In order to
required, proving the lower bound. confirm the linearity of the results, a regression line is drawn
in each graph using the least square regression method based
6.2. Empirical analysis on the average value gathered during the simulation.

To study the complexity of the contributed algorithm, 2.5


10 5

Shape 1
Shape 2
The method presented in [26] is followed. The authors 2
Shape 3
Mean
Regression line

defined the efficiency of a distributed algorithm with at


Elapsed time in s

1.5

least one out of three conventional distributed complexity


measures: 1

0.5

• Time complexity (number of rounds for synchronous


algorithms) 0
0 200 400 600 800
Number of modules
1000 1200 1400

• Communication or bit complexity (overall range of


bits transmitted) Figure 9: Execution time Vs. number of modules
• Message complexity (total number of messages
transmitted). Figure 9 shows the obtained results of the time needed to
finish the execution versus the number of modules presented
Depending on the scenario, one or another measure in the system. First, this figure shows that for the same num-
might be more relevant. The bit complexity will be dropped ber of modules the execution time remains almost the same
in this analysis, since the size of the messages sent in while varying the shape of the modular robot. Furthermore
programmable matter is considered to be negligible. as expected, it is noticeable that the execution time increases
The modules used in the simulations are Blinky Blocks in in a linear manner with the number of modules. The co-
2D but the algorithm should work on all types of modules. efficient of determination of the regression line in Figure
At the initial state, all modules are identical. In 2D, the 9 has a value of 97.5%. In another word, the regression
Blinky Blocks has 4 connections numbered from 1 to 4.
Each module is aware of the interfaces that are connected. 2. YouTube: https://youtu.be/jW6Qnuw4hIo
line drawn is considered to be 97.5% accurate. Therefore needs far fewer messages exchanged between modules in
the time complexity is considered to be linear with high order to elect a leader.
accuracy.
10 5

To compare the proposed work to the literature, the 18


ELECTOR
Emek et al
16

algorithm presented in [20] was implemented under the 14

same conditions as the proposed algorithm. The results of

Number of messages exchanged


12

the execution time are shown in Figure 10. It is clearly 10

shown that the proposed algorithm outperforms the approach 6

presented in [20] in terms of execution time as well as in 4

terms of event processing and energy consumption since 0


0 200 400 600 800 1000 1200 1400

in [20] the modules should move physically in order to find Number of modules

one leader. Figure 12: Message complexity comparison between the


proposed algorithm and [20]
5
10

ELECTOR
15 EMEK et al
Elapsed time in s

10 7. Conclusion and future work


5
This paper presented a fast, reliable and robust leader
0 election algorithm for modular robots. Conversely to ex-
0 200 400 600 800 1000 1200 1400
Number of modules isting work, the proposed algorithm ends up with a leader
Figure 10: Time complexity comparison between the pro- elected in high probability. It does not use random number
posed algorithm and [20] generation. It works on 2D and 3D systems and has a
complexity of O(n2 ) in the worst case and a complexity
of θ(n) in the average case. Both theoretical and empirical
analysis were presented in this chapter. The Theoretical
6.2.2. Message complexity analysis. In this section the analysis showed that the algorithm has a squared complexity,
message complexity of the proposed algorithm is discussed whereas the empirical analysis showed that the complexity
(i.e. the number of exchanged messages between modules is linear. An in-depth study showed that the reason behind
before electing one leader). Figure 11 shows the number of the linear complexity is that the worst case is almost never
messages exchanged to finish the execution of the algorithm attainable. Therefore, the random simulations that we ran
on the simulator versus the number of modules presented never encountered the worst case.
in the system. Similarly to the time complexity analysis, it The proposed algorithm is a six phases-based algorithm.
is clear that for the same number of modules the number First, the modules generate integers based on the number of
of the exchanged messages remains almost the same while connected interfaces. After that, spanning trees are created
varying the shape of the modular robot. Furthermore, the using a recruitment method. The generated spanning trees
number of the exchanged messages increases linearly with compete and the loosing trees are dismantled until one tree
the number of modules. The coefficient of determination of remains, and a leader is elected. The simulation results show
the graph in Figure 11 has a value of 97.8%. In another the efficiency of the proposed algorithm.
word, the regression line drawn is considered to be 97.8%
In a future work, a theoretically study on the impact
accurate. Therefore the message complexity of the proposed
of the delays on the execution of the algorithms could
algorithm is considered linear as well with high accuracy.
be presented, and vary the parameters in function of the
diameter of the network and the speed of the message
12000
Shape 1
Shape 2
Shape 3
Mean
propagation in the system.
10000 Regression line
Number of messages exchanged

8000

6000
References
4000

2000 [1] Seth Copen Goldstein, Jason D. Campbell, and Todd C. Mowry.
0
Programmable matter. IEEE Computer, 38(6):99–101, June 2005.
0 200 400 600 800 1000 1200 1400
Number of modules

[2] A. Naz, B. Piranda, J. Bourgeois, and S. C. Goldstein. Electing an


Figure 11: Number of messages exchanged Vs. the number approximate center in a huge modular robot with the k-bfs sumsweep
algorithm. In 2018 IEEE/RSJ International Conference on Intelligent
of modules Robots and Systems (IROS), pages 4825–4832, 2018.

Figure 12 shows a comparison of the proposed approach [3] André Naz, Benoı̂t Piranda, Julien Bourgeois, and Seth Copen Gold-
stein. A time synchronization protocol for large-scale distributed em-
and the one proposed in [20] in terms of message complex- bedded systems with low-precision clocks and neighbor-to-neighbor
ity. Once again, it is clearly noticeable that the proposed communications. Journal of Network and Computer Applications,
algorithm outperforms the approach presented in [20] and 105:123 – 142, 2018.
[4] Damien Woods, Ho-Lin Chen, Scott Goodfriend, Nadine Dabby, Erik [21] Rida Bazzi and Joseph L. Briones. Brief announcement: Deterministic
Winfree, and Peng Yin. Active self-assembly of algorithmic shapes leader election in self-organizing particle systems. In Stabilization,
and patterns in polylogarithmic time. In Proceedings of the 4th Safety, and Security of Distributed Systems - 20th International Sym-
conference on Innovations in Theoretical Computer Science, pages posium, Lecture Notes in Computer Science, pages 381–386, 2018.
353–354. ACM, 2013.
[22] Zahra Derakhshandeh. Algorithmic Foundations of Self-Organizing
[5] Matthew J. Patitz. An introduction to tile-based self-assembly. In Programmable Matter. PhD thesis, Arizona State University, 2017.
Unconventional Computation and Natural Computation, pages 34– [23] Cem Ünsal, Han Kiliççöte, and Pradeep K. Khosla. A modular self-
62. Springer Berlin Heidelberg, 2012. reconfigurable bipartite robotic system: Implementation and motion
[6] Giuseppe A Di Luna, Paola Flocchini, Nicola Santoro, Giovanni planning. Autonomous Robots, 10(1):23–40, Jan 2001.
Viglietta, and Yukiko Yamauchi. Shape formation by programmable [24] N Rama Devi, G Uma, TS Praveena, and M Naga Jyothi. Emerging
particles. Distributed Computing, pages 1–33, 2019. and challenging applications in swarm robotics. Int J Eng Sci, 2:318–
[7] Yao Lu, Jianping Chen, Ioan Comsa, Pierre Kuonen, and Beat Hirs- 321, 2013.
brunner. Construction of data aggregation tree for multi-objectives in [25] Iwan Jensen and Anthony J Guttmann. Statistics of lattice animals
wireless sensor networks through jump particle swarm optimization. (polyominoes) and polygons. Journal of Physics A: Mathematical
Procedia Computer Science, 35:73–82, 2014. and General, 33(29):L257–L263, jul 2000.
[8] Nicolas Gastineau, Wahabou Abdou, Nader Mbarek, and Olivier [26] Johannes Schneider and Roger Wattenhofer. Trading bit, message, and
Togni. Distributed leader election and computation of local identifiers time complexity of distributed algorithms. In Distributed Computing,
for programmable matter. In International Symposium on Algorithms pages 51–65, 2011.
and Experiments for Sensor Systems, Wireless Networks and Dis-
[27] Visiblesim. https://projects.femto-st.fr/projet-visiblesim/en. Ac-
tributed Robotics, pages 159–179. Springer, 2018.
cessed: 2020-03-31.
[9] Nikita Pavliuk, Anton Saveliev, Ekaterina Cherskikh, and Dmitriy
Pykhov. Formation of modular structures with mobile autonomous
reconfigurable system. In Proceedings of 14th International Con-
ference on Electromechanics and Robotics “Zavalishin’s Readings”,
pages 383–395. Springer, 2020.
[10] Serhat Ikizoglu, Gokhan Ozer, and Omer C Sari. Improving the
functionality and performance of m-tran robots by constructional
flexibility. Int. Jour. of Robotics and Automation, 35(1), 2020.
[11] Xin ZHANG and Yan-qiong FEI. A self-repair algorithm for self-
reconfigurable modular robots based on geometrical characteristics.
Journal of Shanghai Jiaotong University, 2008, 7, 2008.
[12] Thadeu Tucci, Benoı̂t Piranda, and Julien Bourgeois. A distributed
self-assembly planning algorithm for modular robots. In Proceedings
of the 17th International Conference on Autonomous Agents and
MultiAgent Systems, AAMAS 2018, pages 550–558, 2018.
[13] Pierre Thalamy, Benoı̂t Piranda, and Julien Bourgeois. Distributed
self-reconfiguration using a deterministic autonomous scaffolding
structure. In Proceedings of the 18th International Conference on
Autonomous Agents and MultiAgent Systems, AAMAS ’19, Montreal,
QC, Canada, May 13-17, 2019, pages 140–148, 2019.
[14] Victor Andreev and Pavel Pletenev. Organizing network interaction
in modular robot with multilevel control system. Annals of DAAAM
& Proceedings, 2020, 30, 2019.
[15] Chih-Han Yu, Justin K Werfel, and Radhika Nagpal. Collective
decision-making in multi-agent systems by implicit leadership. As-
sociation for Computing Machinery Press, 2010, 2010.
[16] Feng Jiang, Yongyang Cheng, Changkun Dong, and Erdong Yu.
A novel weight-based leader election approach for split brain in
distributed system. In IOP Conference Series: Materials Science and
Engineering, page 012005. IOP Publishing, 2020.
[17] Scott D Stoller. Leader election in asynchronous distributed systems.
IEEE transactions on computers, 49(3):283–284, 2000.
[18] Dana Angluin. Local and global properties in networks of processors.
In Proceedings of the twelfth annual ACM symposium on Theory of
computing, pages 82–93, 1980.
[19] Joshua J Daymude, Robert Gmyr, Andréa W Richa, Christian Schei-
deler, and Thim Strothmann. Leader election with high probability for
self-organizing programmable matter. CoRR, abs/1701.03616, 2017.
[20] Yuval Emek, Shay Kutten, Ron Lavi, and William K Moses Jr. Deter-
ministic leader election in programmable matter. In 46th International
Colloquium on Automata, Languages, and Programming. Schloss
Dagstuhl-Leibniz-Zentrum fuer Informatik, 2019.

You might also like