Disclosure of Invention
The invention aims at the technical problems and provides a bus transfer method based on a bidirectional search and estimation function pruning mode, and the method can find a relatively superior and complete bus transfer scheme in complicated traffic and map data.
In order to achieve the purpose, the invention designs a public transportation transfer method based on a bidirectional search and estimation function pruning mode, which comprises the following steps:
step 1: the server respectively carries out direct line and special vehicle line calculation, primary transfer line calculation with walking before transfer, twice transfer line calculation with walking before the first transfer, twice transfer line calculation with walking before the second transfer and twice transfer line calculation with walking before the two transfers according to the starting station and the ending station which are transmitted by the client by the following methods:
the method for calculating the direct route and the special vehicle route comprises the following steps:
calculating x (p) ═ y (q) (1)
X (p) represents the line number of the bus line passing through the start station set, and y (q) represents the line number of the bus line passing through the end station set;
if the result is a non-empty set, a direct riding scheme is represented, and a starting station number I, a riding line number p and an end station number J corresponding to the intersection element in the formula 1 are obtained;
the calculation method of the primary transfer line comprises the following steps:
all stations included in each line number p in a set X (I, p) representing bus lines passing through a start station set, I representing the number of a start station, p representing a bus line number, which represents a first-time bus line number, in a set Y (J, q), U representing a transfer station number in the start station set, a set Y (J, q) representing bus lines passing through an end station set, J representing an end station number, q representing a bus line number before an end point, V representing a transfer station number in the end station set, are represented as a station set a1(I, p, U) representing bus lines passing through the start station set, and all stations included in a bus line number q before the end point in a set Y (J, q),
calculation a1(U) ═ b (v) (2)
If the result is a non-empty set, representing a one-transfer riding scheme, and obtaining a starting station number I, a riding line number p, a riding line number before the end point and a riding line number before the end point, wherein the starting station number I, the riding line number p, the riding line number before the first riding line number, the riding line number before the end point and the end point number J correspond to the intersection elements in the formula 2;
the first transfer route with walking before transfer is calculated as:
for a transfer station U in each starting station set in the station set A1(I, p, U), searching other bus stations within a preset radius range around, wherein the other bus stations are marked as a station set A2(I, p, U, M), and M represents the number of transfer stations;
calculation a2(M) ═ b (v) (3)
If the result is a non-empty set, the scheme indicates that a primary transfer line scheme with walking before transfer exists, V indicates the number of the transfer station in the destination station set, and the number I of the starting station corresponding to the intersection element in the formula 3, the number p of the bus line, which indicates the number of the first bus line, the number U of the transfer station, which indicates the number of the transfer departure station, the number M of the transfer departure station, the number q of the bus line before the destination, and the number J of the destination station are obtained;
the two transfer lines are calculated as:
the bus lines passing through each transfer station U in the initial station set in the station set A1(I, p, U) are recorded as a line set A3(I, p, U, k), k represents the serial number of the lines for the second time, all stations passing through each line in the line set A3(I, p, U, k) are recorded as a station set A4(I, p, U, k, S), and S represents the serial number of the stations for the second time;
calculation a4(S) ═ b (v) (4)
If the result is a non-empty set, the riding scheme with twice transfer is shown, and a starting station number I, a riding line number p, a first riding line number and a transfer station number U which correspond to the intersection elements in the formula 4 are obtained, wherein the first riding line number is shown here, the first transfer getting-off station number is shown here, the second riding line number k is shown here, the second transfer getting-off station number is shown here, the riding line number q before the terminal is shown here, and the terminal station number J is shown here;
the two transfer routes with a walk before the first transfer are calculated as:
the bus lines passing through each station transfer getting-on station number M in the station set A2(I, p, U, M) are recorded as a line set A5(I, p, U, M, k), all stations passing through each line in the line set A5(I, p, U, M, k) are recorded as a station set A6(I, p, U, M, k, S), and S is the station number of the second transfer getting-off station;
calculation a6(S) ═ b (v) (5)
If the result is a non-empty set, the scheme indicates that two transfer lines with walking before the first transfer are available, and a starting station number I, a riding line number p, a first riding line number, a first transfer station number U, a first transfer getting-off station number, a transfer getting-on station number M, a first transfer getting-on station number, a second riding line number k, a second transfer getting-off station number S, a riding line number q before the terminal and a terminal station number J, which correspond to the intersection element in formula 5 are obtained;
the two transfer routes with a walk before the second transfer are calculated as:
for each second-time transfer getting-on/off station number S in the station set A4(I, p, U, k, S), searching other bus stations within a preset radius range around, and marking as a station set A7(I, p, U, k, S, G), wherein G represents an getting-on station number of a riding route before a terminal;
calculation a7(G) ═ b (v) (6)
If the result is a non-empty set, the scheme indicates that two transfer lines with walking before the second transfer are available, and a starting station number I, a riding line number p, a first riding line number, a transfer station number U, a first transfer getting-off station number, a second riding line number k, a second transfer getting-off station number S, a getting-on station number G of a riding line before the terminal, a riding line number q before the terminal and a terminal station number J, which correspond to the intersection element in formula 6 are obtained;
the two transfer routes with walking before the two transfers are calculated as:
for each second transfer getting-on/off station number S in the station set A6(I, p, U, M, k, S), searching other bus stations within a preset radius range around, and marking as a station set A8(I, p, U, M, k, S, G) which represents the getting-on station number of a bus line before the terminal;
calculation A8(G) ═ b (v) (7)
If the result is a non-empty set, the scheme indicates that two transfer lines with walking before two transfers are available, and a starting station number I, a taking line number p, a first taking line number, a transfer station number U, a first transfer getting-off station number, a transfer getting-on station number M, a first transfer getting-on station number, a second taking line number k, a second transfer getting-off station number S, a getting-on station number G of a taking line before the terminal, a taking line number q before the terminal and a terminal station number J corresponding to the intersection element in formula 7 are obtained;
step 2: and (3) respectively calculating the required time of the available bus taking scheme in the step (1) by the server according to the starting station and the ending station which are transmitted by the client, and recommending the bus taking scheme with the least consumed time to the client.
According to the method, a large number of lines and station coordinates in the virtual map are utilized, and the riding scheme of citizens is predicted through the transfer scheme. Compared with the traditional method introduced in the background technology, the method has the advantages of simple algorithm, less calculation amount, high efficiency, complete predicted transfer lines and the like; the method utilizes the bus route and station information drawn in the map, filters some too far stations by using a bidirectional search and valuation function pruning mode for reference, avoids the calculation of too many invalid routes, can obtain the running condition of vehicles on the corresponding routes according to a scheduling system, and calculates the transfer scheme of citizens going out by combining the transfer routes, the weight calculation and the vehicle running state.
Detailed Description
The invention is described in further detail below with reference to the figures and the specific embodiments.
The invention discloses a bus transfer method based on a bidirectional search and valuation function pruning mode, which comprises the following steps:
step 1: the server respectively utilizes database information (bus lines and station information drawn in a digital map) in the server to calculate direct lines and special vehicle lines, calculate a transfer line for one time with walking before transfer, calculate transfer lines for two times with walking before the first transfer, calculate transfer lines for two times with walking before the second transfer and calculate transfer lines for two times with walking before the two transfers according to the starting station and the ending station transmitted by the client by the following methods:
the method for calculating the direct route and the special vehicle route comprises the following steps:
as shown in fig. 1, x (p) ═ y (q) (1) is calculated
X (p) represents the line number of the bus line passing through the start station set, and y (q) represents the line number of the bus line passing through the end station set;
if the result is a non-empty set, a direct riding scheme is represented, a starting station number I, a riding line number p and an end station number J corresponding to the intersection element in the formula 1 are obtained, and if the result is an empty set, the calculation is ignored;
the calculation method of the primary transfer line comprises the following steps:
all stations included in each line number p in a set X (I, p) representing bus lines passing through a start station set, I representing the number of a start station, p representing a bus line number, which represents a first-time bus line number, in a set Y (J, q), U representing a transfer station number in the start station set, a set Y (J, q) representing bus lines passing through an end station set, J representing an end station number, q representing a bus line number before an end point, V representing a transfer station number in the end station set, are represented as a station set a1(I, p, U) representing bus lines passing through the start station set, and all stations included in a bus line number q before the end point in a set Y (J, q),
as shown in fig. 2, a1(U) ═ b (v) (2) is calculated
If the result is a non-empty set, representing a one-transfer riding scheme, obtaining a starting station number I, a riding line number p, which represents a first riding line number, a transfer station number U, a riding line number q before the terminal and a terminal station number J corresponding to the intersection element in formula 2, and if the result is an empty set, ignoring the calculation;
the first transfer route with walking before transfer is calculated as:
for each transfer station U in the initial station set in the station set A1(I, p, U), searching other bus stations within a radius range of 350 meters around, and recording the other bus stations as a station set A2(I, p, U, M), wherein M represents the number of transfer stations;
as shown in fig. 2, a2(M) ═ b (v) (3) is calculated
If the result is a non-empty set, the scheme indicates that a primary transfer route scheme of walking before transfer exists, V indicates the number of transfer stations in the destination station set, and the number I of the starting station corresponding to the intersection element in the formula 3, the number p of the bus line, which indicates the number of the first bus line, the number U of the transfer station, which indicates the number of the bus station for transferring, the number M of the bus station for transferring, the number q of the bus line before the destination and the number J of the destination station are obtained;
the two transfer lines are calculated as:
the bus lines passing through each transfer station U in the initial station set in the station set A1(I, p, U) are recorded as a line set A3(I, p, U, k), k represents the serial number of the lines for the second time, all stations passing through each line in the line set A3(I, p, U, k) are recorded as a station set A4(I, p, U, k, S), and S represents the serial number of the stations for the second time;
as in fig. 3, a4(S) ═ b (v) (4) is calculated
If the result is a non-empty set, the riding scheme with twice transfer is shown, and the starting station number I, the riding line number p, the first riding line number and the transfer station number U which correspond to the intersection elements in the formula 4 are obtained, wherein the first transfer getting-off station number, the second riding line number k, the second transfer getting-off station number S, the riding line number q before the terminal and the terminal station number J are shown, and if the result is an empty set, the calculation is omitted;
the two transfer routes with a walk before the first transfer are calculated as:
the bus lines passing through each station transfer getting-on station number M in the station set A2(I, p, U, M) are recorded as a line set A5(I, p, U, M, k), all stations passing through each line in the line set A5(I, p, U, M, k) are recorded as a station set A6(I, p, U, M, k, S), and S is the station number of the second transfer getting-off station;
as in fig. 3, a6(S) ═ b (v) (5) is calculated
If the result is a non-empty set, the scheme indicates that two transfer lines with walking before the first transfer are available, and a starting station number I, a riding line number p, a first riding line number, a transfer station number U, a first transfer lower station number, a transfer upper station number M, a first transfer upper station number, a second riding line number k, a second transfer lower station number S, a riding line number q before the terminal and a terminal station number J corresponding to the intersection element in the formula 5 are obtained, and if the result is an empty set, the calculation is omitted;
the two transfer routes with a walk before the second transfer are calculated as:
for each second-time transfer getting-on/off station number S in the station set A4(I, p, U, k, S), searching other bus stations within a radius range of 350 meters around, and marking as a station set A7(I, p, U, k, S, G), wherein G represents an getting-on station number of a riding route before a terminal;
as in fig. 3, a7(G) ═ b (v) (6) is calculated
If the result is a non-empty set, the scheme indicates that two transfer lines with walking before the second transfer are available, and a starting station number I, a riding line number p, a first riding line number, a transfer station number U, a first transfer getting-off station number, a second riding line number k, a second transfer getting-off station number S, a getting-on station number G of a riding line before the terminal, a riding line number q before the terminal and a terminal station number J corresponding to the intersection element in the formula 6 are obtained, and if the result is an empty set, the calculation is ignored;
the two transfer routes with walking before the two transfers are calculated as:
for each second transfer getting-on/off station number S in the station set A6(I, p, U, M, k, S), searching other bus stations within a radius range of 350 meters around, and marking as a station set A8(I, p, U, M, k, S, G) wherein G represents an getting-on station number of a riding route before a terminal;
as in fig. 3, A8(G) ═ b (v) (7) is calculated
If the result is a non-empty set, the scheme indicates that two transfer lines with walking before two transfers are available, and a starting station number I, a taking line number p, a first taking line number, a first transfer station number U, a first transfer getting-off station number, a transfer getting-on station number M, a first transfer getting-on station number, a second taking line number k, a second transfer getting-off station number S, a getting-on station number G of a taking line before the terminal, a taking line number q before the terminal and a terminal station number J corresponding to the intersection element in the formula 7 are obtained, and if the result is an empty set, the calculation is omitted;
step 2: and (3) respectively calculating the required time of the available bus taking scheme in the step (1) by the server according to the starting station and the ending station which are transmitted by the client, and recommending the bus taking scheme with the least consumed time to the client.
In the step 2 of the technical scheme, the server lists and recommends the available bus taking schemes in the step 2 to the client according to the sequence of time from less to more.
In the above technical scheme, when calculating the required time of the bus taking scheme available in step 1, the required time per kilometer of the vehicle for driving is determined to be 1.5 minutes, the required time per hundred meters for walking is determined to be 1.5 minutes, the required time per one station of the bus for driving is determined to be 2 minutes, the required time per hundred meters for walking is determined to be 1.5 minutes, and the required time for the transfer waiting time is determined to be 5 minutes.
Aiming at the lines and the stations mentioned in the scheme, a large amount of data are collected in advance, a corresponding data structure is constructed, information such as the stations, the relationship between the lines and the stations, line information and the like is stored, and the corresponding stations and lines are drawn in a map; the 7 transfer schemes are obtained by using a bidirectional search and valuation function pruning mode as a reference; the direct and special line scheme comprises the following steps: searching effective stations in the range at the same time at the starting point and the end point, and then, through a line corresponding to the stations, overlapping the line found at the starting point with the line found at the end point, namely a direct or special line scheme; a first transfer scheme: searching effective stations in a range at the same time at a starting point and an end point, then obtaining respective stations by lines through the lines corresponding to the stations, matching the stations of the two lines at the starting point, wherein the stations of the two lines in the searching scheme are a one-time transfer scheme; a secondary transfer scheme: similar to the first transfer scheme, after the starting point is matched with the first matching line, the station of the line needs to be matched with the station of the second line and the corresponding line, and then is matched with the station of the destination station, and the station which is in line with the search range is the second transfer scheme; a large number of repeated schemes exist in the transfer scheme obtained according to the above-mentioned scheme, and the time required by each scheme needs to be calculated;
aiming at a special car, direct, once-and-twice transfer scheme is adopted for duplication removal:
1. and (3) removing the weight of the special vehicle through scheme: and selecting the scheme with the minimum required time by taking the line in the first scheme (the direct riding scheme) as the unique identifier.
2. One-time transfer scheme deduplication: the scheme with the minimum required time is selected by two lines (p-q) in a second scheme and a third scheme (a riding scheme for one transfer and a one-transfer line scheme for walking before the transfer).
3. And (3) duplicate removal by a quadratic transfer scheme: and selecting the scheme with the minimum required time according to three lines (p-k-q) in four schemes (a riding scheme with twice transfer, a two-transfer-line scheme with walking before the first transfer, a two-transfer-line scheme with walking before the second transfer and a two-transfer-line scheme with walking before the two transfers) of 4 th, 5 th, 6 th and 7 th.
And then, the running state of the vehicle is obtained through a dispatching system, all the optimal riding schemes are finally obtained, and the least walking, the least time, the least transfer and the least travel cost and the nearest vehicle can be calculated according to the corresponding schemes, so that convenience is brought to the traveling of citizens.
Details not described in this specification are within the skill of the art that are well known to those skilled in the art.