Kinetic Nearest Neighbor Search in Black-Box Model

Proximity problems is a class of important problems which involve estimation of distances between geometric objects. The nearest neighbor search which is a subset of proximity problems, arises in numerous ﬁelds of applications, including Pattern Recognition, Statistical classiﬁcation, Computer vision and etc. In this study, a nearest neighbor search is presented to move points in the plane, while query point is static. The proposed method works in the black-box KDS model, in which the points location received at regular time steps while at the same time, an upper bound dmax is known on the maximum displacement of any point at each time step. In this paper, a new algorithm is presented for kinetic nearest neighbor search problem in the black-box model, under assumptions on the distribution of the moving point set P. It has been shown how the kinetic nearest neighbor will be updated at each time step in O(k∆k logn) amortized time, where ∆k is the k-spread of a point set P. Key words: Computational Geometry, Black Box Model, Kinetic, Nearest Neighbor.


Introduction
In recent years, there has been a growing amount of research dealing with moving, or kinetic, data. Algorithms dealing with objects in motion traditionally discretized time and recompute the structure of interest at every time step from scratch. This can be wasteful, especially if time steps are small. Since objects will move more slightly, and the structure may not change at all. Ideally an object receives attention if and only if, its new location triggers an actual change in the structure. A basic assumption in the Kinetic Data Structure (KDS), which is introduced by Basch et al. [1], is that the object trajectories are known. This assumption severely limits the applications of KDS framework.
Sometimes in an online manner, the object locations are available only at time steps. So when future tracking moving object is not available, the basic assumption in the KDS model is not always valid (refer to surveys by Guibas for more information about KDSs [5,6]). Certainly, there is a need for a hybrid model, which combines ideas from the KDS model with a traditional time-slicing approach. De Berge et al. [2] introduced kinetic data structures in black-box model with fewer restrictions, instead of knowing knowledge of the trajectories. They only assume that they know upper bounds on objects' speed and can compute their positions at regular time steps. They develop KDSs in the black-box model that consider under certain assumptions on the trajectories which is proved to be more efficient than recomputing the structure from scratch. Additionally, in recent years, some problems (e.g., convex hull, 2-center) have been studied in black box model [2,3].
Proximity problems is a class of important problems in computational geometry which involve estimation of distances between geometric objects. The nearest neighbor search problem arises in numerous fields of applications, including Pattern Recognition, Statistical classification, Computer vision and etc.
In this paper, a black-box KDSs has been studied to find the nearest neighbor in a set P of n points moving to a static query point q in the plane. There is a need to make assumptions on the point movements and time steps to obtain proved efficient solutions. Time steps should be small enough to have coherency between the objects' positions in consecutive time steps. Otherwise, there is no better way than recomputing the structure from scratch. Also, it has been assumed that in most of our results that P is fairly distributed at each time step. In the following, firstly, the black-box model which was introduced by de Berg et al. [2] and the concept of k-spread will be described. Furthermore, an algorithm that updates the nearest neighbor search at each time step in O(k∆ k log n) amortized time, where ∆ k is the k-spread of a point set P will be presented.
The Back-Box model: Let P be a set of moving points in plane. In black-box model, the exact motions of the points are unknown and a new location p(t) for each point p ∈ P is available at regular time steps t = 63 This paper is presented at 1st Iranian Conference on Computational Geometry: Bahram Sadeghi Bigham, Maryam Nezami, Marziyeh Eskandari , (2018). Kinetic Nearest Neighbor Search in Black-Box Model.
For any point p ∈ P , it is assumed a maximum displacement d max that indicates how far the point can move between two consecutive time steps. For a (static) set S of points and a point s ∈ S, let N N k (s, S) denote the k-th nearest neighbor of s in S\{s}. Let dist(p 1 , p 2 ) denotes the Euclidean distance between two points p 1 and p 2 , and At any time step t, d max is assumed the most mindist k (P (t)). Displacement Assumption: There is a maximum displacement d max , such that at any time step t i : This means that there are no more than k points within a distance d max of each other.
The k-spread of a point set: In this model, a conception called k-spread is utilized, as introduced by Erickson [4] for distribution of a set of point. The k-spread, ∆ k of a set P of static points is defined as: Lemma 1 Let P be a set of points and R be a region in the plane such that diam(R) < mindist k (P ), then R contains at most k points of P [2].

Maintaining the nearest neighbor search
Let P be a set of n moving points in the plane and q be static query point that adheres to the Displacement Assumption with parameters k and d max . The goal is to compute the nearest neighbor to q from moving points P at regular time steps t = t 1 , t 2 , t 3 , · · · . Let N N S(P (t)) denotes the nearest neighbor in P (t):= {p(t) : p ∈ P } to q. N N S(t) is used as a shorthand for N N S(P (t)). The maintenance of some structures always depends on all the points and the others are defined by only a subset of the points. The nearest neighbor search is latter type; so as previously mentioned, the algorithm does not need to ask for all new positions at every time step. It may ignore some points, if the new locations of these points cannot change the structure. Thus, an efficient algorithm is potentially exist. A subset Q(t) ⊆ P (t) is introduced in this paper, so that N N S(Q(t))= N N S(t). A point in P (t) is called active if it is part of Q(t) at time step t; and the points that are not in Q(t) are called inactive. N N S(t) can be computed using only points from Q. If Q is much smaller than P , this may be much faster than computing N N S(t) directly. In a kinetic setting, knowledge from previous time steps can be used to find Q quickly. The coherency between structures at successive time steps are to find Q quickly at each time step. To this end, a bound can be computed for each point, on the number of time steps that must pass before it can become part of Q. Let P be a set of moving points and t be a time step. A function τ N N S (p, t) is called an inactivity function if the point p is inactive at any time t i with t < t i ≤ t + τ N N S (p, t). For the nearest neighbor search problem, it is defined where dist(p 1 , p 2 ) denotes the minimum Euclidean distance p 1 to p 2 . The following lemma shows that this is a valid inactivity function.
Lemma 2 For any point p ∈ P and any time step t, Proof. In the black-box model, each point p can move at most d max per time step. This includes the nearest neighbor of q, therefore the distance between a point p and q can decrease by at most 2d max per time step. Also, the distance between N N S(t) and q can increase by at most 2d max in each time step; as dist(p, q) − dist(q, N N S(t)) can decrease by at most 2d max per time step. As a result, p cannot be active point at any time step t i with t < t i ≤ t+τ N N S (p, t).
For each point p ∈ P , a time stamp T p maintained that indicates the first time in the future at which p can be active. At the time step t = T p , we say that the time stamp of p has expired. The general algorithm thus works as follows: N N S(t 0 ) initially is computed by scratch. Then each point p ∈ P enter in a queue with the time stamp T p = t 0 +τ N N S (p, t)+1 as its key. At each time step t, the set Q(t) of all points with key t retrieved from the queue. approach is made explicit in Algorithm 1. Note that the algorithm needs to know only d max to work properly and it does not need to know bounds on the k-spread.

Algorithm 1 UPDATENNS Q(t) ← set of points stored in A[t]
Compute N N S(Q(t)) and set N N S(P (t)) ← N N S(Q(t)) for each p ∈ Q(t) do compute τ N N S (p, t) Add p to A[t + min(τ N N S (p, t) + 1, n) mod n] end for t ← (t + 1) mod n It is worth mentioning that how can compute N N S(t) and τ N N S . Computing N N S(Q(t)) can be done by nearest neighbor search algorithm at static mode in |Q(t)| time and clearly computing τ N N S is done in O(1) time, so the time to update algorithm 1 at time step t, depends on the size of Q(t). In the worst case, all points may expire in a single time step, but when the k-spread of P is low, it is possible to show that on average only a small number of points expire. The number of points that can expire in a single time step -the size of Q(t)-can be bounded by amortized analysis using γ N N S (P ) as a parameter, which will define a bound on the maximum number of points p ∈ P at any time t which τ N N S has the same value.
Lemma 4 The number of points p ∈ P for which τ N N S (p, t) = i is bounded by γ N N S (P ) = O(k∆ k ) for any 0 ≤ i ≤ n.
Proof. Let G i denotes the set of points p ∈ P for which τ N N S (p, t) = i, according to the definition τ N N S (p, t) for any point p ∈ P can conclude the following statement: So, the number of points which distance dist(p, q) − dist(q, N N S(t)) is between i · 2d max and (i + 1) · 2d max should be bounded. The points in G i reside in area C that which are centered at the same point q, but differ in radius length 2d max as illustrated in Figure 1. Now consider overlaying this area with an axis-aligned grid G of which each cell has edge length mindist k (P ). From Lemma 1, it is clear that each cell contains O(k) points. This region C can be subdivided into four axis aligned rectangles R n , R w , R s and R e with edge lengths at most 2d max and dam(P ) (see Figure 2). Firstly, the maximum number of cells in R n are computed. From the definition of the k-spread and the Displacement Assumption, it is obvious that each rectangle of R n intersects at most O(∆ k ) cells of this grid and similar argument can be made for R w , R s and R e and so, it follows that R = R n ∪ R s ∪ R e ∪ R w contains O(∆ k ) cells of this grid. Then, according the areas defined in Figure 3, should be fixed out the maximum number of cells in C is less than R.
Let N C denotes the maximum number of cells of C (and similarly for other regions). The areas of r ne , r se , r nw and r sw are pink regions, c ne , c se , c nw and c sw are yellow regions and red regions in Figure 3 are s ne , s se , s nw and s sw . In the following, we define: It is clear that the area of c nw is less than the area of r nw ; therefore N cnw < N rnw . Similarly it can be seen that N cne < N rne , N cse < N rse and N csw < N rsw . So, according to statement , the maximum number of cells in C is less than R. As a result, C contains O(∆ k ) cells. As already mentioned, each cell contains O(k) points from P , so set G i contains O(k∆ k ) points.  In the worst case, all points will expire in a single time step. However, using an amortization argument and Lemma 4 it can be shown that on average, only O(k∆ k log n) point will expire in each time step.
Lemma 5 If the number of points p(t) ∈ P (t) with τ N N S (p, t, P ) = i is at most γ N N S (P ) for any 0 ≤ i ≤ n and any t, then on average only O(γ N N S (P ) log n) points expire per time step [2].
From Lemma 3 and 5 the following theorem can be concluded: Theorem 6 Under the Displacement Assumption, the nearest neighbor in a set P of n points moving to static query point q in the plane, can be maintained in the black-box model in O(k∆ k log n) amortized time per time step, where ∆ k is the maximum k-spread of P at any time.

Conclusion
In this paper, an algorithm is presented to maintain the nearest neighbor in a set points moving to static query point in the KDS black-box model. The algorithm does not require knowledge of k or ∆ k . It only needs to know d max , the maximum displacement of any point in one time step and also does not need to know the point trajectories. It is also shown that the proposed algorithm can update nearest neighbor in O(k∆ k log n) amortized time at each time step. Interesting open problems arise when someone talks about time bound in worst-case rather than amortized.