Adaptation of k-Nearest Neighbor Queries for Inter ...... · Nearest Neighbor Algorithm Nearest...

12
Adaptation of k-Nearest Neighbor Queries for Inter-building Environment Diska Andini 1(B ) , Dawam Dwi Jatmiko Suwawi 1(B ) , Kiki Maulana Adhinugraha 1(B ) , and Sultan Alamri 2(B ) 1 School of Computing, Telkom University, Bandung, Indonesia [email protected], {dawamdjs,kikimaulana}@telkomuniversity.ac.id 2 College of Computing and Informatics, Saudi Electronic University, Riyadh, Saudi Arabia [email protected] Abstract. Nearest neighbor (kNN) is a spatial query where its main aim is to find k nearest object around a query point. This query has been widely used in outdoor environment to obtain point of interests in various GIS system, such as navigation and routing. The floor layout of a building can be represented with simple graph network. Unlike out- door road network that usually only has single layer, an indoor network might have multiple layers which represents floors. In a multi-building area, buildings can be connected with the other buildings and create more complex network, which is called inter-building environment. In this paper, Dijkstra and Floyd Warshall algorithms as kNN algorithm are adapted and implemented in inter-building environment. Our exper- iments show that these algorithms are be able to adapt three dimensional graph for inter-building environment. Keywords: Nearest neighbor · Inter-building Three dimensional network 1 Introduction Nearest neighbor (kNN) is a spatial query where its main aim is to find k near- est object around a query point. This query has been widely used in outdoor environment to obtain point of interests in various GIS system, such as naviga- tion and routing [10]. In navigational system, kNN is commonly used to identify nearby objects either in static or dynamic objects [3, 6], especially in mobile devices to support road navigations [1, 9, 15]. From Fig. 1 nearest neighbor query can be used to find the objects of interests (such as restaurants) from the query location. Nearest neighbor query in indoor space can be used as in outdoor space to finding the objects of interest type in inter-building environment. But differences in some aspects of indoor and outdoor spaces, nearest neighbor in indoor space should consider the elements c Springer International Publishing AG, part of Springer Nature 2018 O. Gervasi et al. (Eds.): ICCSA 2018, LNCS 10960, pp. 183–194, 2018. https://doi.org/10.1007/978-3-319-95162-1_13

Transcript of Adaptation of k-Nearest Neighbor Queries for Inter ...... · Nearest Neighbor Algorithm Nearest...

Page 1: Adaptation of k-Nearest Neighbor Queries for Inter ...... · Nearest Neighbor Algorithm Nearest neighbor is an algorithm to finding the given object of interest that is closest to

Adaptation of k-Nearest NeighborQueries for Inter-building Environment

Diska Andini1(B), Dawam Dwi Jatmiko Suwawi1(B),Kiki Maulana Adhinugraha1(B), and Sultan Alamri2(B)

1 School of Computing, Telkom University, Bandung, [email protected],

{dawamdjs,kikimaulana}@telkomuniversity.ac.id2 College of Computing and Informatics, Saudi Electronic University,

Riyadh, Saudi [email protected]

Abstract. Nearest neighbor (kNN) is a spatial query where its mainaim is to find k nearest object around a query point. This query hasbeen widely used in outdoor environment to obtain point of interests invarious GIS system, such as navigation and routing. The floor layout ofa building can be represented with simple graph network. Unlike out-door road network that usually only has single layer, an indoor networkmight have multiple layers which represents floors. In a multi-buildingarea, buildings can be connected with the other buildings and createmore complex network, which is called inter-building environment. Inthis paper, Dijkstra and Floyd Warshall algorithms as kNN algorithmare adapted and implemented in inter-building environment. Our exper-iments show that these algorithms are be able to adapt three dimensionalgraph for inter-building environment.

Keywords: Nearest neighbor · Inter-buildingThree dimensional network

1 Introduction

Nearest neighbor (kNN) is a spatial query where its main aim is to find k near-est object around a query point. This query has been widely used in outdoorenvironment to obtain point of interests in various GIS system, such as naviga-tion and routing [10]. In navigational system, kNN is commonly used to identifynearby objects either in static or dynamic objects [3,6], especially in mobiledevices to support road navigations [1,9,15].

From Fig. 1 nearest neighbor query can be used to find the objects of interests(such as restaurants) from the query location. Nearest neighbor query in indoorspace can be used as in outdoor space to finding the objects of interest typein inter-building environment. But differences in some aspects of indoor andoutdoor spaces, nearest neighbor in indoor space should consider the elementsc© Springer International Publishing AG, part of Springer Nature 2018O. Gervasi et al. (Eds.): ICCSA 2018, LNCS 10960, pp. 183–194, 2018.https://doi.org/10.1007/978-3-319-95162-1_13

Page 2: Adaptation of k-Nearest Neighbor Queries for Inter ...... · Nearest Neighbor Algorithm Nearest neighbor is an algorithm to finding the given object of interest that is closest to

184 D. Andini et al.

Fig. 1. Geo-Positioning system implementation in outdoor

contained in indoor space to be implemented for inter-building environment. Inindoor, buildings may have a number of rooms and corridors. Every rooms allowsfor a variety of doors that connect with another spaces. Moreover, the buildingcan be multi level building or on three dimensional spaces that has stairs, liftsor elevators to move from one level to another level. The entire space must haveidentified labels as well as connection between the spaces [2,7].

Although indoor and outdoor have differences in some aspects, but there issimilarity in representing data model. The floor layout of a building is similarwith road network in outdoor, where this layout can be represented as a graphnetwork. While it’s not common in a road network to have multiple layer, inindoor environment, a building can have multiple floors [11]. Therefore, the net-work structure in indoor space is more complex than the road network. Moreoverin a multi-building area, some buildings can be connected with each other andcreate an inter-building environment. In this paper, adaptation and implemen-tation several kNN algorithm for inter-building environment is proposed. Ourexperiments show that the algorithms can be well implemented in inter-buildingenvironment.

This paper is organized as follows: Sect. 2 discusses the related work andprevious studies that used in this case, Sect. 3 will explain the system adaptationanalysis. After that will discuss evaluation of this system such as testing, analysisin Sect. 4 and last of section is the conclusion of this study.

2 Related Works

Nearest Neighbor Algorithm

Nearest neighbor is an algorithm to finding the given object of interest thatis closest to the query location. From the space perspective, this query can bedivided into three categories, which are: (i) Euclidean space, (ii)spatial road net-work space and (iii) combination of Euclidean and spatial road network space[12]. In Euclidean space, the distance is measured by a straight and direct dis-tance between two spatial objects. The work for NN query in Euclidean distance

Page 3: Adaptation of k-Nearest Neighbor Queries for Inter ...... · Nearest Neighbor Algorithm Nearest neighbor is an algorithm to finding the given object of interest that is closest to

Adaptation of k-Nearest Neighbor Queries for Inter-building Environment 185

has been extended to calculate the obstacled during the process [13,14]. Theidea is if the Euclidean distance between two spatial objects are obstructed withobstacles, the path from Euclidean distance needs to be bend to avoid the obsta-cles. Therefore, the distance will be longer (Figs. 2 and 3).

Fig. 2. NN based on Euclidean Fig. 3. NN based on road network

Neighbor query in road networks uses a two dimensional representation ofroad network as a data structure to support nearest neighbor query, they pro-posed positioning units to report the query location and location of points ofinterests. From the representation of road network, measure the distance usedthe shortest distance between points algorithm. By the positioning system showsthe points of interests location, the measure used road network graph represen-tation to finding the nearest object [8]. However, the existing literature does notexplain about based nearest neighbor for building in inter-building environmentthat may have multi-level-floor building.

Indoor Environment

The indoor positioning literature is vast and diverse as it takes advantageof several technologies, including: RFID, Wireless LANs, Infrared, Bluetooth,Ultra-Wide-Band, etc, beside their combinations into hybrid systems. Thesetechnologies deliver a promising level of accuracy, comparable to GNSS (GlobalNavigation Satellite System) that is not efficient in indoors. With the presentavailability of sensor-rich mobiles which have increased the interest for a varietyof indoor buildings location-based services, such as, querying, in-building guid-ance and navigation [11]. This is important since most of people spend their timein indoor environments such as houses, offices, shopping malls and others [3].

Moreover, most of buildings are multi-floor environments, where manyqueries can be raised. This clear in Inter-building environment where somequeries such as KNN, which shows the importance of adopting this type ofquery in this environment. For example, a user wants to retrieve the nearestprayer room to its location in Inter-building environment. Note that these inter-building may have buildings with multi-floor environments which gives a higherimportance for determining the best path for the user (Figs. 4 and 5).

In [5], they proposed a floor layout information that specified the coordinatesof each room and also obtained the coordinates of three base stations. However,this study does not explain the floor layout information that have different floorsin a building. [7] proposes a representation in indoor space identify an object

Page 4: Adaptation of k-Nearest Neighbor Queries for Inter ...... · Nearest Neighbor Algorithm Nearest neighbor is an algorithm to finding the given object of interest that is closest to

186 D. Andini et al.

Fig. 4. Inter-building Fig. 5. Indoor space

accurately by storing geographic data that are represented to undirected graphform which has three dimensional attributes x, y, and z, where x and y are thecoordinates of a point, and z represents the height level of the points. Thereare various kinds of elements in indoor spaces such as rooms, doors, corridors,floors, stairs, elevators and the road connection between buildings. Indoor spacesare represented by undirected graph with nodes and edges. The various kindsof elements in indoor can be represented with modeling concept, such as: A cellrepresent room, edge represent door and one or more cells with one or moreedges represent corridor and stair [2,4,7].

From this related work, this paper will define the nearest neighbor adapta-tion based on road network with the combination by considering indoor envi-ronment elements such as the connection between floor. Nearest neighbor forinter-building environment will represent inter-building by graph. The graphused to measure the distance between query location and points of interest.

3 Adaptation Analysis

The general process of this implementation can be modeled with the flowchartbelow (Fig. 6).

Fig. 6. General system process of proposed system

Page 5: Adaptation of k-Nearest Neighbor Queries for Inter ...... · Nearest Neighbor Algorithm Nearest neighbor is an algorithm to finding the given object of interest that is closest to

Adaptation of k-Nearest Neighbor Queries for Inter-building Environment 187

The first step of adaptation is collecting the dataset. The dataset used in thisstudy is the School of Computing, Telkom University’s spatial data in Fig. 7.

Fig. 7. Dataset location of School of Computing, Telkom University

The dataset is geographic data of latitude and longitude of buildings, rooms,label spaces, coordinates and connectivity between spaces. There are three coor-dinates, first longitude as x, latitude as y and z represent level of a buildings,stairs an corridors. Figure 7 an example of how to get the coordinate. Everyrooms, stairs, label spaces and connectivity between spaces are marked to getthe latitude and longitude.

By the dataset, graph data structure will be built by implementing indoorspace representation. At this stage it will be built is undirected graph datastructure by using a representation of three-dimensional space. Unlike the indoorrouting data representation already described, this will represent a phase-storeybuilding in three dimensions based on the location of the coordinates x, y, andz. The value of x is the longitude coordinate, y is the latitude coordinate, and zis the height level of the building.

After building the graph representation, finding the nearest object will be per-formed on undirected graph through measuring distances between query locationand objects of interests. The distances calculate by implement road network forindoor space and use the routing algorithm. The search is performed in generaland with the filtration technique implements a closed space. Performance will bemeasured on the performance of the system is associated with speed of executiontime.

3.1 Three Dimensional Representation

The three dimensional representation captures data by x, y and z coordinates.Unlike two dimensional, three dimensional representation difficult to implementtwo dimensional Euclidean distances cause there are walls, path, stairs and oth-ers. Three dimensional represents every rooms, corridors, stairs of a building.Rooms, corridors and stairs representation by nodes. For each rooms (node) willbe represented according the door of a room. And for each stairs, a node will berepresented as the start of the stair begins and each corner of the stair stop. To

Page 6: Adaptation of k-Nearest Neighbor Queries for Inter ...... · Nearest Neighbor Algorithm Nearest neighbor is an algorithm to finding the given object of interest that is closest to

188 D. Andini et al.

represent three dimensional representation, latitude and longitude every rooms,corridors and stair can used as x and y coordinates. For z coordinates will berepresent by floor.

Fig. 8. Coordinate point of room, corridor and stair on A building

Figure 8 shows the points that represent rooms, corridor and stairs on firstfloor A building. For the second and the third and floors will do the same thing.Latitude, longitude coordinate and floor of each point will be used to build graphrepresentation.

3.2 Graph Representation

Graph representation in Table 1 have some nodes with different colors that sym-bolized different objects. Table 1 is three dimensional representation of buildingsthat was built represent to graph representation.

Table 1. Graph symbol

1 Black node Represents the first floor corridors

2 Red node Represents the third floor corridors

3 Green node Represents the second floor corridors

4 Grey node Represents all rooms

5 Blue node Represents the stairs

6 Line All segments

The define of graph representation and objects have to related to three dimen-sional representation. From the three dimensional representation, there are nodesand segment that can used on graph representation to build a graph. Every nodeis marked by roomid, stairid or corridorid as shown in Fig. 9. It illustrates a graphrepresentation that was built from three dimensional representation.

Page 7: Adaptation of k-Nearest Neighbor Queries for Inter ...... · Nearest Neighbor Algorithm Nearest neighbor is an algorithm to finding the given object of interest that is closest to

Adaptation of k-Nearest Neighbor Queries for Inter-building Environment 189

Fig. 9. Graph representation of A and B building (Color figure online)

3.3 NN in Inter-building Environment

This section will describe the adaptation and implementation of Dijkstra andFloyd Marshall algorithm for NN in inter-building environment. There are threesteps which are: (i) to find nearest neighbor candidates (objects of interest), (ii)to compute the distance between query location and each objects of interests, (iii)to sort the distances. In this adaptation, the NN query that will be performedis monochromatic query.

At this stage, shortest path algorithms will be implemented. In this case thereare Dijkstra’s and Floyd Warshall algorithms that adapted to give the shortestpath and also to calculate the measure between query location and objects ofinterests. Those algorithms used to compare the shortest path algorithm thatfind the shortest path between single node and all pairs of nodes. After all themeasure between objects of interests is calculated, by default, the systems showsthe nearest object and the path to the nearest object (Table 2).

Table 2. Path symbol

1 Yellow nodes Represent objects of interests

2 Brown nodes Represent nodes using Floyd Warshall

3 Purple nodes Represent nodes using Dijkstra

4 Orange line Represent segments using Floyd Warshall

5 Pink line Represent segments using by Dijkstra

In Fig. 10 objects of interest with yellow nodes and the nearest practicumlaboratory from IF2.02.02 is IF02.03.05 and there are similar paths betweenDijkstra and Floyd Warshall. Figure 10 shows there is no pink line or purplenode that represent Dijkstra Algorithm, because the nodes and segments ofDijkstra Algorithm covered by Floyd Warshall.

Page 8: Adaptation of k-Nearest Neighbor Queries for Inter ...... · Nearest Neighbor Algorithm Nearest neighbor is an algorithm to finding the given object of interest that is closest to

190 D. Andini et al.

Fig. 10. Nearest practicum laboratory from IF2.02.02 (Color figure online)

4 Evaluation

4.1 Discussion

Based on first section there are two objectives of testing process: Correctnesstesting to test the correctness of adaptation nearest neighbor query in indoorspace and performance testing to analyze the performance of nearest neighborquery.

We proposed some testing scenarios in this study, related to system’s accu-racy and performance in execution time. The aim of the test of system’s accuracyis to compare between the desired objects with different objects. Another testingscenario is to test of system’s performance in execution time, the aim is to com-pare running time between Dijkstra Algorithm and Floyd Warshall Algorithm.Both of algorithms tested five times with same data and scenario to get theexecution time and also tested with different data and scenario.

4.2 Experiment and Analysis

There are two parts in this experiment. First, experiment for result of the sys-tem’s accuracy. “IF3.02.06” were chosen as a query location and “PracticumLaboratory” as desired object. Table 3 shows the distance between query loca-tion and each objects that have type “Practicum Laboratory”.

Page 9: Adaptation of k-Nearest Neighbor Queries for Inter ...... · Nearest Neighbor Algorithm Nearest neighbor is an algorithm to finding the given object of interest that is closest to

Adaptation of k-Nearest Neighbor Queries for Inter-building Environment 191

Table 3. Distance from IF3.02.06 to Practicum Laboratory

Source Destination Length

IF3.02.02 IF2.03.05 285.299 m

IF3.02.02 IF2.03.06 275.899 m

IF3.02.02 IF2.03.07 262.399 m

IF3.02.02 IF3.01.06 60.442 m

IF3.02.02 IF3.03.01 83.332 m

IF3.02.02 IF3.03.03 69.842 m

IF3.02.02 IF3.03.05 60.442 m

IF3.02.02 IF3.03.07 50.058 m

IF3.02.02 B203B 433.650 m

Table 3 shows that between all of the distances from source is IF3.02.02 todestination object: practicum laboratory, IF3.03.07 is the nearest practicum lab-oratory from IF3.02.02 by the distance is 50.058 m.

Fig. 11. Nearest practicum laboratory from IF3.02.02 (Color figure online)

Figure 11 shows the visualization of distance from query location and theobjects of interests. It shows that there are five practicum laboratories in thesame building that represent by yellow nodes. From all of objects of interests,it show that IF3.03.07 is the nearest practicum laboratory from IF3.02.02 andhave the same result with Table 3.

Part two, experiments were performed to performance testing of the algo-rithm. The nearest Assistant Room from A307A were chosen as a sample. Thistesting do the searching process five times and it take the average value of theexecution times as the result. Figure 12 the comparison clearly according to theconsole output of running execution time the system.

Consider the chart in Fig. 12 it shows the comparison in both shortest pathalgorithm, Floyd Warshall always give the best result. This is evidenced fromthe results of execution time that Floyd Warshall Algorithm shows the lowerexecution for each running program than Dijkstra Algorithm.

Page 10: Adaptation of k-Nearest Neighbor Queries for Inter ...... · Nearest Neighbor Algorithm Nearest neighbor is an algorithm to finding the given object of interest that is closest to

192 D. Andini et al.

Fig. 12. Execution time comparison

The second test choose different query locations and objects with the differentscenarios. Second test is divided into four scenarios: the query location and theobject have same floor and same building, query location and the object havedifferent floor and same building, query location and the object have same floorand different building, query location and the object have different floor anddifferent building. The result of Tables 4 and 5 shown in Figs. 13, 14, 15 and 16.

Table 4. Testing result

No Scenario Querylocation

Destination Result Distance Time execution

Dijskra FloydWarshall

1 Same floor,same building

A101A Serviceroom

A112 71.367 m 2.362 s 1.342 s

2 Different floor,same building

TA1-2 Musholla MA 99.79 m 0.86 s 1.338 s

3 Same floor,different building

B109 Serviceroom

A203A 149.07 m 1.502 s 1.332 s

4 Different floor,different building

A101A Laboratory B203 189.739 m 8.935 s 1.43 s

From the experiment result, nearest neighbor query can adapt in indoor spaceand the shortest path algorithm used on this study have different executiontimes. From Fig. 12 show that Floyd Warshall execution time is more consistent,

Page 11: Adaptation of k-Nearest Neighbor Queries for Inter ...... · Nearest Neighbor Algorithm Nearest neighbor is an algorithm to finding the given object of interest that is closest to

Adaptation of k-Nearest Neighbor Queries for Inter-building Environment 193

Fig. 13. Data process Fig. 14. Distance

Fig. 15. Dijkstra execution time Fig. 16. Floyd execution time

then Dijkstra algorithm that depends on how much data is executed that shownFigs. 13 and 15 that have same graphic. The more data executed the more timerequired by Dijkstra algorithm, but not with Floyd Warshall algorithm. FloydWarshall has consistent execution time because the execution time does not riseor fall much different and does not depend on the amount of data. Based onFigs. 14, 15 and 16 execution time both of Algorithm does not depend on thedistance between the query location and objects.

5 Conclusion

While nearest neighbor queries are commonly used in outdoor, the implemen-tation in indoor is very limited. However, since the network structure of indoorenvironment and outdoor environment are very similar, the adaptation andimplementation of well known kNN algorithms are highly possible. In this paper,we have demonstrated that both Dijkstra and Floyd Warshall algorithms are ableto cope with inter-building environment.

We are now working with implementation and adaptation with NN types,which is reverse nearest neighbour queries to be implemented in inter-buildingenvironment.

Page 12: Adaptation of k-Nearest Neighbor Queries for Inter ...... · Nearest Neighbor Algorithm Nearest neighbor is an algorithm to finding the given object of interest that is closest to

194 D. Andini et al.

References

1. Alamri, S.: An efficient shortest path routing algorithm for directed indoor envi-ronments. ISPRS Int. J. Geo-Inf. 7(4) (2018)

2. Alamri, S., Taniar, D., Safar, M.: Indexing moving objects in indoor cellular space.In: NBiS, pp. 38–44 (2012)

3. Alamri, S., Taniar, D., Safar, M.: A taxonomy for moving object queries in spatialdatabases. Future Gener. Comput. Syst. 37, 232–242 (2014)

4. Alamri, S., Taniar, D., Safar, M., Al-Khalidi, H.: Spatiotemporal indexing for mov-ing objects in an indoor cellular space. Neurocomputing 122, 70–78 (2013)

5. Bahl, P., Padmanabhan, V.N.: RADAR: an in-building RF-based user location andtracking system. In: Proceedings IEEE INFOCOM 2000, Conference on ComputerCommunications, Nineteenth Annual Joint Conference of the IEEE Computer andCommunications Societies, Cat. No. 00CH37064, vol. 2, pp. 775–784 (2000)

6. Cheema, M.A., Lin, X., Zhang, Y., Wang, W., Zhang, W.: Lazy updates: an efficienttechnique to continuously monitoring reverse knn. Proc. VLDB Endow. 2(1), 1138–1149 (2009)

7. Dionti, T.A., Adhinugraha, K.M., Alamri, S.M.: Inter-building routing approachfor indoor environment. In: Gervasi, O., et al. (eds.) ICCSA 2017. LNCS, vol.10404, pp. 247–260. Springer, Cham (2017). https://doi.org/10.1007/978-3-319-62392-4 18

8. Jensen, C.S., Kolarvr, J., Pedersen, T.B., Timko, I.: Nearest neighbor queries inroad networks. In: Proceedings of the 11th ACM International Symposium onAdvances in Geographic Information Systems, pp. 1–8. ACM (2003)

9. Nghiem, T., Green, D., Taniar, D.: Peer-to-peer group k-nearest neighbours inmobile ad-hoc networks. In: 2013 International Conference on Parallel and Dis-tributed Systems, ICPADS, pp. 166–173, December 2013

10. Safar, M.: K nearest neighbor search in navigation systems. Mob. Inf. Syst. 1(3),207–224 (2005)

11. Alamri, D.T.S., Nguyen, K.: Vertical indexing for moving objects in multifloorenvironments. Mob. Inf. Syst. 15 (2018)

12. Taniar, D., Rahayu, W.: A taxonomy for nearest neighbour queries in spatialdatabases. J. Comput. Syst. Sci. 79(7), 1017–1039 (2013)

13. Xia, C., Hsu, D., Tung, A.K.H.: A fast filter for obstructed nearest neighbor queries.In: Williams, H., MacKinnon, L. (eds.) BNCOD 2004. LNCS, vol. 3112, pp. 203–215. Springer, Heidelberg (2004). https://doi.org/10.1007/978-3-540-27811-5 19

14. Zhang, J., Papadias, D., Mouratidis, K., Zhu, M.: Spatial queries in the presence ofobstacles. In: Bertino, E., Christodoulakis, S., Plexousakis, D., Christophides, V.,Koubarakis, M., Bohm, K., Ferrari, E. (eds.) EDBT 2004. LNCS, vol. 2992, pp.366–384. Springer, Heidelberg (2004). https://doi.org/10.1007/978-3-540-24741-8 22

15. Zhao, G., Xuan, K., Taniar, D.: Path knn query processing in mobile systems.IEEE Trans. Ind. Electron. 60(3), 1099–1107 (2013)