• Keine Ergebnisse gefunden

Data: A set of normalized data pointsV, delta domain ˜δ.

if δ˜≤v2˜ then

1

B={(vj−vi) mod ˜v|vi, vj ∈V, i6=j};

2

/* Initialize static segmentation tree t. */

3

/* Build the static segmentation tree. */

7

Extract τ with the algorithm StaticTreeSearch-τ in section 6.4.3;

11

6.4.2 Static Insert Algorithm

Input to the algorithm StaticInsert is a region Ri derived from a bi and the pointer to the actual node positionn. In the first iteration call this node position pointer is the tree rootnroot. At this first call, the tree contains only the root node, which encodes the region encompassed at this point, namely the entire domain defined by the input data points.

First, we compare the new region Ri to be inserted to this root node subspaceRroot. As we merge the modulo transformation into the tree construction process, we designed a regionRi to be constructed from a node difference bi by subtracting ˜δ. Thus, it may happen that the cor-responding ˜δ-sized bounding box is negative and reaches outsideRroot and thus lies outside our domain. When this happensbdi−˜δd<0 for one or more dimensions. For identifying such cases we perform an inside/outside test and thus determine if the new regionRi lies inside or (partially)

6.4. The Static Segmentation Tree Chapter 6. Solving the Pricing Problem

outside our root node subspaceRroot.

When inserting such regions into the segmentation tree, parts lying outsideRroot have to be iden-tified and modulo transformed into our domain, so that in the and a correct segmentation of the finite domain with ring structure is achieved. A region Ri lies outside the domain, if Ri ⊂Rroot is false orRroot∩Ri =∅. IfRi bases on a node differencebihaving one or more coordinates equal zero, the respective bounding box lies outsideRrootwith exception of the (d−1)-hyperplane lying at 0. This hyperplane is irrelevant for our purposes. Having such a region, we transform this region entirely intoRrootby a modulo operation of its defining corner points. Thus all coordinates equal to 0 become ˜vd. We re-insert the transformed region recursively into our tree.

If the region is onlypartially negative, as exampleR1in figure 6.6, and has one or more coordinates

<0 andRroot∩Ri6=∅. Our region is partially located inside and outside our root node subspace Rroot. We splitRi it into two subregions with the splitting hyperplane (0, dimneg) wheredimneg

is the first negative dimension found. So we get two regions, one lying inside our domain, and one lying outside. The region Rright is regular and we insert it normally by calling recursively StaticInsert(Rright, nroot). RegionRlefthas to be transformed into our domainRrootby a mod-ulo transformation w.r.t. dimneg and then recursively re-inserted. Further negative coordinates (as would be the case forR2 in figure 6.6) are handled in the same manner after the re-insertion in the next iteration, as long there exist negative dimension coordinates. Parts representing ir-relevant subspaces are omitted. By subsequently splitting away all negative parts of regions and transforming them into the domain at one dimension coordinate by one, we make them all regular.

The example regionR2 in figure 6.6 would be first split at coordinate 0, dimension 0 and we get the regionsR2A∪R2DandR2B∪R2C, which in the next recursion are split toR2AandR2D,R2B andR2C respectively.

Figure 6.6: Partially negative regions and their transformation to the working domain. Re-gions R1A and R2A are regular, the other are modulo transformed into domainD.

We proceed with the static insertion process and proceed with the case of having Ri⊂Rroot. IfRi liesinside the domain borders and is regular, we determine: If the actual node positionnis no leaf and has successors, we recursively descend into the tree by determining the appropriate successor. If our region to be inserted is Ri ≤(c, dim), ı.e. less2 than the splitting hyperplane (c, dim) of the actual node positionn, the new region lies for certain left of (c, dim) and thus in the left subtree. We save the actual indexi fromRi into the actual node upper bound set UB, since the area encompassed at this node containsRi for sure3. The setUBencodes all node difference ids, that lie in the subspace nR defined by the actual node. Then we make a recursive call to StaticInsert(Ri, nleft), wherenleftis the left son of the actual node positionn. In this manner we descend into the left subtree and update the bound sets at the tree nodes on the way down.

IfRi ≥(c, dim), we save again the indexiat the actual node and descend into the right subtree with a recursive call toStaticInsert(Ri, nright).

2“left” or “below” in 2-dimensional case.

3The inside test before was positive.

6.4. The Static Segmentation Tree Chapter 6. Solving the Pricing Problem

If the actual node pointer nis aleaf and has no successors, we proceed with segmenting the subspace, defined by noden, by means of the corner points of the new region to be inserted.

Simple Segmentation

As we intend to segment the actual subspace along the facets ofRi, we perform a series ofsplits ς with alternating dimensions. The actual nodenencodes the discriminator for the split, and we get the splitting dimension bydim=ndisc modd. We begin with pointp(i)0 defined by the new regionRi and make dsplits, one for each dimension, followed bydsplits for pointp(i)2d−1. In the special case, when having overlapping points for a region with the actual subspace defined by a node, we can leave out the splits at this point.

By continuing the example, we split the actual domain atc = (p(i)0 )dim and save at node n the resulting splitting hyperplane (c, dim) = ((p(i)0 )dim, dim). Two successors nleft and nright are generated and appended to the tree at the actual node n. As at the actual node encodes the subspace R=hp0, p2d−1i, the left son now defines the subspaceRleft =hp00, p2d−1i, where point p00has the new valuecatdim. The right son hasRright=hp0, p02d−1i, wherep02d−1 hascatdim.

Figure 6.7 illustrates the working principle of a simple segmentation, e.g. a simple split sequence.

The resulting segmentation tree is depicted in figure 6.8.

u1= 11

p(1)0

p(1)3

b1

ς1= (p(1)0 , d1) ς2= (p(1)0 , d2)

ς4= (p(1)3 , d2)

ς3= (p(1)3 , d1)

d1 d2

Figure 6.7: Simple segmentation of node differenceb1. The figure shows four splits ς, two at p(1)0 and two at p(1)2d−1. The resulting segmentation tree is depicted in figure 6.8.

ς1

ς2

ς3

ς4

{1},{1}

{1},{}

{1},{}

{1},{}

{1},{}

{},{}

{},{}

{},{}

{},{}

Figure 6.8: Segmentation tree after insertion ofb1.

The actual node upper bound set is again updated by saving index i, thus denoting that the subspace encompassed at the actual node includesRi. Each time we append new nodes we also have to carefully inherit upper and lower bound sets, in order not to loose some previously inserted Ri. As the elements for LB are for sure in this subtree, they are simply propagated. Only the elements inUBmust be checked against being part of the new subnodes.

6.4. The Static Segmentation Tree Chapter 6. Solving the Pricing Problem

By performing such a split, the subspace encoded by node n is split into two subspaces, one containing our region to be inserted Ri and one not containing it. This is easily checked by Ri ≤ (c, dim) and Ri ≥ (c, dim). Having completed the split, the StaticInsert algo-rithm descends into the tree by determining the successor containing ourRi by deciding whether Ri≤(c, dim) orRi≥(c, dim).

The splits for the remaining dimensions are performed in the same manner. By executing the last split, either Rleft or Rright are equal to the actual region Ri. At this point, we save the indexiadditionally to lower bound set. Furthermore, we carefully propagate the setsUBandLB from the predecessor node to the successor nodes. The lower bound setLB then holdsall node difference indices that are expressed by the subspace encompassed at the actual point.

The algorithm performs 2·d splits, dsplits at corner point p(i)0 and dsplits at p(i)2d−1. This procedure can be tuned by leaving out overlapping or redundant corner points, but we must pay attention to not destroy the dimension sequence in the tree levels. We reduced these 2·dsplits by leaving out equals corner points:

• If a new region Ri equals the subspace at the actual node nR, we perform no splits at all, since both corner points are equal for Ri and nR. We simply add the indexi of bi to UB andLB atn. We omit all 2·dsplits.

• If one of the corner points for Ri is coincident to the respective corner point ofnR, omit these point, thus leaving outdsplits.

We can safely omit these splits without disturbing the dimension sequence in the tree levels. Fur-ther optimizations require a more sophisticated handling.

On the other side we have to absolutely maintain the dimension sequence in the tree levels.

The difference between a conventionalk-d-tree and the segmentation tree is depicted in figure 6.9.

ς1

Figure 6.9: The reason, why null subspaces have to be inserted. How, in figure 6.9b, shouldς60, ς600 be segmented and the dimension sequence retained? Figure 6.9c shows the correct segmentation by inserting a null subspaceς5NULL.

Maintaining the dimension sequence means, that the sequence d0, d1, . . . , dd always has to remain intact when descending into the tree levels. Since the segmentation tree is not a conven-tionalk-d tree, situations arise, where a special split has to be performed, that dividesnR into a subregion containingnR itself and an “empty” subspaceRNULL with size 0. We call such empty subspacesnull subspace. Such a null subspace lies exactly onto the actual splitting hyperplane and is trivially performed by the split operation automatically. Such a split is depicted in figure 6.10b.

6.4. The Static Segmentation Tree Chapter 6. Solving the Pricing Problem

Normal Segmentation

Until now we do not take into account overlapping regions, which is the trickier part. When insert-ing more and more regions, the chance increases that somewhere an overlap of regions takes place.

In such a case (and there are probably many such cases) at some nodennone of the two conditions Ri≤(c, dim) andRi ≥(c, dim) is true, since the new region has parts on both sides of the split-ting hyperplane. Having such a case, we split upRi at the actual splitting hyperplane intoRileft

andRiright and insert the “left” (ifRi ≤(c, d)) part into the left subtree by invoking recursively StaticInsert(Rileft, nleft) . The “right” part is inserted byStaticInsert(Riright, nright)into the right subtree. At the actual node we save again the index ofbi toUB.

In each subtree, Rileft and Riright are handled recursively in the same manner. Thus, an ac-curate segmentation of the domain is constructed. The figures 6.10a and 6.10b illustrate these steps, by continuing the example in figure 6.7. The resulting segmentation tree is depicted in figure 6.11. Both figures show also the handling of a null split ς7NULL. The corresponding seg-mentation tree has a null subspace at the right successor of the node corresponding to splitς7NULL.

u1= 11

Figure 6.10: Figure 6.10a) shows the insertion ofb2, overlaps at splitsς1andς4take place. Figure 6.10b) shows the segmentation ofb2: SinceR2 is located on both sides ofς1, the algorithm splits R2 into two subregionsR02=hp00, p(2)3 iandR002 =hp(2)0 , p03i, and inserts them recursively into the left and right subtree respectively. First, the algorithm descends left withR02 and encounters an overlap again atς4. AgainR02

is split up intohp000, p(2)3 i andhp00, p03i, which are re-inserted recursively. These two subregions as well as R200are further simply segmented. Figure 6.11) shows the resulting segmentation tree with bounds after insertion ofb2.

6.4.2.1 Algorithms

We describe now in detail the algorithm outlined in the preceding paragraphs. For simplicity reasons, the described method was split up into two procedures. Pseudo code 6.2 lists the algo-rithmStaticInsert(Ri, n). This algorithm basically manages the tree descending process and the segmentation at the region corner points.

Input parameters for StaticInsert are the region Ri, generated from a bi, and the actual node positionn. In the first iteration n=nroot, and the algorithm decides first of all, if Ri lies inside or (partially) outside the subspace defined bynroot, e.g. our working domain. This is done

6.4. The Static Segmentation Tree Chapter 6. Solving the Pricing Problem

Figure 6.11: Segmentation tree with bounds after insertion ofb2.

at line 2 by performing the appropriateinside check. If the region to be inserted is partially neg-ative (p(i)2d−1 is negative for some dimensions), this region is split up the first negative dimension found (lines 40-43) and coordinate 0 and Rleft transformed into our domain (lines 48, 49, 50).

Then,RleftandRrightare re-inserted recursively (lines 46, 51). Parts representing null subspaces (determined at line 45) are omitted.

If the region to be inserted is regular and inside Rroot, the algorithm proceeds normally. In the next step (line 4), the algorithm determines, it the actual nodenis a leaf or an intermediate node. Whennis a leaf the algorithm proceeds with segmenting the subspace encompassed bynR

(line block 6-24). If n is no leaf, the algorithm expands theUB set atn (line 25), and decides if one or both successors contain Ri. If Ri lies left of the actual splitting hyperplane at n, the algorithm descends recursively into the left subtree (lines 27-28), else ifRilies right of the splitting hyperplane it descends into the right subtree (lines 29-30). IfRi lies on both sides of the splitting hyperplane, the algorithm performs a split and dividesRi at the splitting hyperplane (line 33).

After this, it inserts the resulting subregions recursively into their respective subtree at the actual node positionn (line 34 and 35). Next, if nis a leaf, the algorithm determines, if segmentation occurs. If both corner points for Ri and nR are equal (line 6), the algorithm updates only the bound sets atn. It simply adds the index iofbi to the actual nodes upper and lower bound set (line 7) and performs no segmentation. In the other case the algorithm determines the splits that must be made by constructing the set of split coordinates P: If the corner points p0 are equal for nR and Ri, only the splits at coordinates P = (p12d−1, p22d−1, . . . , pd2d−1) ofRi are performed (lines 13-14 ). Ifp2d−1 are equal for nR andRi, the splits are performed atP = (p10, p20, . . . , pd0) forRi (lines 15-16). If no corner points are equal, all 2·dsplits are performed and setP holds all coordinates (line 18). With the loop at line 19, all splits are made sequentially by calling the algorithmStaticAppendNodesat line 20, which handles all the segmentation steps and adds each time it is called two new successors encoding the actual split. Since the segmentation is performed based on aRi, which dividesnR into one subspace containing Ri and into one not containing it, the appropriate successor for descending into the tree for performing the next split is selected by identifying this successor (lines 22-23). Thus, the algorithm determines the correct successor by checking ifRi ≤(nc, nd) (line 22), or Ri ≥(nc, nd) (line 23) respectively and descends into the appropriate subtree by setting the node pointernto the newly determined successor.

6.4. The Static Segmentation Tree Chapter 6. Solving the Pricing Problem