Disclosure of Invention
In order to solve the above problems, the present disclosure provides a method, a system, a device and a medium for planning an aircraft flight procedure, which perform path planning by adopting an a-x algorithm based on various flight factors, so as to obtain a better flight procedure.
The following is the content of the invention:
an aircraft flight trip planning method, comprising:
Constructing a flight information diagram by utilizing the flight information of a plurality of cities, wherein the flight information of each city a in the flight information diagram comprises a city a, coordinates of the city a, a city b with a direct flight between the city a and the city a, and the average duration of flights from the city a to the city b directly;
Acquiring a departure city and a target city, wherein the departure city is taken as a starting node, and the target city is taken as a target node;
Calculating the distance between the city a node and the target node based on the coordinates of the city a node and the target node and dividing the distance by the flight speed of the aircraft as a heuristic function h (a), constructing a loss function g (b), wherein g1 is the loss of one basis added per passing through one city, g2 (b) is the average duration of flights from the city a directly to the city b, and constructing a desired loss function f (n), f (n) =h (a) +g (b);
Based on the heuristic function h (a), the loss function g (b) and the expected loss function f (n), carrying out path planning by using an A-path planning algorithm, and outputting a planned path from the initial node to the target node;
And matching flights based on the planned paths to obtain and output matching results.
Further, the method comprises the steps of,
The flight information of city a further includes:
the number of flights from city a, and the number of flights from city a directly to city b.
Further, the method comprises the steps of,
Recording flight information of the city a by using a data dictionary;
the flight information of the city a in the data dictionary comprises keys and key values corresponding to the keys, wherein the keys are names of the city a, the key values are a first tuple, the first position of the first tuple records the flight number of the city a, the second position records the coordinates of the city a, and the third position is a first data dictionary of a sub-level;
The key of the first data dictionary is the name of a city b which is directly reached by a city a, the key value of the first data dictionary is a second tuple, the first bit of the second tuple records the number of flights from the city a to the city b, and the second bit records the average duration of flights from the city a to the city b.
Further, the method comprises the steps of,
The method for updating the data in the flight information graph by using the data of the aviation schedule comprises the following steps:
initializing a data dictionary of the flight information graph;
Reading flight record data of an aviation schedule, extracting a departure city a and a destination city b related to an aviation, and calculating the flight time t of the aircraft between cities;
Searching in the data dictionary by taking the city a as a key to find the city a;
searching a city b in a first data dictionary in the key value corresponding to the city a;
After finding city b, adding 1 to the number of flights of city a in the record of city a, adding 1 to the number of flights from city a directly to city b in the first data dictionary of city a, and modifying the average duration of flights from city a directly to city b.
Further, the method comprises the steps of,
The method for planning the aircraft flight procedure by using the A-path planning algorithm and outputting the planned path comprises the following steps:
Taking the initial node as a current node n1, and calculating a heuristic function h (n 1) of the current node n 1;
Calculating a loss function g (n 2) and a heuristic function h (n 1) of all neighbor cities by taking a city with a direct flight between the departure city as a neighbor city of the departure city, and calculating an expected loss function f (n) of all neighbor cities based on the loss function g (n 2) and the heuristic function h (n 1);
selecting a neighbor city n2 with the lowest value of the expected loss function f (n), and recording that the current node n1 is a father node of the neighbor city n 2;
taking the neighbor city n2 as a new current node, and repeatedly selecting neighbor nodes of the new current node until a target node is selected;
Starting from the target node, tracing back to the starting node through the parent node link, and constructing and outputting the shortest path from the starting node to the target node.
Further, the method comprises the steps of,
The matching of flights based on the planned path comprises:
retrieving flight information which accords with time constraint and has redundant tickets from a flight schedule for each path;
Scoring and sorting each flight using a recommendation algorithm;
And selecting flights according to the scoring sequence result, and generating a plurality of passes conforming to the personalized characteristics of the user.
Further, the method comprises the steps of,
The recommendation algorithm is a collaborative filtering algorithm or a recommendation algorithm based on a deep neural network.
An aircraft flight trip planning system, comprising:
The information construction module is used for constructing a flight information diagram by utilizing the flight information of a plurality of cities, wherein the flight information of each city a in the flight information diagram comprises a city a, coordinates of the city a, a city b with direct flights between the city a and the city a, and average duration of flights from the city a to the city b;
the data updating module is used for updating the data in the flight information graph by utilizing the data of the aviation timetable, acquiring a departure city and a target city, taking the departure city as a starting node and taking the target city as a target node;
The path planning module is used for calculating the distance between the city a node and the target node based on the coordinates of the city a node and the target node and dividing the distance by the flight speed of the airplane to obtain a heuristic function h (a), constructing a loss function g (b), wherein g1 is the loss of one basis added every time one city passes, g2 (b) is the average duration of flights from the city a to the city b, and constructing a desired loss function f (n), wherein f (n) =h (a) +g (b);
Based on the heuristic function h (a), the loss function g (b) and the expected loss function f (n), carrying out path planning by using an A-path planning algorithm, and outputting a planned path from the initial node to the target node;
And the flight matching module is used for matching flights based on the planned path, obtaining a matching result and outputting the matching result.
Compared with the prior art, the method has the following advantages:
According to the invention, the flight information graph comprising the information of cities, coordinates, direct flights, average duration and the like is constructed, so that the flight data can be comprehensively integrated, and the problem that the upper limit of the matching effect cannot be influenced by the flight time in consideration of the traditional graph construction is solved;
Calculating the distance by city coordinates and constructing a heuristic function h (a) by combining the aircraft speed, so that cost estimation from the current node to the target node can be provided for an A-algorithm to guide the searching direction, and blindness is reduced;
The construction of the loss function g (b) is aimed at comprehensively measuring the path cost in the flight path planning and guiding the algorithm to plan a better scheme. From the aspect of transfer times, basic loss is increased every time one city is passed, because the more the transfer times are, the greater uncertainty and inconvenience the passengers face are, and the algorithm is caused to preferentially select routes with less transfer through the arrangement, so that the link quality and the passenger experience are improved. In the aspect of flight time, the average duration of flights from city to city is included, the flight time is a key factor of the link planning, the total duration of the passenger journey is directly related, the average duration difference of flights among different cities is obvious, the algorithm is more focused on selecting a flight combination with short flight time by the inclusion of the flight time, and the total travel time is reduced, so that the route planning achieves better balance on the transfer times and the flight duration, and the scientificity and rationality of the whole flight link planning are improved;
The function of constructing the expected loss function f (n) is to comprehensively evaluate the path quality;
The algorithm A can efficiently optimize under the guidance of the functions, improves the path planning efficiency and quality, and finally accurately matches flights based on the planned paths, meets the time and individuation requirements of users, and improves the user experience, thereby solving the problems in the background technology.
Additional features and advantages of the disclosure will be set forth in the description which follows, and in part will be apparent from the description, or may be learned by practice of the disclosure. The objectives and other advantages of the disclosure may be realized and attained by the structure particularly pointed out in the written description and claims hereof as well as the appended drawings.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the embodiments of the present disclosure more apparent, the technical solutions of the embodiments of the present disclosure will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present disclosure, and it is apparent that the described embodiments are some embodiments of the present disclosure, but not all embodiments. Based on the embodiments in this disclosure, all other embodiments that a person of ordinary skill in the art would obtain without making any inventive effort are within the scope of protection of this disclosure.
The technology extracts and sorts valuable data of the route planning in the flight schedule in advance, and constructs a flight information diagram for the route planning. According to the scheme, the route planning process and the flight schedule are decoupled while the flight schedule data are utilized, so that the route planning effect can be improved under the condition that the time consumption of an algorithm is increased acceptably, and the overall flight schedule recommending effect is improved.
In general, the present invention requires maintenance of a flight information map, in which the number of flights from each city to other cities and the average flight duration are recorded.
The flight information graph is recorded by using a data dictionary, wherein a key is a city a list, a corresponding key value is a tuple, wherein the first bit records the number of flights related to the city, the second bit records the longitude and latitude coordinates of the city, the third bit is a sub-level data dictionary, the key of the sub-level data dictionary is a city b list which can be reached by the city a, the corresponding key value is a tuple, and the number and average duration of flights from the city a to the city b are recorded. These data will be used to calculate heuristic and loss functions in the a-trip planning algorithm.
The method is divided into two large stages, namely a flight information diagram maintenance stage and a link generation stage;
the first stage is to extract information in the flight schedule to the flight information graph, and when the flight schedule changes, the flight information graph needs to be adjusted;
The second stage is a stage of actually performing link recommendation with user interaction, and needs to make an a-path planning on the flight information diagram and match a proper flight for each path.
As shown in fig. 1, which shows a schematic diagram of a method according to the invention, the specific implementation details of the invention include:
1. step one, preparing and initializing a system:
Step 101, preparing aviation schedule data, and ensuring validity of a city corresponding to each record in the aviation schedule and time data of an airplane in the city;
Step 102, initializing a flight information graph data dictionary, establishing a record for a city related to an aviation schedule, wherein a key is a name or a number a of the city, a key value is a tuple, wherein a first bit records the number of related flights of the city and is initialized to 0, a second bit records a longitude and latitude coordinate pair of the city, a third bit is a sub-level data dictionary, a list of cities b directly reaching the city a is recorded in the dictionary, and the data dictionary is initialized to be empty.
2. Initializing a flight information diagram according to a flight schedule:
step 201, reading an unprocessed flight record, extracting a departure city a and a destination city b related to the flight, and calculating the flight time t of the aircraft between the cities;
step 202, searching and initializing in the flight information graph. If the record in the city b is contained in the data dictionary of the sub-level in the key value corresponding to the city a, if yes, turning to step 203, otherwise, initializing the record in the city b in the sub-level data dictionary, wherein the key is the city b, the corresponding key value is a tuple, the first record can directly reach the number of flights, and the second record a can directly reach the average duration of the flights of b;
Step 203, updating records from city a to city b in the flight information diagram, specifically, the related flight number +1 of the first-order record in the record of city a, and the average duration of the second-order record is modified by the directly available flight number +1 of the first-order record of city b in the sub-level data dictionary of city a.
3. Step three, modifying the flight information diagram according to the change of the flight schedule:
step 301, reading a historical flight information diagram from a memory file;
Step 302, reading an unprocessed flight record, extracting a departure city a and a destination city b related to the flight, calculating the flight time t of the aircraft between the cities, and marking whether the flight is an added flight or a deleted flight;
Step 303, modifying the flight information diagram in a manner of referring to steps 202 to 203;
And 304, deleting the record in the data dictionary when the number of flights related to one city is 0, and deleting the record of the city b in the sub-primary data dictionary under the city a when the number of flights which can be directly reached after deleting a certain flight from the city a to the city b is 0.
4. And step four, storing the real-time flight information graph into a memory file for standby, and marking the updating time.
5. And fifthly, receiving a user request from a user interface, extracting a departure city and a destination city of the user request, and recording the departure time of the user.
6. Step six, defining heuristic function, loss function and expected loss function:
Step 601, defining a heuristic function h (n 1) for estimating the shortest path cost from the current node n1 to the target node, wherein the input of the function is coordinates of a departure city and a destination city, and then calculating the actual distance between the two coordinates, dividing the actual distance by the general speed of the aircraft and outputting the calculated distance;
Step 602, defining a loss function g (n 2) for calculating current path loss (hereinafter referred to as g value), wherein n2 is a history city, wherein a basic loss g1 is added to reduce the number of times of transfer of the result every time one city passes, and an average flight duration between cities is queried in an aviation information graph as loss g2 (n 2), and g (n 2) =g1+g2 (n 2);
Step 603, defining a desired loss function f (n) =h (n 1) +g (n 2), where n is a union of n1 and n2, to estimate a desired loss function (hereinafter referred to as f-value) of the current path, representing a desired union Cheng Shichang.
7. Initializing a path planning part:
step 701, reading a flight information diagram from a memory file, and verifying whether the flight information diagram is the latest flight information diagram according to the update time;
Step 702, initializing an algorithm open list for storing nodes to be expanded. At the initial moment, adding the initial node into an open list, and setting the f value of the initial node;
step 703, initializing an algorithm closing list for storing the nodes which have been completely processed, avoiding repeated processing, and initializing to be empty.
8. Step eight, path search cyclic expansion current node:
Step 801, when the open list is empty, it indicates that no path exists between the departure city and the destination city to meet the condition that all adjacent cities can directly reach the aircraft, and the algorithm ends to return to the link planning failure;
step 802, selecting a node with the minimum f value from the open list as a current node when the open list is not empty, ending the algorithm if the current node is a target node, and returning a path;
Step 803, expanding the current node, for each neighbor m of the current node n, skipping this neighbor if neighbor m is in the closed list, otherwise calculating the cost from the starting node to neighbor m, i.e. the cost g (m) of reaching neighbor m through the current node, if neighbor m is not in the open list, or the new cost of reaching neighbor m through the current node is less than the previous cost, updating the g value of neighbor m and adding it to the open list. Meanwhile, recording that the current node n is a father node of the neighbor m;
Step 804, for each updated neighbor m, recalculate its f-value, and adjust its position in the open list according to the f-value.
9. And step nine, outputting a planned path, namely if the planning is successful, starting from a target node, backtracking to the starting node through a parent node link, constructing and returning a shortest path from the starting node to the target node, and outputting the shortest path to a recommendation algorithm for flight matching.
10. Step ten, matching flights for each path:
Step 1001, for each path, retrieving flight information which accords with time constraint and has redundant tickets from a flight schedule;
Step 1002, scoring and sorting each flight by using a recommendation algorithm, wherein the recommendation algorithm used in the step can be various types, can be a traditional collaborative filtering-based method or a latest recommendation algorithm based on a deep neural network, is easy to realize, and can provide personalized services, and the two recommendation algorithms are widely applied to various industries;
step 1003, selecting flights according to the scoring sequence result, and generating a plurality of passes conforming to the personalized characteristics of the user.
11. And step eleven, outputting the link planning result to the user, namely outputting the link result to a user interface for the user to check and purchase after receiving the link planning recommendation of the rear end.
The following is a specific embodiment of a flight information map maintenance process:
fig. 2 is a flow chart of a flight information map maintenance process, which functions to initialize or change a flight information map to be consistent with the latest flight schedule when the system is initialized or the flight schedule is changed. Specifically, if the system is initialized, first, the flight information is initialized, and if the module is called due to the flight schedule change, the historical flight information diagram should be read from the external memory file.
And then reading a flight to be processed, extracting the related city pairs, and calculating the estimated time of the airplane sailing between the city pairs according to the time marked in the schedule, wherein the time loss involved in the step is that the flight information is read and preprocessed, and the time complexity is O (1).
After obtaining the city pairs and the time, searching the corresponding city pairs in the data dictionary, if not, creating a new city pair, wherein the number of flights is initialized to 0, and the average duration is 0 (the data is immediately covered). The average length of time and number of flights are then updated and if the data dictionary is implemented with a hash table, the time complexity used for this step can be considered as O (1).
After the piece-by-piece processing, a city can be deleted if there is a flight number of 0 between the city pair (this is not always the case in a real scenario). And after all the processing is finished, storing the new flight information graph into an external memory file. In general, if the number of flights is n, the time complexity of the method is O (n), since this operation is only invoked when the flight schedule is changed, i.e., each flight record will only be processed once at the time of change, rather than every user inquiry, and the time required by the system is negligible except for the time necessary to read the flight schedule.
FIG. 3 is a flowchart of a procedure recommendation process:
The algorithm generally uses an a-algorithm framework, relying on the flight information map mentioned above. Specifically, after receiving the departure destination city pair input by the user, only the situation of transfer is processed, so if the departure destination city pair can be directly reached, and the situation that a side exists between the departure city and the destination city in the flight information diagram is corresponding, the side is shielded (the directly-available flights are recommended separately).
And then based on the information such as the distance between cities and the data recorded in the flight information graph, respectively calculating heuristic estimation functions of the losses between the current visited cities and the destination, calculating the loss functions of the distance travelled by the current visited cities, selecting the next-hop cities based on the heuristic estimation functions and the destination, outputting city strings if the destination is reached, otherwise continuing searching, and selecting proper flights for matching by using various recommendation algorithms after path planning.
In summary, the present invention provides an efficient path planning method, which performs dynamic preprocessing on a flight schedule, extracts a valuable part of the path plan from a large table of the flight schedule in advance in an efficient manner, and stores the extracted valuable part in a flight information graph, so that the large table of the original flight schedule is prevented from being searched and processed each time a user query is processed, and the search is performed in the flight information graph by using an a-frame, so that the query process is more efficient, the path planning speed can be effectively improved, the query cost of the flight schedule is reduced, the response time of a system is reduced, the use experience of the user is improved, and meanwhile, the system can respond to the dynamic change of the flight schedule.
Based on the method of the present invention, the embodiments of the present disclosure also provide a system corresponding to the method, which includes:
The information construction module is used for constructing a flight information diagram by utilizing the flight information of a plurality of cities, wherein the flight information of each city a in the flight information diagram comprises a city a, coordinates of the city a, a city b with direct flights between the city a and the city a, and average duration of flights from the city a to the city b;
the data updating module is used for updating the data in the flight information graph by utilizing the data of the aviation timetable, acquiring a departure city and a target city, taking the departure city as a starting node and taking the target city as a target node;
A path planning module for calculating the distance between the city a node and the target node based on the coordinates of the city a node and the target node and dividing the distance by the flight speed of the aircraft as a heuristic function h (a), constructing a loss function g (b) based on the average duration of flights from the city a directly to the city b, wherein g1 is the loss of one basis per increment through one city, g2 (b) is the average duration of flights from the city a directly to the city b, and constructing a desired loss function f (n) based on the heuristic function h (a) and the loss function g (b), f (n) =h (a) +g (b);
Based on the heuristic function h (a), the loss function g (b) and the expected loss function f (n), carrying out path planning by using an A-path planning algorithm, and outputting a planned path from the initial node to the target node;
And the flight matching module is used for matching flights based on the planned path, obtaining a matching result and outputting the matching result.
Based on the same inventive concepts as those disclosed above, the disclosed embodiments also provide an apparatus corresponding to the above method, comprising at least one processor, and a memory communicatively coupled to the at least one processor, wherein the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the above method.
It should be noted that, the electrical connection between the above units does not necessarily represent connection between lines, and an indirect connection manner may be applied to the embodiments of the present disclosure as long as the purpose of the present disclosure is achieved.
Based on the same inventive concept, the present disclosure also provides a computer storage medium having stored thereon executable instructions that are executed by a processor to perform the above-described method.
Although the present disclosure has been described in detail with reference to the foregoing embodiments, those skilled in the art will understand that modifications may be made to the technical solutions described in the foregoing embodiments or equivalents may be substituted for some of the technical features thereof, and these modifications or substitutions do not depart from the spirit and scope of the technical solutions of the embodiments of the present disclosure in essence.