• 沒有找到結果。

Algorithms for Event Surrounding Queries

4.2 Greedy Algorithm: Greedy-ES

4.2.1 Design Concepts

Although it is intuitive to select surrounding nodes of the event by RNN-ES algorithm, there are some deficiencies in RNN-ES algorithm. It may be costly to search RNNs edges by edges. Also, RNN-ES algorithm requires that each sensor node caches neighbor nodes in its communication range in case of RNNs selected not enclosing the event. Therefore we propose a greedy algorithm for ES query processing and it is abbreviated as Greedy -ES.

In our Greedy-ES algorithm, we need to calculate minimum distance between sensor nodes to the approximate polygonal boundary of the event boundary. Then we select from near-est neighbor nodes of the approximate polygonal boundary of the event every time as our surrounding node candidates. The search process will stop until we find a set of nearest surrounding nodes of the event that enclose the event.

Node si si.left si.right

20 27 21

21 20 30

27 34 20

Table 4.2: Neighborhood relationships after modification

When we takes two search schemes mentioned of R-tree index structure, BFS and DFS, into consideration, we choose BFS search paradigm according to the essence of our Greedy algorithm. The definition of minimum distance of a sensor node to the approximate polyg-onal event boundary is similar to MINDIST defined in [15]. If the approximate polygpolyg-onal event boundary is inside MBR of R-tree fully, minimum distance is zero. If the approximate polygonal event boundary covers partial region of MBR, minimum distance is also zero. If the approximate polygonal event boundary is outside MBR fully, minimum distance is the minimal Euclidean distance between the node to nearest edge of the approximate polygonal event boundary. We use minimum distance defined to sort nodes in our priority queue for BFS search paradigm. Conceptually, we retrieve NN of current processing as our surrounding nodes by popping the priority queue. However, not all K NNs searched accessed till now are surrounding nodes of the event. It may be redundant for current NN retrieved to join the set of surrounding nodes of the event. Therefore, we introduce how to construct neighborhood relationships for each surrounding node candidates NN and current ES results.

In our assumption, nearest surrounding nodes that enclose the event must satisfy the criteria, sensing ranges of adjacent surrounding nodes are overlapping. Distances between every two adjacent surrounding nodes is small than the summation of their radius of sensing ranges. Therefore, we check the distance between each surrounding nodes candidates NN and current ES results. If a surrounding nodes candidate NN retrieved satisfy the criteria, NN has neighborhood relationship with current ES results. Next, we define left-hand side neighbor and right-hand side neighbor for a surrounding node candidate NN advancedly.

Neighborhood relationships construction of a surrounding node candidate is depicted in Figure 4.3. We mark current surrounding node candidate processed as si. Sensor nodes sj, sk are surrounding nodes and have been recognized as neighborhood of si by the criteria aforementioned. We set center point of the approximate polygonal event boundary as a reference point. If there is a polar angle formed by the reference point, the surrounding node

Algorithm 3 Greedy-ES(BN,root)

Input: An approximate polygonal event boundary (BN), and A R-tree root index node(root).

Output: A set of surrounding nodes of the event S.

1: Let Q be a priority queue and be initialized with root;

2: Let S be results of ESN Query and be initialized φ;

3: Let Mark be a redundant surrounding nodes mark if n is added to S and be initialized 0;

4: while (Surrounding nodes in S are not enclosed or S==φ) do

5: Dequeue node n from Q;

6: if (n is a spatial object) then

7: n.left = null;

8: n.right = null;

9: if (S != φ) then

10: foreach nodes si in S do

11: if (dist(n,si) ≤ rn+rsi) then

12: Build neighborhood relationships for n such as n.left = si or n.right = si;

13: end if

14: end for

15: end if

16: if ((n.left==si) and (si.right==null)) then

17: si.right = n;

18: else if ((n.right==si) and (si.left==null)) then

19: si.left = n;

30: Mark = 0; //reinitialize Mark as 0

31: end if

s

i

s

j

s

k

BN

Figure 4.3: The neighborhood relationships among surrounding nodes

candidate si, a neighbor of si in current ES result sj, sj is a left-hand side neighbor of the surrounding node candidate si. This means that if the surrounding node candidate in Figure 4.3 is si, si to si’s neighbor, sj, makes counterclockwise turn relative to the reference point, sj is si’s left-hand side neighbor. Similarly, if there is a solar altitude angle formed by the reference point, the surrounding node candidate si, a neighbor of si in current ES result sk, sk is a right-hand side neighbor of the surrounding node candidate si. In Figure 4.3, the surrounding node candidate si to si’s neighbor, sk, makes clockwise turn relative to the reference point.

Thus, sk is si’s right-hand side neighbor.

We construct such neighborhood relationship for each surrounding node candidate and initialize their left-hand side and right-hand side neighbor as null first in our Greedy-ES algorithm. Then , it will go on to check whether there any surrounding nodes in current ES result set are its neighbors. If there is none, it will join current ES result set directly and continue the procedure. If it has neighbors in current ES result set, it will examine this neighbor belongs to left-hand side or right-hand side neighbor advancedly. In order to avoid redundant surrounding nodes to join ES result set, we will check neighborhood relationships of each surrounding node candidate and its corresponding neighbors in ES result set. There

si

sj

sk sj si

sk

(i) (ii)

sc BN

BN

Figure 4.4: (i) Case 1. and (ii) Case 2.

are two cases that surrounding node candidates are redundant (See Figure 4.4):

Case1. The sensing range of a surrounding node candidate si is overlapping with an element sj in ES result set, and sj is si’s right(left)-hand side neighbor. But sj’s according left(right)-hand side neighbor is sk. This means the role of current surrounding node candidate is already played by sk and si is farther than sk. We avoid si to join the ES result set.

Case 2. The sensing range of a surrounding node candidate si is overlapping with two elements sj and sk in ES result set. sj is si’s left(right)-hand side neighbor and sk is si’s right(left)-hand side neighbor. But sj’s right(left)-hand side neighbor and sk’s left(right)-hand side neighbor are sc not si. This can just use case 1 to check whether neighborhood relationships of a surrounding node candidate exits or not. There is no need to check twice.

Therefore, if surrounding node candidate si’s left(right)-hand side neighbor is sj in ES result set and sj’s according right(left)-hand side neighbor is null. This means that surrounding node is not redundant to enclose the event. We construct corresponding neighborhood relationship of si and sj and add si into our ES result set. Thereafter, we avoid redundant surrounding nodes to join ES result set by neighborhood relationship examination likewise.

R1

Figure 4.5: R-Tree index structure

event

Figure 4.7: Processing a surrounding node candidate 27

27

60

47

30

BN

Figure 4.8: Processing a surrounding node candidate 30

27

60

47

30

34 BN

Figure 4.9: Processing surrounding node candidate 34

相關文件