R-Trees Albert-Jan Yzelman December 10, 2007 Albert-Jan Yzelman - - PowerPoint PPT Presentation

r trees
SMART_READER_LITE
LIVE PREVIEW

R-Trees Albert-Jan Yzelman December 10, 2007 Albert-Jan Yzelman - - PowerPoint PPT Presentation

R-Trees R-Trees Albert-Jan Yzelman December 10, 2007 Albert-Jan Yzelman R-Trees > History Outline R-trees History 1 Current status 2 Future 3 Albert-Jan Yzelman R-Trees > History Goals 1 Create a datastructure which will enhance


slide-1
SLIDE 1

R-Trees

R-Trees

Albert-Jan Yzelman December 10, 2007

Albert-Jan Yzelman

slide-2
SLIDE 2

R-Trees > History

Outline

R-trees

1

History

2

Current status

3

Future

Albert-Jan Yzelman

slide-3
SLIDE 3

R-Trees > History

Goals

1 Create a datastructure which will enhance Shell’s oil reservoir

simulation software

2 Obtain a generic, customisable R-tree software library for using

R-trees in many other areas

Albert-Jan Yzelman

slide-4
SLIDE 4

R-Trees > History

Reminder We can let each node of a tree correspond to an MBR and obtain the so called R-trees. Let each internal node of the R-tree correspond to the MBR of all MBRs stored in the children of that internal node Let each leaf node of the R-tree correspond to the MBR of a single object stored in the R-tree

Albert-Jan Yzelman

slide-5
SLIDE 5

R-Trees > History

Reminder

Albert-Jan Yzelman

slide-6
SLIDE 6

R-Trees > History

Reminder

Albert-Jan Yzelman

slide-7
SLIDE 7

R-Trees > History

Reminder

Albert-Jan Yzelman

slide-8
SLIDE 8

R-Trees > History

Reminder

Albert-Jan Yzelman

slide-9
SLIDE 9

R-Trees > History

Implemented operations The R-tree library software presently enables one to obtain efficient answers to the following types of queries: Point Line Box k-nearest-neighbourhood

Albert-Jan Yzelman

slide-10
SLIDE 10

R-Trees > History

Storage scheme Presently stores container elements consisting of a d-dimensional hypercube with an identification number.

Albert-Jan Yzelman

slide-11
SLIDE 11

R-Trees > History

Storage scheme Presently stores container elements consisting of a d-dimensional hypercube with an identification number. Can be easily extended to hyperspherical container elements,

  • r any other volume.

Albert-Jan Yzelman

slide-12
SLIDE 12

R-Trees > History

Implemented R-tree variants Basic R-tree with linear splitting Basic R-tree with quadratic splitting Hilbert R-tree

Albert-Jan Yzelman

slide-13
SLIDE 13

R-Trees > History

Implemented bulk-loading schemes Top-down Greedy Split (TGS)

total volume as cost function intersection volume as cost function

Random TGS Hilbert TGS Hilbert Packed

Albert-Jan Yzelman

slide-14
SLIDE 14

R-Trees > History

Experiments: construction time

10

3

10

4

10

5

10

6

10

7

10 10

1

10

2

10

3

10

4

10

5

10

6

Number of grid elements Building time (in processor ticks) Grid size vs. building time Bisection tree. 2/4 RandomTGS bulk−loaded basic R−tree. 2/4 HilbertTGS bulk−loaded basic R−tree.

Albert-Jan Yzelman

slide-15
SLIDE 15

R-Trees > History

Experiments: point query time

10

2

10

3

10

4

10

5

10

6

10

7

10

−5

10

−4

10

−3

10

−2

10

−1

10 Number of grid elements Average required time per point query (in seconds) Grid size vs. query time −− point query Bisection tree. 2/4 RandomTGS bulk−loaded basic R−tree. 2/4 HilbertTGS bulk−loaded basic R−tree.

Albert-Jan Yzelman

slide-16
SLIDE 16

R-Trees > History

Experiments: knn query time

10

2

10

3

10

4

10

5

10

6

10

7

10

−3

10

−2

10

−1

10 10

1

10

2

Number of grid elements Average required time per knn query (in seconds) Grid size vs. query time −− knn query Bisection tree. 2/4 RandomTGS bulk−loaded basic R−tree. 2/4 HilbertTGS bulk−loaded basic R−tree.

Albert-Jan Yzelman

slide-17
SLIDE 17

R-Trees > History

Experiments: line query time

10

2

10

3

10

4

10

5

10

6

10

7

10

−4

10

−3

10

−2

10

−1

10 10

1

Number of grid elements Average required time per line query (in seconds) Grid size vs. query time −− line query Bisection tree. 2/4 RandomTGS bulk−loaded basic R−tree. 2/4 HilbertTGS bulk−loaded basic R−tree.

Albert-Jan Yzelman

slide-18
SLIDE 18

R-Trees > History

Experiments: box query time

10

2

10

3

10

4

10

5

10

6

10

7

10

−4

10

−3

10

−2

10

−1

10 10

1

10

2

Number of grid elements Average required time per box query (in seconds) Grid size vs. query time −− box query Bisection tree. 2/4 RandomTGS bulk−loaded basic R−tree. 2/4 HilbertTGS bulk−loaded basic R−tree.

Albert-Jan Yzelman

slide-19
SLIDE 19

R-Trees > Current status

Outline

R-trees

1

History

2

Current status

3

Future

Albert-Jan Yzelman

slide-20
SLIDE 20

R-Trees > Current status

The previously mentioned variations have been implemented in C++. The resulting library went public as an open-source project: http://www.sourceforge.net/projects/rtree-lib The R-tree library as available there only includes the core R-tree sources; experimentation software used with the Shell datasets are not included. The first release available is in effect the same source used for generating the results just seen. The SVN repository however already contains a newer version; Petr Sereda optimised an essential part of the software resulting in large (20 percent?) speedups in TGS bulk-loading.

Albert-Jan Yzelman

slide-21
SLIDE 21

R-Trees > Current status

Coding example We will now demonstrate the ease of use of the library as is. We will use the release version as available on SF (which is at 54 downloads at the time of writing). After downloading the tarball we simply unzip it in a directory (./rtree-ex/) and unpack it. We then type ”make” to compile the library object files; this runs fine on our test linux machine. Our example application will be aptly called example.cpp.

Albert-Jan Yzelman

slide-22
SLIDE 22

R-Trees > Current status

Pair.h class Pair { public: double x; double y; Pair( double _x, double _y ){ x=_x; y=_y; } };

Albert-Jan Yzelman

slide-23
SLIDE 23

R-Trees > Current status

example.cpp #include<iostream> #include<vector> std::vector<Pair> data; int main() { createData(); loadData(); doQueries(); }

Albert-Jan Yzelman

slide-24
SLIDE 24

R-Trees > Current status

example.cpp void createData() { double cx, cy; Pair* temp; while( true ) { std::cin >> cx; std::cin >> cy; if ( cx == 0 && cy == 0 ) return; temp = new Pair( cx, cy ); data.push_back( temp ); } }

Albert-Jan Yzelman

slide-25
SLIDE 25

R-Trees > Current status

example.cpp #include "Hilbert_R-Tree.h" #include "HilbertTGS.h" typedef Hilbert_TGS_tree< Hilbert_R_tree > tree_type; tree_type* tree; void loadData() { R_tree_props* props = new R_tree_props(); props->minimum = 2; props->maximum = 6; tree = new tree_type( props ); tree->insertElements( data.begin(), data.end() ); tree->ensureReady(); }

Albert-Jan Yzelman

slide-26
SLIDE 26

R-Trees > Current status

Data translation; utils/BBGenerator.h #include "Polytope.h" #include "Cubic_Bounding_Box_Container.h" #include "../Pair.h" Cubic_Bounding_Box_Container* extractCubicBoundingBox( const Polytope * const poly ); Cubic_Bounding_Box_Container* extractCubicBoundingBox( Pair * pair );

Albert-Jan Yzelman

slide-27
SLIDE 27

R-Trees > Current status

Data translation; utils/BBGenerator.cpp Cubic_Bounding_Box_Container* extractCubicBoundingBox( Pair * pair ) { Cubic_Bounding_Box_Container *temp; std::vector< double > min; min.resize(2); std::vector< double > max; max.resize(2); min[0]=pair->x-0.05; min[1]=pair->y-0.05; max[0]=pair->x+0.05; max[1]=pair->y+0.05; temp = new Cubic_Bounding_Box_Container( min, max, rand() ); return temp; }

Albert-Jan Yzelman

slide-28
SLIDE 28

R-Trees > Current status

example.cpp void doQueries() { double qx, qy; while( true ) { std::cin >> qx; std::cin >> qy; if ( qx==0 && qy==0 ) break; Point p(2); p.setCoordinate(0, qx); p.setCoordinate(1, qy); vector<int> hits = tree->intersects( p ); if (hits.size()>0) std::cout << hits.at( 0 ); } }

Albert-Jan Yzelman

slide-29
SLIDE 29

R-Trees > Future

Outline

R-trees

1

History

2

Current status

3

Future

Albert-Jan Yzelman

slide-30
SLIDE 30

R-Trees > Future

Future plans: Even more performance tuning Additional query type: hyperplane query Better build system (automake) Contacting http://www.rtreeportal.org/ for more publicity Including example applications on the sourceforge page

Albert-Jan Yzelman

slide-31
SLIDE 31

R-Trees > Future

Possible other application areas: Databases Graphics/Gaming Chip Design Navigation Systems Image Processing Geographical Information Systems (GIS) Robot Control PCB Manufacturing ...? See also: http://home.altennederland.nl/wiki/index.php/R-Tree_ Project#Ideas

Albert-Jan Yzelman

slide-32
SLIDE 32

R-Trees > Future

Questions?

Albert-Jan Yzelman

slide-33
SLIDE 33

R-Trees > Extra material

Grouping criteria

✁ ✁ ✁ ✁ ✁ ✁ ✁ ✁ ✁ ✁ ✁ ✁ ✁ ✁ ✂ ✂ ✂ ✂ ✂ ✂ ✂ ✂ ✂ ✂ ✂ ✂ ✂ ✂ ✄ ✄ ✄ ✄ ✄ ✄ ✄ ✄ ✄ ✄ ✄ ✄ ✄ ✄ ☎ ☎ ☎ ☎ ☎ ☎ ☎ ☎ ☎ ☎ ☎ ☎ ☎ ☎ ☎ ✆ ✆ ✆ ✆ ✆ ✆ ✆ ✆ ✆ ✆ ✆ ✆ ✆ ✆ ✆ ✝ ✝ ✝ ✝ ✝ ✝ ✝ ✝ ✝ ✝ ✝ ✝ ✝ ✝ ✞ ✞ ✞ ✞ ✞ ✞ ✞ ✞ ✞ ✞ ✞ ✞ ✞ ✞

Figure: Minimum overlap criteria

Albert-Jan Yzelman

slide-34
SLIDE 34

R-Trees > Extra material

Grouping criteria

✁ ✁ ✁ ✁ ✁ ✁ ✁ ✁ ✁ ✁ ✁ ✁ ✁ ✁ ✂ ✂ ✂ ✂ ✂ ✂ ✂ ✂ ✂ ✂ ✂ ✂ ✂ ✂ ✄ ✄ ✄ ✄ ✄ ✄ ✄ ✄ ✄ ✄ ✄ ✄ ✄ ✄ ☎ ☎ ☎ ☎ ☎ ☎ ☎ ☎ ☎ ☎ ☎ ☎ ☎ ☎ ☎ ✆ ✆ ✆ ✆ ✆ ✆ ✆ ✆ ✆ ✆ ✆ ✆ ✆ ✆ ✆ ✝ ✝ ✝ ✝ ✝ ✝ ✝ ✝ ✝ ✝ ✝ ✝ ✝ ✝ ✞ ✞ ✞ ✞ ✞ ✞ ✞ ✞ ✞ ✞ ✞ ✞ ✞ ✞

Figure: Minimum total volume criteria

Albert-Jan Yzelman

slide-35
SLIDE 35

R-Trees > Extra material

Grouping criteria Dead space: Volume(V − W )

V−W W V V−W

  • 1
  • 2

V

Figure: V = MBR(o1 ∪ o2), W = MBR(o1) ∪ MBR(o2)

Albert-Jan Yzelman

slide-36
SLIDE 36

R-Trees > Extra material

Packed Hilbert R-tree Observation: Which object is in which leaf node defines the whole R-tree

Albert-Jan Yzelman

slide-37
SLIDE 37

R-Trees > Extra material

Packed Hilbert R-tree Observation: Which object is in which leaf node defines the whole R-tree So if the objects to-be added are known beforehand, why not build the tree ground-up?

Albert-Jan Yzelman

slide-38
SLIDE 38

R-Trees > Extra material

Packed Hilbert R-tree Initially, sort objects on Hilbert coordinates. Let an ordered set N of leaf nodes correspond to those objects. Group N into subsets Ni, each of size M Let ˜ N correspond to an ordered set of internal node, each with children as in a subset Ni If |˜ N| > 1, repeat process with N = ˜ N

Albert-Jan Yzelman

slide-39
SLIDE 39

R-Trees > Extra material

Packed Hilbert R-tree

Figure: Packed Hilbert R-tree example with M = 3.

Albert-Jan Yzelman