Police strength resource regulating method based on optimal path
[technical field]
The present invention relates to a kind of algorithm, refer in particular to a kind of police strength resource regulating method based on optimal path.
[background technology]
In existing police strength scheduling of resource; The general air line distance that adopts is the shortest, uses optimal path even have, and also is simple bee-line; Reckon without traffic rules and real-time road; And travel speed above the different roads and road information, the police strength that often occurs calling arrives at the actual range of alert spot maybe be much larger than the situation of all the other police strength, and the processing alert occasions a delay.
Because the police strength scheduling requires real-time than higher, often will search for nearly ten paths simultaneously p.s. in addition, original algorithm is very unreasonable, thereby fails slowly rationally to utilize and scheduling police strength resource.
[summary of the invention]
The objective of the invention is to overcome above-mentioned defective, a kind of police strength resource regulating method based on optimal path is provided.
The objective of the invention is to realize like this: a kind of police strength resource regulating method based on optimal path, it is characterized in that: it comprises step
A), mark alert spot, utilize the spatial relationship algorithm search to obtain available police strength resource around it according to the alert spot then;
B), each police strength resource of mark is starting point, is terminal point with the alert spot, search optimal path, and obtain and arrive the destination required time,
B1), whether the starting point of inquiry police strength resource be the existing node of road network with the terminal point of alert spot, is then to change step B3 over to, otherwise continuation;
B2), starting point and/or the terminal point to non-existing node generates a dummy node with this point coordinate; And give an identity (ID) value; The closest approach of searching on a nearest road of this point adds into node data with new start point/end point as node as start point/end point in road net data; With starting point and terminal point is focus, and standardized oval, finds out all at oval inner point set;
B3), make start node equal starting point; End node also equals starting point; Covering omnidistance required time makes zero; Road between start node and the end node is empty, and with start node, end node, road and cover omnidistance required time integral body and join in the priority query as an element, this priority query with cover omnidistance required time value minimum serve as preferential;
B4), judge element in the priority query, if priority query be a sky, then turn to B7; Otherwise element of deletion from priority query, and this element judged is when if the end node of this element equates with terminal point; Then this element is added in the array of path, and turn to B7, otherwise judge whether this element end node equates with the end node of certain element in the array of path; If equate to carry out again this step, otherwise continue step;
B5), judge end node in the element from priority query, delete whether in oval inner point set, if would continue step, do not exist, turn to step B4;
B6), make the end node of the element that start node equals from priority query, to delete; Cover the omnidistance required time of element that omnidistance required time equals from priority query, to delete, find all roads that link to each other with start node, through existing traffic rules; Find out the road that can walk logical; Respectively to every road that walks logical, make end node equal the another one end points of road, call then road this time be engraved in the knotmeter at actual this crossing; Obtain real-time speed; Obtain covering time in this path with the length of road divided by real-time speed, with start node, end node, road with cover omnidistance required time and add the time of covering this path and join in the priority query, turn to step B4 as element;
B7), judge whether end node equals terminal point, is then to turn to B8, otherwise judge that whether enough the ellipse in the B2 step big, be to make then that the path is empty, turn to B9, otherwise enlarge oval and find out wherein oval inner point set, turn to B3;
B8), the start node of last element of array looks for the end node of element the priority query to equate with it one by one forward from the path; Take out the element that equates; The end node of searching certain element more forward with the start node of this element again equates with it; Till the start node of finding certain element was starting point, a group element of finding was the optimal path of being asked, and wherein last element covers omnidistance required time for covering the omnidistance needed time; Turn to B9;
B9), find optimal path;
C), arrive needed time of alert, find the shortest police strength that expends time in, accomplish scheduling according to each police strength.
Than common police strength resource regulating method; Beneficial effect of the present invention is in the optimal path search process; Combine to utilize road information fully comprehensively, and the acquisition methods of optimal path is optimized, add the oval hunting zone that reduces the path; Use dictionary type storage data, make algorithm speed faster.
[description of drawings]
Below in conjunction with detailed description of the drawings concrete structure of the present invention
Fig. 1 is a method flow diagram of the present invention
[embodiment]
As shown in Figure 1, it comprises step to the present invention relates to a kind of police strength resource regulating method based on optimal path:
A), mark alert spot, utilize the spatial relationship algorithm to search for immediately to obtain available police strength resource around it according to the alert spot then.
B), each police strength resource of mark is starting point, is terminal point with the alert spot, search optimal path, and obtain and arrive the destination required time, the concrete step that comprises:
B1), whether the starting point of inquiry police strength resource be the existing node of road network with the terminal point of alert spot, is then to change step B3 over to, otherwise continuation;
B2), starting point and/or the terminal point to non-existing node generates a dummy node with this point coordinate; And give an identity (ID) value; The closest approach of searching on a nearest road of this point adds into node data with new start point/end point as node as start point/end point in road net data; With starting point and terminal point is focus, and standardized oval, finds out all at oval inner point set Oval;
B3), make start node sv equal starting point; End node ev also equals starting point; Covering omnidistance required time cost makes zero; Road road between start node sv and the end node ev is empty, and with start node sv, end node ev, road road and cover omnidistance required time cost integral body and join among the PQueue of priority query as an element, the PQueue of this priority query with cover omnidistance required time value cost minimum serve as preferential;
B4), judge element pathinfo among the PQueue of priority query, if the PQueue of priority query be a sky, then turn to B7; Otherwise element pathinfo of deletion from the PQueue of priority query; And this element pathinfo judged, if when the end node ev of this element pathinfo equates with terminal point, then with among this element pathinfo adding path array path; And turn to B7; Otherwise judge whether this element pathinfo end node ev equates with the end node ev of certain element pathinfo in the path array of path,, otherwise continue step if equate to carry out again this step;
B5), judge end node ev among the element pathinfo from the PQueue of priority query, delete whether in oval inner point set Oval, if would continue step, do not exist, turn to step B4;
B6), make the end node ev of the element pathinfo that start node sv equals from the PQueue of priority query, to delete; Cover the omnidistance required time cost that covers of element pathinfo that omnidistance required time cost equals from the PQueue of priority query, to delete; Find all road road that link to each other with start node sv; Through existing traffic rules, find out the road that can walk logical, respectively to every road that walks logical; Make end node equal the another one end points of road; Call then road road this time be engraved in the knotmeter at actual this crossing, obtain real-time speed v, obtain covering the time tim in this path divided by real-time speed v with the length of road road; With start node sv, end node ev, road road with cover omnidistance required time cost and add the time time that covers this path and join among the PQueue of priority query, turn to step B4 as element pathinfo;
B7), judge whether end node ev equals terminal point, is then to turn to B8, otherwise judge that whether enough the ellipse in the B2 step big, be then to make path path for empty, turn to B9, otherwise enlarge oval and find out wherein oval inner point set Oval, turn to B3;
B8), the start node sv of last element pathinfo of path array looks for the end node ev of element pathinfo the PQueue of priority query to equate with it one by one forward from the path; Take out the element pathinfo that equates; The end node ev that searches certain element pathinfo more forward with the start node sv of this element pathinfo again equates with it; Till the start node sv that finds certain element pathinfo is starting point; A group element pathinfo who finds is the optimal path of being asked, and wherein last element pathinfo's covers omnidistance required time cost for covering the omnidistance needed time; Turn to B9;
B9), find optimal path.