Air-rail transit method based on undirected weighted graph

文档序号:1087060 发布日期:2020-10-20 浏览:2次 中文

阅读说明:本技术 一种基于无向加权图的空铁中转方法 (Air-rail transit method based on undirected weighted graph ) 是由 于成龙 邹延迪 李尚锦 于 2020-07-08 设计创作,主要内容包括:本发明公开一种基于无向加权图的空铁中转方法。所述方法包括:构建国内空铁无向加权图G=(V,E);生成出发地O和到达地D之间空铁组合键值对集合K,基于G=(V,E)得到由对应K中每个键值对的空铁中转路径组成的集合P<Sub>OD</Sub>;将P<Sub>OD</Sub>中的中转路径按中转城市分类,取每类中转路径中权重最小的中转路径按照权重从小到大的顺序排队,取排在前面的N个中转路径;根据出行日期查询航班和/或高铁车次及余票,并进行组合拼接,得到所述N个中转路径对应的空铁中转路线集合L;对空铁中转路线进行打分,按照打分从高到低的顺序向用户推荐空铁中转路线。本发明能够免去用户自行拼接中转方案的麻烦;也不需要对中转方案的优劣进行人工手动排序。(The invention discloses an air-iron transfer method based on an undirected weighted graph. The method comprises the following steps: constructing a Chinese air-iron undirected weighted graph G ═ V, E; generating a set K of empty iron combined key value pairs between the departure place O and the arrival place D, and obtaining a set P consisting of empty iron transit paths corresponding to each key value pair in the K based on G ═ V, E OD (ii) a Will P OD The transit paths in the system are classified according to transit cities, the transit path with the smallest weight in each class of transit paths is queued according to the sequence from small to large, and N transit paths arranged in the front are selected; inquiring flights and/or high-speed rail train numbers and surplus tickets according to the travel date, and combining and splicing to obtain an air-rail transit route set L corresponding to the N transit routes; and scoring the air-rail transit routes, and recommending the air-rail transit routes to the user according to the order of the scores from high to low. The invention canThe trouble of splicing a transfer scheme by a user is avoided; and manual sorting of the advantages and the disadvantages of the transfer scheme is not required.)

1. The air-rail transit method based on the undirected weighted graph is characterized by comprising the following steps of:

step 1, constructing a domestic air-rail undirected weighting graph G ═ V, E, wherein V is a vertex set, and each vertex V in ViAirport V representing the ith cityi-aAnd/or railway station Vi-s,Vi-aAnd Vi-sAre communicated with each other; any two airport vertexes are connected intoOne side Vi-aVj-aAny two railway station vertexes are connected into one side Vi-sVj-sObtaining an edge set E; the weight of each edge at least comprises a time consumption weight and a price weight;

step 2, generating O, D space-rail combination key value pair set K by using domestic airport data and station data according to the departure place O and the arrival place D input by the user: any airport or railway station of the O and any airport or railway station of the D form a key value pair, and K is a set formed by all the key value pairs; obtaining a set P consisting of empty iron transit paths corresponding to each key value pair in K based on G ═ V, EOD

Step 3, adding PODThe transit paths in the system are classified according to transit cities, the transit path with the minimum weight in each class of transit paths is taken, queuing is carried out according to the sequence of the weights from small to large, and N transit paths arranged in the front are taken;

step 4, inquiring flights and/or high-speed rail train numbers and surplus tickets according to the travel date input by the user, and combining and splicing to obtain an air-rail transit route set L corresponding to the N transit routes;

and 5, scoring each air-rail transit route in the L based on price and time consumption, and recommending the air-rail transit routes to the user according to the sequence of the scores from high to low.

2. The method for air-iron transfer based on undirected weighted graph according to claim 1, wherein the edge V in the undirected weighted graphiVjWeight W ofijComprises the following steps:

Wij=wln(PRij)+(1-w)ln(Tij)

in the formula, ViVjIs a Vi-aVj-aOr Vi-sVj-s,PRij、TijAre respectively and ViVjCorresponding price and time consumption, PRijIs given as the unit of Yuan, TijIn minutes, ln () denotes taking the natural logarithm, ln (PR)ij) For price weight, ln (T)ij) W is the weighting factor of the price weight for the time-consuming weight.

3. The method for air-iron transfer based on the undirected weighted graph according to claim 1, wherein the step 5 scores each air-iron transfer route according to the following formula:

S=[log(1+LP/Z)*ln(LP)+(1-log(1+LP/Z))*ln(LT)]-1

wherein S is a score, LP and LT are respectively the total price and the total time consumption of the air-rail transit route, Z is a price threshold value, the units of LP and Z are both elements, the unit of LT is hour, log () represents a logarithm taking the base 10, and ln () represents a natural logarithm.

Technical Field

The invention belongs to the technical field of machine/ticket query, and particularly relates to an air-rail transit method based on an undirected weighted graph.

Background

At present, two systems of civil aviation and railways in China are more and more perfect, the demand of the nation for travel is greatly increased, and more travel scheme choices are faced. When the passenger selects the travel mode, the passenger can use each big airline department ticketing official network, 12306 ticketing official network and OTA ticketing official network to inquire and order. However, most of the websites show a single flight travel mode or a railway travel mode. When the destination can not be reached directly by a transportation mode, the travel mode provided by the ticketing official network is inconvenient for the passenger to quickly select a transfer scheme, so that bad travel experience is brought to the passenger.

Compared with a direct flight, the air-iron combined transportation has the advantage of price, and compared with flight transit, the air-iron combined transportation is safer and more stable, and can experience three-dimensional travel. For the journey without direct flight navigation, the air-iron combined transportation provides more travel options and more intelligent combined schemes for passengers.

Disclosure of Invention

In order to solve the problems in the prior art, the invention provides an air-iron transfer method based on an undirected weighted graph.

In order to achieve the purpose, the invention adopts the following technical scheme:

a method for air-rail transit based on an undirected weighted graph comprises the following steps:

step 1, constructing a domestic air-rail undirected weighting graph G ═ V, E, wherein V is a vertex set, and each vertex V in ViAirport V representing the ith cityi-aAnd/or railway station Vi-s,Vi-aAnd Vi-sAre communicated with each other; any two airport vertexes are connected into a side Vi-aVj-aAny two railway station vertexes are connected into one side Vi-sVj-sObtaining an edge set E; the weight of each edge at least comprises a time consumption weight and a price weight;

step 2, generating O, D space-rail combination keys by using domestic airport data and station data according to the departure place O and the arrival place D input by the userAnd (4) value pair set K: any airport or railway station of the O and any airport or railway station of the D form a key value pair, and K is a set formed by all the key value pairs; obtaining a set P consisting of empty iron transit paths corresponding to each key value pair in K based on G ═ V, EOD

Step 3, adding PODThe transit paths in the system are classified according to transit cities, the transit path with the minimum weight in each class of transit paths is taken, queuing is carried out according to the sequence of the weights from small to large, and N transit paths arranged in the front are taken;

step 4, inquiring flights and/or high-speed rail train numbers and surplus tickets according to the travel date input by the user, and combining and splicing to obtain an air-rail transit route set L corresponding to the N transit routes;

and 5, scoring each air-rail transit route in the L based on price and time consumption, and recommending the air-rail transit routes to the user according to the sequence of the scores from high to low.

Compared with the prior art, the invention has the following beneficial effects:

the invention creates a set K of empty iron combined key value pairs between a departure place O and an arrival place D by constructing a home empty iron undirected weighting graph G (V, E), and obtains a set P consisting of empty iron transit paths corresponding to each key value pair in the K based on G (V, E)ODA 1 is to PODThe intermediate transit routes are classified according to transit cities, the transit route with the smallest weight in each class of transit routes is taken, queuing is carried out according to the sequence from small to large in weight, N transit routes arranged in front are taken, flights and/or high-speed train numbers and surplus tickets are inquired according to travel dates, and combined splicing is carried out to obtain an air-railway transit route set L corresponding to the N transit routes, each air-railway transit route in the L is scored based on price and time consumption, the air-railway transit routes are recommended to a user according to the sequence from high to low in scoring, and the trouble of splicing transit schemes by the user can be avoided; and manual sorting of the advantages and the disadvantages of the transfer scheme is not required.

Drawings

Fig. 1 is a flowchart of an air-to-rail transit method based on an undirected weighted graph according to an embodiment of the present invention.

Detailed Description

The present invention will be described in further detail with reference to the accompanying drawings.

The embodiment of the invention provides an air-to-rail transit method based on an undirected weighted graph, a flow chart is shown in figure 1, and the method comprises the following steps:

s101, constructing a domestic air-rail undirected weighting graph G ═ V, E, wherein V is a vertex set, and each vertex V in ViAirport V representing the ith cityi-aAnd/or railway station Vi-s,Vi-aAnd Vi-sAre communicated with each other; any two airport vertexes are connected into a side Vi-aVj-aAny two railway station vertexes are connected into one side Vi-sVj-sObtaining an edge set E; the weight of each edge at least comprises a time consumption weight and a price weight;

s102, generating O, D space-rail combination key value pair set K by using domestic airport data and station data according to a departure place O and an arrival place D input by a user: any airport or railway station of the O and any airport or railway station of the D form a key value pair, and K is a set formed by all the key value pairs; obtaining a set P consisting of empty iron transit paths corresponding to each key value pair in K based on G ═ V, EOD

S103, adding PODThe transit paths in the system are classified according to transit cities, the transit path with the minimum weight in each class of transit paths is taken, queuing is carried out according to the sequence of the weights from small to large, and N transit paths arranged in the front are taken;

s104, inquiring flights and/or high-speed rail train numbers and surplus tickets according to the travel date input by the user, and combining and splicing to obtain an air-rail transit route set L corresponding to the N transit routes;

and S105, scoring each air-rail transit route in the L based on price and time consumption, and recommending the air-rail transit routes to the user according to the sequence of low scoring to high scoring.

In this embodiment, step S101 is mainly used to construct a domestic subway undirected weighted graph. An undirected weighted graph is a graph in which edges have weights but no directions. A graph is a data structure that represents a collection of objects and their relationships. The objects of the graph are referred to as nodes or vertices, and the "relationship" refers to the relationship between a vertex and a vertex, and is referred to as an edge. The embodiment establishes that the national air-rail undirected weighted graph G is (V, E), the top airport and/or the railway station are communicated with the airport and the railway station at the same place. An edge is a connecting line between any two airport vertices or between any two train station vertices. The weight of each edge is used to indicate a person's preference for the flight or train to which the edge corresponds. The preference level is related to many factors, most commonly, the price of the ticket is high or low, and the travel time is long.

In this embodiment, step S102 is mainly used to establish a set of empty transit paths from the departure location O to the location D. First, a set K of air-rail combination key value pairs between O, D is generated using domestic airport data and station data. The key-value pair is obtained by: an airport or a railway station is selected from the departure place O, and an airport or a railway station is selected from the arrival place D, and the selection and the combination of the airport or the railway station obtain a key value pair. For example, if the origin O has an airport V1-aStation V1-sThe arrival place D has an airport V2-aTrain station V2-sThen O, D there are 4 key-value pairs, each V1-a-V2-a、V1-a-V2-s、V1-s-V2-aAnd V1-s-V2-s. The number of all possible key-value pairs between O, D is equal to the product of the total number of airport and train stations at origin O and the total number of airport and train stations at arrival D, according to the principle of permutation and combination. Then, obtaining the empty iron transfer path corresponding to each key value pair in the K by using the G ═ (V, E), thereby obtaining a set P consisting of all empty iron transfer pathsOD

In the present embodiment, step S103 is mainly used for P pairODAnd screening the hollow iron transit path. Due to PODThe transit paths in the middle are too many, and many transit paths obviously do not meet the requirements, such as too far flight distance or too high price. The screening method comprises the following steps: will PODThe transit routes in the system are classified according to transit cities, namely, the transit routes identical to the transit cities are classified into one class, and only the weight is taken from each class of transit routesAnd queuing the transit paths according to the sequence of the weights from small to large, and taking the N transit paths in the front.

In the present embodiment, the step S104 is mainly used to convert the transit route into a transit route, i.e. a transit plan. And inquiring flights and/or high-speed rail train numbers and surplus tickets corresponding to each transfer route according to the travel date input by the user, and combining and splicing to obtain a set L consisting of air-rail transfer routes.

In the present embodiment, step S105 is mainly used for recommending the air-rail transit route to the user in the order of goodness. And scoring each air-rail transit route in the set L based on price and time consumption, and recommending the air-rail transit routes to the user according to the order of the scores from high to low. It should be noted that scoring based on price and time is only one preferred embodiment, and is not limited to scoring based on these two factors, and other scoring factors such as airline, whether to fly or drive at night, etc. may be added.

As an alternative embodiment, the edge V in the undirected weighted graphiVjWeight W ofijComprises the following steps:

Wij=wln(PRij)+(1-w)ln(Tij)

in the formula, ViVjIs a Vi-aVj-aOr Vi-sVj-s,PRij、TijAre respectively and ViVjCorresponding price and time consumption, PRijIs given as the unit of Yuan, TijIn minutes, ln () denotes taking the natural logarithm, ln (PR)ij) For price weight, ln (T)ij) W is the weighting factor of the price weight for the time-consuming weight.

This embodiment provides a technical solution for calculating the weight of an edge in an undirected weighted graph. In this embodiment, the weight of the edge is obtained by weighted summation of the price weight and the time-consuming weight. In the calculation formula, PRij、TijAre respectively and ViVjThe corresponding price and time consumption are obtained by counting historical data. PRij、TijRespectively obtaining the sum of the price weightsTime consuming weighting. w, (1-w) are weighting coefficients of the price weight and the time consumption weight respectively, and the value of w is determined according to industry experience, for example, w can be 0.5.

As an alternative example, the S105 scores each empty rail transit line according to the following formula:

S=[log(1+LP/Z)*ln(LP)+(1-log(1+LP/Z))*ln(LT)]-1

wherein S is a score, LP and LT are respectively the total price and the total time consumption of the air-rail transit route, Z is a price threshold value, the units of LP and Z are both elements, the unit of LT is hour, log () represents a logarithm taking the base 10, and ln () represents a natural logarithm.

The embodiment provides a technical scheme for calculating the score of the air-rail transit line. In the calculation formula, Z is a price threshold, and Z can be used for balancing the relative size of the price factor influence and the time consumption factor influence. Z can be the price value of a transit line in the air railway, the size of the transit line is determined according to industry experience, and Z can be 500 yuan. log (1+ (LP/Z)) is a function of the decrease in growth rate with increasing price. When the total price LP is about 2 times of Z, the function value reaches about 0.5; about 0.75 when about 5 times; approximately 1, i.e., 100%, when the ratio is about 9 times. The natural logarithm is taken to reduce the influence of an excessive difference between the total price LP and the total time consumption LT. According to the above, when the total price LP is about 2 times of Z, the proportion of the price and the consumed time respectively accounts for about 50 percent; when LP is less than 2 times of Z, the time-consuming influence is dominant; at LP over 2 times Z, the price plays a dominant role. As prices rise, the time consuming impact decreases. In the formula, the value of the reciprocal internal function increases with the increase of LP and LT, and the reciprocal is taken and then decreases with the increase of LP and LT.

6页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:图数据库的构建方法及装置、电子设备、存储介质

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!