Faster and More Robust Meshbased Algorithms for Obstacle Nearest Neighbour
Abstract
We are interested in the problem of finding nearest neighbours in the plane and in the presence of polygonal obstacles (OkNN). Widely used algorithms for OkNN are based on incremental visibility graphs, which means they require costly and online visibility checking and have worstcase quadratic running time. Recently Polyanya, a fast pointtopoint pathfinding algorithm was proposed which avoids the disadvantages of visibility graphs by searching over an alternative data structure known as a navigation mesh. Previously, we adapted Polyanya to multitarget scenarios by developing two specialised heuristic functions: the Interval heuristic and the Target heuristic . Though these methods outperform visibility graph algorithms by orders of magnitude in all our experiments they are not robust: expands many redundant nodes when the set of neighbours is small while performs poorly when the set of neighbours is large. In this paper, we propose new algorithms and heuristics for OkNN which perform well regardless of neighbour density.
Monash University
Melbourne, Australia
David Taniar david.taniar@monash.edu
Monash University
Melbourne, Australia
Daniel D. Harabor daniel.harabor@monash.edu
Monash University
Melbourne, Australia
1 Introduction
The Obstacle (equiv. Obstructed) kNearest Neighbour Problem (OkNN) is a generalised variant of the well known Euclidean kNearest Nearest Problem (kNN) in two dimensions. In both cases the objective is to return the closest neighbours (equiv. targets) to an a priori unknown query point . In the case of OkNN however polygonal obstacles are introduced and the objective is to return shortest distances to each of the closest neighbours without crossing any obstacles. We refer to this metric as the obstacle distance between traversable points. Fig 1 highlights the differences between the two problem settings.
OkNN problems appear in a number of different application areas and are of interest in several different research fields. For example, in the context of spatial databases, it is often desirable to perform clustering queries in the presence of natural or manmade obstacles (such as rivers, trees or buildings) (?). In the context of computer games meanwhile, e.g. as described in (?), agents often rely on nearestneighbour information, such as the location of enemies or resource points, for creating higherlevel plans. Besides being a problem of direct interest, OkNN is also a fundamental subproblem for a number of related spatial queries such as:

Obstacle Range Query (OR) (?): given a query point and a range , find all targets whose obstacle distance to at most equal to . OkNN algorithms can be applied to range queries by setting to be infinite and terminating when the distance to the next closest target is greater than .

Obstacle Reverse kNearest Neighbor (ORkNN) and variants (?, ?)): given a query point and a value , return a set of targets that have as one of their nearest neighbours: i.e. . ORkNN typically involes two stages: (i) search stage, which explores the space to obtain a set of candidates; (ii) refine stage, which removes from the set of candidates those for which is not in the top neighbours. Each of the two stages benefits directly from an efficient routine for OkNN.

Continuous Obstacle kNearest Neighbor (COkNN) (?): similar to OkNN, but the query point is generalised to a line segment. Solving such queries typically involves generating a list of socalled “split points”, and then invoking an OkNN query for each of these points.
Two popular algorithms for OkNN, which can deal with obstacles, are local visibility graphs (?) and fast filter (?). Though different in details, both of these methods are similar in that they depend on the incremental and online construction of a graph of covisible points followed by an online Dijkstra search. Algorithms of this type are simple to understand, provide optimality guarantees and the promise of fast performance. Such advantages make incremental visibility graphs attractive to researchers. However, incremental visibility graphs also suffer from a number of notable disadvantages including: (i) online visibility checks; (ii) an incremental construction process that has up to quadratic space and time complexity for the worst case; (iii) duplicated effort, since the graph is discarded each time the query point changes.
In a previous paper (?) we develop a new method for computing OkNN which avoids these disadvantages and which can improve runtime performance by several orders of magnitude. Our work extends Polyanya (?): a recent and very fast algorithm for computing Euclidean shortest paths on a navigation mesh: a data structure comprised of convex polygons which taken together represent the entire traversable space. Compared to visibility graphs, navigation meshes are much cheaper to construct and sometimes available as input “for free” (e.g. in computer game settings, navigation meshes are often created, at least in part, by human designers). In a range of experiments we show that each of our previously proposed techniques can be several orders of magnitude faster than LVG (?), a stateoftheart algorithm based on incremental visibility graphs.
Limitations in Our Previous Work. Our previous work described three multitarget variants of Polyanya, each of which offers state of the art performance but only in specific experimental scenarios:

Bruteforce Polyanya, a simple algorithm that invokes pointtopoint Polyanya repeatedly, once for each target. Though extremely naive this algorithm was undominated in our experiments in scenarios with few targets and for values of .

Interval Heuristic , which replaces the pointtopoint heuristic function of the original algorithm with a consistent and online alternative that minimises costtogo distance for all targets in the candidate set. In our experiments this algorithm was undominated in densetarget scenarios where the map contains many nearest neighbour candidates.

Target Heuristic , a costly preprocessingbased heuristic function which always chooses the Euclideannearest candidate for computing costtogo estimates. In our experiments this algorithm was undominated in sparsetarget scenarios with small values of .
Contributions. In this paper, we propose new preprocessingbased algorithms and heuristics for OkNN which improve on the performance of our previous work and which are more robust, in the sense that they perform well across a larger range of experimental scenarios including different target densities and for a wider range of values for :

We combine Polyanya with a technique known as Incremental Euclidean Restriction to derive a simple but very effective OkNN algorithm based on repeatedly solving pointtopoint queries.

We develop an efficient preprocessing framework that involves computing labels that we store with the edges of the navigation mesh. We exploit these labels during a subsequent online phase and derive two new OkNN query algorithms: (i) Fence checking which is very fast but only works when ; (ii) Fence Heuristic which works in the general case and which performs as well as and sometimes better than and , regardless of target density.
2 Related work
2.1 Rtree and traditional kNN
Traditional kNN queries in the plane (i.e. no obstacles) is a well studied problem for which there exists many well known and efficient spatial indexing schemes. Perhaps the most successful and well known of these is the Rtree (?), a hierarchical data structure which organises a collection of spatial objects embedded in the plane (e.g. points or polygons) into a heightbalanced tree. Though many variants exist (?, ?, ?), each of which improves the basic idea in some way, they all operate similarly and provide similar functionality. For this reason we opt to describe only the original work.
There are two types of nodes in an Rtree: leaves, which represent single objects, and interior nodes which are associated with a Minimal Bounding Rectangle (MBR). The MBR of an interior node contains the objects of all of its children and their associated MBRs. Meanwhile, nearestneighbour queries involve a branchandbound traversal that depends on two important metrics:

mindist, which bounds from below the minimum distance from the query point to the closest object in the MBR of the current node;

minmaxdist, which bounds from below the minimum distance from the query point to the furthest object in the MBR of the current node.
The query algorithm starts at the root of the tree node and proceeds down, prioritizing nodes by mindist and pruning the search space by minmaxdist. Though improvements to this basic algorithm exist they employ a similar schema, albeit with different prioritisation and pruning strategies; e.g. (?, ?).
2.2 OkNN Queries and Visibility Graphs
Solving pointtopoint obstacle distance queries in mainmemory is a well studied problem for which many algorithms exist (?). Optimal methods usually precompute a visibility graph (VG), which adds edges between pairs of vertices that are covisible. Figure 3 shows an example.
Once the graph is created (including all candidate target points in the case of OkNN), queries can be resolved by way of A* or using Dijkstra’s well known algorithm. In case the query point is not one of the existing vertices of the graph, a further online insertion operation is performed before search can begin. The main drawback of visibility graphs is their worstcase time and space complexity which can be up where is the number of vertices in the map (?). In spatial database scenarios, for example, can be more than , so inmainmemory approaches are not suitable. Researchers in this field are thus motivated to design variant algorithms that only consider and process obstacles relevant to the current query. Two popular methods based on this idea are Local Visibility Graphs(LVG) (?) and Fast Filter (?). We have previously discussed the strengths and weaknesses of these methods in Section 1.
2.3 Pathfinding on Navigation Mesh
A navigation mesh is a data structure that divides the traversable space into a set of convex polygons. Originally proposed by Arkin (?), this spatial representation technique has been widely applied to pathfinding problems in areas such as robotics and computer games. Navigation meshes can be generated easily and efficiently. For example, Constrained Delaunay Triangulations (?), a popular starting point for many meshbased algorithms, can be constructed in time. In other settings, such as computer games, navigation meshes are available as input “for free”, having been created, at least in part, by human designers.
Until recently pathfinding algorithms developed for navigation meshes have typically lacked both strong performance and optimality gurantees (?, ?). Polyanya (?) is a recent navigation mesh algorithm which changes the status quo by being compromisefree: i.e. simultaneously fast, optimal and (assuming the mesh is given as input) entirely online. We give a technical description of this algorithm in Section 4. Our previous work on the topic of OkNN (?) extends Polyanya, from pointtopoint pathfinding to the multitarget case.
3 Problem Statement
OkNN is a nearestneighbour search in two dimensions that can be formalised as follows:
Definition 3.1.
Obstacle kNearest Neighbour (OkNN): Given a set of points , a set of obstacles , a distinguished point and and an integer : return a set such that for all .
Where:

is a set of nontraversable polygonal obstacles.

is a set of traversable points called targets.

is a traversable point called the query point.

is an input parameter that controls the number of nearest neighbours that will be returned.

and are functions that measure the shortest distance between two points, as discussed below.

is the nearest neighbour of .
Stated in simple words, the objective is to find the set of targets which are closest to from among all possible candidates in .
When discussing distances between two points and we distinguish between two metrics:
which is the well known Euclidean metric (i.e. “straightline distance”) and
which measures the length of a shortest path
between points and such that no pairwise segment of the path intersects any point inside an obstacle (i.e. “obstacle avoiding distance”).
Solution approaches for OkNN can be broadly categorised into two schemas:

Linear search methods, which involve the repeated application of a pointtopoint pathfinding algorithm, from to selected . Linear search methods terminate when it can be proven that the obstacle distance to all nearest neighbours has beeen found. Instatiations of this schema include the OkNN algorithms known as LVG (?) and fast filter (?).

Spatial partitioning methods, which consider all candidate targets simultaneously and which attempt to solve a given instance of kNN in a single integrated search. Such methods apply prioritised search (e.g. best first or branchandbound) in combination with specialised heuristics that prune the set of candidates and focus attention toward the most promising target first. Instantiating this schema are a variety of Euclidean kNN methods such as Rtree (?) and Spatial KDtree (?).
In our previous work we describe three algorithms for OkNN: Bruteforce Polyanya, which instantiates linear search, and Polyanya in combination with the heuristics and , both of which instatiate the spatial partioning search schema.
4 Polyanya and heuristic functions: h, h, h
In its canonical form Polyanya is a pointtopoint Euclidean shortest path algorithm which can be seen as an instance of A*: it performs a bestfirst search using an consistent heuristic function to prioritise nodes for expansion. The mechanical details are however quite different. Since we will employ a similar search methodology to Polyanya, we give herein a brief description of that algorithm. There are three key components:

Search Nodes: Conventional search algorithms proceed from one traversable point to the next. Polyanya, by comparison, searches from one edge of the navigation mesh to another. In this model search nodes are tuples where each is a contiguous interval of points and is a distinguished point called the root. Nodes are constructed such that each point is visible from . Meanwhile, itself corresponds to the last turning point on the path: from to any . Fig 5 shows an example.

Successors: Successor nodes are generated by “pushing” the current interval away from its root and through the interior of an adjacent and traversable polygon. A successor is said to be observable if each point is visible from . The successor node in this case is formed by the tuple . By contrast, a successor is said to be nonobservable if the taut (i.e. locally optimal) path from to each must pass through one of the endpoints of current interval . The successor node in this case is formed by the tuple with as one of the points or . Fig 5 shows an example.
Note that the target point is inserted in the open list as a special case (observable or nonobservable) successor whenever the search reaches its containing polygon. The interval of this successor contains only the target.

Evaluation using h: When prioritising nodes for expansion, Polyanya makes use of an value estimation for a given search node , and target :
where represents the length of a concrete shortest path from to , and represents the lowerbound from to via some . There are three cases to consider which describe the relative positions of the in relation to the . These are illustrated in Fig 6. The objective in each case is to choose the unique that minimises the estimate. The three cases together are sufficient to guarantee that the estimator is consistent.
Similar to A*, Polyanya terminates when the target is expanded or when the open list is empty. In (?) this algorithm is shown to outpeform a range of optimal and suboptimal competitors, often by orders of magnitude.
4.1 Interval Heuristic h
In some OkNN settings targets are myriad and one simply requires a fast algorithm to explore the local area. The idea we introduce for such settings takes the form of a specialised heuristic function which we combine with Polyanya. It can be formalised as follows:
Definition 4.1.
Given search node , the interval heuristic is the minimum Euclidean distance from to any point .
The Interval Heuristic is consistent (?), and applying it only requires solving a simple geometric problem: finding the closest point on a line. Since this operation is trivial has a low computation overhead and can be applied entirely online. Stated differently, discards all spatial information about any target and performs instead a Dijkstralike search which can quickly explore surrounding polygons. When targets are many and randomly distributed this approach can be highly efficient. The main drawback is redundant search effort in nontarget areas, such as can occur when targets are few and sparsely distributed.
4.2 Target Heuristic h
In some OkNN settings the targets are sparse, so we need an effective method to prune the search space. The idea we introduce for such settings again takes the form of a specialised and consistent heuristic, , which we again combine with Polyanya.
Definition 4.2.
Given search node , the target heuristic is:
The idea is simple: each time Polyanya expands a node computes a costtogo it does so with respect to the Euclideannearest candidate which has not yet been added to the nearest neighbour set. Selecting such a target involves four nearest neighbour queries which we solve using an Rtree. This approach computes all nearest neighbours in a single run. Compared to , this heuristic can significantly reduce the number of node expansions because it always drives the search in the direction of the most promising candidate point. This approach performs well when target are sparse. The main drawback is the high cost of computing nearest neighbours when targets are numerous, dense and found in any direction.
5 Proposed Methods
We propose two distinct ideas for improving OkNN Search. The first idea involves computing, during an offline preprocessing step, a set of “fence labels” for each edge of the navigation mesh. The labels bound the distance from the edge to the nearest point in the target candidates set. We exploit the labels to improve the performance of a subsequent online search. The second idea we propose involves running pointtopoint Polyanya, from the query location and to each target in the candidate set, in the order specified by a preprocessingbased heuristic technique known as Incremental Euclidean Restriction.
5.1 Fence Labelling
Interval heuristic can give us the minimum obstacle distance from the root to an edge of the mesh, an interesting observation is that if the algorithm have explored the entire map, then each edge of meshes must contains such information. Furthermore, if we ran such fullmap exploration starting with each target and store obtained information, we would utilize such information for actual queries.
The described idea cannot be efficient, in spite of the time complexity, we need at least space to store obtained information, where is the number of mesh edges, and is the number targets.
However, similar to traditional nearestneighbour query (?, ?), we can apply minmaxdist pruning in this case.
Definition 5.1.
Given a mesh edge , a search node where and (resp. ) is the endpoint of closer to (resp. ), then:

mindist ,

minmaxdist
In other words, for a given root , the length of shortest path to any point must in range , see an example in Fig 7.
To distinguish the gvalue in preprocessing and search, let’s define as follow:
Definition 5.2.
Let be a search node produced by target in preprocessing:
Definition 5.3.
Dominate: Given two search nodes and , where and are on same mesh edge , dominates iff .
Lemma 5.1.
Let and be two search nodes in preprocessing stage, where and are on same mesh edge , and dominates ; for a given query point , let be any point on . Then:
Proof.
We have two equations:
(1) 
(2) 
then is:
according to definition 5.1, we have:
(3) 
(4) 
and because dominates , we have:
(5) 
thus . ∎
Lemma 5.1 implies that, in preprocessing, we can discard those search nodes who is dominated by others, let’s call this fence pruning.
Definition 5.4.
Fence lies on each mesh edge, it contains a collection of search nodes produced by preprocessing, let’s call those search nodes labels ^{1}^{1}1To make discussion clear, we call this ”search node” in context of preprocessing, and ”label” in context of query processing. Fence has a property (default value is INF), and in preprocessing stage, it blocks all passing search nodes that:
.
Finally we propose a floodfilllike algorithm: in initialization, for each target , generate successors on the edges of mesh that contains , and store those search nodes in a openlist; similar to OkNN search, we expand search nodes in the order of their fvalue, where ; meanwhile, we apply fence pruning and update upperbound of the fence befor the expansion; the algorithm terminates when openlist becomes empty, see in algorithm 1.
Notice that the total number of search nodes can still up to , one case is that targets are distributed in a single cluster, and all obstacles line in two rows, so that all targets produce labels on mesh edges in the middle (see in Fig 7(b)). However, our experiment in section 6 indicates that most of fence only contains 2 to 3 labels (search nodes), and there are two observations to convince us the effectiveness of preprocessing (see in Fig 7(b)):

If two targets are very close, their may produce labels on same fence, but their successors must be pruned by one of other when root changes (known as root pruning (?));

If two targets are not close, they will dominate surrounding mesh edges and block search nodes from further targets.
5.2 Apply on nearestneighbour query
After preprocessing, for a given query point , there are tow cases:

Case 1: there’s no labels on surrounding fences;

Case 2: all surrounding fences contain labels;
The Case 1 implies that there’s no path from to any target ;
Lemma 5.2.
In the Case 2, at least one of label is produced by the obstacle nearestneighbour of .
Proof.
Assume the obstacle nearest neighbour of is , and surrounding fences of not contain any label produced by , then:

Case 1: there’s no path from to , which contradict to the assumption;

Case 2: all successors of are dominated by others, and according to lemma 5.1, can not be the nearestneighbour of , which contradict to the assumption as well.
Thus, such doesn’t exists. ∎
Therefore, we can run pointtopoint search from to all roots of search nodes in surrounding fences, and find the nearestneighbour, we call this algorithm Fence Checking, see details in algorithm 2. Notice that algorithm 2 only search to the last vertex instead of the entire path, so it is very fast.
5.3 Generalize to knearest neighbours
When , search nodes of next nearestneighbour may be dominated by a visited nearestneighbour and thus no labels on surrounding fences. So we still need a search process to explore the map, and we need to design heuristic function to prioritise search nodes in query processing. We first present an admissible but not consistent heuristic naive fence heuristic: ; then we show how to adapt it to a consistent heuristic fence heuristic: .
Definition 5.5.
: let be the fence lies on mesh edge , be a label on , be a search node produced by query point , where on , then
Stated in simple words, evaluates the distance from current root to the nearest target through interval and .
Theorem 5.3.
is admissible, more specific: given a search node , for :
Proof.
Given a search node , let be the label on fence that used by : and is produced by a target ; and let be the shortest path from to any target pass through and ; there are three cases:

If and has label on the , according to definition 5.5, we have ;

If and none of ’s label on the , then they must be dominated by some fences, according to lemma 5.1, we still have .
Thus, is admissible. ∎
Notice that when are covisible, and otherwise it’s an underestimation. Such observation indicates that may not consistent, Fig 9 shows an example.
Therefore, when we expand a search node , those labels who lay on the fence but are not covisible may ruin the consistency. To fix this problem, instead of checking visibility in , we can simply keeping the maximum fvalue during the search.
Definition 5.6.
Fence heuristic : for a given search node , guarantees
where is the fvalue of the parent search node.
Theorem 5.4.
The is consistent, more specific, is admissible and for a given search node and it’s successor :
Proof.
Let be the current search node, and be any successor. First, we show that is admissible by mathematic induction:

Initially, when doesn’t has any parent, which is admissible according to theorem 5.3;

Assume for is admissible during the search;

For successor , if then is admissible;

Otherwise which is also admissible;
Thus is admissible, and according to definition 5.6, is always true, so it is consistent. ∎
Finally, we implement the fence heuristic search in algorithm 3.
5.4 IERPolyanya: Polyanya with Incremental Euclidean Restriction
From previous experiments (?), we notice that the bruteforce Polyanya, a naive adaption of Polyanya that running pointtopoint search for each target, outperforms other sophisticated comptitors under certian scenarios. Such positive results motivate us to design more efficient algorithm.
Notice that for same pair of points , we always have , this is called Euclidean lowerbound property (?). Utilize such property, we can prune the search space, similar ideas also appeared in previous literatures (?, ?, ?). We implement this idea as follow: given query point , the algorithm use incremental nearest neighbor query in Rtree (?) to visit target in order of , then use Polyanya to compute and keep track knearest neighbours with metric; the algorithm terminates when where is the current th obstacle nearest neighbour of , see in algorithm 4.
Lemma 5.5.
When algorithm 4 terminates, the candidates stores top smallest obstacle distances.
Proof.
Assume there is an unvisited that , where is the th nearest neighbor. Since is s unvisited, we have ; according to Euclidean lowerbound property, we have and , therefore we have which contradict to the assumption, so such doesn’t exist. ∎
The effectiveness of IERPolyanya affected by two factors:

False hit: a searched target not being retrieved is called false hit. False hit is more likely happen when Euclidean metric is misleading, for example in Fig 1, is the first target to search but wouldn’t be retrieved when .

Overlapping search space: since each search is independent, same search space may be explored multiple times.
In section 6, we will examine the performance of IERPolyanya based these considerations.
6 Empirical Analysis
OkNN problem often appears in both AI pathfinding and spatial query preprocessing, so we examine the performance of proposed methods on different maps that corresponding two these two application scenarios. Fig 10 shows the set of maps that we consider in our experimental evaluation.


We choose three maps from a well known AI pathfinding benchmark sets (?): AR0602SR, brc202d, CatwalkAlley; and a synthetic map 8K tiled obstacles from our previous work (?)^{2}^{2}2There are few real datasets (e.g. http://www.rtreeportal.org/), but all expired that not publicly available, the way we created such synthetic map is described below:

Tiled obstacles map. we extract the shape of all parks in Australia from OpenStreetMap(?) and use these shapes as polygonal obstacles. There are initially 9000 such polygons^{3}^{3}3In our previous (?), it’s called 9000 obstacles map., after removing invalid polygons, there are 8385 polygons left. Next we generate a map by tiling all obstacles in the empty square plane. For the tiling, we first divide the square plane into grid having number of rows and columns. Then we assign each polygon to a single grid cell and normalize the shape of polygon by to fit inside the cell.
The navigation mesh of map is generated by Constrained Delaunay Triangulation, which is ; the implementation of such algorithm is in library Fade2D ^{4}^{4}4http://www.geom.at/fade2d/html, the total time on such preprocessing is about 6s.
Parameters  Values 

1, 5, 10, 25, 50  
Maps  AR0602SR, brc202d, CatwalkAlley, 8Ktiledobs 
Target Density ()  0.0001, 0.001, 0.01, 0.1 
Target distribution  random, clustered 
In each query processing experiment, we choose parameters from Table 1. Notice that we define target density by where is the number of vertices, while other works (?, ?, ?) used as their density where is the number of obstacles. The reason is that game maps usually have few large continuous obstacles.
We’re using random query points for each setting, grouping results by xaxis, and computing average; the size of each bucket is at least 10; All algorithms appear in experiments are:

LVG: Local Visibility Graph (?);

h: Interval heuristic (?);

h: Target heuristic (?);

h: Fence heuristic (Algorithm 3);

fc: Fence Checking (Algorithm 2);

IERPoly: Polyanya with Incremental Euclidean Restriction (Algorithm 4);
These algorithms are implemented in C++ and compiled with clang902.0.39.1 using O3 flag, under x86_64appledarwin17.5.0 platform. All of our source code and test data set are publicly available ^{5}^{5}5http://bitbucket.org/dharabor/pathfinding. All experiments are performed on a 2.5 GHz Intel Core i7 machine with 16GB of RAM and running OSX 10.13.4.
6.1 Experiment 1: preprocessing
This experiment is to examine the performance of preprocessing. For each map, we generated random distributed target set with four density and run floodfill with fence pruning (algorithm 1).
Time cost. We collect the execution time of each instance and group by map, each group contains data from different density. Tabel 2 shows that the std of each group is relative small but the mean of groups are very different, so we can conclude that the time cost of preprocessing is not sensitive to density of targets but the map itself (e.g. number of vertices).
map  vertices  mean  std  min  25%  50%  75%  max 

AR0602SR  5504  6.92  0.14  6.72  6.84  6.92  6.98  7.21 
brc202d  4164  6.11  0.25  5.63  5.98  6.09  6.25  6.54 
CatwalkAlley  15301  26.73  2.35  22.83  25.55  26.15  28.49  30.87 
8Ktiledobs  109171  537.16  24.94  499.93  522.24  537.60  552.43  580.43 
Label size. This metric indicates the space cost and the performance during the query processing. We collect the number of labels on each mesh edge and group by map, then in each group, we further group data by density^{6}^{6}6There are of edges have more than 10 and up to 300 labels, we filter these out for better visualisation. Fig 11 shows that for all maps and all densities, medians of label size per edge are simlar.
6.2 Experiment 2: random distributed targets
The aim of this experiment is to examine the performance of proposed algorithms when and (density) change, by default, and . The effectiveness of heuristic function is measured by total search time divide by number of generated node, so for same search time, larger heuristic cost meaning smaller search space. We also include the previous stateoftheart LVG in comparison, and since this method may reach quadratic time complexity under some scenarios, we clip the execution time by ms.
From Fig 12 and Table 3, we make the following observations:

IERPolyanya always outperforms others, and when is fixed it’s nearly order of magnitude faster than and . The reason is that Euclidean metric in this map with random distributed targets is very good, so it has small number of false hit and thus get benefit from the fast pointtopoint search.

Fence heuristic has simlar number of generated search nodes to regarding the heuristic cost, and in general, it also has similar time cost to . Besides, it significantly outperforms when and is fixed. So we can conclude that has both good time cost and small number of generated nodes.

LVG is completely dominated by others in all cases, so we can remove this competitor in further experiments.
heuristic  mean  std  min  25%  50%  75%  max 

0.82  0.19  0.05  0.72  0.80  0.91  2.83  
0.26  0.07  0.02  0.23  0.25  0.29  1.77  
162.19  262.96  9.23  71.29  93.23  112.16  8191.00  
0.42  0.12  0.08  0.34  0.39  0.44  1.42 
6.3 Experiment 3: clustered targets
One drawback of IERPolyanya is that each repeated search is independent, so that it makes many redundant computation when those searches are overlapped. The aim of this experiment is to examine the performance of IERPolyanya when search space overlapped. We create a single cluster of targets, and to get rid of the influence of false hit, we let the size of cluster be , so that when the false hit becames .
From Figs 12(a),12(b) we make following observations:

when , IERPolyanya is outpeformed by because the false hit;

when , false hit is , but IERPolyanya is still significantly outpeformed by , while in previous experiment, it’s faster than for all . So we can conclude that IERPolyanya has bad performance when search space overlapped.
6.4 Experiment 4: varying maps
Another drawback of IERPolyanya is that the Euclidean metric can be misleading in some maps. The aim of this experiment is to examine the performance of IERPolyanya on different types of maps.
We run random queries with default parameter where targets are randomly distributed. To show the influence of misleadingness, we analyze results as follow:

We use the number of nodes generated by measure the difficulty of search;

For each search, we evaluate the speedup factor of each method by time cost of such method divide by time cost of ;

We plot the number of falsehit and the speedup factor with increasing difficulty for each map.
Such speedup comparison also appears in other pathfinding literature (?).
From fig 15 we make following observations:

In all maps, when false hit increases the speedup factor decreases, meaning that false hit affect the performance of IERPolyanya.

AR0602SR,brc202d,CatwalkAlley have more false hit than 8K tiled obstacles, meaning that Euclidean metric is misleading in those maps.

In those misleading maps, speedup factor of IERPolyanya is relative small, and sometimes less than (worse than ), meaning that IERPolyanya doesn’t work well when Euclidean metric becomes misleading.
6.5 Experiment 5: Nearest neighbor query
The advantage of fence checking is only searching the last vertex of the shortest path, the aim of this experiment is to examine when it performs well. In the experiment, we run random queries with different densities, then we analyze results in two aspects: (i) grouping results by number of vertices on path to examine the performance when it gets advantage; (ii) grouping results by to examine the general performance in different density.
Fig 13(a) shows that fence checking is not sensitive to the number of vertices on path and can be orders of magnitude faster than other competitors when it gets advantage.
Fig 13(b) shows that fence checking outperforms others when , the reason is that when density increases, the number of vertices on shortest path decrease, thus fence checking gradually lose the advantage.




7 Conclusion and Future Work
We study the obstacle knearest neighbours problem which appears in both AI pathfinding and spatial database areas. In this paper, we proposed two efficient methods: fence heuristic and IERPolyanya.
Fence heuristic utilizes precomputed information to guide the search process, compare to and in our previous work, it has both cheap heuristic cost and small search space, and it performs well in whatever target density. The preprocessing for Fence heuristic has bad theoretical upper bound, but it is efficient in practical when a pruning strategy be applied. IERPolyanya utilizes a fast pointtopoint search to compute obstacle distance and Euclidean restriction to prune candidate set, it sometimes outperforms Fence heuristic order of magnitude, but such performance is not stable that sensitive to the distribution of targets and obstacles.
There are several possible directions for future work. Firstly, current Fence heuristic performs a linear search for labels on fence to compute the heuristic value, an obvious improvement is to store labels by their interval, and during the search, only retrieval labels with overlapped interval (meaning visible). Secondly, notice that adding or deleting targets only affect a small area of the map, so that we can develop these operations to efficiently maintain fence labels when targets change. Thirdly, one possible way to deal the worst case in preprocessing is reconstructing part of the navigation mesh.
References
 Abeywickrama et al. Abeywickrama, T., Cheema, M. A., & Taniar, D. (2016). knearest neighbors on road networks: A journey in experimentation and inmemory implementation. PVLDB, 9(6), 492–503.
 Aha et al. Aha, D. W., Molineaux, M., & Ponsen, M. (2005). Learning to win: Casebased plan selection in a realtime strategy game. In MuñozÁvila, H., & Ricci, F. (Eds.), Proceedings of the International Conference on CaseBased Reasoning (ICCBR), pp. 5–20.
 Arkin Arkin, R. C. (1989). Navigational path planning for a visionbased mobile robot. Robotica, 7(1), 49–63.
 Beckmann et al. Beckmann, N., Kriegel, H., Schneider, R., & Seeger, B. (1990). The r*tree: An efficient and robust access method for points and rectangles. In GarciaMolina, H., & Jagadish, H. V. (Eds.), Proceedings of the 1990 ACM SIGMOD International Conference on Management of Data, Atlantic City, NJ, USA, May 2325, 1990., pp. 322–331. ACM Press.
 Cheung & Fu Cheung, K. L., & Fu, A. W. (1998). Enhanced nearest neighbour search on the rtree. SIGMOD Record, 27(3), 16–21.
 Chew Chew, L. P. (1989). Constrained delaunay triangulations. Algorithmica, 4(1), 97–108.
 Cui et al. Cui, M., Harabor, D. D., & Grastien, A. (2017). Compromisefree pathfinding on a navigation mesh. In Sierra, C. (Ed.), Proceedings of the TwentySixth International Joint Conference on Artificial Intelligence, IJCAI 2017, Melbourne, Australia, August 1925, 2017, pp. 496–502. ijcai.org.
 de Berg de Berg, M. (2000). Computational geometry: algorithms and applications, 2nd Edition. Springer.
 Demyen & Buro Demyen, D., & Buro, M. (2006). Efficient triangulationbased pathfinding. In Proceedings, The TwentyFirst National Conference on Artificial Intelligence and the Eighteenth Innovative Applications of Artificial Intelligence Conference, July 1620, 2006, Boston, Massachusetts, USA, pp. 942–947. AAAI Press.
 Gao et al. Gao, Y., Liu, Q., Miao, X., & Yang, J. (2016). Reverse knearest neighbor search in the presence of obstacles. Inf. Sci., 330, 274–292.
 Gao et al. Gao, Y., Yang, J., Chen, G., Zheng, B., & Chen, C. (2011). On efficient obstructed reverse nearest neighbor query processing. In Cruz, I. F., Agrawal, D., Jensen, C. S., Ofek, E., & Tanin, E. (Eds.), 19th ACM SIGSPATIAL International Symposium on Advances in Geographic Information Systems, ACMGIS 2011, November 14, 2011, Chicago, IL, USA, Proceedings, pp. 191–200. ACM.
 Gao & Zheng Gao, Y., & Zheng, B. (2009). Continuous obstructed nearest neighbor queries in spatial databases. In Çetintemel, U., Zdonik, S. B., Kossmann, D., & Tatbul, N. (Eds.), Proceedings of the ACM SIGMOD International Conference on Management of Data, SIGMOD 2009, Providence, Rhode Island, USA, June 29  July 2, 2009, pp. 577–590. ACM.
 Ghosh & Mount Ghosh, S. K., & Mount, D. M. (1991). An outputsensitive algorithm for computing visibility graphs. SIAM J. Comput., 20(5), 888–910.
 Guttman Guttman, A. (1984). Rtrees: A dynamic index structure for spatial searching. In Yormark, B. (Ed.), SIGMOD’84, Proceedings of Annual Meeting, Boston, Massachusetts, USA, June 1821, 1984, pp. 47–57. ACM Press.
 Harabor et al. Harabor, D. D., Grastien, A., Öz, D., & Aksakalli, V. (2016). Optimal anyangle pathfinding in practice. J. Artif. Intell. Res., 56, 89–118.
 Hjaltason & Samet Hjaltason, G. R., & Samet, H. (1999). Distance browsing in spatial databases. ACM Trans. Database Syst., 24(2), 265–318.
 Kallmann Kallmann, M. (2005). Path planning in triangulations. In Proceedings of the IJCAI workshop on reasoning, representation, and learning in computer games, pp. 49–54.
 Kamel & Faloutsos Kamel, I., & Faloutsos, C. (1994). Hilbert rtree: An improved rtree using fractals. In Bocca, J. B., Jarke, M., & Zaniolo, C. (Eds.), VLDB’94, Proceedings of 20th International Conference on Very Large Data Bases, September 1215, 1994, Santiago de Chile, Chile, pp. 500–509. Morgan Kaufmann.
 Ooi Ooi, B. C. (1987). Spatial kdtree: A data structure for geographic database. In Schek, H., & Schlageter, G. (Eds.), Datenbanksysteme in Büro, Technik und Wissenschaft, GIFachtagung, Darmstadt, 1.3. April 1987, Proceedings, Vol. 136 of InformatikFachberichte, pp. 247–258. Springer.
 OpenStreetMap contributors OpenStreetMap contributors (2017). Planet dump retrieved from https://planet.osm.org . https://www.openstreetmap.org.
 Roussopoulos et al. Roussopoulos, N., Kelley, S., & Vincent, F. (1995). Nearest neighbor queries. In Carey, M. J., & Schneider, D. A. (Eds.), Proceedings of the 1995 ACM SIGMOD International Conference on Management of Data, San Jose, California, USA, May 2225, 1995., pp. 71–79. ACM Press.
 Sellis et al. Sellis, T. K., Roussopoulos, N., & Faloutsos, C. (1987). The r+tree: A dynamic index for multidimensional objects. In Stocker, P. M., Kent, W., & Hammersley, P. (Eds.), VLDB’87, Proceedings of 13th International Conference on Very Large Data Bases, September 14, 1987, Brighton, England, pp. 507–518. Morgan Kaufmann.
 Sturtevant Sturtevant, N. R. (2012). Benchmarks for gridbased pathfinding. IEEE Trans. Comput. Intellig. and AI in Games, 4(2), 144–148.
 Tung et al. Tung, A. K. H., Hou, J., & Han, J. (2001). Spatial clustering in the presence of obstacles. In Proceedings 17th International Conference on Data Engineering, pp. 359–367.
 Xia et al. Xia, C., Hsu, D., & Tung, A. K. H. (2004). A fast filter for obstructed nearest neighbor queries. In Williams, M. H., & MacKinnon, L. M. (Eds.), Key Technologies for Data Management, 21st British National Conference on Databases, BNCOD 21, Edinburgh, UK, July 79, 2004, Proceedings, Vol. 3112 of Lecture Notes in Computer Science, pp. 203–215. Springer.
 Zhang et al. Zhang, J., Papadias, D., Mouratidis, K., & Zhu, M. (2004). Spatial queries in the presence of obstacles. In Bertino, E., Christodoulakis, S., Plexousakis, D., Christophides, V., Koubarakis, M., Böhm, K., & Ferrari, E. (Eds.), Advances in Database Technology  EDBT 2004, 9th International Conference on Extending Database Technology, Heraklion, Crete, Greece, March 1418, 2004, Proceedings, Vol. 2992 of Lecture Notes in Computer Science, pp. 366–384. Springer.
 Zhao et al. Zhao, S., Taniar, D., & Harabor, D. D. (2018). Fast knearest neighbor on a navigation mesh. In Bulitko, V., & Storandt, S. (Eds.), Proceedings of the Eleventh International Symposium on Combinatorial Search, SOCS 2018, Stockholm, Sweden  1415 July 2018, pp. 124–132. AAAI Press.