The method of realizing route planning in navigator
Technical field
The present invention relates to the algorithm of the path planning in field of traffic, particularly path planning.
Background technology
Di Jiesitela algorithm (Dijkstra) is by Dutch computer scientist Hull Di Jiesitela (the Edsger Wybe Dijkstra) invention that ends hereby.What algorithm solved is the shortest route problem that in digraph, single source point arrives other summits.If the weight on the ,Er limit, vertex representation city in figure represents intercity distance, this algorithm can be used for finding two shortest paths between city.
The input of this algorithm has comprised a digraph G who has weight, and we represent the set on all summits in G with V.Limit in figure, be two formed Sequential Elements in summit to (Vi, Vj), represent to have from summit Vi to Vj path to be connected.We represent the set on all limits with E, the weight on limit is by weighting function w:E → [0, ∞] definition, and weight can represent distance.Therefore, w (Vi, Vj) is exactly from the summit Vi distance of Vj to the limit.In figure, appointing the distance of inter-two-point path, is exactly the distance summation on all limits on this path.In known figure, V has summit V0, and Di Jiesitela algorithm can find V0 to arrive the shortest path on every other summit.
When calculating V0 arrives the shortest path on other summits, carry out in the steps below:
1. first, two vertex set S and T are set, S={V0}, all the other summits of T={ }, in T, distance value corresponding to summit is d (V0, Vi), if having limit to be connected between V0 and Vi, d (V0, Vi)=w (V0, Vj), otherwise d (V0, Vi) is ∞
2. from T, choose summit W, condition is that the distance value of W and V0 is minimum, and W is moved into S set from set T,
3. in couple T, the distance value on summit is modified: if add W, make intermediate vertex, the distance value from V0 to Vi is shorter than the path that does not add W, revises this distance value.
Repeat above-mentioned steps 2,3, until in S, comprise all summits, till S=T.
This algorithm is adopted in a large number because of the efficiency of its algorithm in navigation software.
In navigation software, for the map of path planning, come from the Traffic Net of reality, therefore this figure is typical digraph, and use Di Jiesitela algorithm to do in the process of path planning according to this figure, also must consider the traffic rules that comprise on each summit in figure (being crossing in reality).Known navigation software path planning, the general planning principles of dispersing to terminal from the starting point of path planning that adopts.Simultaneously in order to shorten the time of path planning, improve the efficiency of path planning, often adopt from starting point and diffuse to the principle that terminal comes to an end, and in fact, such planning principles shortens the efficiency of the time raising path planning of path planning often to sacrifice the rationality of path planning.
Because road network is digraph; usually there are traffic rules in the crossing on road network simultaneously; consider the characteristic of Di Jiesitela path planning algorithm: the summit of determining shortest path can not be opened again; so usually can cause the path planning failure from origin-to-destination; its reason is: if two location points are all communicated to a common point; the path planning process of coming from common point, the road between these 2 can not found by algorithm.In Fig. 1, location point B and C are communicated to common point D by S4 and S5, from D to B, the path planning process of C direction, the road S3 between B and C can be not found.
As shown in Figure 1, Start is starting point, End is terminal, traffic rules regulation: can not arrive road S2 through B point from road S4, we are according to Di Jiesitela path planning principle, from Start point, when G point, D point are opened successively, Start, G and D point are for there being the set on the summit of shortest path
S={Start,G,D},
And End, A, B, C not yet determine the vertex set of shortest path,
T={End、A、B、C}。
The topological relation of ordering according to D, again outwards disperses and can open C point and B point from D point, when C point and B point are opened,
S={Start,G,D,C,B},
T={End、A}。
Suppose that the distance that C point is ordered to Start is less than the distance that B point is ordered to Start, therefore should first disperse C point, but the summit that the B point that our discovery is connected with C point and D point are shortest path is dispersed from C point, without summit, can again be opened, via C point ground path planning, to C point, be finished, get rid of after C point, we can find that another summit that has shortest path is B, the topological relation of ordering according to B, from B point, again outwards disperse the point that can open and only have A point, but analyze B point ground traffic programme, from S4, through B point, can not arrive S2, can determine that so from S4, arriving path, B point ground can not open A point, and the point that B point does not exist other to open yet, therefore can determine, via S4, arriving B point ground path planning finishes at B point, since then, the path planning carrying out in conjunction with actual traffic rules according to Di Jiesitela path planning principle all finishes, but the node diffusing to from Start point only has B, C, G, D point, and A point and End point are not all diffused to, that is to say from Start point and do not have shortest path to End point.And in fact we observe figure and can find: during the path of ordering to End from Start point, exist, both:
How to address the above problem, be ubiquitous technical barrier in navigation software path planning algorithm.
Summary of the invention
For addressing the above problem, the present invention proposes following technical scheme: the method for realizing route planning in navigator, the processor depending in navigator is realized, with in the supporting storage medium of processor, store the traffic rules at each crossing in map and figure, after definite starting point and terminal, path planning comprises following steps:
A, storage area SA is set, according to Di Jiesitela principle, according to the map and traffic rules calculate the path from origin-to-destination, and result is dumped in SA,
B, storage area SB is set, according to Di Jiesitela principle, according to the map and traffic rules, usings the terminal set as beginning, the starting point of setting is as end, calculating path, and result is dumped in SB,
Result in C, comparison SA and SB, if there is the path from origin-to-destination, gets the short path of its middle distance as the result of this path planning; If only have one from the path of origin-to-destination, the result using winner as this path planning; When all do not have from origin-to-destination path time, path planning failure.
More specifically, in step B, adopt the traffic rules from origin-to-destination direction.
Use this method, from positive and negative both direction, carry out path planning, can overcome the defect of " summit of determining shortest path can not be opened again " in algorithm, principle is if certain road can not find from forward, from oppositely finding, so just can avoid because there is the failure problem of the caused path planning of similar Fig. 1 in navigation data, the navigation performance and the user that have improved navigation software experience, and have reduced the technology degree that navigation data is produced simultaneously.
Accompanying drawing explanation
Fig. 1 is a path planning figure.
Wherein: Start is starting point, End is terminal, A, B, C, D, G are intermediate point, S1 is the road between End point and A point, and S2 is the road between A point and B point, and S3 is the road between B point and C point, S4 is the road between B point and D point, S5 is the road between C point and D point, and S6 is the road between D point and G point, and S7 is the road between G point and Start point.
Embodiment
The method of realizing route planning in navigator, the processor depending in navigator is realized, and in the supporting storage medium of processor, stores the traffic rules at each crossing in map and figure, and after definite starting point and terminal, path planning comprises following steps:
A, storage area SA is set, according to Di Jiesitela principle, according to the map and traffic rules calculate the path from origin-to-destination, and result is dumped in SA,
B, storage area SB is set, according to Di Jiesitela principle, according to the map and traffic rules, usings the terminal set as beginning, the starting point of setting is as end, calculating path, and result is dumped in SB,
Result in C, comparison SA and SB, if there is the path from origin-to-destination, gets the short path of its middle distance as the result of this path planning; If only have one from the path of origin-to-destination, the result using winner as this path planning; When all do not have from origin-to-destination path time, path planning failure.
In step B, adopt the traffic rules from origin-to-destination direction.
Below in conjunction with accompanying drawing, the present invention is described in detail.
Example 1: referring to Fig. 1, there is no special traffic rules in this example.
First perform step A: according to the traffic rules at each crossing in Di Jiesitela path planning principle, path planning figure and figure, planning is from the path of origin-to-destination, and process is as follows:
Conclusion: use forward path planning, obtain Start and to the route programming result of End be:
Total distance is: S7+S6+S4+S2+S1
The above results is dumped in the SA of memory block.
Then perform step B1-B3: according to the traffic rules at each crossing in Di Jiesitela path planning principle, path planning figure and figure, the path of planning from terminal to starting point, process is as follows:
Conclusion: use reverse path planning, obtain S and to the route programming result of E be:
Total distance is: S7+S6+S4+S2+S1
The above results is dumped in the SB of memory block.
In step C, in SA and SB, the path planning of origin-to-destination is consistent, adopts any one result all to can be used as programme path.
Example 2: referring to Fig. 1, have traffic rules at B point in this example: can not arrive S2 from S4 through B point.
First perform step A: according to the traffic rules at each crossing in Di Jiesitela path planning principle, path planning figure and figure, planning is from the path of origin-to-destination, and process is as follows:
Conclusion: the path that does not arrive E from S.
The above results is dumped in the SA of memory block.
Then perform step B: according to the traffic rules at each crossing in Di Jiesitela path planning principle, path planning figure and figure, the path of planning from terminal to starting point, process is as follows:
Conclusion: use reverse path planning, obtain Start and to the route programming result of End be:
Total distance is: S7+S6+S5+S3+S2+S1
The above results is dumped in the SB of memory block.
In step C, adopt in SB from the path of origin-to-destination as programme path.
In this example, as shown in Figure 1: in reverse path planning, End is known point, according to End point ground road topological relation, End point can open A point, according to A point ground road topological relation, A point can open B point again, then according to B point ground road topological relation, B point can open C point, D point, but because B point exists, can not through S4, arrive the road rule of S2, so B point can only open C point, C point can open D point, D point can open G point, G point can open Start point, and when Start point is opened, path planning finishes.