Framework for Onboard Bus Comfort Level Predictions Using the Markov Chain Concept

: E ﬃ ciently functioning public transport has a signiﬁcant positive impact on the entire transportation system performance through numerous aspects, such as the reduction of congestion, energy consumption, and emissions. In most cases, the basic elements of public transport are the bus transport subsystem. Currently, in addition to criteria such as punctuality, the frequency of departures, and the number of transfers, a travelling comfort level is an important element for passengers. An overcrowded bus may discourage travelers from choosing this mode of transport and induce them to use a private car despite the existence of many other facilities o ﬀ ered by a given public transport system. Therefore, the forecasting of bus passenger demand, as well as bus occupancy at individual bus stops, is currently an important research direction. The main goal of the article is to present the conceptual framework for the Advanced Travel Information System with the prediction module. The proposed approach assumes that the prediction module is based on the use of the Markov Chain concept. The e ﬃ ciency and accuracy of the obtained prediction were presented based on a real-life example, where the measurements of passengers boarding and alighting at bus stops were made in a selected Cracow bus line. The methodology presented in the paper and the obtained results can signiﬁcantly contribute to the development of solutions and systems for a better management as well as a cost and energy consumption optimisation in the public transport system. Current and forecasted information related to bus occupancy, when properly used in the travel information system, may have a positive impact on the development of urban mobility patterns by encouraging the use of public transport. This article addresses the current and practical research problem using an adequate theoretical mathematical tool to describe it, reﬂecting the characteristics and nature of the phenomenon being studied. To the best of the authors’ knowledge, the article deals for the ﬁrst time with the problem of prediction of onboard bus comfort levels based on in-vehicle occupancy.


Introduction
Efficiently functioning public transport has a significant positive impact on the entire transportation system performance through numerous aspects, such as the reduction of congestion, energy consumption, and emissions. In most cases, the fundamental elements of public transport are the bus transport subsystem. Currently, in addition to criteria such as punctuality, the frequency of departures, and the number of transfers, the comfort of travelling is an essential element for travelers. It may be significantly related to the degree of occupancy and capacity of the bus. An overcrowded bus may discourage travelers from choosing this mode of transport and induce him to use a private car despite the existence of many other facilities offered by a given public transport system. Therefore, the forecasting of bus passenger demand and the forecasting of bus occupancy at individual bus stops is currently an important research direction. The variability and cyclicity in passenger flows make such forecasts extremely useful. From the perspective of transport system planners, they can be used for an optimal allocation of resources and bus types in relation to current demand. From the traveler's point of view, the use of this type of forecast can help to reduce waiting times at the bus stop as well as helping him choose the right departure time. The forecasting methods and techniques used in this area mainly concern long-term prediction. Given the above, the main goal of the article is to present the framework of the prediction subsystem for the Advanced Travel Information System (ATIS), which enables one to predict the onboard comfort level related to the actual bus occupation.
The article is organized as follows. The first section is a literature review. It describes the conceptual framework for the ATIS subsystem with the comfort level prediction module. It also discusses the potential application of the proposed approach. The main core of the article concerns the forecasts in the public transportation system; hence, the second part of the literature review deals with that area. Subsequently, the theoretical background of the Markov chain (MC) for the prediction model is presented, defining the comfort level states. The characteristics and benefits of applying the MC for an onboard bus comfort level prediction based on a real-life case study summarise the previous theoretical discussion.

Predictive Framework for ATIS Subsystem
The principle of information is defined as one of the foundations of the city's transport policy. The Advanced Traveler Information System (ATIS) is a way to implement the information principle and is an integral part of the Intelligent Transport Systems (ITS) [1,2]. ATIS systems can use all transport data, including the traffic volume, journey times, and restrictions on selected sections, timetables, vehicles locations in the network, interchanges, traffic events, and weather conditions. The information can come both from the vehicles and traffic management centres [3,4].
Access to information from ATIS systems can be public or limited. Restrictions may result from the payment of access to the system or from the fact that the system is dedicated to selected users [5]. Research [6] shows that mobile phone users with Internet access are most likely to use information from ATIS systems, and the interest of travelers in accessing travel information is directly related to the usefulness of the presented data by ATIS systems [4].
The considered issue in the paper is one of the crucial problems, mainly when bus congestion results in the resignation of some passengers from travelling with public transport. Well-prepared forecasts make it possible to make good use of rolling stock, to plan a journey, and to manage urban public transport. Figure 1 presents a diagram of the information flow and relevance of a forecasting module within ATIS. The data based on which the model was created and tested came from buses operating in Cracow. The development of information technology has a significant impact on the functioning of cities and urban public transport. This has enabled the development in a short time of many mobile applications aimed at facilitating travel. They relate to trip planning, checking timetables, or information about the location of the exact vehicle based on the GPS signal. Common access to such extensive information has led to an increase in passenger requirements.
Moreover, information about the current or predicted passenger demand in public transport vehicles is becoming critical. The automatic passenger counting systems using buses do not provide the utilization of data in real time. However, the data will be sufficiently accurate to be used to produce a forecast. Such predictions will enable the optimization of the allocation of buses to public transport lines and the creation of applications for passengers (in the framework of ATIS).
The problem connected with bus allocations to public transport lines is important for carriers. The increasing number of rolling stocks types makes it more challenging to obtain an optimal solution. A large number of urban bus manufacturers and the choice of the cheapest offers by carriers make it difficult to maintain a uniform fleet of vehicles. Vehicles of the same dimensions may differ in travel comfort with the same number of passengers. That is why, in order to achieve a high level of comfort for passengers with a maximum use of rolling stock, it is necessary to optimise the allocation of buses to public transport lines. The solutions that emerged within this topic are described in articles, the most important of which are presented in the table below (Table 1). The development of information technology has a significant impact on the functioning of cities and urban public transport. This has enabled the development in a short time of many mobile applications aimed at facilitating travel. They relate to trip planning, checking timetables, or information about the location of the exact vehicle based on the GPS signal. Common access to such extensive information has led to an increase in passenger requirements.
Moreover, information about the current or predicted passenger demand in public transport vehicles is becoming critical. The automatic passenger counting systems using buses do not provide the utilization of data in real time. However, the data will be sufficiently accurate to be used to produce a forecast. Such predictions will enable the optimization of the allocation of buses to public transport lines and the creation of applications for passengers (in the framework of ATIS).
The problem connected with bus allocations to public transport lines is important for carriers. The increasing number of rolling stocks types makes it more challenging to obtain an optimal solution. A large number of urban bus manufacturers and the choice of the cheapest offers by carriers make it difficult to maintain a uniform fleet of vehicles. Vehicles of the same dimensions may differ in travel comfort with the same number of passengers. That is why, in order to achieve a high level of comfort for passengers with a maximum use of rolling stock, it is necessary to optimise the allocation of buses to public transport lines. The solutions that emerged within this topic are described in articles, the most important of which are presented in the table below (Table 1). Optimisation of the allocation of rolling stock to lines to minimise fuel consumption Oziomek J., Rogowski A. [17,18] The optimisation of bus allocations to urban public transport lines is presented in different ways in scientific publications. First, the allocation of rolling stock to public transport lines is taken as the queuing of vehicles at depots [7]. However, this solution does not take into account the possibility of a rolling stock rotation between different depots. When there is more than one depot, it is impossible to obtain an optimal solution. Other articles define the allocation of rolling stock as scheduling that reduces costs and the number of vehicles that are needed [8,17,18]. This approach is characterised by the use of various optimisation methods, both traditional linear programming methods and heuristics [9]. However, it should be noted that the analysed models do not use data on the forecast of demand for transport services. In [13], the problem of a model that is resistant to fluctuations in parameters was noted (the issue of planning the allocation of rolling stock for each day). The solutions presented in the publication are based on the example of railway transport. Another type of criterion which is becoming more and more important due to the growing social awareness of environmental protection is the optimization of the allocation of rolling stock as a means of minimising the environmental impact. This topic is described extensively in [10][11][12]19]. Finally, there are publications that describe the existing tools to support decision-making when scheduling the allocation of rolling stock to public transport lines [10,14,16,20].

Prediction Methods in Public Transportation
The main problem in public transportation, which researchers are trying to model and predict, is passenger demand. It has a direct influence on the efficiency of the public transport system, raising the competitiveness of this mean of transport and, lastly, fulfilling the expectations of passengers and encouraging them to choose this type of transport. The problem of bus occupancy level forecasting is quite an important aspect, particularly for decision-makers. This is why there is an abundance of articles addressing this issue. A plurality of methods whose aim is to deal with this kind of forecasting shows an interest attached to the seriousness of this issue. Table 2 shows selected methodologies, types, modes of transport and the studies in which they were presented. According to Table 2, it is evident that there were not so many papers that tried to solve the passenger prediction problem using the Markov Chain method. Most of the presented methods are used to predict the passenger flow or demand in the short-term. The Markov chain method appears mostly in a combination of Markov and Grey models to forecast the passenger flow or as a hybrid model-the Back Propagation neural network and Markov model-to forecast the daily passenger volume in the rail transit station. This shows the existence of different fields of research on the most accurate methods for forecasting the passenger demand or flow to improve public transportation efficiency directly.
There are certain areas in public transportation in which prediction can be beneficial during not only the organisation process but also the adaptation to real conditions. These may include, besides the passenger demand or flow prediction, the bus arrival time [36] prediction. From the public transport organiser's point of view, the passenger structure prediction in the transportation corridor may also be useful. For this purpose, D. Wang, X. Sun and Y. Li utilized the Markov process [37]. In order to meet the expectations of public transport users, an important area of prediction is public transport trip flows [38].

Bus Comfort Level
Onboard bus comfort is an essential aspect of the satisfaction perceived by bus passengers. The quality of the bus transit in terms of passenger comfort is usually an extensive set of partial influence factors, which are very difficult to quantify. Hence, this is usually the reason why they are not included in the various indicators for assessing the quality of public transport. Therefore, the group of indicators describing the comfort of travel include the inconvenience of travel resulting from the limited availability of seats or even standing in the vehicle. The literature most frequently mentions the nuisance ratio, and the nuisance ratio or seat occupancy rate, for different reference levels in the form of standards for the number of seats in a vehicle. The driving discomfort coefficient µ j determines how many times a journey by public transport in specific conditions is more onerous in comparison with a journey where the passenger sits and the filling of standing places is small (0.5 passenger/m 2 ). The driving discomfort µ j is calculated from the following formula (based on [39]): where q is the relative onboard occupation calculated as: where N is the absolute onboard occupation (number of passengers in the vehicle), and C N is the nominal capacity of the vehicle (using the area of standing places as 0.15 m 2 /person).
The onboard comfort level can be defined based on the calculated value of the driving discomfort µ j , and it could be one of the below possibilities [39]:

1.
Comfort level A (corresponding to a factor of discomfort µ j < 0.8)-means that: approximately 10-70% of the vehicle seats are occupied; each passenger has a guaranteed seating position without being forced to travel in the immediate vicinity of another passenger; passengers travel without difficulty in carrying luggage, trolleys, bicycles, etc.

2.
Comfort level B (corresponding to a factor of discomfort µ j [0.8, 1.0) means that: all or almost all seating positions are occupied (70-100%); possibility to easily carry a baggage, trolleys, bicycles, etc.

3.
Comfort level C (corresponding to a factor of discomfort µ j [1.0, 1.4) means that: the small number of standing places is occupied, but it is possible to have free movement within the vehicle: easy access to the punch (up to 2 persons/m 2 ). 4.
Comfort level D (corresponding to a factor of discomfort µ j [1.4, 2.1) indicates that the onboard occupancy level results in a difficulty of free movement in the vehicle and in access problems to the punch (up to 4 persons/m 2 ). 5.
Comfort level E (corresponding to the discomfort factor µ j [2.1, 3.4) indicates an already high onboard congestion causing very difficult access to the punch (up to 6-7 persons/m 2 ). 6.
Comfort level F (corresponding to a factor of discomfort µ j ≥ 3.4 is characterised by: very high in-vehicle congestion, during which it is not possible to cancel the ticket; the ride involves a large physical effort, with standing passengers pressing into the seating area; there are large difficulties in closing the door and incidental damages to the closing device; it is necessary to give way to passengers getting off their seats (over 7 persons/m 2 ).

Short-Term In-Vehicle Occupation Predictions Based on Markov Chains Model
The problem of in-vehicle occupancy forecasting in public transport may be closely related to previously defined comfort levels. The specificity of the inflow of passengers to the given bus line stops in the following hours is stochastic. Therefore, it seems appropriate to use discrete Markov processes to determine the expected occupancy level of the vehicle at subsequent departures from a given stop on the line. Markov's process is a sequence of random variables, in which the probability of what will happen depends only on the present state. In the considered issue, only Markov processes defined on a discrete space of states will be used (Markov chains).
Let us denote by X = (X 0 , X 1 , . . .) a sequence of discrete random variables. The value of the variable X t will be called the state of the chain at the moment t. It is assumed that the set of states S is calculable. The finite set of states can be defined as the state space S as follows: s ∈ S, S = s 1 , s 2 , . . . , s k−1, s k , k < ∞ The discrete timestamps used in the considered problem can be defined as follows:

Definition 1. A sequence of random variables X is a Markov chain if the Markov condition is fulfilled:
Thus, for the Markov chain, the distribution of the conditional probability of the position in the time step t depends only on the conditional probability of the position in the previous step and not on the previous trajectory points (history).
The elements of the transition matrix p i j fulfill the following conditions: Definition 3. The Markov chain is homogenous when for each time stamp it is described by the same transition matrix P. The transition matrix is fixed and does not depend on time.
In the use of Markov chains, the initial state plays a crucial role. Formally, the initial state is a random variable X 0 . Therefore, the Markov chain often starts with a certain probability distribution across the state space.

Definition 4.
The initial distribution is a vector defined as follows: To determine the distribution of the forecasted state of the modelled object for the n-th time step ahead, the following equation can be used: where n is the parameter defining the forecasting horizon.

Case Study
In order to verify the approach proposed in the article, a simulation experiment was carried out. The basis of the example was to estimate the forecasted state of the vehicle occupancy for a selected communication line with a given number of stops. In the example, a real data set from the automatic counting systems of the vehicle was used. The analysed time horizon covered two weeks for one of the most crowded bus lines in Cracow. The line under consideration belongs to one of the highest frequency levels and contain 19 bus stops. On business days, the number of trips on the line under consideration was t max = 68, whereas on weekends t max = 47. In the computational example, the forecasts of the occupation state S = {1, 2, . . . 6} were determined sequentially for one time step ahead (each single departure from the bus stop was a correspondingly successive time step). The state s 1 = 1 corresponds to the lowest level of vehicle occupancy, while s 6 = 6 denotes the highest. For each time step t, the initial state distribution D (t) has been updated on the basis of the available historical data. The elements of the transition matrix P were estimated empirically based on the historical data set individually for each bus stop in order to map its specificity and dynamics. The forecasted state was assumed to be the one for which the probability of occurrence in the forecasted state distribution D (t+1) was the highest. Figure 2 shows an exemplary adjustment of state forecasts to the real observed states of vehicle occupancy for a selected bus stop on a given day.

Case Study
In order to verify the approach proposed in the article, a simulation experiment was carried out. The basis of the example was to estimate the forecasted state of the vehicle occupancy for a selected communication line with a given number of stops. In the example, a real data set from the automatic counting systems of the vehicle was used. The analysed time horizon covered two weeks for one of the most crowded bus lines in Cracow. The line under consideration belongs to one of the highest frequency levels and contain 19 bus stops. On business days, the number of trips on the line under consideration was = 68, whereas on weekends = 47. In the computational example, the forecasts of the occupation state = {1, 2, … 6} were determined sequentially for one time step ahead (each single departure from the bus stop was a correspondingly successive time step). The state = 1 corresponds to the lowest level of vehicle occupancy, while = 6 denotes the highest. For each time step , the initial state distribution ( ) has been updated on the basis of the available historical data. The elements of the transition matrix were estimated empirically based on the historical data set individually for each bus stop in order to map its specificity and dynamics. The forecasted state was assumed to be the one for which the probability of occurrence in the forecasted state distribution ( ) was the highest. Figure 2 shows an exemplary adjustment of state forecasts to the real observed states of vehicle occupancy for a selected bus stop on a given day. The presented sequence of observed vehicle occupancy states and received forecasts concerns the bus stop located in the second part of the analysed transport line. This is evidenced by the high variability of the observed states during the working day. The obtained forecast values, despite errors, try to keep up with the pace of changes in the observed time series.
The distribution of the root means square errors for each bus stop for the considered period is shown in Figure 3. The presented sequence of observed vehicle occupancy states and received forecasts concerns the bus stop located in the second part of the analysed transport line. This is evidenced by the high variability of the observed states during the working day. The obtained forecast values, despite errors, try to keep up with the pace of changes in the observed time series.
The distribution of the root means square errors for each bus stop for the considered period is shown in Figure 3. The distribution of Root Mean Square Error (RMSE) errors received along the time horizon and bus stop number indicates that the highest values occur at the bus stops in the second part of the line journey (counting from the first stop). This results in the specificity of the analysed line, which passes through crucial areas in the city and numerous interchange nodes. This generates a greater randomness and variability among the incoming passengers, which leads to more significant forecasting errors. Lower errors characterise periods (t = 6 Saturday, t = 7 Sunday) due to the reduced number of trips.
In order to determine how often the model made an error and how much the predicted occupancy state of the vehicle differed from the observed state, an error histogram was prepared, as shown in Figure 4. The histogram shows the frequency occurrence of a forecast error equal to = 1, = 2, … = 5, where is the difference by one state, by two states, etc. In the period of time covered by the analysis, the most numerous group is the error set, where the obtained forecast differs only by The distribution of Root Mean Square Error (RMSE) errors received along the time horizon and bus stop number indicates that the highest values occur at the bus stops in the second part of the line journey (counting from the first stop). This results in the specificity of the analysed line, which passes through crucial areas in the city and numerous interchange nodes. This generates a greater randomness and variability among the incoming passengers, which leads to more significant forecasting errors. Lower errors characterise periods (t = 6 Saturday, t = 7 Sunday) due to the reduced number of trips.
In order to determine how often the model made an error and how much the predicted occupancy state of the vehicle differed from the observed state, an error histogram was prepared, as shown in Figure 4. The distribution of Root Mean Square Error (RMSE) errors received along the time horizon and bus stop number indicates that the highest values occur at the bus stops in the second part of the line journey (counting from the first stop). This results in the specificity of the analysed line, which passes through crucial areas in the city and numerous interchange nodes. This generates a greater randomness and variability among the incoming passengers, which leads to more significant forecasting errors. Lower errors characterise periods (t = 6 Saturday, t = 7 Sunday) due to the reduced number of trips.
In order to determine how often the model made an error and how much the predicted occupancy state of the vehicle differed from the observed state, an error histogram was prepared, as shown in Figure 4.  The histogram shows the frequency occurrence of a forecast error equal to e 1 = 1, e 2 = 2, . . . e 5 = 5, where e 1 is the difference by one state, e 2 by two states, etc. In the period of time covered by the analysis, the most numerous group is the e 1 error set, where the obtained forecast differs only by one state from the observed real value. The second, much less numerous group is e 2 . The sets of errors e 3 and e 4 constitute a small percentage of the whole population, while the remaining errors did not occur at all during the examined time horizon.
The averaged absolute percentage forecast errors for the relevant period and subsequent stops are presented in Table 3. Table 3. Mean absolute percentage forecast errors.

MEAN ABSOLUTE PERCENTAGE ERRORS [%]
ANALYZED TIME HORIZON

Discussion
The results of the research presented in this article indicate that the application of Markov chains to forecast the bus occupancy level in public transport is entirely justified because it represents, to a reasonable degree, the features of the urban public transport system. Compared to the works mentioned in the literature review, which mostly refer to the problem of passenger flow forecasting in the transport network, the authors' research was strictly focused on forecasting the bus comfort level related to the vehicle occupancy, which can be directly used by travelers to optimize their trips and to change their travel patterns to more environmentally friendly ones. The obtained results can be useful not only for fleet management in the public transport system but also for the development of passenger information systems and trip planning.
Nevertheless, this approach requires further research based on a larger data set sample from an automatic counting system over a longer time horizon. It would also be desirable to determine the influence of other factors on the forecasting effectiveness (season of the year, weather, and specificity of the analysed communication line). The calculated forecast errors are the most significant for interchanging stops, due to the high variability of passenger flows in these places. Therefore, it seems justified to carry out studies with the use of heterogeneous Markov chains, where the transition matrix would be variable depending on the time, type of bus stop or communication line. Such an analysis could be very useful for the practical application and further verification of the proposed approach.

Conclusions
The discussed issue in the article concerns the problem of forecasting vehicle occupation in public transport. The analysed issue is particularly important due to the growing problems of congestion and the negative impact of road transport in cities. The methodology presented in the paper and the obtained results can significantly contribute to the development of solutions and systems for a better management as well as a cost and energy consumption optimisation in the public transport system. Current and forecasted information related to bus occupancy, when used correctly in the travel information system, such as ATIS, may have a positive impact on the development of urban mobility patterns by encouraging the use of public transport. In this way, it is possible to support the implementation of a sustainable development postulate in the context of transport.
The transportation system, especially public transport, is an artificial, complex, dynamic and uncertain system. These features influence the internal transport process, which is why proper management is challenging to implement. Therefore, it seems appropriate to use discrete Markov processes to determine the expected occupancy level of vehicles at subsequent departures from a given stop on the line. The presented calculation shows that the thesis is correct and creates an incentive for more in-depth investigations.