Mobile Device Programming for Finding Optimal Path on a Fast-Bus System Sonia Vivas and Germán Riaño Abstract— In this project, we developed a real-time software solution that helps users to find the optimal combination of routes in a bus-based passenger mass transportation system, TransMilenio (TM), in Bogotá, Colombia. The TM users face the need to choose the best route between two points, and the information presented, in form of maps and operation hours for each route, usually is not enough to make that choice. Even if a user could have all the information about the system, the decision would not be trivial. Also, there is not a unique way to define the optimality criteria, since besides total travel time, the user might want to avoid changing buses which might involve long walks in the stations, or avoid congested routes to increase the chance of finding an available seat. This paper describes the problem faced and the proposed solution. I. I NTRODUCTION Nowadays, mass transportation systems are an important part of our lives. In any of these systems, finding the best route between two points means a problem, because for doing so one should not only know all the information about the system, but be able to process it at great velocity. Usually, this decision is defined by the expertise of the user and the randomness of the system. In some transportation systems, information is given to the user, so he can make a better choice, even more, there is software available for metro systems that allow users to find the best route for them. Is then clear that the problem is interesting, and it goes further than the merely search for a shortest path, it also involves the user necessity of ubiquity for any solution to this problem. With that in mind, the propose of this research was to find a solution for the shortest path problem in the TransMilenio (TM) system, in Bogotá, Colombia. This is a fast bus system, which will be described later. We developed a model of this system so it could be used computationally. The shortest path problem was then redefined so it could take in consideration all the extra data available (like schedules, occupation levels, stochastic times). An algorithm was developed for this research project, and finally a software application was developed. This application was programmed for mobile devices, so it could be used by any user, anywhere and at all times. Our choice of programming for mobile devices arose from the problem that some other solutions might have: they are S. Vivas is with the Department of Computer Science, Universidad de los Andes, Colombia G. Riaño is with the Centro de Optimización y Probabilidad Aplicada – COPA, Department of Industrial Engineering, Universidad de los Andes, Colombia. Fig. 1. TransMilenio Buses(Taken form [1]) attached to a single place, even the software for computers is not as portable as one could like, because portable computers are not popular between most of TM users. Cellular phones, on the contrary, are really popular, and receiving and sending calls are the smallest tasks that users perform on their phones. These means that any tool for these devices will be broadly accepted. However the algorithm runs on a server, so, in the future, other clients (like a web page) can be written to access the information. The results are basically two: an algorithm that finds the shortest path, and considers many of the TM characteristics and an application that implements the algorithm on mobile devices. This paper will explain the specific problem addressed and will resume the results of the research. The remainder of the paper is organized as follows. In Section II we describe the characteristics of the TransMilenio system, in Section III we review some of the shortest path problems and algorithms that solve them, in Section IV we explain the network design used to represent the problem and the solution algorithms and software is described in Section V. In section VI we present the results obtained with the program and, finally, in Section VII we give some concluding remarks and propose developments that can be build as extensions of this research. II. T HE T RANS M ILENIO SYSTEM For a better understanding of the problem, it is necessary to explore the particular characteristics of the TransMilenio (TM) system. TM consists on a fleet of articulated buses that run on exclusive corridors (see Figure 1). These buses stop at stations, which are distributed along the city. Since the corridors have two lanes not all the buses stop in every station along the corridor. Groups of buses cover a route path, meaning they run on a specific corridor and stop on some specific stations, so it is usual for two routes to take the same corridor, but stop in a different set of stations. For sake of clarity, think of two different routes 50 and 70, these two run on the same route (see Figure 2), but as you can see in the map, the set of stations in which they stop is different from each other and the number of stops is different, affecting the time between two stations. For the weekdays, there are 18 different routes, and because some of them stop in the same station, for several stations, there is a significant number of possible route changes. There are multiple reasons to change from a route to another different of the path like comfort or speed. Beside the number of routes, the system has 94 stations. The different routes that stop at a station, stop in different doors, so in order to calculate the total time of a specific path, it is necessary to include the walking time between doors, and the waiting time in the case of a change of bus. In order to serve the traffic of people, TM developed a time schedule, so not all the routes are available all the time (and nor every day). A user can decide which routes to take using the information available: in the TM web page, where he can find the TM map, maps in the stations and information boards, which inform about the remaining time for a bus to arrive ( these boards inform only about the routes that stop in the door where they are installed); TM employees, who can inform about the stops of a route, and give their personal opinion about the velocity and comfort that each route could provide. III. S HORTEST PATH P ROBLEM The shortest path problem is interesting because it can be used to solve a broad amount of every day problems, as transport and telecommunication issues, turning the shortest path problem in one of the most important problems in the study of network flow models [2]. This problem can be defined as the need of finding an optimal path in a specific graph. The specification of the begin and end points, the weights of the edges and the definition of ‘optimal’ determine the type of the problem. The simplest definitions of the shortest path problem are the simple shortest path and the shortest path between all pairs of nodes. A. Simple Shortest Path Problem This problem can be explained considering a graph G = (N, A), where N represent a set of nodes and A is the set of edges, and let s ∈ N be a node chosen as origin. The problem consist in finding all the shortest paths between s and all the other nodes v ∈ N . Is common to consider that the edges have an associated weight, so the shortest path will not be the one with less number of nodes, but the one with minimum weight, thinking in the weight of a path as the sum of the weights of all the edges that are part of the path. If the edge has a negative weight cycle, reachable from the beginning node s, a shortest path could not be defined to the nodes in the cycle, nor to any node v reachable trough the cycle. This because in each turn of the cycle, the weights will be lower, so if the cycle is repeated lots of times, the weight between s and v would be inf inity. B. Shortest Path Between All Pairs of Nodes Using the same notation as before, we define this problem as finding the shortest path between all pairs of nodes (i, j) ∈ N × N . [3]. This problem can be taken as n problems of simple shortest path. C. Problem variants There are lots of variants to the shortest path problem [4], between them: • Shortest path with one begin and one end. It issues a simple shortest path problem, with only one end. • Shortest path with one end. It addresses the shortest path problem between every node in the graph and a specific end point. • Maximum capacity path. In this problem, the weights in the edges are considered flow capacities, so the objective path is that in which the capacity is maximized [5]. D. Problem Solutions The most known algorithm to solve this kind of problem is the Dijkstra algorithm, nevertheless there are diverse algorithms that address different specific problems, depending on the application and the variation of the shortest path problem. In this paper we will consider only two algorithms: Dijkstra and Brumbaugh-Smith and Shier algorithms. The reason for this decision is that the implemented solution only uses this two algorithms. Other interesting algorithms for this problem are: A*, Floyd-Warshal, Johnson’s Algorithm. [6] E. Dijkstra Algorithm Dijkstra algorithm is one of the simplest an most effective shortest path algorithms. It works on non-negative weighted graphs, solving the simple shortest path problem. The algorithm uses the greedy method, in which in order to construct the solution for a big problem, smaller sub problems are solved, and their size is incremented until these sub problems reach the objective. It resembles dynamic programming, but it does not save different partial solutions, it only saves one (the best one). The necessary time for the Dijkstra algorithm in a graph with m nodes and m depends on the way that Q is implemented. If q is implemented as a linked list or an array, the time would be O(n3 ). With a binary algorithm, the time required will be O((m + n) log n). With a Fibonacci algorithm, the time will be O(m + n log n). [2] In case that the graph involves negative weights, the Bellman Forman algorithm will provide a solution, but this algorithm is less efficient than the Dijkstra algorithm, so it is only used in the case of negative weights. F. Brumbaugh-Smith and Shier Algorithm [7] This algorithm finds a solution for the bi-objective shortest path problem. The algorithm considers a graph and two objectives c and t. Using a labeling technique, the algorithm steps in some nodes, from the origin node to the destination node. In each of them, the algorithm consider the linear Fig. 2. Map of the TransMilenio System. Taken from [1]. maximization of the objectives, storing this answer as the best route from the beginning node to the node that is being reviewed, this answer is stored as the best c and t for the node, and the id of the last node in the path that is being stored. Not necessarily every node is explored, the nodes reviewed are the ones that are connected in a path to the beginning node. The algorithm returns the best route for every reviewed node, so it is necessary to backtrack the path from the destination node to the begin node. G. The Extended Brumbaugh-Smith and Shier [8] Suárez proposed an extended algorithm that allows to incorporate dynamic behavior in the model. Suárez addressed the TransMilenio problem, considering as the objectives the minimization of time and of bus changes. His algorithm requires a weighted graph with no negative cycles, the begin and destination nodes and the time restrictions for the edges, making the graph dynamic (the edges are or not valid depending on the time). Besides he asks the final user for a maximum number of bus changes that he is willing to make, let call it M . The algorithm works as the original, but it stores all possible solutions for each node, and before storing a solution, reviews the time restrictions, so the solution will only be stored if all the edges are active at the time of the query. The algorithm returns a set of solutions for each node, in order to find the paths it is necessary (as in the original algorithm) to backtrack each path beginning at the destination node. With this paths, Suárez uses the M index to choose the ones that are valid, according to the index, and he returns the path with less time, that is valid according to the index, and that has the less number of bus changeovers. IV. S HORTEST PATH P ROBLEM IN THE T RANS M ILENIO S YSTEM The problem we want to address is a variant of the shortest path, that includes concepts as stochastic weights, multiple objectives and time restrictions. We want to minimize the time that the user expends inside the TransMilenio system, minimize the quantity of bus changeovers, minimize the level of occupation of the buses in the path, take in account the dynamism of the graph and incorporate the concept of random parameters. This definition of the problem could mean that we need a really complex algorithm, but the problem characteristics are usually limited by the user will. Checking the characteristics one by one, the limits become clear: • • • Bus changes There is a maximum quantity of bus transfers that a user is willing to do. Checking the map, is clear that the maximum number of necessary bus changes between any two points is 3, nevertheless a bigger number could be chosen in the sake of the minimization of time, or in the minimization of the bus occupation. In this way, the problem of minimizing the number of bus transfers is reduced to a non-negative restriction with a upper bound. Occupation The occupation of a bus could be defined as the number of persons that are in the bus divided by the capacity of the bus. This characteristic is not an imperative need, so the decision can be leaved to the user to choose, transforming this restriction in just information for the user choice. Dynamic graph This characteristic does not depend on T , so its mean is known to be T /2. Since the frequency of buses change during the day, the time associated with these edges also changes. Since not all routes operate at all times the model has a dynamic behavior. To model this behavior, each edge has a state, which can be either active or inactive. B. Model Assumptions • Fig. 3. From the TM Map to the TM Graph • • the user but on the time of the query, so the solution to the problem can not have inactive edges, and that must be secured by the solution algorithm. Total time This characteristic is the most important one for the users of this type of system, in fact the short times are part of the publicity of the system, so this will be the parameter to minimize. V. I MPLEMENTED S OLUTION The problem was reduced to a variation of the simple shortest path problem, that takes in account restrictions and dynamic edges. The solution considers a graph that models the TransMilenio system, and uses the algorithms of Dijkstra and of Brumbaugh-Smith and Shier. The model and the algorithm will be described in this section. • • • • • The time needed to go from one station to another is a random variable, and it is represented by the mean and the standard deviation. The time needed to change from one bus to another is a random variable, and it considers the time needed to walk between doors and the time needed to wait the new bus. The hour in which a route is scheduled to begin is taken as the moment in which the first bus of the route start running from the two portals of the route. The system is modeled as it was at December 31 of 2005. We only consider the express and common routes from Monday to Friday, de super express and the weekend routes are not taken in consideration. The time and occupation levels are estimates, and are based on official TransMilenio information and in intuition on busy traffic hours. The stochastic nature of the edges is vaguely exploited, although the model uses media and deviation, the stochastic variables could be deeply exploded to obtain even more realistic solution. A. TransMilenio as a Graph In order to model the TransMilenio system, we consider a set of nodes and edges for the graph, and a set of routes for the algorithm. • Nodes: There are two types of nodes: The first represent pair (station, route), allowing to model bus changes, and the second station nodes, identified by the station name. • Edges: We defined three types of edges: entrance, movement and bus transfer. The first ones link a station node and a regular node, reflecting the time of waiting for the first bus to arrive; the second ones consider tuples with same route and different station, reflecting the movement time; the third ones consider tuples with the same station and different routes, reflecting bus changeovers. In the Figure reffig:tmmtg a example of the model is shown. Graph Characteristics: Since we want to involve the characteristics of TransMilenio, we need to define some details for the graph: The movement edges had an associated weight, specified by a media and a deviation. This weight represents the time needed to go from one station to another in a specific route. The transfer edges consider the time needed to walk between two doors (the doors where the buses stop), and the waiting time for the new bus. This time is random. If the buses come deterministically, one every T minutes this is a uniform random variable between 0 and C. Proposed Algorithm Taking into account the Suárez [8] algorithm, the introduction of the new model characteristics should be easy. Nevertheless the model defined is really big, and could have lots of cycles. Besides the idea of implementing the solution on mobile technology force us to use an efficient algorithm, and because of the size of the model, the Suárez algorithm is not as efficient as we may want. The proposed algorithm consider as beginning node a station node, because the user knows in which station he is, but he does not necessarily know which should be the first route to use. Under the need of efficiency, we use an important assumption: we consider a perimeter when searching for the shortest path between two stations a and b. The perimeter contains 3 different sets: the begin and end stations (a and b), the stations that are physically between a and b, and the stations that are less than 3 stations away (physically) from the stations in the last two sets. This allows the algorithm to ignore some stations (and nodes) making the search quicker. The algorithm also checks that a path does not return to a station, in other words, unless we are dealing with a bus changeover, the path can not have two or more nodes with the same station. The presence of infinite cycles is also checked, in the every bus change there is a possibility for the labeling algorithm to collapse, because the nodes involved in the change could be checked repeatedly forever. The maximum number of bus transfers is chosen by the user between 1 and 5. The proposed algorithm requires a graph, the begin and end station, the maximum number of bus transfers, the time schedule of the routes and the physical station distribution. The algorithm starts defining the perimeter and then start a cycle in which for each labeled node s, s is unlabeled, the route changes are reviewed (to avoid infinite cycles) and then, according to the perimeter, a node n is chosen from the set of next nodes from s is checked, to validate the route schedule, and if it is valid, the number of bus changeovers is checked so it will be inside the limits; if it is, the solution is added to a list of solutions for the node that is being reviewed. The solution is formed by the time, the deviation, the previous node of the path and the occupation level. The node n is labeled. The result of the cycle is a set of paths for each reviewed node, and the path from de begin node to the end node is backtracked as in the Brumbaugh-Smith and Shier original algorithm. Since this algorithm takes a little much time for a mobile application, we use first Dijkstra algorithm to provide a faster answer, and then we allow the user to run this algorithm. D. Implementation Fig. 4. • • • The solution was implemented using JAVA as programming language, creating a solution that is able to run in most of the operatives systems. We used the J2ME (Java Micro Edition) [9] as the environment for mobile applications. The Mobile Information Device Profile (MIDP), is the Java runtime environment for the most popular compact mobile information devices, such as cell phones and mainstream PDAs. The application was implemented in a server - client architecture, principally because of the size restrictions of the MIDP package. The communication between the server and the client is based on sockets and threads. The client was implemented as a light MIDP application. It has classes that structure the user interface and the path management. The client is concerned with the translation of the server data into clear information to the client. In the server is where the algorithm was implemented. The server reads some xml archives, and with that information it loads the TransMilenio graph. Both the server and the client are implemented in a way that allows to easily extend the software and to use the classes that are already implemented as base for new classes that implement the methods to serve any particular problem. The application is based on the work of K. Knizhnik, who developed a mobile application for finding the shortest path in the Kiev metro [10]. VI. R ESULTS To describe the application we will consider its use cases. The initial screen can be seen in Figure 4. • • • • Initial Screen and Choose Station Screen To choose the begin and destination stations The application allow the user to display all the stations either by runway, by route or in alphabetic order. Once both stations are chosen, the application displays the shortest path using the Dijkstra algorithm (without concerning about restrictions). See Figure 4. To see the description of the shortest path Once the shortest path is calculated, the user can review this solution. The application shows the time, the deviation of the time, the number of bus changeovers, the stations in which the routes stop, the description of the bus changeovers, the routes that must be taken in this path and the level of occupation of each of these routes. To choose a maximum number of bus changeovers The system display a “It does not matter” sign and the numbers from 1 to 5, so the user can choose. If the user choose that it does not matter, the preset value is 3 bus changeovers. To see more solutions Once the begin and end stations are selected, and the maximum number of changeovers is set, the user can check the solutions obtained by the implemented algorithm. When the user select to see more solutions, the application displays a set of the 10 better possible solutions, described in terms of time, time deviation, number of bus changeovers and media of the occupation levels. To select a solution When the user is seeing the possible solutions, he can select a solution, returning to the main menu. The time of the selected solution is displayed in the screen. To see the description of a solution The information displayed is the same as in the case of the seeing of the description of the shortest path. Figure 5 To see the map of a solution This choice displays the TransMilenio map in which the chosen solution is marked. Figure 5 The algorithm has a poor efficiency in matter of time, nevertheless the effectiveness is complete, the paths are found correctly and the model restrictions are taken in account. In order to determine the algorithm efficiency, we conducted 10 tests between every pair of stations at a high traffic time. The tests were conducted in a AMD Athlon XP 1800, with 480 MB in ram. The shortest time for the algorithm to find an answer was observed in pairs of physically close • • • • • Fig. 5. Path Description and Path Map Screens Improve the algorithm efficiency, by means of data structures. Include the routes that have not been considered. Run a market research in order to find out the user preferences when choosing a path. Consider the possibility of link the application with a satellite in order to know where are the buses, and, with this, obtain real times. Consider dynamic times, times that change in time. For example, in a busy traffic hour, the waiting for a bus time will be longer than in a low traffic hour. Same as in the case of rain, or in the case of a traffic accident. R EFERENCES stations. Although is difficult to resume in one average all the possibilities, we can assure that in close stations, the time of search is between 0.5 and 5 seconds. The problem comes between physically far stations (from one portal to another), the average time is between 1 and 3 minutes. The average time for a consult between two stations is 0.7 minutes. This tests were done with a limit of bus changeovers set to 2. If this number is augmented, the time grows exponentially, meaning that with 5 bus changeovers, the average time will be 3 minutes. VII. C ONCLUSIONS AND F UTURE W ORK The principal objective of the realized study was to give to the TransMilenio user a tool for facilitate the decision of which path to take between two stations of the system. The solution was an application, implemented for mobile devices, that find a set of good solutions and leave the final decision to the user. The algorithm takes in account the time schedules of the routes, the stochastic nature of the displacement times, and a limit in the number of bus changeovers. The algorithm considers also a perimeter, which allows to leave apart some stations in the quest for the best path. The final solution set has 10 solutions that minimized time, minimized number of changeovers and considered the level of occupation. The algorithm efficiency is diminished by the graph complexity. Of course there is a bias introduced by the machine in which the test were realized. The run times could be improved in a better machine. The application was developed thinking in expansion possibilities, therefore any limitation that could be inserted in this work can be easily overcome. This research van be continued in a number of ways: • Exploit the stochastic nature of the graph, to obtain more realistic times. [1] Transmilenio S.A., “http://www.transmilenio.gov.co,” 2005. [2] R. K. Ahuja, T. L. Magnanti, and J. B. Orlin, Network Flows. Upper Saddle River, NJ, USA: PrenticeHall, Inc, 1993. [3] T. T. Shane Saunders, “Efficient algorithms for solving shortest pathson nearly acyclic directed graphs,” Research and Practice in Information Technology, vol. 41, 2005. [4] D. P. Bertsekas and J. N. Tsitsiklis, “An analysis of stochastic shortest path problems,” Mathematics of Operations Research, vol. 16, pp. 580–595, 1991. [5] P. Charnsethiku and K. Virojsailee, “The linear constrained maximun capacity path problem,” Industrial Engineering Departament, Kasetsart University, Bagkok, Thailand, Tech. Rep., 2000. [6] S.-J. Lee, “Routing and multicasting strategies in wireless mobile ad hoc networks,” Ph.D. dissertation, University of California, 2000. [7] J. Brumbaugh-Smith and D. Shier, “An empirical investigation of some bicriterion shortest path algorithms,” European Journal of Operational Research, vol. 43, pp. 216–224, 1989. [8] J. P. Suárez, “Aproximacion al problema de ruta más corta con transbordos,” Master’s thesis, Universidad de los Andes, 2005. [9] S. Microsystems, “Java technology,” Jan. 2006. [Online]. Available: http://www.java.sun.com/ [10] K. Knizhnik, “J2ME applications for mobile phones,” Moscow State University, http://www.garret.ru/ knizhnik/mobile.html, Tech. Rep., Sept. 2005. [Online]. Available: http://www.garret.ru/∼knizhnik/ mobile.html AUTHORS BIOGRAPHIES Sonia Vivas received a B.Sc. (2005) in Systems Engineering from Universidad de los Andes. She is a B.Sc. student in Industrial Engineering and and this is her graduation project. She is also a M.Sc. student in Computer Science at Universidad de los Andes. She works with the Formal Methods Group of the Computer science Department. She can be reached by e-mail at [email protected]. Germán Riaño received a M.Sc. and a Ph.D. from Georgia Institute of Technology, U.S.A. in 1996 and 2002, respectively. He also holds B.Sc. degrees in Industrial Engineering and Physics form Universidad de los Andes in Colombia, where he is currently working as an Assistant Professor. He is a founding member of the Centro de Optimización y Probabilidad Aplicada (COPA). His research interests include the development of tools for stochastic modeling. He can be reached by e-mail at [email protected] and his web address is http://wwwprof.uniandes.edu. co/˜griano/.
© Copyright 2026 Paperzz