• No results found

The broker-placement algorithm

In this section we present our broker-placement algorithm. After a short outline of the algorithm (Section 5.4.1), we present the algorithm’s pseudocode (Section 5.4.2) and a detailed explanation of the essential element that significantly reduces the complexity of the algorithm (Section 5.4.3).

5.4 The broker-placement algorithm 93

5.4.1

Solution outline

The general idea of the algorithm is simple: whenbis the overloaded broker, consider the

regionsrinRone by one, find for each suchrthe regionr b in

R (b)that contains it, and

check whether the weights ofrandr

bsatisfy the two conditions for a solution. When the

first such pair(r;r b

)is found, the algorithm can be terminated, and the new broker ^ b can

be located at any point inr. Because for a region inRit is easy to find the corresponding

region in R (b) that contains it, we are going to explain only the method for finding an

element ofRwith an appropriate weight.

The main problem that needs to be solved is how to efficiently enumerate the elements ofR. A naive approach is to consider all possible subsets of servers and check whether

their balls intersect to create a region. As withn servers there are 2 n

such subsets, this approach has exponential complexity, rendering it infeasible.

Our solution is based on the observation that in order to enumerate the regions inR, it

is sufficient to find a set of characteristic points forR (see Section 5.3.2). An advantage

of representing regions with points is that for a particular point it is relatively easy to find the regions that contain this point. Note that a point located on the boundary of a region may belong to more than one region. Our algorithm selects a set of characteristic points by taking suitable points on the intersections of at mostdserver spheres. Because there is O(n

d

)of such intersections and from each intersection we select at most two points, the

size of the set of characteristic points found by our algorithm is of orderO(n d

), with n

denoting the number of servers, which will turn out to reduce the worst-case complexity of our algorithm toO(n

d+1 ).

5.4.2

The algorithm

The high-level pseudocode of the broker-placement algorithm is presented in Figure 5.4. The algorithm is iterative (line 1). Each iteration starts with selecting a subset ^

U of the set U of all server spheres with not more thandelements (line 2). If all possible sets

^ U have

already been examined, the algorithm terminates without providing a solution (lines 3 to 5). In line 6 we compute the intersections^of all spheres in

^

U. According to Theorem 1

in Section 5.3.2,s^is either empty or is a sphere. We continue the current iteration of the

algorithm only if^sis non-empty (line 7).

In lines 8 to 11 we construct set ^

P by selecting some points froms^. Keeping in mind

that every 0-sphere contains at most two points, the size of set ^

P equals either one or

two. In line 12 we iterate over the regions that contain one of the points in ^

P (a point

in ^

P is a characteristic point of the regions selected in line 12). We will show later in

this section that each set inRwill be eventually considered in one of the iterations of the

algorithm (the union of the sets ^

P across all iterations constitutes a set of characteristic

points of the set of regionsR). The method of finding regions in R with a point in ^ P

Input:

b // the overloaded broker

^

b // the new broker to place

ex ess load// the excess load that needs to be removed from

// broker b

apa ity // the capacity of the new broker ^ b

d // the dimension of the space

U // the set of server spheres

R // the set of regions defined by spheres in U

Output:

p // a location for broker

^ b, or NULL if no suitable // location exists whilep== NULL do 1 ^

U a set of at mostdspheres fromU which was not considered in any of the

2

previous iterations

if all possibilities for ^

U are exhausted then

3 p NULL 4 return 5 ^

s the intersection of the spheres in ^ U 6 ifs^6=;then 7 ifs^is a 0-sphere then 8 ^

P the set of all points ins^

9

else

10

^

P the one-element set containing any point ofs^

11 forallr2Rwithr\ ^ P 6=;do 12 w the weight ofr 13 w

b the weight of the region in

R (b)which containsr

14

ifw apa ity andw b

ex ess loadthen

15

p any point in the interior ofr

16

return

17

Figure 5.4: High-level pseudocode of the broker-placement algorithm.

as well as computation of the weights of those regions (lines 13 and 14) is described in Section 5.4.3. The weights are used to determine if a region is a suitable location for the new broker (line 15). If the region satisfies the capacity and excess load requirements, then any point inside that region is a suitable location for the new broker (line 16).

5.4 The broker-placement algorithm 95

in different solutions. The nondeterminism is caused by the freedom of choice of ^ U in

line 2 and the selection of ^

P in line 11. We will show that this nondeterminism does not

affect the correctness and the completeness of our algorithm.

The correctness of our algorithm—the pointpselected in line 16 is a suitable location

for broker^

b—is a simple consequence of the conditions in line 15. However, the com-

pletenessof our algorithm, which means that it does find a solution if one exists, requires explanation. In order to prove completeness, it is enough to show that if the algorithm terminates without finding a solution, every region inR has been considered in lines 13

to 17. In turn, it is sufficient to show that the points in the union of the sets ^

P selected in

all iterations in lines 8 to 11 forms a set of characteristic points.

Let’s take a regionr 2 R. According to Theorem 3 in Section 5.3.2, there exists an

intersection of a number of spheres inU that is contained inr or that is a 0-sphere with

a point inr. Theorem 2 adds that we can limit ourselves to the intersections of at most d spheres, and this is precisely what we do when selecting

^

U in line 2. Let’s assume

that s^computed in line 6 is the intersection mentioned in Theorem 3. There are two

possibilities: ^s is either (a) fully contained inr, or (b) is a 0-sphere that has a point in r. If (a) is the case, then regardless of the point selected in lines 8 to 11, the region r

is considered in lines 13 to 17. On the other hand, ifs^is a 0-sphere (case (b)), then in

lines 13 to 17 we consider all regions that have a point in common withs^(r is one of

those regions). Consequently, if the algorithm terminates without finding a solution we can be sure that all regions inRhave been considered, and so no solution exists.

5.4.3

The computation of the region weights

In this section we describe in detail a method for finding the weights of the regions in

Rcontaining a specific pointpthat is on the boundary of all regions it belongs to. Note

that indeed all points in ^

P in the algorithm satisfy this condition. The idea presented here

is crucial for the efficient implementation of line 15 of the broker-placement algorithm presented in the previous section. The idea amounts to finding which regions we can enter when going frompinto all possible directions in a neighborhood ofp.

Let’s denote byR

p the set of all regions in

Rto which pointpbelongs. LetB

1 be the

set of server balls that containpin their interior, and letB

2 be the set of server balls that

containpon their boundary. Because a ball inB

1 contains an environment of

p, such a

ball contains also all regions inR

p. Now the weight of any

r 2 R p can be expressed as x 1 +x 2, with x

1 the sum of the weights of the balls in B

1 and x

2 the sum of weights of

some of the balls inB

2, respectively. Which balls add to x

2 will be explained below.

To illustrate the meaning ofx 1 and

x

2, let in Figure 5.3(a)

pbe the point of the inter-

section of the server spheres ofs3 ands4 that is located insideB(s2). In this case, R p

contains the regions III, VII, VIII and X,B

1contains only

B(s2), andB

s3 s4 VII h’ X p’ VIII p h" III p"

Figure 5.5: An illustration of the criterion to determine the set of balls that contain a particular point.

B(s3)andB(s4). Therefore, the value ofx

1 for all regions in R

p is equal to the weight

of ballB(s2), which is 4. As both balls inB

2contain region X, the value of x

2 for region

X is 24, which is the sum of the weights of ballsB(s3)andB(s4). The values ofx 2 for

regions III, VII, and VIII can be found in a similar way to be 0 (no balls inB

2 enter in the

computation ofx

2), and 8 and 16 (only one ball in B

2adds to x

2).

In general, the elements ofB

1and the value x

1, which is independent of the particular

region inR

p, can of course be determined in a simple way.

We describe the method of finding the valuesx

2for the regions in R

p in two steps:

1. We define a criterion that allows us to decide for a subsetB 3

 B

2 whether there

exists a region inR

pwhich is contained in all balls in B

3, but not in any of the balls

inB

2 which are not in B

3. The value of x

2 of this region is then the sum of the

weights of the balls inB 3.

2. Rather than having to consider in step 1 all subsets of B 3 of

B

2, we show how to

limit the number of setsB

3that need to be considered.

Ad 1. We claim that for a subset B 3

 B

2 there exists a region in R

p which is

contained in all balls inB

3, but not in any of the balls in B

2 which are not in B

3, if and

only if the centers of the balls in B

3 can be separated from the centers of the balls in B

2 nB

3 with a hyperplane containing point

p. A pointp 0

located close top lies inside a

ball inB

3 centered at

sif the angle between the vectors (p;p 0

)and(p;s)is smaller than =2. As a consequence, a point p

0

lies inside the intersection of the balls in B

3 if and

only if their centers andp 0

lie on the same side of the hyperplane orthogonal to(p;p 0

)and

containing pointp.

As an example, in Figure 5.5 we show a detail of Figure 5.3(a) around the pointp,