Skip to content

Commit 22f4f58

Browse files
committed
TopologyManipulation changes
1 parent 2868de5 commit 22f4f58

4 files changed

Lines changed: 208 additions & 63 deletions

File tree

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.doit.db
2+
__pycache__/conf.cpython-310.pyc
3+
cache/
4+
output/
5+
**pyc

conf.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@
195195
# 'html' assumes the file is html and just copies it
196196
COMPILERS = {
197197
"rest": ('.rst', '.txt'),
198-
"markdown": ('.md', '.mdown', '.markdown'),
198+
#"markdown": ('.md', '.mdown', '.markdown'),
199199
"textile": ('.textile',),
200200
"txt2tags": ('.t2t',),
201201
"bbcode": ('.bb',),
@@ -209,7 +209,7 @@
209209
# Pandoc detects the input from the source filename
210210
# but is disabled by default as it would conflict
211211
# with many of the others.
212-
# "pandoc": ('.rst', '.md', '.txt'),
212+
"pandoc": ( '.md', '.mdown','.markdown'),
213213
}
214214

215215
# Create by default posts in one file format?
@@ -551,20 +551,20 @@
551551
# MATHJAX_CONFIG = ""
552552

553553
# If you are using the compile-ipynb plugin, just add this one:
554-
# MATHJAX_CONFIG = """
555-
# <script type="text/x-mathjax-config">
556-
# MathJax.Hub.Config({
557-
# tex2jax: {
558-
# inlineMath: [ ['$','$'], ["\\\(","\\\)"] ],
559-
# displayMath: [ ['$$','$$'], ["\\\[","\\\]"] ]
560-
# },
561-
# displayAlign: 'left', // Change this to 'center' to center equations.
562-
# "HTML-CSS": {
563-
# styles: {'.MathJax_Display': {"margin": 0}}
564-
# }
565-
# });
566-
# </script>
567-
# """
554+
MATHJAX_CONFIG = """
555+
<script type="text/x-mathjax-config">
556+
MathJax.Hub.Config({
557+
tex2jax: {
558+
inlineMath: [ ['$','$'], ["\\\(","\\\)"] ],
559+
displayMath: [ ['$$','$$'], ["\\\[","\\\]"] ]
560+
},
561+
displayAlign: 'left', // Change this to 'center' to center equations.
562+
"HTML-CSS": {
563+
styles: {'.MathJax_Display': {"margin": 0}}
564+
}
565+
});
566+
</script>
567+
"""
568568

569569
# Do you want to customize the nbconversion of your IPython notebook?
570570
# IPYNB_CONFIG = {}
@@ -577,7 +577,7 @@
577577
# done in the code, hope you don't mind ;-)
578578
# Note: most Nikola-specific extensions are done via the Nikola plugin system,
579579
# with the MarkdownExtension class and should not be added here.
580-
MARKDOWN_EXTENSIONS = ['extra','toc']
580+
MARKDOWN_EXTENSIONS = ['extra','toc','markdown.extensions.extra']
581581

582582
# Social buttons. This is sample code for AddThis (which was the default for a
583583
# long time). Insert anything you want here, or even make it empty.
409 KB
Loading

pages/papers/TopologyManipulation.md

Lines changed: 186 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313

1414
We provide extra information for the experiments and results in the paper.
1515

16-
<!-- \section{Appendix}\label{Appendix}
17-
In this section, we provide extra information required for replicating the results in Section~\ref{sec:Exp} and the simulation codes are available on our repository\footnote{\href{https://git.mistlab.ca/skarthik/local-operations-on-trees}{https://git.mistlab.ca/skarthik/local-operations-on-trees}}. -->
1816

17+
***
18+
19+
## Decentralised rules for robots swarms to form Line and Star
1920

20-
## Decentralised rules for robots to form Line and star
2121
***
2222

2323
### 1. Line formation
@@ -28,7 +28,7 @@ The line topology is a special topology, where all the robots have either one ne
2828

2929
* Robots with exactly two neighbors try to straighten the angle between their neighbors by moving towards a direction so as to reduce the obtuse angle.
3030

31-
The parameters used for line formation experiment are $R_{transfer} = 1m$, *R_{mission} = 1.5m*, $R_{range} = 2.5m$.
31+
The parameters used for line formation experiment are $R_{transfer} = 1m$, $R_{mission} = 1.5m$, $R_{range} = 2.5m$.
3232

3333
***
3434

@@ -40,11 +40,17 @@ We consider a single root star formation. In star topology, all the robots excep
4040

4141
This table shows the parameters used in the star formation experiments.
4242

43-
No of robots | $R_{range}$(m) | $R_{transfer}$(m) | $R_{Mission}$ |
44-
------------- | ------------- | ------------- | ------------- |
45-
15 | 2.5 | 1 | 1.5 |
46-
30 | 5 | 2 | 3 |
47-
60 | 10 | 4 | 6 |
43+
***
44+
45+
+--------------+-----------------+-------------------+----------------+
46+
| No of robots | $R_{range}$(m) | $R_{transfer}$(m) | $R_{Mission}$ |
47+
+--------------+-----------------+-------------------+----------------+
48+
| 15 | 2.5 | 1 | 1.5 |
49+
+--------------+-----------------+-------------------+----------------+
50+
| 30 | 5 | 2 | 3 |
51+
+--------------+-----------------+-------------------+----------------+
52+
| 60 | 10 | 4 | 6 |
53+
+--------------+-----------------+-------------------+----------------+
4854

4955
***
5056

@@ -55,68 +61,195 @@ No of robots | $R_{range}$(m) | $R_{transfer}$(m) | $R_{Mission}$ |
5561

5662
This shows an example as to how to use the prufer sequences and the operations to converrt from any initial tree to final tree.
5763

58-
![Example-12](https://user-images.githubusercontent.com/47322496/179253692-27db898f-b635-484e-ba93-de5220ed956e.png)
64+
<img src="/papers/TopologyManipulation/Example-12.png" alt="NSERC" height="1500px" width="900px" />
65+
5966

6067
***
6168

62-
### `test_theorem.ipynb`
69+
### [test_theorem.ipynb](https://git.mistlab.ca/skarthik/local-operations-on-trees/-/blob/main/python-scripts/test_theorem.ipynb)
6370

6471
In order to verify transformation of trees, we implemented a script in python which verifies the conversion of all possible topologies for a swarm of size 10 to a specific random topology. We also verify that from a random topology it is possible to convert to all other possible topologies.
6572

73+
74+
75+
```
76+
def sequence_output(input_prufer,final_prufer,plot=False):
77+
78+
A_input,input_leaves = visualizeP2A(input_prufer,plot=plot,title="Input")
79+
A_final,final_leaves = visualizeP2A(final_prufer,plot=plot,title="Output")
80+
81+
i = 0
82+
for i in range(len(input_prufer)):
83+
if i == 0:
84+
if not is_leaf(A_input,final_leaves[i]-1): #if the first leaf of final tree is not a leaf
85+
neighbour = np.nonzero(A_input[final_leaves[i]-1])[0][0]
86+
#if the first leaf of the final tree is not a leaf in the first leaf leaflize it.
87+
temp_a = leaflize(A_input,final_leaves[i]-1,neighbour)
88+
title = "Leaflize: "+str(final_leaves[i])+" with: "+str(neighbour+1)
89+
_ = visualizeA2P(temp_a,prufer_flag=True,plot=plot,title=title)
90+
91+
if temp_a[final_leaves[i]-1][final_prufer[i]-1] == 0: #if the created leaf is not connected to the final prufer do a leaf transfer.
92+
neighbour = np.nonzero(temp_a[final_leaves[i]-1])[0][0]
93+
temp_a = leaftransfer(temp_a,neighbour,final_leaves[i]-1,final_prufer[i]-1)
94+
title = "Leaftransfer: leaf: "+str(final_leaves[i])+" from: "+str(neighbour+1)+" to: "+str(final_prufer[i])
95+
_ = visualizeA2P(temp_a,prufer_flag=True,plot=plot,title=title)
96+
97+
elif is_leaf(A_input,final_leaves[i]-1): #if it is a leaf
98+
if A_input[final_leaves[i]-1][final_prufer[i]-1] == 0: #if it is not connected to final prufer do a leaf transfer
99+
neighbour = np.nonzero(A_input[final_leaves[i]-1])[0][0]
100+
temp_a = leaftransfer(A_input,neighbour,final_leaves[i]-1,final_prufer[i]-1)
101+
title = "Leaftransfer: leaf: "+str(final_leaves[i])+" from: "+str(neighbour+1)+" to: "+str(final_prufer[i])
102+
_ = visualizeA2P(temp_a,prufer_flag=True,plot=plot,title=title)
103+
104+
105+
else: # good to proceed
106+
temp_a = np.copy(A_input)
107+
108+
elif i>0:
109+
if is_leaf(temp_a,final_leaves[i]-1):
110+
if temp_a[final_leaves[i]-1][final_prufer[i]-1] == 0: #if the leaf is not connected to the final prufer do a leaf transfer.
111+
neighbour = np.nonzero(temp_a[final_leaves[i]-1])[0][0]
112+
temp_a = leaftransfer(temp_a,neighbour,final_leaves[i]-1,final_prufer[i]-1)
113+
title = "Leaftransfer: leaf: "+str(final_leaves[i])+" from: "+str(neighbour+1)+" to: "+str(final_prufer[i])
114+
_ = visualizeA2P(temp_a,prufer_flag=True,plot=plot,title=title)
115+
116+
elif not is_leaf(temp_a,final_leaves[i]-1):
117+
all_neighbours = np.nonzero(temp_a[final_leaves[i]-1])[0]
118+
neighbours = np.setdiff1d(all_neighbours,np.subtract(final_leaves[0:i],np.ones(len(final_leaves[0:i]),dtype=int)))
119+
branches_to_keep = np.intersect1d(all_neighbours,np.subtract(final_leaves[0:i],np.ones(len(final_leaves[0:i]),dtype=int)))
120+
if len(neighbours) == 1: # the subtree is a leaf
121+
if temp_a[final_leaves[i]-1][final_prufer[i]-1] == 0: #if the created leaf is not connected to the final prufer do a leaf transfer.
122+
neighbour = neighbours[0]
123+
temp_a = leaftransfer(temp_a,neighbour,final_leaves[i]-1,final_prufer[i]-1)
124+
title = "Leaftransfer: leaf: "+str(final_leaves[i])+" from: "+str(neighbour+1)+" to: "+str(final_prufer[i])
125+
_ = visualizeA2P(temp_a,prufer_flag=True,plot=plot,title=title)
126+
127+
elif len(neighbours) > 1: #leaflize the superleaf
128+
temp_a = leaflize(temp_a,final_leaves[i]-1,neighbours[0],branches_to_keep)
129+
title = "Leaflize: "+str(final_leaves[i])+" with: "+str(neighbours[0]+1)
130+
_ = visualizeA2P(temp_a,prufer_flag=True,plot=plot,title=title)
131+
132+
if temp_a[final_leaves[i]-1][final_prufer[i]-1] == 0: #if the created leaf is not connected to the final prufer do a leaf transfer.
133+
neighbour = neighbours[0]
134+
temp_a = leaftransfer(temp_a,neighbour,final_leaves[i]-1,final_prufer[i]-1)
135+
title = "Leaftransfer: leaf: "+str(final_leaves[i])+" from: "+str(neighbour+1)+" to: "+str(final_prufer[i])
136+
_ = visualizeA2P(temp_a,prufer_flag=True,plot=plot,title=title)
137+
138+
if i == len(input_prufer)-1:
139+
P = visualizeA2P(temp_a,prufer_flag=True,plot=False)
140+
if (P == final_prufer):
141+
print("input_prufer: " + str(input_prufer) + " final_prufer: "+ str(final_prufer)+" success: "+"True")
142+
return True
143+
else:
144+
print("input_prufer: " + str(input_prufer) + " final_prufer: "+ str(final_prufer)+" success: "+"False")
145+
return False
146+
147+
```
148+
149+
66150
***
67151

68-
### `test_theorem_line_star.ipynb`
152+
### [test_theorem_line_star.ipynb](https://git.mistlab.ca/skarthik/local-operations-on-trees/-/blob/main/python-scripts/test_theorem_line_star.ipynb)
69153

70154

71155
We also have verified this algorithm in a python script where starting from any random topology we were able to form a star/line for a swarm of size 10 for all the possible $10^8$ combinations.
72156

157+
```
158+
def line(input_prufer,plot=False):
159+
160+
temp_a,_ = visualizeP2A(input_prufer,plot=plot,title="Input")
161+
num_neighbours = np.matmul(temp_a,np.ones((temp_a.shape[0],1))).reshape(-1)
162+
prev_leaf_transfer = np.ones(temp_a.shape[0])*-1
163+
164+
while np.count_nonzero(num_neighbours > 2)>0:
165+
leaf_transferers = np.argwhere(num_neighbours>=3).reshape(-1)
166+
np.random.shuffle(leaf_transferers)
167+
168+
for leaf_transferer in leaf_transferers:
169+
neighbours = np.argwhere(temp_a[leaf_transferer]==1).reshape(-1)
170+
np.random.shuffle(neighbours)
171+
leaf = neighbours[0]
172+
to_exclude = np.array([leaf,prev_leaf_transfer[leaf]])
173+
neighbours_to_transfer = np.setdiff1d(neighbours,to_exclude)
174+
np.random.shuffle(neighbours_to_transfer)
175+
neighbour_to_transfer = neighbours_to_transfer[0]
176+
prev_leaf_transfer[leaf] = leaf_transferer
177+
temp_a = leaftransfer(temp_a,leaf_transferer,leaf,neighbour_to_transfer)
178+
_ = visualizeA2P(temp_a,prufer_flag=True,plot=plot,title=title)
179+
180+
num_neighbours = np.matmul(temp_a,np.ones((temp_a.shape[0],1))).reshape(-1)
181+
182+
return np.matmul(temp_a,np.ones((temp_a.shape[0],1))).reshape(-1)
183+
184+
```
185+
186+
```
187+
188+
def star(root,input_prufer,plot=False):
189+
root = root
190+
input_prufer = input_prufer
191+
n = len(input_prufer) + 2
192+
temp_a,_ = visualizeP2A(input_prufer,plot=plot,title="Input")
193+
neighbours_root = np.argwhere(temp_a[root]==1).reshape(-1)
194+
195+
while len(neighbours_root) < n - 1:
196+
for neighbour in neighbours_root:
197+
if not is_leaf(temp_a,neighbour):
198+
title = "leaflize: " + str(neighbour+1) + " with " + str(root+1)
199+
temp_a = leaflize(temp_a,neighbour,root)
200+
visualizeA2P(temp_a,prufer_flag=True,plot=plot,title=title)
201+
neighbours_root = np.argwhere(temp_a[root]==1).reshape(-1)
202+
203+
return np.matmul(temp_a,np.ones((temp_a.shape[0],1))).reshape(-1)
204+
205+
```
206+
73207
***
74208

75209
## Supplementary plots for the experiments
76210

77211
![DARS2022_paper_9102-2-10(1)](https://user-images.githubusercontent.com/47322496/190194702-f57e9ee3-b5fd-492a-ba48-8d9bb8b18aff.png)
78212
![DARS2022_paper_9102-2-11(1)](https://user-images.githubusercontent.com/47322496/190194705-6338c10d-d549-4aae-845b-ff5c8a79aaa7.png)
79213

80-
% Figures~\ref{fig:line_formation} and \ref{fig:star_formation} depict
81-
% $\lambda_2$, coverage area, and progress of operations. We plot the time
82-
% evolution of $\lambda_2$ of the graph and the maintained spanning tree, as a connectivity index and a parameter specifying consensus rate.
83-
84-
% The evolution of the number of nodes with $\text{degree(robot)}=1$ (i.e., having only one
85-
% neighbor) and $\text{degree(robot)}=2$ is sketched for the line formation and
86-
% the evolution of the number of nodes with $\text{degree(robot)}=1$ and nodes
87-
% with $\text{degree(robot)}\geq2$ for the star formation, which is a progress
88-
% index in each case. The $\lambda_2$ of the manipulated spanning tree and the
89-
% whole graph examine the connectivity awareness of our method which has to stay
90-
% greater than zero over the experiment. In the specific case of line, $\lambda_2$
91-
% of the tree reduces with time and reaches a constant value when the line has
92-
% been straightened out. Also, $\lambda_2$ of the graph will approach the same
93-
% value, if $R_{\text{mission}}$ is close to $R_{\text{range}}$, which is the minimum for a
94-
% given connected graph of $N$ nodes. However, In the case of the star topology,
95-
% $\lambda_2$ of the tree increases to a constant value of one at the end of the
96-
% experiment no matter the number of nodes in the system, and the $\lambda_2$ of
97-
% the graph increases. If $R_{\text{mission}}<R_{\text{range}}/2$ it would have approached an
98-
% all to all graph which has the maximum $\lambda_2$ for a given connected graph
99-
% of $N$ nodes. The coverage area has been shown to decrease for the star and to
100-
% increase for the line case which is showing the trade-off between $\lambda_2$
101-
% and the coverage area and that is why topology manipulation is needed to provide
102-
% flexibility. Furthermore, for the star formation, we have plotted the number of
103-
% nodes with $\text{degree(robot)}=1$ and the number of nodes with
104-
% $\text{degree(robot)}\geq2$. This is to show that the manipulation operations
105-
% are changing the topology closer to the star topology with time. The number of
106-
% nodes with $\text{degree(robot)}=1$ for the star case increases to $N-1$ and
107-
% there is exactly one node that has $N-1$ neighbors, which is the root. The plots
108-
% show the evolution of these metrics which is increasing for the number of nodes
109-
% with $\text{degree(robot)}=1$ and decreasing for the number of nodes with
110-
% $\text{degree(robot)}\geq2$. For line formation, we have shown a similar metric
111-
% that reduces to 2 for the number of nodes $\text{degree(robot)}=1$ and increases
112-
% to $N-2$ for the number of nodes $\text{degree(robot)}=2$ which is the
113-
% definition of a line topology.
214+
Figures 3 and 4 depict $\lambda_2$, coverage area, and progress of operations. We plot the time
215+
evolution of $\lambda_2$ of the graph and the maintained spanning tree, as a connectivity index and a parameter specifying consensus rate.
216+
The evolution of the number of nodes with $\text{degree(robot)}=1$ (i.e., having only one
217+
neighbor) and $\text{degree(robot)}=2$ is sketched for the line formation and
218+
the evolution of the number of nodes with $\text{degree(robot)}=1$ and nodes
219+
with $\text{degree(robot)}\geq2$ for the star formation, which is a progress
220+
index in each case. The $\lambda_2$ of the manipulated spanning tree and the
221+
whole graph examine the connectivity awareness of our method which has to stay
222+
greater than zero over the experiment. In the specific case of line, $\lambda_2$
223+
of the tree reduces with time and reaches a constant value when the line has
224+
been straightened out. Also, $\lambda_2$ of the graph will approach the same
225+
value, if $R_{\text{mission}}$ is close to $R_{\text{range}}$, which is the minimum for a
226+
given connected graph of $N$ nodes. However, In the case of the star topology,
227+
$\lambda_2$ of the tree increases to a constant value of one at the end of the
228+
experiment no matter the number of nodes in the system, and the $\lambda_2$ of
229+
the graph increases. If $R_{\text{mission}}<R_{\text{range}}/2$ it would have approached an
230+
all to all graph which has the maximum $\lambda_2$ for a given connected graph
231+
of $N$ nodes. The coverage area has been shown to decrease for the star and to
232+
increase for the line case which is showing the trade-off between $\lambda_2$
233+
and the coverage area and that is why topology manipulation is needed to provide
234+
flexibility. Furthermore, for the star formation, we have plotted the number of
235+
nodes with $\text{degree(robot)}=1$ and the number of nodes with
236+
$\text{degree(robot)}\geq2$. This is to show that the manipulation operations
237+
are changing the topology closer to the star topology with time. The number of
238+
nodes with $\text{degree(robot)}=1$ for the star case increases to $N-1$ and
239+
there is exactly one node that has $N-1$ neighbors, which is the root. The plots
240+
show the evolution of these metrics which is increasing for the number of nodes
241+
with $\text{degree(robot)}=1$ and decreasing for the number of nodes with
242+
$\text{degree(robot)}\geq2$. For line formation, we have shown a similar metric
243+
that reduces to 2 for the number of nodes $\text{degree(robot)}=1$ and increases
244+
to $N-2$ for the number of nodes $\text{degree(robot)}=2$ which is the
245+
definition of a line topology.
114246

115247

116248

117249

118250
## Setting up the simlations for Line and Star in Argos3 and Buzz.
119251

252+
The code for the experiments can be found [here](https://git.mistlab.ca/skarthik/local-operations-on-trees).
120253
ARGoS3 Simulator ARGoS3 simulator can also be installed from binaries please refer to the official website for more information: https://www.argos-sim.info/
121254
The instructions below are for installing ARGoS3 from its source.
122255
Official code repository: https://github.com/ilpincy/argos3
@@ -186,3 +319,10 @@ argos3 -c files/star.argos # for 15 robots
186319
argos3 -c files/line.argos # for 15 robots
187320
```
188321

322+
***
323+
324+
## Video for 60 robots (line and star formation)
325+
326+
<iframe width="1100" height="500" src="https://www.youtube.com/embed/QNoxGxlbseE" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
327+
328+
***

0 commit comments

Comments
 (0)