In this section, we develop algorithms to optimize the path scheduling of the mobile sink so as to visit as many UGVs as possible.
4.1. The Ideal Case
In this section, we first try to find a solution to solve the path optimizing problem of the mobile sink when each UGV follows its monitoring cycle strictly. Therefore, we have all the information to guide the scheduling. As described above, we now have the spatialtemporal graph of the system. The goal is to find a trajectory of the mobile sink that could visit UGVs as many times as possible. The problem is unique and quite different from the traditional salesman problem, i.e., the TSP problem. A TSP problem is trying to find the shortest path that visits all the points from the starting point and finally returns to the same point. The graph is a precedence graph that can not be solved using traditional algorithms.
Definition 1. A path that visits all points in the precedence graph is called a complete path.
Definition 2. If b is to the right of a and there is an edge linking them, we say that b is a’s neighbor. In other words, b appears later than a in the graph.
Definition 3. If b is the closest point to a among all neighbors of a in the time scale, we say that b is a’s nearest neighbor.
We have Theorem 1 that shows our problem is not equal to the traditional TSP problem since only one complete path exists, so it is not necessary to find the shortest path.
Theorem 1. If paths passing all points in the given Graph do exist, they are the same path.
Proof. Suppose there exists two different paths that pass all points, i.e., ${P}_{1}$ and ${P}_{2}$. ${P}_{1}$ has the point sequence of $({v}_{0},{v}_{1},\dots ,{v}_{i},\dots ,{v}_{j},\dots {v}_{n})$. Then, there exists at least two points having different sequences in ${P}_{2}$, e.g., ${v}_{i}$ and ${v}_{j}$. However, if there is path between ${v}_{i}$ and ${v}_{j}$, then ${t}_{{v}_{j}}$ must be greater than ${t}_{{v}_{i}}$. Therefore, the path is not valid from ${v}_{j}$ to ${v}_{i}$, which means path ${P}_{2}$ is not a valid path. ☐
Theorem 2. The necessary and sufficient condition under which we could find a complete path in a given graph is that each point has an edge to its nearest neighbor.
Proof. Suppose there exists at least two points ${v}_{i}$ and its nearest neighbor ${v}_{j}$, and there is no direct edge between them. Therefore, the path connecting ${v}_{i}$ and ${v}_{j}$ must go through at least one middle point ${v}_{k}$. However, since ${v}_{j}$ is already the nearest neighbor of ${v}_{i}$, there is no point ${v}_{k}$ between them, i.e., ${v}_{k}$ does not exist at all. Thus, there is no such path that can visit both ${v}_{i}$ and ${v}_{j}$. ☐
From Theorems 1 and 2, we propose the algorithm 1 to find the complete path in the given graph.
Algorithm 1 Complete path finding algorithm in the precedence graph 
Require: adjacency matrix M Ensure: a point sequence $P=\{{v}_{0},{v}_{1},\dots ,{v}_{m}\}$ forming a path.
 1:
Set current point q to the leftmost point in the graph (starting from the element $M[q,q]$ where $q=0$), $P=\left\{q\right\}$  2:
For current point q, find its nearest neighbor r in the graph (the first element $M[q,r]$ that has a nonnegative value). If there are no more neighbors, the algorithm ends.  3:
Add point r into the P. Then, $P=P\cup \left\{r\right\}$  4:
Set $q=r$ as the current point, and GOTO step 2

The algorithm is very simple, according to Theorem 2. At each step, we only need to follow the edge to the nearest neighbor of the current point. Finally, all of the edges will form a path from the first point to the last. If the same pattern appears somewhere along the time scale, then it can be declared that an effective cycle has been found. Since there is only one complete path, it is also the shortest path.
Algorithm 2 Optimal shortest path finding algorithm in the precedence graph 
Require: adjacency matrix M Ensure: hop number ${s}_{i}$ of each point i and a point sequence $P=\{{v}_{0},{v}_{1},...,{v}_{m}\}$ forming a path. Initialize 1:
Set current point q to the rightmost point in the graph (starting from the element $M[q,q]$ where $q=n$). Mark  2:
For current point q, find a point r with the largest hop number and shortest path length among all q’s neighbor, and set ${s}_{q}={s}_{r}+1$, ${l}_{q}={l}_{r}+{d}_{qr}$. If there is no neighbor, set ${s}_{q}=1$, ${l}_{q}=0$.  3:
If q is the leftmost point, GOTO step Finish. Otherwise, set the first point to the left of the current point q (i.e., $q=q1$) as the current point, GOTO step Mark. Finish  4:
Start from the point(s) with the largest hop number and smallest path length, add it into P, and recursively add its neighbor with the hop number decreasing by one. When there is more than one point having the same largest hop number, the algorithm records all the paths.

However, in many cases, it is impossible to find a trajectory of the mobile sink to visit every UGV upon their appearance—e.g., when the interval of two UGVs reappearing is less than the traveling time between them, there is no doubt that one mobile sink cannot reach them both. In this case, the objective is to visit as many UGVs as possible so that more data can be collected in time. To find a path that visits the most number of UGVs, the easiest way is to exhaust all possibilities. The time complexity, which is $O(n\times {2}^{n})$, increases quickly as the number of UGVs increases. In this paper, we propose a simple algorithm (Algorithm 2) that achieves the same goal, taking advantage of the precedence graph.
Definition 4. The term hop number of point q stands for the optimal number of points that can be visited until the rightmost point when starting from q.
Definition 5. The term path length of point q (denoted as ${l}_{q}$) stands for the sum of all edges from q to the rightmost point with hop number of 1.
The algorithm starts from the farthest right point on the time scale, and then scans and marks from the right to the left one by one. At each point, it tries to connect to the neighbor with the longest path. Scanning along the time scale ensures that no point is ignored and is in accordance with the precedence requirement. The time complexity is $O(l\times n)\to O\left(n\right),$ in which n is the total number of points in the precedence graph, and l is the number of UGVs ($l\ll n$). There may exist more than one optimal path. In the TSP problem, it is NPComplete to find the shortest path. However, since there are time window and precedence constraints, and a point will not have more than l edges, the combination in our case is very limited. In the Mark phase of the algorithm 2, it is easy to choose the neighbor of the shortest path by recording the neighbor with the shortest path.
Theorem 3. Algorithm 2 can obtain the optimal path that contains the largest number of points (UGVs).
Proof. We use mathematical induction. Supposing that there is only one point, the algorithm obviously works. Then, suppose that the algorithm finds the optimal path(s) starting from a set of points Q when there are n points. If we insert one more point r on top of it that increases the total number to $n+1$, without loss of generality, we can always add it to the left side of the other points since the algorithm starts from the rightmost and searches to the left. If there is an edge between r and any point in Q, according to the algorithm, r will be added to the optimal path. When there is no edge between r and any point in Q, no matter which path r will join, the hop number of it can not be greater than ${s}_{Q}$ since all other points have smaller hop numbers (at least one less) than ${s}_{Q}$. In that case, if ${s}_{r}$ equals ${s}_{Q}$, r will be added into the point set Q. Therefore, for $n+1$ points, the algorithms still works. ☐
4.2. The Practice Case
As we mentioned before, in practice, each UGV is not able to follow their schedule strictly due to the various facts. Most of the time, they will arrive slightly ahead or later than scheduled, while, in rare cases, there is a large deviation. Therefore, it is not possible to build a precedence graph since the future is not predetermined and predictable so that “backward” algorithms cannot work anymore. In this paper, according to the statistics, we model the interval between two appearances of a UGV as the Gaussian distribution. Only the expected time of the first appearance and the expected cycle time of each UAV are known to the mobile sink. All other additional information, such as the exact appearing time of a UGV in a certain cycle, can only be received when the mobile sink visits a UAV and meets it during its appearance. Therefore, if any proactive solutions still rely on the precedence graph without timely information updating, a time interval for the mobile sink arriving early and staying long enough at each UGV point must be preserved on the base of the worst case of the possibility. However, the consequence is a sharp degression in performance due to accumulated errors.
In this paper, we propose a distributed greedy algorithm called
khop (Algorithm 3) to solve the problem.
k means the depth of the search algorithm. As shown in
Figure 3, there are three UGVs, and nine points are generated along the time scale. Points with a darker color are the last appearance times known, while points with a lighter color are the predicted appearance times. The search starts from the point
q and expands the path by adding points until the path reaches three edges. Many paths may exist, and the points at the end of those paths are called
q’s khop neighbors. As seen in the
Figure 3, where
k = 3, these points in the area between the line
${t}_{1}$ and
${t}_{2}$ are all khop neighbors of
q. In other words, the mobile sink needs to cross three edges (hops) to reach any of those points. Since it is not possible to fully predict the future, in order to visit as many points as possible, a local optimal can be achieved instead, where we need find the path passing the same number of points in the least amount of time. In
Figure 3, when
k = 3, there are two paths leading to the nearest 3hop neighbor, point
r. We can pick any one of them to start the next round search. The simplest way is giving
k the value of “1”. Then, the algorithm will set the nearest neighbor in the time scale of the current point as the next point. Apparently, the greater the
k is, the more possibilities we have in finding the optimal path. However, since the UGVs appear irregularly, the more hops we consider, the more errors as well as computational costs will be introduced. There must be a tradeoff between the performance and the cost.
In the worst case, the complexity of the khop algorithm is
$O\left({n}^{k}\right)$. Therefore, we must find the balance of the performance and the overhead of the
k. In this paper, we propose the empirical value of
k as
where
n is the total number of points in the precedence graph and
${\overline{A}}_{out}$ stands for the averaged out degree in the graph. The idea behind the equation is that if the averaged out degree is large, then the algorithm can search closer for a better path since multiple paths overlap at many common points. In a few steps, different paths may be connected to the same point. On the other hand, when
${\overline{A}}_{out}$ is small, the path is more independent so the algorithm needs to check more steps before it can make a decision on which one is better because, if the chosen path is not good, the mobile sink has to stay in this path for some steps before it can choose another path. The shortest path can also be achieved based on our algorithms since, in the matrix
M, the distance between two points is recorded. It is not difficult to calculate the shortest path.
Algorithm 3 khop path finding algorithm in the precedence graph 
Require: adjacency matrix M Ensure: a point sequence $P=\{{v}_{0},{v}_{1},\dots ,{v}_{m}\}$ forming a path. Initialize 1:
Set current point q to the leftmost point in the graph khop search  2:
For current point q, among its khop neighbors, find a point r that is the closest to q along the time scale (the leftmost among all khop neighbors). If there is no khop neighbor, decrease k by 1, GOTO khop search. If q does not have any neighbors, GOTO Finish.  3:
Else, add point r into the P then $P=P\cup \left\{r\right\}$, set current point q as r, $P=\left\{q\right\}$ Finish  4:
The algorithm ends.
