The method of realizing route planning in the navigator
Technical field
The present invention relates to the algorithm of the path planning in the field of traffic, particularly path planning.
Background technology
Di Jiesitela algorithm (Dijkstra) ends now by Dutch computer scientist, and Hull Di Jiesitela (Edsger Wybe Dijkstra) invents.What algorithm solved is the shortest route problem that single source point arrives other summits in the digraph.If the vertex representation city among the figure, and the weight on the limit is represented intercity distance, this algorithm can be used for finding two shortest paths between the city.
The input of this algorithm has comprised a digraph G that weight is arranged, and we represent the set on all summits among the G with V.Limit among the figure is that two summits are formed has order elements to (Vi, Vj), Vi has the path to link to each other to Vj from the summit in expression.We represent the set on all limits with E, and then by weighting function w:E → [0, ∞] definition, weight can be represented distance to the weight on limit.Therefore, (Vi Vj) is exactly from the summit Vi distance of Vj to the limit to w.The distance of appointing inter-two-point path among the figure, be exactly on this path all limits apart from summation.V has summit V0 among the known figure, and the 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 by following step:
1. at first, two vertex set S and T are set, S={V0}, all the other summits of T={ }, among the T the corresponding distance value in summit be d (V0, Vi), if having the limit to be connected between V0 and the Vi, then 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. the distance value on summit among the T is made amendment: if adding W makes intermediate vertex, the distance value from V0 to Vi is shorter than the path that does not add W, then revises this distance value.
Repeat above-mentioned steps 2,3, in S, comprise all summits, promptly till the S=T.
This algorithm is adopted by a large amount of in navigation software because of the efficient of its algorithm.
The map that is used for path planning in the navigation software comes from the Traffic Net of reality; Therefore this figure is typical digraph; And use the 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 among the figure (being the crossing in the reality).Known navigation software path planning, the general planning principles of dispersing to terminal point that adopts from the starting point of path planning.Simultaneously in order to shorten the time of path planning; Improve the efficient of path planning; Often adopt from starting point and diffuse to the principle that terminal point promptly comes to an end, and in fact, such planning principles shortens the efficient of the time raising path planning of path planning often with the rationality of sacrificing path planning.
Because road network is a digraph; Usually there are traffic rules in crossing on road network simultaneously; Consider the characteristic of Di Jiesitela path planning algorithm: the summit of having confirmed shortest path can not be opened once more, so usually can cause the path planning failure from origin-to-destination, and its reason is: if two location points all are communicated to a common point; Then from the path planning process that common point is come, the road between these 2 can not found by algorithm.In Fig. 1, location point B and C are communicated to common point D through S4 and S5, then from D to the path planning process of B, C direction, the road S3 between B and the C can not found.
As shown in Figure 1, Start is a starting point, and End is a terminal point; Traffic rules regulation: can not arrive road S2 through the B point from road S4; We are according to Di Jiesitela path planning principle, from the Start point, when the G point, when the D point is opened successively; Start, G and D point are the set that the summit of shortest path is arranged
S={Start,G,D},
And End, A, B, C are the vertex set of confirming shortest path as yet,
T={End、A、B、C}。
The topological relation of ordering according to D is outwards dispersed once more from the D point and can be opened C point and B point, when C point and B point are opened,
S={Start,G,D,C,B},
T={End、A}。
Suppose the distance that distance that the C point is ordered to Start is ordered to Start less than the B point; Therefore should disperse the C point earlier, but the summit that B point that our discovery links to each other with the C point and D point are shortest path is dispersed from the C point; Not had the summit can be opened once more, finishes to the C point via C point ground path planning; After getting rid of the C point; We can find that another summit that shortest path is arranged is B; The topological relation of ordering according to B; Outwards disperse the point that can open once more from the B point and have only the A point; But analyze B point ground traffic programme; Can not arrive S2 from S4 through the B point; Can confirm that so arriving path, B point ground from S4 can not open the A point; And the point that the B point does not exist other to open yet; Therefore can confirm; Arriving B point ground path planning via S4 finishes at the B point; Since then, the path planning that carries out in conjunction with the actual traffic rule according to Di Jiesitela path planning principle is all over, but the node that diffuses to from the Start point has only B; C; G; The D point; And A point and End point are not all diffused to, and that is to say from the Start point not have shortest path to the End point.And in fact we observe figure and can find: exist during from the Start point to path that End is ordered, both:
How to address the above problem, be ubiquitous technical barrier in the 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 the navigator; The processor that depends in the navigator is realized; With the traffic rules that store each crossing among map and the figure in the supporting storage medium of processor, behind definite starting point and terminal point, path planning comprises following steps:
A, storage area SA is set,, reaches traffic rules according to the map and calculate path, and the result is dumped among the SA from origin-to-destination according to the Di Jiesitela principle,
B, storage area SB is set, according to the Di Jiesitela principle, reaches traffic rules according to the map, with the terminal point set to start with, the starting point of setting is as end, calculating path, and the result dumped among the SB,
Result among C, comparison SA and the SB if the path from origin-to-destination is arranged, gets wherein apart from the result of short path as this path planning; If have only a path, with the result of winner as this path planning from origin-to-destination; When all not from the path of origin-to-destination, the path planning failure.
More specifically, in step B, adopt traffic rules from the origin-to-destination direction.
Use this method; Carry out path planning from positive and negative both direction, can overcome the defective of " summit of having confirmed shortest path can not be opened once more " in the algorithm, principle is if certain bar road can not find from forward; From oppositely finding; So just can avoid having improved the navigation performance and the user experience of navigation software, reduce the technological degree that navigation data is produced simultaneously because of there being the failure problem of the caused path planning of similar Fig. 1 in the navigation data.
Description of drawings
Fig. 1 is a path planning figure.
Wherein: Start is a starting point, and End is a terminal point, and 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 the navigator, the processor that depends in the navigator realize, with the traffic rules that store each crossing among map and the figure in the supporting storage medium of processor, behind definite starting point and terminal point, path planning comprises following steps:
A, storage area SA is set,, reaches traffic rules according to the map and calculate path, and the result is dumped among the SA from origin-to-destination according to the Di Jiesitela principle,
B, storage area SB is set, according to the Di Jiesitela principle, reaches traffic rules according to the map, with the terminal point set to start with, the starting point of setting is as end, calculating path, and the result dumped among the SB,
Result among C, comparison SA and the SB if the path from origin-to-destination is arranged, gets wherein apart from the result of short path as this path planning; If have only a path, with the result of winner as this path planning from origin-to-destination; When all not from the path of origin-to-destination, the path planning failure.
In step B, adopt traffic rules from the origin-to-destination direction.
Below in conjunction with accompanying drawing the present invention is elaborated.
Example 1:, do not have special traffic rules in this example referring to Fig. 1.
Execution in step A at first: according to the traffic rules at each crossing among Di Jiesitela path planning principle, path planning figure and the figure, planning is from the path of origin-to-destination, and process is following:
Conclusion: use forward path planning, obtain Start and be to the route programming result of End:
Total distance is: S7+S6+S4+S2+S1
The above results is dumped among the SA of memory block.
Execution in step B1-B3 then: according to the traffic rules at each crossing among Di Jiesitela path planning principle, path planning figure and the figure, the path of planning from the terminal point to the starting point, process is following:
Conclusion: use reverse path planning, obtain S and be to the route programming result of E:
Total distance is: S7+S6+S4+S2+S1
The above results is dumped among the SB of memory block.
In step C, among SA and the 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, at the B point traffic rules are arranged in this example: can not arrive S2 through the B point from S4.
Execution in step A at first: according to the traffic rules at each crossing among Di Jiesitela path planning principle, path planning figure and the figure, planning is from the path of origin-to-destination, and process is following:
Conclusion: the path that does not arrive E from S.
The above results is dumped among the SA of memory block.
Execution in step B then: according to the traffic rules at each crossing among Di Jiesitela path planning principle, path planning figure and the figure, the path of planning from the terminal point to the starting point, process is following:
Conclusion: use reverse path planning, obtain Start and be to the route programming result of End:
Total distance is: S7+S6+S5+S3+S2+S1
The above results is dumped among the SB of memory block.
In step C, adopt among the SB path from origin-to-destination as programme path.
In this example; As shown in Figure 1: in reverse path planning; End is a known point; According to End point ground road topological relation; The End point can open the A point; According to A point ground road topological relation, the A point can open the B point again, again according to B point ground road topological relation; The B point can open C point, D point; But because of there is the road rule that can not arrive S2 through S4 in the B point, so the B point can only open the C point, the C point can open the D point; The D point can open the G point; The G point can open the Start point, and when the Start point was opened, path planning finished.