scieee AI-readable full text Open interactive document viewer

A tree-based model for setting optimal train fare zones

Conejero Casares, José Alberto,Jordan Lluch, Cristina,Sanabria Codesal, Esther

Abstract

Given a railway line with n stops and the number of travelers between each pair of stops, we show how to split these stops into k different fare zones in order to maximize the benefit obtained from the sale of tickets to the travelers. We present a method to obtain this solution that is based on finding the longest path in a weighted root tree. This method improves in terms of efficiency the combinatorial method, where all the possible distributions have to be considered for deciding which is the optimal one.

Full text

Research Article A Tree-Based Model for Setting Optimal Train Fare Zones J. Alberto Conejero,1Cristina Jordán,2and Esther Sanabria-Codesal3 1Instituto Universitario de Matem´ atica Pura y Aplicada, Universitat Polit` ecnica de Val` encia, 46022 Val` encia, Spain 2Instituto Universitario de Matem´ atica Multidisciplinar, Universitat Polit` ecnica de Val` encia, 46022 Val` encia, Spain 3Departamento de Matem´ atica Aplicada, Universitat Polit` ecnica de Val` encia, 46022 Val` encia, Spain Correspondence should be addressed to J. Alberto Conejero; [email protected] Received 4 June 2014; Revised 20 August 2014; Accepted 20 August 2014; Published 11 September 2014 Academic Editor: Marcelo M. Cavalcanti Copyright © 2014 J. Alberto Conejero et al. This is an open access article distributed under the Creative Commons Attribution License, which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited. Given a railway line with 𝑛stops and the number of travelers between each pair of stops, we show how to split these stops into 𝑘different fare zones in order to maximize the benefit obtained from the sale of tickets to the travelers. We present a method to obtain this solution that is based on finding the longest path in a weighted root tree. This method improves in terms of efficiency the combinatorial method, where all the possible distributions have to be considered for deciding which is the optimal one. 1. Introduction In regional or local transportation networks a fare system where the stops are grouped into different zones is usually applied. This is the case for subway, bus, and regional railway transportation networks. The price of a ticket between two stops depends on the number of zones that a passenger must traverse during the travel. The stops and the number of zones are determined by the company. The assignment of the stops to certain zones usually depends on their distance to the center of the network. This is usually an arbitrary decision and it could attend to different reasons. The maximization of benefits can be addressed either to social welfare or to profit.Inthislastcase,ananalysisoftheflowoftravelers between every single pair of stops is required. One may wonder whether a change of fares in order to increase the income would result in a decrease of the demand; however this depends on several factors such as the type of area, the trip purposes, the distance of the journey, and the ticket types, among others. Moreover, one also has to distinguish between short, medium, and long-term elasticities [1]. In our work, we will consider that the number of travelers between each pair of stops is constant and independent of the change of the fare prices. 1.1. Related Work. In 1980 Webster and Bly published a collaborative report on [2]identifyingmanyfactorswhich influence demand of travelers. This has been of great value to public transport operators and transport planners. This has been recently updated in [1]. This same year Cervello analyzed the effect of flat rates versus differentiated ones [3]. Inparticular,hestudiedtheimpactofthevariabilityoffares depending on the distance and time-of-day. Moreover, the differentiated fares can be further subdivided into zonal fares, distance-based fares, sectional fares, and time-based fares [4,5]. Zonal-based fares are the most common fare systems in regional railway and underground transportation networks in Spain. Several studies have been conducted in the last thirty years in order to study fare optimization; see, for instance, [6–9]. The objective functions in the above studies were to maximize either total profit and/or social welfare. In some of the cases elasticities in the demand of the transportation service were included. The solution of these problems was given by the maximization of certain profit function subject to certain restrictions. Sometimes, the maximization can be split into two levels using a bilevel model approach, with the operator model at the upper level and the user at the lower one; see [10,11]. For further information we refer the reader to [12,Section2.2]. Hindawi Publishing Corporation Mathematical Problems in Engineering Volume 2014, Article ID 384321, 11 pages http://dx.doi.org/10.1155/2014/384321 2Mathematical Problems in Engineering The problem of fare zone design for local public transportation networks using a graph theoretical approach was considered by Hamacher and Sch¨ obel in [13]; see also [14,15]. In these works, the design is obtained in order to minimize either the maximal or average deviation between the fare zone system and the distance tariff for all the pairs of stops. Some heuristics algorithms were provided in this line in [15]. In this work we present an algorithm to find the optimal fare zone system for a line of transport, where the stops are located one after the other. Our model is based on finding the longest path between the root and one of the leaves on a certain weighted directed tree with root. Weighted graphs often appear in the modeling of problems of logistics [16], scheduling and transport routing [17], and management in the air industry [18,19]andofcar-rentalcompanies[20]; see also [21]. Apart from this problem, the use of discrete mathematics in railway transportation problems is not new and has been considered for different problems [22–24].Thisisdone,for instance, in the rolling stock planning phase [25,26]andin its integration with the timetabling phase [27–29], or in the assignment tracks to the trains [30,31]. In particular, graph models have been used for choosing a fare planning model that maximizes the revenue [32,33]. 1.2. Preliminaries on Weighted Graphs and Trees. We recall that a directed weighted graph is a 3-tuple 𝐺 = (𝑉,𝐸,𝑤) where 𝑉is the set of nodes,𝐸is the set of arcs (ordered pairs of nodes), and 𝑤:𝐸→N0assigns to every arc (𝑢,V)∈𝐸, with 𝑢,V∈𝑉, a positive integer amount (or zero) denoted by 𝑤(𝑢,V),orjustas𝑤𝑢,V.Apath on a graph is defined as an alternate sequence of nonrepeated nodes and arcs of the form 𝑢1,(𝑢1,𝑢2),𝑢2,(𝑢2,𝑢3),𝑢3,...,𝑢𝑛−1,(𝑢𝑛−1,𝑢𝑛),𝑢𝑛for some nodes 𝑢1,𝑢2,...,𝑢𝑛∈𝑉and (𝑢1,𝑢2),(𝑢2,𝑢3),...,(𝑢𝑛−1,𝑢𝑛)∈ 𝐸. A directed tree is a directed graph which would be a tree if the directions on the arcs were ignored and all the arcs are directed away from a particular node, which is called the root of the tree. A nondirected graph is a tree if it is connected (every pair of nodes are joined by a path) and it verifies that |𝐸|=|𝑉|−1. The solution of the longest path problem on a graph 𝐺= (𝑉,𝐸,𝑤)consists of finding the path between a certain pair of nodes 𝑢,V∈𝑉whose sum of the weights of the arcs is maximized. Despite the fact that this is in general an NP- hard problem, its solution can be computed in a linear time on directed acyclic graphs. For further information on graphs and trees, we refer the reader to [21,34–36]. 1.3. Organization of the Paper. The paper is organized as follows: in Section 2 we introduce the notation and we calculate the total number of admissible solutions to the problem using a combinatorial approach. Section 3 is devoted to the complete analysis of the case of 2 zones. A general algorithm for the construction of a directed rooted tree for an arbitrary number of stops and zones is provided in Section 4. Then the solution to our problem is reduced to find the longest path from the root to one of the leaves in this tree. In Section 5 we give details about the size of the tree constructed in Section 4 and how to label their nodes. This will help us to study the computational cost of this problem that is shown in Section 6. We conclude this section with an example of application. 2. Notation Our algorithm for finding the optimal solution considers partial admissible solutions of the problem and compares among themselves in order to choose the optimal one. For dealing with this partial distributions and with all the admissible solutions to the problem, we introduce a special notation for referring to them. Besides, as we want to get the optimal revenue for the company that supplies the service, then the number of passengers between every pair of stops mustbetakenintoaccount. Firstly, let us consider a railway line where we know the location of 𝑛stops. For determining a fare system of 𝑘 zones, we assume that there is at least one stop at every zone; therefore 𝑛≥𝑘.Thecase𝑛=𝑘has a trivial solution since we have a unique stop at every zone so that the cases of interest will be the ones with 𝑛>𝑘. Secondly, let us consider 𝑛stops, namely, {𝑠1,𝑠2,...,𝑠𝑛}. These stops are assumed to be ordered in the railway line; namely, 𝑠1≺𝑠 2≺𝑠 3,...,≺𝑠𝑛,with𝑠1being the first one and 𝑠𝑛thelastone.Wewillalsoassumethateverysinglestop 𝑠𝑖is located at only one of the 𝑘zones, and we denote by 𝑧𝑖its zone, with 1≤𝑖≤𝑛and 1≤𝑧𝑖≤𝑘. We assume the following statements about the distribution of stops into zones. The first one indicates that two consecutive stops in the line must be in the same zone or in contiguous zones. (A1) For every 1≤𝑖≤𝑛−1,either𝑧𝑖+1 =𝑧𝑖or 𝑧𝑖+1 =𝑧𝑖+1. Among all possible distributions generated under assumption (A1), only some of them will be admissible distributions of stops into zones. They will be the ones verifying assumptions (A2) and (A3). (A2) Consider 𝑧1=1and 𝑧𝑛=𝑘; that is, the first and the lastcityofthelinearelocatedatthefirstandatthe last zone, respectively. (A3) For every 1<𝑖<𝑘there exists some 1<𝑗<𝑛such that 𝑧𝑗=𝑖; that is, we have at least one stop at every zone. We introduce a notation for referring to particular distributions of 𝑛stops into 𝑘zones. We also consider partial distributions that deal with 𝑛󸀠<𝑛stops distributed into 𝑘 zones. Definition 1. We define a partial distribution of 𝑛󸀠stops into 𝑘 zonesasa𝑘-tuple of the form [𝑦1,𝑦2,...,𝑦𝑘]where 𝑦1+𝑦2+ ⋅⋅⋅+𝑦𝑘≤𝑛with 𝑦𝑖≥0for all 1≤𝑖≤𝑘, and such that if there exists 𝑦𝑖0=0,then𝑦𝑖=0for 𝑖≥𝑖0. The 𝑘-tuple [𝑦1,𝑦2,...,𝑦𝑘]indicates that stops 𝑠1,...,𝑠𝑦1 areinzone1,stops𝑠𝑦1+1,...,𝑠𝑦1+𝑦2areinzone2,andsoon, until we have that stops 𝑠𝑦1+⋅⋅⋅+𝑦𝑘−1+1,...,𝑠𝑦1+⋅⋅⋅+𝑦𝑘are located in zone 𝑘. Mathematical Problems in Engineering 3 If we distribute all the 𝑛stops we refer to this distribution as an admissible one. Definition 2. We define an admissible distribution of 𝑛stops into 𝑘zones as a 𝑘-tuple of the form [𝑦1,𝑦2,...,𝑦𝑘]where 𝑦1+𝑦2+⋅⋅⋅+𝑦𝑘=𝑛and 𝑦𝑖≥1for all 1≤𝑖≤𝑘. The total number of admissible distributions can be computed using a combinatorial approach. Proposition 3. Let 𝑛be the number of stops to be distributed into 𝑘zones. The total number of admissible distributions of this 𝑛stops into 𝑘zones is (𝑛−1)!/(𝑛−𝑘)!(𝑘−1)!. Proof. By assumption (A2), 𝑧1=1and 𝑧𝑛=𝑘.Theother 𝑛−2stops must be distributed into the 𝑘zones. By assumption (A3) we have to assign at least one stop of these 𝑛−2to each zone 𝑖for 2≤𝑖≤𝑘−1.Letuscounthowmanyadmissible distributions can we find rearranging the others 𝑛−2stops. Let us consider two types of symbols, Sand C,where Sstands for a stop and Cfor a change of zone. A string of 𝑛symbols Sand 𝑘−1symbols Crepresents an admissible distribution of 𝑛stops into 𝑘zones whenever there is at least (i) one Sbefore the first C, (ii) one Safter the last C, (iii) one Sbetween every pair of symbols C. If we assume the necessity of having at least one symbol S at every zone, then we can rephrase the problem to calculate how many strings can be constructed with 𝑛−𝑘symbols S and 𝑘−1symbols C. For instance, a string of the form SS ⋅⋅⋅S ⏟⏟⏟⏟⏟⏟⏟⏟⏟⏟⏟⏟⏟⏟⏟ 𝑖1 CSS ⋅⋅⋅S ⏟⏟⏟⏟⏟⏟⏟⏟⏟⏟⏟⏟⏟⏟⏟ 𝑖2 C⋅⋅⋅CSS ⋅⋅⋅S ⏟⏟⏟⏟⏟⏟⏟⏟⏟⏟⏟⏟⏟⏟⏟ 𝑖𝑘,(1) with 𝑖1,...,𝑖𝑘≥0and 𝑖1+𝑖2+⋅⋅⋅+𝑖𝑘=𝑛−𝑘, corresponds to an admissible distribution [𝑖1+1,𝑖2+1,...,𝑖𝑘+1].Thetotal number of strings constructed with two different elements S and C,withSappearing 𝑛−𝑘times and Cappearing 𝑘−1 times, is given by 𝑃𝑛−𝑘,𝑘−1 𝑛−1 =(𝑛−1)! (𝑛−𝑘)!(𝑘−1)!,(2) which is the number of permutations with repetition of 𝑛−1 elements with 𝑛−𝑘of one type and 𝑘−1of the other type. For 𝑛much more greater than 𝑘,thisisoforderO(𝑛𝑘−1). Given an admissible distribution [𝑦1,𝑦2,...,𝑦𝑘]we can compute the benefit obtained from the passengers tickets. For everypairofstops𝑠𝑖,𝑠𝑗with 1≤𝑖,𝑗≤𝑛,𝑖 =𝑗,wedenoteby 𝑝𝑖,𝑗 the number of passengers that depart from 𝑠𝑖and arrive at 𝑠𝑗on a certain period of time. A passenger with a return ticket between two stops is counted twice, one on each sense. We assume that these passengers pay two times the price of a singleticketandnodiscountisgrantedtothem. Once we have an estimation of the number of passengers between every single pair of stops, we can compute which will be the benefit obtained by the sale of tickets after applying a certain assignment of stops to the zones. As we have indicatedintheIntroduction,weareassumingthatachange ofthelocationofthestopsinthezonesdoesnotmodifythe number of travelers between every pair of stops. We consider a fare system for the sale of tickets based on the number of zones. The price of a ticket depends on how many zones a passenger crosses in his/her trip, that is, a counting zone tariff system. If a passenger remains at the same zone, then the fare is ℎ0.Ifitisrequiredtovisit2zones, that is, the initial and final stops are at contiguous zones, then the price would be ℎ0+ℎ1.Whenapassengervisits3 zones, then the cost of the ticket would be ℎ0+ℎ2,andso on. For simplicity, when we compute the benefit coming from a certain distribution of stops into zones we omit the fixed value ℎ0since it is applied to all the tickets. For maximizing the benefit, the idea is to find a distribution that globally forces the passengers to traverse the highest number of zones, taking into account the aforementioned restrictions set on the distribution of stops into zones. This is the underlying idea on which the following algorithms are based. 3. The Case of 2 Zones The simplest case of just a single zone is not a problem for any number 𝑛of stops. In this section we solve the problem of findig a distribution of 𝑛stops into 2zones in order that the revenue obtained from the passengers tickets is maximized. First, we introduce the trees that model this problem in terms of 𝑛∈N.Later,wewillshowhowtocomputetheoptimal solution using the structure of this tree. Some figures will help us to show the construction of the trees used to model different statements of the problem. A dashed line will be used for separating admissible distributions (nodes) with the last stop in different zones. Besides, a node with a thick line around it will be used to indicate the admissible distributions at every step, that is, the ones verifying assumptions (A1), (A2), and (A3). 3.1. Definition of the Tree for 𝑛Stops and 2 Zones, 𝑛≥3.We start at the first stop 𝑠1that must be located at zone 1.This is represented by the partial admissible distribution [1,0]. Thenwecanaddonemorestop,𝑠2. By assumption (A1), 𝑠2 canbeassignedeithertozone1or to zone 2.Thefirstcase corresponds to the partial distribution [2,0]and the second one to the unique admissible distribution [1,1].Apairofarcs departing from [1,0]and arriving at [2,0]and [1,1]shows that these distributions are generated from [1,0];seeFigure 1. Athirdstop,𝑠3can be added. Taking into account (A1) we have two options. On the one hand, the distribution [2,0]lets us generate two new distributions: [3,0],ifweaddthethird stop to zone 1,and[2,1],ifweaddittozone2. On the other hand, from distribution [1,1]we can only add 𝑠3to the second zone since there is no third zone in this case. This enables us to consider the distribution [1,2], too. However, the unique admissible distributions with 3stops will be [2,1]and [1,2], and not [3,0].InFigure 2 we have represented this case. We can proceed by induction using (A1) to construct a tree for each number 𝑛of stops. Suppose that we have done 4Mathematical Problems in Engineering [1, 0] [1, 1][2, 0] Zone 1Zone 2 Figure 1: Tree for 2 zones and 2 stops. [1, 0] [1, 1] [1, 2][2, 1] [2, 0] [3, 0] Zone 1Zone 2 Figure2:Treefor2zonesand3stops. the construction up to 𝑛−1stops. We will see how to get the partial distributions for 𝑛stops. There are two kinds of nodes representing a distribution of 𝑛−1stops attending to its form as follows: (i) [𝑛−1,0], (ii) the nodes of the form [𝑖,𝑗]with 1≤𝑖,𝑗≤𝑛and 𝑖+𝑗= 𝑛−1. On the one hand, from [𝑛−1,0]we can construct two new distributions [𝑛,0]and [𝑛−1,1]. On the other hand, from a node [𝑖,𝑗]of the second form we can only generate one more distribution, [𝑖,𝑗+1];seeFigure 3. With this procedure we construct a tree with a root at [1,0];seeFigure 3. Fixing a value 𝑛∈N, the nodes [𝑖,𝑗] with 𝑖+𝑗=𝑛will be the leaves of the tree. In particular, every leaf, except [𝑛,0], corresponds to one of the admissible distributions of 𝑛stops into 2zones, bijectively. We point out that in our representations of the trees generated under this procedure, all nodes with the same value for 𝑖+𝑗are displayed horizontally as we can also see in Figure 3. Moreover, the nodes of the form [𝑖,𝑗]with 𝑗=0 aresettotheleftofthedashedline,sincetheycorrespondto partial distributions that uniquely have stops in zone 1.The rest of the nodes are set to the right of the dashed line since they have at least one stop in zone 2. 3.2. Optimal Solution for 𝑛Stops and 2 Zones. For finding the optimal arrangement of 𝑛stops into 2zones, we assign weights to all arcs in order that if we take an admissible distribution [𝑖,𝑗]with 𝑖+𝑗=𝑛and 𝑗 =0, then the sum of the weights of the arcs in the path that connects [1,0]with [𝑖,𝑗] will represent the total benefit obtained from the passengers that have to change of zone during their travel. Theorem 4. Let 𝑇be a tree constructed under assumptions (A1), (A2), and (A3), for representing the admissible distributions of 𝑛stops into 2zones. Let us assume that the number of passengers between every pair of stops (𝑝𝑖,𝑗)1≤𝑖,𝑗≤𝑛 is given. Then there is an assignment of weights to the edges in order that the sum of the weights of the longest path from the root to [1,0]toaleafoftheform[𝑖,𝑗]with 1≤𝑖,𝑗≤𝑛and 𝑖+𝑗=𝑛 returns the maximal benefit for distributing 𝑛stops into 2zones. Proof. Take a tree 𝑇constructed under assumptions (A1), (A2), and (A3), for representing the admissible distributions of 𝑛stops into 2zones. Fix 𝑖,𝑗with 𝑖+𝑗<𝑛;thenanarc connectinganoderepresentingthepartialdistribution[𝑖,𝑗] with a node [𝑖+1,𝑗]or [𝑖,𝑗+1]represents that we added one stop to the partial admissible distribution [𝑖,𝑗],namely,𝑠𝑖+𝑗+1. The weight that we assign to this arc will represent the increment of benefit due to the changes of zone of the passengers that travel between each one of the stops {𝑠1,...,𝑠𝑖}and 𝑠𝑖+𝑗+1.Thefollowingformulagivesthevalue of the weights for all the arcs in the tree: 𝑤(𝑢,V)= { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { 0for 𝑢=[𝑖,0], V=[𝑖+1,0], with 1≤𝑖≤𝑛−1, ℎ1 𝑖 ∑ ℓ=1𝑝ℓ,𝑖+1 +𝑝𝑖+1,ℓ for 𝑢=[𝑖,0], V=[𝑖,1], with 1≤𝑖≤𝑛−1, ℎ1 𝑖 ∑ ℓ=1𝑝ℓ,𝑖+𝑗+1 +𝑝𝑖+𝑗+1,ℓ for 𝑢=[𝑖,𝑗], V=[𝑖,𝑗+1]with 1≤𝑖,𝑗≤𝑛−1, 2≤𝑖+𝑗≤𝑛−1.(3) In this way, the optimal solution is given by the weight of the longest path among all the paths from the root [1,0]to Mathematical Problems in Engineering 5 Zone 1Zone 2 [1, 0] [2, 0] [1, 1] [2, 1] [1, 2] [3, 1] [2, 2] [1, 3] [3, 0] [4, 0] [n − 2, 0] [n − 1, 0] [n, 0] [n − 2, 1] [n − 1, 1] [n − 2, 2] [3, n − 4] [3, n − 3] [2, n − 3] [2, n − 2] [1, n − 2] [1, n − 1] [i, j] with i+j=1 [i, j] with i+j=2 [i, j] with i+j=3 [i, j] with i+j=4 [i, j] with i+j=n−1 [i, j] with i+j=n Figure 3: Tree for 2zones and 𝑛stops. any vertex [𝑖,𝑗]with 𝑖+𝑗=𝑛. By properties of trees, once determining [𝑖,𝑗]such a path is unique. 4. The General Case of 𝑘Zones In this section we will see how to construct a tree for the case of 𝑛stops and 𝑘zones, with 𝑘≥2and 𝑛≥3. The algorithm is mainlybasedonassumption(A1),whichpermitsinductively defining the nodes and the arcs as we have seen in Section 3. From Step 1 up to Step 𝑘−1,atthesubsteps𝑞.1and 𝑞.2for 1≤𝑞≤𝑘−1, we define two new nodes from a node [𝑖1,𝑖2,...,𝑖𝑞,0,...],whichare[𝑖1,𝑖2,...,𝑖𝑞+1,...]and [𝑖1,𝑖2,...,𝑖𝑞,1,...]. We also define two arcs connecting node [𝑖1,𝑖2,...,𝑖𝑞,...]with each of them and assign its weight using formulas (4), (5), (6), (7), and (8). When a node is of the form [𝑖1,𝑖2,...,𝑖𝑘]with 𝑖𝑘=0,thenweconnectthisnodewitha single node [𝑖1,𝑖2,...,𝑖𝑘+1]and assign a weight to this arc using formula (9). An example of a tree for 5 stops and 3 zones is represented in Figure 4. 4.1. Definition of the Tree for 𝑛Stops and 𝑘Zones with 𝑛>𝑘≥2 Step 0. Consider the following. (0.1) Define 𝑖0=0.( ∗This index will be used from Step 3 onwards∗). (0.2) Start a tree with a unique node [1,0,0,...,0] ⏟⏟⏟⏟⏟⏟⏟⏟⏟⏟⏟⏟⏟⏟⏟⏟⏟⏟⏟⏟⏟⏟⏟⏟⏟ 𝑘 .Thiswill be its root. (0.3) Define a list 𝐿. We initialize the list with the node [1,0,0,...,0]. Step 1. Wetakethefirstnodeinthelist𝐿,namely,[𝑖1,𝑖2,𝑖3, ...,𝑖𝑘]. 6Mathematical Problems in Engineering Zone 1Zone 2Zone 3 [1, 0, 0] [2, 0, 0] [3, 0, 0] [4, 0, 0] [5, 0, 0] [4, 1, 0] [3, 2, 0] [2, 3, 0] [1, 4, 0] [1, 3, 0] [2, 2, 0] [3, 1, 0] [2, 1, 0] [1, 2, 0] [1, 1, 0] [1, 1, 1] [1, 1, 2] [1, 1, 3] [1, 2, 2] [1, 2, 1] [2, 1, 1] [2, 1, 2] [1, 3, 1] [2, 2, 1][3, 1, 1] Figure 4: Tree for 3zones and 5stops. If 𝑖𝑗=0for 2≤𝑗≤𝑘then consider the following. (1.1) If 𝑖1≤𝑛−𝑘+1then (i) define two new nodes [𝑖1+1,0,0,...,0]and [𝑖1,1,0,0,...,0]that are added to 𝐿; (ii) define the arcs ([𝑖1,0,0,...,0],[𝑖1+1,0,0,...,0]) with weight 0and ([𝑖1,0,0,...,0],[𝑖1,1,0,...,0]) with weight ℎ1(𝑖1 ∑ ℓ=1𝑝ℓ,𝑖1+1 +𝑝𝑖1+1,ℓ); (4) (iii) remove [𝑖1,0,0,...,0]from the list 𝐿and return to the beginning of this step. (1.2) Else if 𝑛−𝑘+1<𝑖1≤𝑛−1then (i) define two new nodes [𝑖1+1,0,0,...,0]and [𝑖1,1,0,0,...,0]that are added to 𝐿; (ii) define the arcs ([𝑖1,0,0,...,0],[𝑖1+1,0,0,...,0]) and ([𝑖1,0,0,...,0],[𝑖1,1,0,...,0])with weight 0; (iii) remove [𝑖1,0,0,...,0]from the list 𝐿and return to the beginning of this step. (1.3) Else if 𝑖1=𝑛then (i) remove [𝑖1,0,0,...,0]from the list 𝐿and return to the beginning of this step. Step 2.If𝑖2=0but 𝑖𝑗=0for 𝑗=3,...,𝑘then consider the following. (2.1) If 𝑖1+𝑖2≤𝑛−𝑘+2then (i) define two new nodes [𝑖1,𝑖2+1,0,...,0]and [𝑖1,𝑖2,1,0,...,0]that are added to 𝐿; (ii) define the arc ([𝑖1,𝑖2,0,...,0],[𝑖1,𝑖2+1,0,..., 0]),withweight ℎ1(𝑖1 ∑ ℓ=1𝑝ℓ,𝑖1+𝑖2+1 +𝑝𝑖1+𝑖2+1,ℓ), (5) and the arc ([𝑖1,𝑖2,0,...,0],[𝑖1,𝑖2,1,0,...,0]) with weight ℎ2(𝑖1 ∑ ℓ=1𝑝ℓ,𝑖1+𝑖2+1 +𝑝𝑖1+𝑖2+1,ℓ) +ℎ1(𝑖1+𝑖2 ∑ ℓ=𝑖1+1𝑝ℓ,𝑖1+𝑖2+1 +𝑝𝑖1+𝑖2+1,ℓ); (6) (iii) remove [𝑖1,𝑖2,0,...,0]from the list 𝐿and return to Step 1. (2.2) If 𝑛−𝑘+2<𝑖1+𝑖2≤𝑛−1then (i) define two new nodes [𝑖1,𝑖2+1,0,0,...,0]and [𝑖1,𝑖2,1,...,0]that are added to 𝐿; (ii) define the arcs ([𝑖1,𝑖2,0,...,0],[𝑖1,𝑖2+1,0,..., 0])and ([𝑖1,𝑖2,0,...,0],[𝑖1,𝑖2,1,...,0]),bothof them with weight 0; (iii) remove [𝑖1,𝑖2,0,...,0]from the list 𝐿and return to Step 2. (2.3) If 𝑖1+𝑖2=𝑛then (i) remove [𝑖1,𝑖2,0,...,0]from the list 𝐿and return to Step 2. (∗For 𝑞=3,...,𝑘−1the steps are defined following the next pattern:∗) Step q.If𝑖𝑞=0and 𝑖𝑗=0for 𝑗=𝑞+1,...,𝑘then consider the following. Mathematical Problems in Engineering 7 (q.1) If 𝑖1+𝑖2+⋅⋅⋅+𝑖𝑞≤𝑛−𝑘+𝑞then (i) define two new nodes [𝑖1,𝑖2,...,𝑖𝑞+1,0,...,0], [𝑖1,𝑖2,...,𝑖𝑞,1,...,0]that are added to 𝐿; (ii) define the arc ([𝑖1,𝑖2,...,𝑖𝑞,0,...,0],[𝑖1,𝑖2,..., 𝑖𝑞+1,0,...,0]),withweight 𝑞−1 ∑ 𝑟=1ℎ𝑞−𝑟 (𝑖0+𝑖1+⋅⋅⋅+𝑖𝑟 ∑ ℓ=𝑖0+𝑖1+⋅⋅⋅+𝑖𝑟−1+1𝑝ℓ,𝑖1+𝑖2+⋅⋅⋅+𝑖𝑞+1 +𝑝𝑖1+𝑖2+⋅⋅⋅+𝑖𝑞+1,ℓ), (7) and the arc ([𝑖1,𝑖2,...,𝑖𝑞,0,...,0],[𝑖1,𝑖2,...,𝑖𝑞, 1,0,...,0])with weight 𝑞 ∑ 𝑟=1ℎ𝑞−𝑟+1 (𝑖0+⋅⋅⋅+𝑖𝑟 ∑ ℓ=𝑖0+⋅⋅⋅+𝑖𝑟−1+1𝑝ℓ,𝑖1+𝑖2+⋅⋅⋅+𝑖𝑞+1 +𝑝𝑖1+𝑖2+⋅⋅⋅+𝑖𝑞+1,ℓ); (8) (iii) remove [𝑖1,𝑖2,...,𝑖𝑞,0,...,0]from the list 𝐿and return to Step 1. (q.2) If 𝑛−𝑘+𝑞<𝑖1+𝑖2+⋅⋅⋅+𝑖𝑗≤𝑛−1then (i) define two new nodes [𝑖1,𝑖2,...,𝑖𝑞+1,0,...,0] and [𝑖1,𝑖2,...,𝑖𝑞,1,...,0]that are added to 𝐿; (ii) define the arcs ([𝑖1,𝑖2,...,𝑖𝑞,0,...,0],[𝑖1,𝑖2,..., 𝑖𝑞+1,0,...,0])and ([𝑖1,𝑖2,...,𝑖𝑞,...,0],[𝑖1,𝑖2, ...,𝑖𝑞+1,0,...,0]),bothofthemwithweight0; (iii) remove [𝑖1,𝑖2,...,𝑖𝑞,0,...,0]from the list 𝐿and return to Step 1. (q.3) If 𝑖1+𝑖2+⋅⋅⋅+𝑖𝑞=𝑛then (i) remove [𝑖1,𝑖2,...,𝑖𝑞,0,...,0]from the list 𝐿and return to Step 1. Step k.Since𝑖𝑘=0then consider the following. (k.1) If 𝑖1+𝑖2+⋅⋅⋅+𝑖𝑘≤𝑛−1then (i) define a new node [𝑖1,𝑖2,...,𝑖𝑘−1,𝑖𝑘+1]and add it to 𝐿; (ii) define the arc ([𝑖1,𝑖2,...,𝑖𝑘−1,𝑖𝑘],[𝑖1,𝑖2,...,𝑖𝑘−1, 𝑖𝑘+1])with weight 𝑘−1 ∑ 𝑟=1ℎ𝑘−𝑟 (𝑖0+⋅⋅⋅+𝑖𝑟 ∑ ℓ=𝑖0+⋅⋅⋅+𝑖𝑟−1+1𝑝ℓ,𝑖1+𝑖2+⋅⋅⋅+𝑖𝑘+1 +𝑝𝑖1+𝑖2+⋅⋅⋅+𝑖𝑘+1,ℓ); (9) (iii) remove [𝑖1,𝑖2,...,𝑖𝑘−1,𝑖𝑘]from the list 𝐿and return to Step 1. (k.2) If 𝑖1+𝑖2+⋅⋅⋅+𝑖𝑘=𝑛then (i) remove [𝑖1,𝑖2,...,𝑖𝑘−1,𝑖𝑘]from the list 𝐿and we are done. 4.2. Optimal Solution for 𝑛Stops and 𝑘Zones. With a similar argument as in the proof of Theorem 4,wecangettheoptimal solution for 𝑘zones. Theorem 5. Let us consider 𝑛stops to be distributed into 𝑘 zones and assume that the number of passengers between every pair of stops (𝑝𝑖,𝑗)1≤𝑖,𝑗≤𝑛 is given. Let 𝑇be a weighted tree constructed under assumptions (A1), (A2), and (A3) as it is indicated in Section 4.1. Then the longest path from the root to [1,0,...,0]to a leaf of the form [𝑖1,...,𝑖𝑘]with 1≤𝑖1,...,𝑖𝑘≤𝑛and 𝑖1+⋅⋅⋅+𝑖𝑘=𝑛 returns the maximal benefit for distributing 𝑛stops into 𝑘zones. Remark 6. We point out that in substeps 1.2,...,𝑘−1.2some nodes defined are useless for finding the solution, since they do not belong to any path from the root [1,0,0,...,0]to any admissible distribution. However, their definition will simplify the enumeration of the nodes as we will see in the next section. 5. Some Considerations regarding the Nodes The algorithm in Section 4 lets us construct a tree that models ourproblem.Aswehaveseenintheprevioussection,the construction of the nodes and the arcs joining them can be done inductively. However, it could be of interest to find an explicit formula for calculating the total number of nodes in each tree; see, for instance, the case of 3zones and 5 stops in Figure 5 and the case of 4zones and 6stops in the figure in the Supplementary Material available online at http://dx.doi.org/10.1155/2014/384321. Suppose that we have 𝑛stops and 𝑘zones, with 𝑛>𝑘≥2. At the 𝑞th step of the construction of the tree, 𝑞=1,...,𝑛, we have all admissible distributions of 𝑞stops distributed in a row. More precisely we have all distributions of the form [𝑖1,...,𝑖𝑘]with ∑𝑘 ℓ=0 𝑖ℓ=𝑞and if 𝑖ℓ=0, then the next indexes are null; that is, 𝑖ℓ+1 =⋅⋅⋅=𝑖𝑘=0. We recall that for every 𝑞<𝑛,everynodelabelledin the step 𝑞as [𝑖1,...,𝑖𝑘]is split into one or two nodes at step 𝑞+1.Moreprecisely,anode[𝑖1,...,𝑖𝑗,0,...,0],with 𝑖1,...,𝑖𝑗=0and 𝑗<𝑘,givesbirthto[𝑖1,...,𝑖𝑗+1,0,...,0] and [𝑖1,...,𝑖𝑗,1,...,0]. A node at zone 𝑘in the step 𝑞of the form [𝑖1,...,𝑖𝑘],with𝑖𝑘=0, is only connected with the node [𝑖1,...,𝑖𝑘+1]at the zone 𝑘in the step 𝑞+1. All these nodes can be enumerated using properties of Pascal’s triangle; see, for instance, [37]. Theorem 7. Let us denote by 𝑧𝑞,𝑗 the number of nodes at zone 𝑗 at Step 𝑞of the construction of the tree that models the problem for 𝑛stops into 𝑘zones. Then 𝑧𝑞,𝑗 =(𝑞−1 𝑗−1)=∏𝑗−1 𝑙=1 (𝑞−𝑙) (𝑗−1)! 𝑓𝑜𝑟1≤𝑞≤𝑛,1≤𝑗≤𝑘. (10) Proof. Let us denote by 𝑧𝑞,𝑗 the number of nodes at zone 𝑗 at Step 𝑞of the construction of the tree, which is defined for 8Mathematical Problems in Engineering Zone 1 1 2 4 8 15 16 17 10 11 56 3 9 18 19 2120 22 23 24 25 14 13 12 7 [1, 0, 0] [2, 0, 0] [3, 0, 0] [4, 0, 0] [5, 0, 0] [4, 1, 0] [3, 2, 0] [3, 1, 0] [2, 2, 0] [2, 3, 0] [1, 4, 0] [1, 3, 0] [2, 1, 0] [1, 2, 0] [1, 1, 0] Zone 2Zone 3 [3, 1, 1] [2, 2, 1] [1, 3, 1] [2, 1, 2] [1, 2, 2] [1, 1, 3] [1, 1, 2] [1, 2, 1] [2, 1, 1] [1, 1, 1] Figure 5: Tree for 3zones and 5stops with labels at the nodes. all pairs (𝑞,𝑗)with 1≤𝑞≤𝑛and 1≤𝑗≤min{𝑘,𝑞}.The sequence {𝑧𝑞,𝑗}𝑗,𝑞 canbeinductivelydefinedas { { { { { 𝑧𝑞,1 =1 ∀1≤𝑞≤𝑛, 𝑧𝑞,𝑞 =1 ∀1≤𝑞≤𝑘, 𝑧𝑞,𝑗 =𝑧𝑞−1,𝑗−1 +𝑧𝑞−1,𝑗 if 1<𝑞≤𝑛,𝑞<𝑗≤𝑘. (11) Thisrecurrenceissimilartotheoneusedforgeneratingthe combinatorial numbers in Pascal’s triangle [37]. Therefore, we can identify the numbers 𝑧𝑞,𝑗 with the combinatorial numbers expressed in (10). As the number of nodes in a row is represented by combinatorial numbers, in order to assign labels to the nodes, we can use an existing connection with the partial sums by rows of Pascal’s triangle. Furthermore, explicit formulas for these numbers can be provided using generating functions [38]. Proposition 8 (see [38]). Let us consider the functions 𝐺𝑗(𝑥):= 1 𝑥𝑗−1 (𝑗−1 ∑ 𝑖=0 𝑥𝑖 (1−𝑥)𝑖+1 −(2𝑥)𝑗−1 −1 2𝑥−1 )𝑓𝑜𝑟1≤𝑗≤𝑘. (12) If we denote by 𝐺𝑗,𝑖 the 𝑖th coefficient of the Taylor expansion of 𝐺𝑗at 𝑥=0, then the following relation holds: 𝑗 ∑ ℓ=1𝑧𝑞,ℓ =𝑗 ∑ ℓ=1 (𝑞−1 ℓ−1)=𝐺𝑗,𝑞−𝑗 𝑓𝑜𝑟𝑗≤𝑞. (13) Example 9. Let us analyze with more details the basic cases of 2and 3zones with 𝑛stops. For 2zones, the total number of nodes of the tree generated for distributing 𝑛stops is 𝑛 ∑ 𝑞=1 (𝑞−1 0)+𝑛 ∑ 𝑞=2 (𝑞−1 1)=𝑛2+𝑛 2.(14) Similarly, for 3zones and 𝑛stops the number of nodes needed to define the tree is 𝑛 ∑ 𝑞=1 (𝑞−1 0)+𝑛 ∑ 𝑞=2 (𝑞−1 1)+𝑛 ∑ 𝑞=3 (𝑞−1 2)=𝑛3+5𝑛 6,(15) and for 4 zones and 𝑛stopswehaveatreewiththefollowing number of nodes: 𝑛 ∑ 𝑞=1 (𝑞−1 0)+𝑛 ∑ 𝑞=2 (𝑞−1 1)+𝑛 ∑ 𝑞=3 (𝑞−1 2)+𝑛 ∑ 𝑞=4 (𝑞−1 3) =𝑛4−2𝑛3+11𝑛2+14𝑛 24 .(16) Remark 10. The formulas in Proposition 8 and in Example 9 canbeobtainedtakingintoaccountthatthesumofcombinatorial numbers along a diagonal of Pascal’s triangle can be expressed as an arithmetic sequence of higher order [39]. The general formula for the number of nodes in the problem of 𝑘 zones and 𝑛stops is given by 𝑘 ∑ 𝑗=1 𝑛 ∑ 𝑞=1 (𝑞−1 𝑗−1)(17) that can be also rewritten as 𝑛+1 2! 1 ∏ 𝑙=0 (𝑛−𝑙)+1 3! 2 ∏ 𝑙=0 (𝑛−𝑙) +⋅⋅⋅+ 1 (𝑘−1)!𝑘−2 ∏ 𝑙=0 (𝑛−𝑙)+1 𝑘!𝑘−1 ∏ 𝑙=0 (𝑛−𝑙).(18) Therefore, using properties of arithmetic sequence of higher order [39]andif𝑛is much more greater than 𝑘,we affirm that the number of nodes of the tree for the problem of 𝑘zones and 𝑛stops is of order O(𝑛𝑘). Mathematical Problems in Engineering 9 We can also enumerate all admissible distributions of a tree using a sequential order. As we have already seen, this can be done recursively. Here we provide explicit formulas for the cases of 2and 3zones. Example 11. The number corresponding to a node representing the admissible distribution corresponding to the case of 2 zones and 𝑛stops [𝑖1,𝑖2],with𝑖1+𝑖2≤𝑛, can be easily defined from the sequence {𝑎𝑗}𝑗≥1 with 𝑎𝑗=(𝑗2+𝑗)/2: {1+𝑎𝑖1−1 for 𝑖1=0,𝑖2=0, 1+𝑎𝑖1+𝑖2−1 +𝑖2for 𝑖1,𝑖2=0. (19) For the case of 3zones and 𝑛stops, the number assigned to a (partial) admissible distribution [𝑖1,𝑖2,𝑖3],with𝑖1+𝑖2+ 𝑖3≤𝑛, can be easily defined from the sequence {𝑎𝑗}𝑗≥1 with 𝑎𝑗=(𝑗3+5𝑗)/6.Thelabelof[𝑖1,𝑖2,𝑖3]is { { { { { { { { { { { { { { { 1+𝑎𝑖1−1 for 𝑖1=0,𝑖2,𝑖3=0, 1+𝑎𝑖1+𝑖2−1 +𝑖2for 𝑖1,𝑖2=0,𝑖3=0, 1+𝑎𝑖1+𝑖2+𝑖3−1 +𝑖2 +𝑖3 ∑ 𝑙=1 (𝑖1+𝑖2+𝑖3−𝑙) for 𝑖1,𝑖2,𝑖3=0. (20) Remark 12. We point out that in the algorithm of Section 4,at some steps of the form (∗.2), we were introducing additional nodes for simplifying the notation as it is indicated at the beginning of this section; see also Remark 6, despite the fact that they are not considered for finding the optimal solution. Since no admissible distribution is accessible from one of these nodes, then we can remove them and reduce the number of nodes that we are considering in our model. Nevertheless, we have preserved them for the clarity of the enumeration. 6. Discussion and Results As we have already mentioned in Section 2,for𝑛stops to be distributed into 𝑘zones, we have to evaluate a number of (𝑛−1 𝑘−1 )possible solutions. The cost of generating all these solutionsisoforderO(𝑛𝑘),since𝑘nested loops from 1to 𝑛are required. For each one of these possible solutions one has to consider the 𝑛(𝑛−1)arrangements of two different stops and to compute the income received from the passengers between every pair of stops (in both directions). Then the cost is of order O(𝑛𝑘+2). If we think in terms of the tree constructed in Section 4.1 for modeling the problem, each possible solution to the problemoftheoptimalassignmentofstopsintozonesis associatedwithaleafofthattree,orinotherwordstoa node in the zone 𝑘at step 𝑛. This is consistent with the definition of 𝑧𝑛,𝑘, which is in fact (𝑛−1 𝑘−1 ).Soastogetthe benefit from a certain distribution [𝑖1,...,𝑖𝑘],of𝑛stops into 𝑘zones, we have to compute the length (in terms of weight) oftheuniquepaththatconnectstheroot[1,0,...,0]with the node associated with [𝑖1,...,𝑖𝑘]. Each path from the root to a leaf consists of 𝑛−1edges. The tree structure used for representing the distributions of stops into zones lets us obtain the weight of each of them by computing once the weight of each arc in order to get the optimal solution to our problem. This improves the computational cost of the solution with respect to the combinatorial approach. Let us see in detail the benefits of using the tree-based approach. Firstly, as we have indicated in the previous section, the number of nodes is of order O(𝑛𝑘).Thisalsoholdsforthe number of arcs, since the number of arcs in a tree is equal to the number of nodes minus 1. Secondly, the computational cost of the calculations for assigning a weight to a single arc is of order O(𝑛):foreveryarc with an end node of the form [𝑖1,𝑖2,...,𝑖𝑗,0,...,0]we need at most 2(𝑖1+𝑖2+⋅⋅⋅+𝑖𝑗−1)sums plus at most 𝑗−1products in order to determine the benefit from the passengers between the first 𝑖1+⋅⋅⋅+𝑖𝑗−1 and the last one; see (7), (8), and (9). These computations are of order O(𝑛).Thesameestimation of the computational cost is obtained if the end node is of the form [𝑖1,𝑖2,...,𝑖𝑘]with 𝑖𝑘=0. Therefore, the cost of assigning weights to all arcs of the tree is of order O(𝑛𝑘+1). Finally, for finding the longest path from the root to a leaf we need O(𝑛𝑘)operations because we only need to consider each arc only once as we can see right now. Consider the 𝑧𝑛,𝑘 leaves of the tree, which are located at level 𝑛.Eachoneis connected to a different node in the level 𝑛−1.Butsomeof the nodes at level 𝑛−1share their adjacent node at level 𝑛− 2. For instance, a pair of nodes of the form [𝑖1,...,𝑖𝑘−1,1], [𝑖1,...,𝑖𝑘−1 +1,0]at level 𝑛−1, share its adjacent node at level 𝑛−2,whichis[𝑖1,...,𝑖𝑘−1,0]. This also holds for nodes of the form [𝑖1,...,𝑖𝑗,1,0,...,0],[𝑖1,...,𝑖𝑗+1,0,0,...,0]for 𝑗=2,...,𝑘−2. Our strategy will be to start with the leaves and find their adjacent nodes at level 𝑛−1. Then we find the adjacent nodes to them at level 𝑛−2. For every node at level 𝑛−2,wechoose between the two only possibilities we have and record which is the path to a leaf that provides a longer path. Inductively, we repeat the process with nodes at an upper level until we arrive at the root. Therefore, once the tree is defined, for finding the distribution with highest revenue, we have to perform a number of computations of order O(𝑛𝑘), similar to the order of the number of arcs in the tree. All this together gives that we need O(𝑛𝑘+1)computations to find the solution using the tree-based approach for finding the solution to our problem, which is smaller than the computational cost of the combinatorial approach, O(𝑛𝑘+2). For illustrating these results we have considered the problemofsplitting10stopsinto2,3,4,5,and6zones.In particular we have considered an estimation of the number of the passengers of the railway line Valencia-Castell´ on over the month of August 2013. The number of passengersbetween eachpairofstopsisgiveninTable 1. We present in the table the most efficient distributions of the 10 stops into different number of zones. For 3zones the optimal distribution is [7,1,2]and for 4 zones [6,1,1,2]. Besides, for 5and 6zones the results are the ones shown in Figures 6and 7.