Fault Tolerance provided by
Capillary Routing
Description of the AMPL code
Building the random walk network
Script |
Comments |
printf "Preparing the
timeframes of random walk ad-hoc network:\n"; for{i in NODES} { let xx[i] := Uniform(0,x_max); let yy[i] := Uniform(0,y_max); let x[1,i] := xx[i]; let y[1,i] := yy[i]; } |
◄Initializing the coordinates of the first timeframe |
printf " (1) Positions of nodes evolving over time
... "; for{t in 2..T} { |
◄the loop of frames starting from the second timeframe |
for{i in NODES} { |
◄loop for each node |
if 0 <= Uniform(0,walk) <= step then let a[i] := Uniform(0,2*PI); |
◄if it is a time for a turn, randomly change the direction of the node |
repeat { let xxx := xx[i]+step*cos(a[i]); let yyy := yy[i]+step*sin(a[i]); |
◄compute the next position of the node |
if xxx in interval [0,x_max] && yyy in interval [0,y_max] then break; let a[i] := Uniform(0,2*PI); } |
◄if the next position of the node is not in the allowed rectangular area, change randomly the direction of the node and retry |
let xx[i] := xxx; let yy[i] := yyy; } |
◄store the new valid coordinates of the node |
for{i in NODES} { let x[t,i] := xx[i]; let y[t,i] := yy[i]; } |
◄save under the index of the current timeframe the coordinates of all nodes |
} printf "Ok\n"; |
◄close the loop of timeframes |
printf " (2) Adding links ... "; |
◄computing the links |
for{t in 1..T} let LINKS[t] := union{i in 1..N, j in i+1..N:
(x[t,i]-x[t,j])^2+(y[t,i]-y[t,j])^2<=r^2} {(i,j), (j,i)}; |
◄for each pair of nodes (a pair is considered only once) we add two arcs of opposite directions (symmetric directed graph) if the geometrical distance between the nodes is less or equal the coverage radius of the node |
printf "Ok\n"; printf
"Done.\n\n"; |
◄end of the construction of the random walk network |
* * *