Bus Scheduling Application

Download as pdf or txt
Download as pdf or txt
You are on page 1of 60

BUS SCHEDULING APPLICATION

USING ANDROID

A PROJECT REPORT

Submitted by

P. BHARATHI (623018104008)
D. JOTHIKA (623018104021)
S. KEERTHANA (623018104024)
V.VENMATHI (623018104060)

In partial fulfillment for the award of the degree


of

BACHELOR OF ENGINEERING
In
COMPUTER SCIENCE AND ENGINEERING

TAGORE INSTITUTE OF ENGINEERING AND


TECHNOLOGY

DEVIYAKURICHI - 636112

ANNA UNIVERSITY::CHENNAI 600 025

JUNE 2022
ANNA UNIVERSITY::CHENNAI 600 025

BONAFIDE CERTIFICATE

Certified that this report titled “BUS SCHEDULING


APPLICATIONUSING ANDROID” is the bonafide work of P. BHARATHI
(623018104008),D. JOTHIKA (623018104021), S. KEERTHANA
(623018104024) andV.VENMATHI (623018104060) who carried out the
project work under my supervision. Certified further that to the best of my
knowledge the work reported herein does not form part of any other thesis or
dissertation on the basis of which a degree or award was conferred on an earlier
occasion on this or any other candidate.

SIGNATURE SIGNATURE
Dr., R. VASANTHI, M.E., Ph.D., Mrs. A. SANTHI, AP/CSE
HEAD OF THE DEPARTMENT SUPERVISOR
Department of Computer Science Department of Computer Science

and Engineering, and Engineering,

Tagore Institute of Engineering Tagore Institute of Engineering

and Technology, and Technology,

Deviyakurichi-636112. Deviyakurichi-636112.

Submitted for the project VIVA-VOCE held at Tagore Institute of Engineering and
Technology, Deviyakurichi-636 112 on………………………..

INTERNAL EXAMINER EXTERNAL EXAMINER


ACKNOWLEDGEMENT
It is a fact that the completion of any work depends on the sustained guidance
of different people from different corners.

I express my sincere thanks to our Management members for the help and
facilities provided to me during the courses of my project.

I would like to express my heartfelt thanks to Dr. S. JAYANTHI M.E.,


Ph.D., Principal, Tagore Institute of Engineering and Technology, who
extended the fullest support throughout the duration of the project.

I record my sincere gratitude to Dr. R. VASANTHI, M.E., Ph.D.,


Professor, and Head of the Department, her critical advice and constant support have
shaped the ideas embedded in the project work. Without his motivation,
encouragement, and care this project work would not have materialized.

I express my sincere thanks to my Team Guide Mrs. A. SANTHI Assistant


Professor, Department of Computer Science and Engineering, for her constant support
and motivation during the completion of my project.

I thank all the faculties of the CSE department, my parents,and all my


friends for all their suggestions and assistance that made this project an immense
success.

[P. BHARATHI]
[D. JOTHIKA]
[S.KEERTHANA]
[V.VENMATHI]
ABSTRACT
The planning process of urban bus lines is a complex activity that is
usually decomposed into several stages, traditionally network design, line
planning, bus scheduling, rolling stock scheduling, and crew scheduling. This
paper focuses on the designand optimization of bus schedules for an urban bus
transit lineunder the static and oversaturated passenger demand. The objective is
to minimize the total waiting time of passengers at platforms. In order to obtain
high-quality solutions, a genetic algorithm is adopted to solve the proposed
model. Finally, some numerical experiments based on the Beijing Changping
line are implemented to demonstrate the effectiveness of the proposed model
and algorithm.In public transport operations, vehicles tend to bunch together
due to the instability of passenger demand and traffic conditions. Fluctuation of
the expected waiting times of passengers at bus stops due to bus bunching is
perceived as service unreliability and degrades the overall quality of service.
For assessing the performance of high-frequency bus services, transportation
authorities monitor the daily operations via Transit Management Systems
(TMS) that collect vehicle positioning information in near real-time. This work
explores the potential of using Automated Vehicle Location (AVL) data from
the running vehicles for generating bus schedules that improve the service
reliability and conform to various regulatory constraints. The computer-aided
generation of optimal bus schedules is a tedious task due to the nonlinear and
multi-variable nature of the bus scheduling problem. For this reason, this work
develops a two-level approach where (i) the regulatory constraints are satisfied
and (ii) the waiting times of passengers are optimized with the introduction of
an evolutionary algorithm. This work also discusses the experimental results
from the implementation of such an approach in a bi-directional bus line
operated by a major bus operator in northern Europe.

iv
TABLE OF CONTENT

CHAPTER NO TITLE PAGE NO

ABSTRACT iv
LIST OF FIGURES vii
LIST OF ABBREVIATIONS viii
1. INTRODUCTION 9
1.1 BUS TRAVELING 9
1.2 BUS SCHEDULING 12

2. LITERATURE REVIEW 26
2.1 OVERVIEW 26
2.2 PROBLEM STATEMENT 26
2.3 OBJECTIVE 26
3. SYSTEM SPECIFICATION 37

3.1 HARDWARE REQUIREMENTS 37


3.2 SOFTWARE REQUIREMENTS 37
3.2.1 Software Specification 37
3.2.2 Architecture 39

4. SYSTEM MODEL 40
4.1.1 Structure 40
4.1.2 Module Description 41
4.1.2.1 Read Data 41
4.1.2.2 Pre-Process Data 41
4.1.2.3 Data Training 41
4.1.2.4 Load Test Data 41
4.1.2.5 Predict Bullying Message 41

v
5. SYSTEM STUDY 44
5.1 FEASIBILITY STUDY 44
5.1.1 Economic Feasibility 44
5.1.2 Technical Feasibility 44
5.1.3 Social Feasibility 45
6. SYSTEM TESTING 46
7. CONCLUSION AND FUTURE WORK 49
7.1 CONCLUSION 49
7.2 FUTURE WORK 49

vi
LIST OF FIGURES

FIGURE NUMBER FIGURE NAME PAGE NUMBER

1.1 Bus Traveling 11


1.2 Image Of Traveling 15
1.3 Booked Buses 21
1.4 Multiple Access Bus 22
1.5 Entity Diagram 22
1.6 Block Diagrams 23
1.7 Architecture 24
1.8 Flow Chart 25
3.1 Python Architecture 38
4.1 Dijkstra’s Algorithm Example 40

vii
LIST OF ABBREVIATIONS

EWT Excess Waiting Time


LWT Least Waiting Time
PVM Python Virtual Machine
POJO Plain Old Java Object
VO Value Object
JVM Java Virtual Machine
SDK Software Development Kit
AVD Android Virtual Device Manager

viii
CHAPTER 1

INTRODUCTION

During the scheduling phase of bus services, a set of conflicting objectives are
optimized
such as the operational costs and the waiting times of passengers at stops. However,
due to many exogenous factors, such as road traffic and Spatio-temporal passenger demand
variations, the optimal schedule does not perform as anticipated, resulting in bus bunching
phenomena. This unreliability leads to passenger dissatisfaction and to additional operational
costs for the service provider. Therefore, several research works related to bus bunching have
tried to address the service reliability problem (Gkiotsalitis and Cats [1], Chapman and
Michel [2], Pilachowski [3], Gkiotsalitis and Maslekar [4]).

In several cities where the timetables of bus services are not strictly followed, a
number of informal methods have been utilized for maintaining the service reliability. In
Chile, for instance, drivers are assisted by an informal group of independent information
intermediaries, known as “Sapos”, who records the arrival time of buses and inform the
subsequent drivers in order to help them maintain uniform headways (Johnson et al. [5]).
These labor-intensive practices of maintaining reliability in bus operations become inefficient
when the frequency of trips is very high. This study focuses specifically on such high-
frequency services with dispatching headways between consecutive bus trips of less than 15
min since several studies (Randall et al. [6], Welding [7]) have shown that the arrivals of
passengers at stops are not random and are tailored to the scheduled arrival times of bus trips
in the case of low-frequency services.

The advent of new monitoring technologies such as in-vehicle telematics and


automated fare collection systems has revolutionized the monitoring capabilities of transit
service operations. Nowadays, the monitoring capabilities of the passenger waiting times at
stops have been increased and, given this new information, bus operators strive to improve
the reliability of their daily operations. In past years, several methodologies were developed
for enhancing the reliability of transit services. Eberlein[8] explained three ways of
controlling the headways: (a) Station-control strategies which consist of (i) holding a bus at a
stop and (ii) stop-skipping; (b) Interstation-control strategies consisting of speed control and

9
traffic signal priorities and (c) On-demand vehicle addition strategies that add vehicles at
some specific points of the bus routes. Of the above-mentioned strategies, the first strategy
that includes holding and stopping skipping is considered to be the most important
methodology.

To further explain the bus holding control strategy, a bus trip can be held at specific
critical stops (known as control points or time points) in an effort to maintain even headways.
In several works, such as the work of Hickman [9], bus holding is proposed as a real-time
strategy to avoid bus bunching. The typical objective of a bus holding strategy is to ensure
that the waiting times of passengers at stops do not vary significantly from the planned ones.
However, recent works, such as the work of Bartholdi and Eisenstein [10], focused on
maintaining even headways between bus trips at the locations of the control point stops
without adhering to the planned headway values. Although bus holding can be proved
beneficial to bus operations, several works have proposed to introduce limitations on holding
strategies because the extensive holding of bus trips can cause inconvenience to passengers,
overcrowding at, stops, and “schedule sliding” if the bus trips are postponed due to holding
(Delgado et al. [11]). Public transport authorities use the passenger waiting times at stops to
evaluate the performance of the operations in the case of high-frequency services. In contrast
to the low-frequency services where the main objective is the service punctuality because
passengers try to synchronize their arrival times at stops with the scheduled arrival times of
bus trips, in high-frequency services the passenger arrival times at stops are random (Welding
[7]) and the waiting times of passengers at stops can be directly linked to the headways
between consecutive trips (they are considered equal to half the valueof the headways).
O’Flaherty and Mancan [12] studied the relationship between bus headways and average
passenger waiting times in peak and off-peak traffic conditions. The holding problem has
been examined as a multi-objective problem in other works such as Barnett [13], where a
holding strategy of individual buses at control stops tries to minimize at the same time the
passenger waiting times and the delay of on-board passengers. Turnquist [14] studied in more
detail the effects of schedule reliability and bus frequency on the waiting times experienced
by the passengers. In addition, the stochastic nature of passenger waiting times was
considered in the work of Gkiotsalitis and Maslekar [15], where a stochastic search and branc
hopping/merging algorithm was used for reducing the excess waiting times of passengers.

10
Apart from bus holding, a variety of other solution strategies have been proposed for
improving bus operations. Adherence to the planned timetables was proposed by Bates et al.
[16] and Daganzo [17] where the latter worked on an adaptive control scheme that focused on
achieving target headways by adjusting the bus cruising speed. In such a scheme, when a bus
arrives at a control point its headway is compared to a pre-specified target headway value for
performing the appropriate adjustment. Other works, such as Friedman [18], have focused
only on the dispatching times of bus trips by developing mathematical models to optimize the
departure times of buses.

1.1

11
BUS TRAVELING

Introduction:
We all love adventure, right? Traveling by bus is one kind of adventure too, not your
regular bus journey at all, a long journey, far away from home, so in this contrary, today we
are going to present an essay on a memorable bus journey mine, so let's jump in!

What is Bus Traveling?


Bus travel is a mode of transportation; within the public transport network or with
chartered buses. All inhabited continents have some sort of bus travel and unless government
regulations or geography prohibit it, you can find some – at least nominal – bus service
almost anywhere you go.While comfort and prices range wildly, from the infamous chicken
buses, the engines of which may or may not survive the next steep ascent, to luxury buses in
countries such as Saudi Arabia, buses are usually the cheapest option at least for short
distances.

Contrary to rail, which is usually organized at the national level, it is often easy for
anyone to start a bus company. Where regulation is absent or moderate, there will thus be
many independent firms, not always coordinating very well. You often have to check the
connections locally.

There may also be a few dominating companies. National monopolies or cartels are rare,
but in some countries government regulation sets (usually rather low) prices and/or pays
subsidies, thus establishing a quite stable market. Still, competition often varies from route to
route. You will not have much trouble finding a company that goes from Washington DC to
New York City, but a trip from Herzogenaurach to Regensburg may only be offered by a
single company or none at all as a direct route.

Where there is a need for public transport, but no economically viable market, there may
be heavily subsidized taxis or minibuses for the target audience, still taking outsiders as
passengers – to find these you may have to get local advice even in places where most
timetables are on the net. School buses sometimes belong to this category (and you might be
able to go in the reverse direction as well).

12
Some main categories of buses are:
● Public transportation
● Independent coach lines
● Tour buses
● Sponsored shuttle buses
● Chartered buses

Public transportation:
● Public transportation is organized passenger transportation. It is usually provided
by buses and rail systems, including rapid transit as well as light
rail, funiculars, monorail, and other modes of transport.
● Depending on the country, commuter rail can be virtually identical to longer-
distance trains while mostly fulfilling an urban rail role. Ticketing can be
integrated with railways (e.g. in Germany) or separate (e.g. in the US).
● While comfort and reliability vary a lot, in Europe and East Asia, it is usually the
most practical way to get around in large cities.
Independent coach lines:
● Typically intercity buses (such as intercity buses in Europe and inter-city buses in
the USA), airport coaches, etc. Comfort and service levels vary a lot; you usually
get what you pay for.

Tour buses:

● In many cities, guided city tours are organized by professionals, companies and
local organizationsfor those wanting to explore the city with professional
guidance.

● Travel agencies provide multi-stop guided journeys, including transportation and


accommodation. This article describes day tours within a destination.

● Also not covered by this article are the tours arranged within museums or other
closed venues.

Sponsored shuttle buses:


● Buses to suburban shopping malls, ferries, etc, on a limited route and schedule. Might
give free rides to the public, or only to patrons of the service provider.

13
Chartered buses:
● Rented by a travel agent, or a travel group.
● Depending on the line, tickets may have to be bought in advance, paid to the driver or
paid to a separate conductor. On some lines it is possible to reserve seats.
● Something being announced as a bus route does not necessarily mean you will ride a
bus. In some regions you may end up in a lorry and where passenger volumes are
small you might have to board what looks like a taxi. Also, bus stops are not always
well marked or marked at all.
Modeling the Multi-Constrained Scheduling Problem:
● Buses are assigned to a service route during the frequency setting phase of transit
planning. The problem of timetable optimization is formulated by considering the
expected trip travel times and the resource limitations of bus lines. A timetable can be
represented by a two-dimensional matrix denoted as D. This matrix has jNj _ jSj
dimensions where jNj represents the number of planned trips for the day and jSj
denotes the number of stops in the line. Every element Di,j in the matrix D represents
the scheduled time of arrival of bus trip i at stop j in minutes. In order to simplify the
notation, the arrival time and the departure time differ by k = 12 s following the work
of Dueker et al. [30] which observed that a typical dwell time is in the range of 12.29
_ 13.47 s.

14
1.2

For improving the efficiency of bus services, the dispatching times of buses are modified
to create an optimized schedule. Table 1 presents the common notation used in this work for
modelling the multi-constrained bus scheduling problem.

Symbols and Description:

● D - Scheduled arrival time of each trip at each stop


● N - Set of trips in the selected line for a day
● S - Set of stops in the selected line
● hmax - Upper limit of dispatching headways between consecutive trips
● hmin - Lower limit of dispatching headways between consecutive trips
● l - Allowed layover/Break time for each trip
● m - Allowed mealtime break for every bus driver
● bfirst- start time of the first trip of the day
● blast - start time of the last trip of the day
● k - typical dwell time at stops

15
● ti,j - estimated travel time of trip i between stops j and j + 1.

Passenger Excess Waiting Times:

The Excess Waiting Times (EWT) of passengers at control point stops is the key
performance index in bus schedule optimization problems of high frequency services.
EWT is the time spent waiting for the bus due to the bus headway deviations from their
target values. The EWT of the entire service is a linear weighted function of the EWTs of
passengers at different stops during different periods of day.

The bus service performance is measured in terms of daily EWT values in several
cities with high frequency services such as London (TfL [31]) and Singapore (LTA [32]).
The EWT targets the improvement of the service reliability from the passengers side,
rather than the service provider’s side as explained in van Oort [33]. For calculating the
waiting time variance of passengers over the entire day, transport authorities in
metropolises such as London and Singapore use the following formula:

where Di, j is time of arrival of the I th trip at j th stop in minutes. The EWT depends on
the scheduled arrival time of buses at each stop. The EWT function of Equation (1) is
nonlinear and this increases the complexity of the optimization problem. In order to
improve the reliability of the service without introducing new trips, the only available
control measure at the timetable design phase is the modification of the dispatching times
of bus trips.
Apart from the EWTs of passengers, transportation authorities impose regulatory
constraints for the bus services. These constraints should be satisfied during the timetable
design phase and a set of such regulatory constraints is described in the remainder of this
section.

Dispatching Headway Range Constraint:

16
A first requirement from transport authorities is that buses from the same line should
not bedispatched simultaneously. In addition, the dispatching times of consecutive bus
trips should not exceed the predefined target of bus dispatching time intervals. These two
requirements establish a lower and upper limit for the dispatching times of consecutive
bus trips. These lower and upper limits for the dispatching headways of successive trips
can vary during different time periods the day since the service frequency is typically
higher during peak times and lower during off-peak periods. The upper limit of
dispatching headways is denoted as h max and the lower limit as h min. Therefore, the
dispatching times of two consecutive bus trips i, i + 1 should satisfy the following
inequality:

where Di,1 and Di+1,1 are the dispatching times of trips i and i + 1. It is worth mentioning
that Equation (2) assumes that the lower and upper dispatching limits are stable throughout
the day; however, their values can vary for different time periods of the day based on the
frequency setting requirements without loss of generality.

Layover Time Constraint


Every daily trip operated by a bus driver should enjoy a specific time period of recovery
before the next trip operated by the same driver starts. This resting time requirement for the
driver is a layover time which can vary from zero to several minutes. A layover time l can be
integrated into the mathematical model in the form of an inequality constraint:

where Di,1 denotes the scheduled departure time of the ith trip and Dip,jSj denotes the
scheduledarrival time of the previous trip operated by the same bus driver at the last stop.
This inequalityconstraint ensures that the bus driver will rest for a time period which is at
least equal to the layover time l before starting his/her next trip.

Mealtime Constraint:

17
Another typical regulatory constraint is the meal time constraint which ensures that a
bus driver has an adequate break during a specific time of the day. The meal time duration,
M, is fixed by the transport authorities and can form the following set of inequality
constraints:

where Di,1 denotes the scheduled departure time of the Ith trip and Dmt,jSj denotes
the scheduled arrival time of the previous trip operated by the same bus driver who had to
take a meal time break at the last stop.

Departure Time Constraint:

This constraint ensures that the dispatching times of the first and the final trip
of the day cannot be modified for avoiding “schedule sliding”. Following this approach, the
total duration of the daily trips is strictly regulated and the daily operations are not
prolonged; this is something that could have implicated the rostering of bus drivers. The
constraints have the following form:

where D1,1 is the dispatching time of the first trip of the day and DjNj,1 the
dispatching time of the last trip of the day.

Mathematical Program of the Timetabling Problem

The service-wide excess waiting times of passengers presented in Equation (1) is the
objective function of our problem which can be written in the standard form by introducing
the full set of regulatory constraints as:

18
As it is evident from the problem definition of Equation (6), the decision variables of
the problem are the arrival times of bus trips at stops, D. However, the arrival time of a trip at
one stop is defined based on the travel times between bus stops that can be derived from the
analysis of historical Automated Vehicle Location (AVL) data. Therefore, the arrival time of
a trip at a stop cannot be decided directly from the bus operator. To the contrary, the bus
operator can define the dispatching times of trips during the timetabling phase and these
dispatching times can modify the respective arrival times at stops. As a result, the following
equality constraint is added to the problem of Equation (6):

where Equation (7) denotes that the arrival time of a bus trip i at stop s 2 S is equal to the
dispatching time of that trip, Di,1, plus the estimated link travel times and dwell times from
the departure stop until stop s.

The objective function of Equation (6) is a non-convex function and computing the
global optimumof such a function is a computational intractable problem. The decision
variables of the timetabling problem, which are the dispatching times of trips, can take
discrete values because a timetable is

19
expressed in minutes and applying exhaustive enumeration for finding the optimal
dispatchingtimes can be practical only for small-scale problems due to the exponential
computational cost ofsimple enumeration.

Exterior Point Penalties for Multi-Constrained Scheduling:


The computed timetable that minimizes the EWTs of passengers should satisfy all
regulatory constraints. Due to the presence of numerous equality and inequality constraints,
an exterior point penalty method is adopted. Penalty methods (known also as barrier
methods) use penalties and weights for transforming constrained optimization problems to
unconstrained ones by adding the constraints to the objective function which ideally
converges to the solution of the original constrained problem. The new objective function that
uses exterior point penalties is called penalty function and such penalty functions are widely
used in software packages for constrained optimization problems.
In our problem, the objective function f (D) of Equation (6) together with the
associated constraints can be reformulated as:

where E1 is the total number of inequality constraints and E2 the total number of equality
constraints presented in Equations (6) and (7). In addition cj(D) represents the value of the jth
constraint for a specific set of arrival times at stops, D. For instance, if the jth constraint
refers to the equality constraint D1,1 􀀀 b first = 0, then cj(D) = D1,1 􀀀bfirst. If cj(D) 6= 0
then this constraint is violated and penalizes the penalty function by a value of wj(cj(D))2
where wj is a weight factor for ensuring that the constraints have more impact to the penalty
function than the objective function score f (D) and are prioritized during the optimization
process.
Similarly, ci(D) represents the value of the ith inequality constraint for a specific set
of arrival times at stops, D. To provide a tangible example, if the inequality constraint is
hmax 􀀀 (Di+1,0 􀀀 Di,0) _ 0, then ci(D) = hmax 􀀀 (Di+1,0 􀀀 Di,0). If ci(D) < 0, then this
inequality constraint is violated. At thesame time, minf0, ci(D)g = ci(D) and the penalty
function value increases by wi(minf0, ci(D)g)2. In contrary, if ci(D) _ 0, then the ith
inequality constraint is satisfied and the penalty function remains unaffected since minf0,
ci(D)g = 0.

20
As it is evident from the analysis, the penalty function is formed in such a way that its
score is increased progressively when a constraint is violated and remains unaffected when a
constraint is satisfied. The constraints of Equation (8) are also interrelated and satisfying one
constraint might lead to the violation of another or to the increase of passengers’ EWTs.

1.3

21
1.4

1.5

22
1.6

What are the 3 types of buses in transportation?

There are four main types of buses:


▪ city or transit
▪ suburban
▪ intercity or tour
▪ school.

1.6

23
ARCHITECTURE:

1.7

24
FLOWCHART

1.8

25
CHAPTER 2

SYSTEM DESIGN

2.1 OVERVIEW

A literature review is the section that provides the detailed description of the work done
under this domain by various researchers. We have divided this description into two
categories: generalized and selective. Next subsection, explain each category in detail with
pros and cons of each.

2.2 PROBLEM STATEMENT:

As a user/person, I don’t know the next coming bus and bus timing for my journey. If I know
the timing and the next coming bus, I will manage my journey and timings.

2.3 ADVANTAGES AND DISADVANTAGES :

ADVANTAGES:

1. TRANSFERS ARE EASY

Once you have the timetables and the route maps, you can plan your trip. You might
have to transfer to different routes on your journey, but these transfer points are easily
identifiable on the maps.

The important thing is to make sure at what time you need to depart to catch
connecting buses to your destination, and still reach it in time.

2. SHORTER ROUTE NOT ALWAYS FASTER


All the GO GEORGE community routes are bidirectional, meaning they go
around in loops, with bus stops on both sides of the road.

You can get on the bus on either side of the road, anywhere on the route, and will
eventually end up back where you started.

26
One might think it’s best to take the shortest path, but depending on the timetable,
the next bus going the long way around may reach your destination sooner, because it departs
earlier than the short-route bus.

The idea is that passengers can decide which direction will get them to their
destination the quickest, although both directions will get them there.

This is where the pocket guide with both route maps and timetables comes in handy
and why it was designed to fit into a pocket or handbag to carry with you at all times.

3. FREQUENCY CHANGES

The frequency or time between buses vary during the day, according to demand, and
should be checked on the timetables. Week-day and weekend schedules also differ for the
same reason.

ECONOMIC BENEFITS:

1. Reduces Congestion
Urban congestion is one of the greatest challenges of developed nations. Statistically,
Australian cities incur a cumulative annual cost of $12.9 billion due to traffic congestion. If
transport systems are not modernized in the near future, this cost could go up to $20 billion.

The solution to this nightmare lies in the expansion of public transportation. For
instance, a single railway can get rid of 1000 cars from the roads.

2. Enhances Productivity
Public transportation plays a significant role in enhancing opportunity and
productivity by moving knowledge, labor, and skills between and within markets.

In the modern globalized world, capital, labor, and enterprise search out for the most
productive markets, promoting healthy competition and symbiotic economic growth.
Investing inremarkable public transportation instigates a series of economic growth.

27
3. Increases Land Value
Improved access to public transport has shown to increase land and property value.
Planning that puts public transportation development on top of its agenda rips huge benefits
in the long run. Land that would have been used for parking and roads is put to profitable use,
such as the generation of revenue to the city council.

4. Financial Benefits of Communities


Approximately for every dollar invested in public transportation, economic returns
generated are $4, and for every $1 billion in investments in the sector, 50,000 jobs are
generated and supported.

According to APTA, an investment of $10 million in public transportation generates


about $30 million in increased business sales, and residential property values for homes
located near public transit with high-frequency service “performed 42% better than other
areas.”

5. Saves Money
Taking public transportation instead of owning a second vehicle can save individuals
a significant amount of money each month in avoided gas, maintenance, parking, and other
expenses. Household Expenses are also reduced by using public transit as the family gets rid
of buying one car and maintaining and operating the car.

ENVIRONMENTAL BENEFITS:

1. Ensures a Cleaner Ecosystem


Public transportation significantly reduces the number of cars on the road. This means
less pollution from motor vehicle emissions. Fumes produced by vehicles can lead to
respiratory diseases. Few cars on the road mean a reduction in the possibility of these
dangerous diseases. A clean environment boosts living standards and brings immense
benefits to the economy.

28
2. Prevents Global Warming
As the impacts of global warming become more apparent, world leaders are looking
for ways to bring down these effects. One of the easiest sectors to deal with is transportation,
and this involves having fewer automobiles on the roads.

Cars emit greenhouse gasses, which are responsible for global warming. By reducing
the number of vehicles, the amount of greenhouse gas produced will not be enough to
cause global warming.

3. Reduces Carbon Footprint


Public transportation offers an immediate alternative for individuals seeking to reduce
their energy use and carbon footprints. This action far exceeds the benefits of other energy-
saving household activities, such as using energy-efficient light bulbs or adjusting
thermostats.

SOCIAL BENEFITS:

1. Improves Health
Bringing health policies in line with transport can significantly reduce the burden on
health services by encouraging active lifestyles. Public transport ensures citizens are at their
best healthwise by encouraging them to walk to bus and railway stations, at the same time
alleviating the stress that comes with driving a car on congested roads.

Research learns that every hour spent driving a car increases the possibility of obesity
by more than 6%.

2. Benefits the Aging Population


Research studies indicate that the number of people older than 65 years is projected to
go up from 14% in 2006 to 22% by 2030. Older adults heavily depend on public transport to
access essential services. This is why public transport authorities must work hard to cater to
this aging population.

29
3. Freedom and Increased Mobility
Many people are unable to drive, and even drivers would appreciate the ability to
walk, cycle, or take public transit, at least when it requires. Public transportation allows them
personal mobility to get to work, to school, to the grocery store or doctor’s chamber, or for
visiting friends, without having to engage a friend or relative to do the driving.

Millions of non-drivers, specifically children, usually stuck up in automobile


dominated suburban locales where they must depend on others for rides.

4. Frees up time
In public transportation, as someone else is doing the driving, which allows riders to
free up a significant amount of time and attention and spend their transit time reading,
working, studying, or being entertained instead of having to watch the road. It can also reduce
commute time. When driving an automobile, one cannot sleep, read, write, relax, or do
anything that transit takers are able to do.

5. Public Transportation is Safer


Taking public transport is safer than driving a car, considering not only the safety of
the vehicles that are maintained on a regular basis than a personal car but also the driving
habits and training of the operators. Transit operators receive much more training than the
average automobile driver (120 minimum hours of training) and also receive refresher
training on a regular basis as well.

A person can reduce his or her chance of being in an accident by more than
90% simply by taking public transit as opposed to commuting by car. Traveling by public
transportation is 10 times safer per mile than traveling by automobile.

6. Social Connections Increase


Robert Putnam, the author of Bowling Alone, said that for every 10 minutes of
additional travel time by car, social connections are reduced by 10%. Millennials consider
public transportation as the best option for digital socializing and among the best for
connecting with communities.

30
Often, car users are people who live in larger houses that are far from their places of
work, and in areas where high-quality public transit is not available. Having more people in
an area means you have a wider labor force, and there is a better chance of matching the
needs of a job with the skills of a worker.Another benefit could be the information exchange.

While public transportation may not be enjoyable to many like riding in your personal
car, it plays a huge role in reducing traffic congestion, minimizing emissions and, according
to you, a whole lot of quality time to watch and interact with your neighbors.

To add to that, public transportation lets you relax, read newspaper or book, take a
nap during commute rather than experiencing the stress that comes with driving on the busy
roads.Enhancing the quality and efficiency of public transport systems is critical to
encouraging individuals to shift to public transport.

DISADVANTAGES:

1.SOME PUBLIC TRANSPORT SYSTEMS ARE QUITE BAD:

Even though we have seen in the previous analysis that public transport can have
many important benefits, there are also some problems related to mass transport.

One major downside of public transport systems is that the quality of those
transportation systems is quite bad in many regions all over the world.

Especially in the US, apart from a few big cities, the quality of the public transport
system is often quite poor and it may take several hours to get to a destination which would
have been reached in just 20 minutes by car.

2. LONG WAITING TIMES

In some areas, you might also have to wait for quite long until the next bus or train
will arrive.

Especially in rural regions, the frequency of public transport vehicles will often be
rather low and sometimes, there will even only be a few buses a day.

31
Thus, if you don’t know the schedule, you might have to wait over an hour until you
can take the next bus that will finally bring you to your destination.

3.UNRELIABLE IN MANY REGIONS

Public transport may also be quite unreliable. In some regions, buses or train may be
late on a regular basis or might not show up at all.

Thus, if you live in one of these areas, you might not want to rely on public transport,
especially if you have important appointments and you cannot afford to show up late.

4.DELAYS MAY IMPLY PROBLEMS AT WORK

By using public transport, you might also come to work too late quite often.

This may cause serious problems and you might even get fired at one point in time.

Thus, you might rather rely on using your car for commuting in order to avoid
unpleasant consequences related to showing up late at work, especially if you like your job
and want to stay in this company for a longer period of time.

5.LESS FLEXIBILITY REGARDING DETOURS

If you drive back home from work with your car, it might come to your mind that you
might have to buy some groceries for dinner.

If this is the case, it will be quite easy for you to make a small detour and to stop at a
local grocery store.

However, if you use public transport instead, this small detour may lead to serious
issues since you might have to wait for quite long hours for the next bus.

Thus, especially if you enjoy a high level of flexibility, using your car might be
preferred over using public transport.

32
6.TRANSPORTATION OF HEAVY GOODS MAY BE A PROBLEM

It may also be quite hard to carry heavy things around you in public transport.

For instance, imagine you bought beer cases at your local store.

This case of beer will often be quite heavy and without a car, it will be quite
exhausting to carry it home.

Thus, in case you have heavy things to bring to your home, your car will definitely the
way to go and you would have a quite hard time using public transport for these kinds of
tasks.

7.HIGHER CHANCE FOR INFECTIONS WITH DISEASES

Since public transport is often crowded and many people will go on a train or on a bus
together, the chance for infections with diseases will be generally much higher compared to
going by private cars.

Thus, if you are unlucky, you might catch the flu or other diseases on your way to
work or back home if you use public transport systems.

Therefore, if you are scared in this regard, refraining from public transport and going
by car might be the way to go for you instead.

You could also consider using an alternative to conventional cars.

This may include the use of electric cars, but also electric scooters or going by bike.

8.PRETTY CROWDED AT RUSH HOUR

In many big cities, the public transport systems are quite crowded, especially at rush
hour.

33
Therefore, it may be quite inconvenient to be stuck with a high number of people on a
crowded train every morning.

This may cause plenty of stress for our body and brain system and may also lead to
serious health conditions in the long run.

9.LESS CONVENIENT COMPARED TO CARS

In general, public transport is considered to be less convenient compared to the use of


cars by most people.

This is due to the fact that if you use your car, you just have to leave your house and
you are ready to go.

You may be able to turn on your air conditioning or your heating whenever you like.

You may also be able to turn on the radio and listen to your favorite music.

However, if you use public transport, you will not have (full) control over those
options since there will be only one setting regarding temperature and other parameters and
you will have to accept those settings, even though they might lower your level of comfort.

10.NOT SUITABLE FOR REMOTE AREAS

Especially in rural and remote areas, public transport is often quite bad or even non-
existent.

In those regions, you will definitely need a car in order to get around and to stay
connected with the outside world.

Thus, depending on where you live, public transport may either be quite good or non-
existent at all.

34
11.MAY BE NOT SAFE IN SOME REGIONS

In cities that are known for high crime rates, it may also not be safe to use public
transport since you might get robbed sooner or later.

This is especially true at nighttime.

If you want to get around at night, you might want to use your car or a cab instead in
order to increase your level of safety, especially if you live in regions that are considered to
be unsafe.

12.YOU MAY HAVE NAVIGATION PROBLEMS

While the navigation in some public transport system is quite good, it can be also
rather bad in other cities.

Thus, especially if you are new in a city, you might have difficulties getting around
and may get lost.

Therefore, make sure to figure out how the public transport system in your area works
in order not to get lost and to avoid being late for important appointments.

13.EXPANSION OF PUBLIC TRANSPORT MAY HURT OTHER INDUSTRIES

Although public transport may greatly benefit the general public, especially if the
public transport system is quite sophisticated, it may also cause serious problems for some
industries.

For instance, if there are significant improvements in public transport, chances are
that more people will use it and that the number of cars that are sold decreases.

In turn, car dealers and manufacturers will significantly suffer and many of them may
even go out of business.

35
14.JOB LOSSES

Due to problems of some industries related to improved public transport, some


workers in those industries may also lose their jobs.

Thus, good public transport may also cause an increase in local unemployment rates,
especially if the local industry is heavily dependent on car manufacturers.

15.YOU MAY GET STUCK LATE AT NIGHT

Even though many public transport systems are quite good at daytime, they often stop
to operate at night.

Thus, if you attend a party and want to get back to your home in the early morning,
chances are that there will be no trains or buses running anymore and you might be stuck.

Therefore, before relying on public transport at nighttime, check out the schedule of
your bus or train in order to avoid unpleasant consequences.

16.PEOPLE MAY NOT WANT TO USE PUBLIC TRANSPORT

Some people are also quite used to their cars and simply do not want to switch to
public transport at all.

Those groups of people may be quite hard to convince about the benefits of public
transport since they used their car all their lives and do not want to make changes soon.

Thus, for those people, public transport may not be the way to go and there will
always be a certain amount of people who simply do not want to refrain from using their cars.

36
CHAPTER 3

SYSTEM SPECIFICATION

The purpose of system requirement specification is to produce the specification analysis of


the task and also to establish complete information about the requirement, behavior and other
constraints such as functional performance and so on. The goal of system requirement
specification is to completely specify the technical requirements for the product in a concise
and unambiguous manner.

3.1 HARDWARE REQUIREMENTS:

System : AMD APU Quad Core/Intel.


Hard Disk : 300GB/More
Floppy Drive : 1.44 Mb.
Mouse : Logitech.
Monitor : 15 VGA Colour.
Ram : 4 GB/More.

3.2 SOFTWARE REQUIREMENTS:


Operating system : Windows 7/8/10/11,Android.
Coding Language : Python 3.X.,
Tool : PyCharm 2020.3

3.2.1 Software Specification:

Python 3.x:
Python is an interpreter, object-oriented, high-level programming language with dynamic
semantics. Its high-level built in data structures, combined with dynamic typing and dynamic
binding; make it very attractive for Rapid Application Development, as well as for use as a
scripting or glue language to connect existing components together. Python's simple, easy to
learn syntax emphasizes readability and therefore reduces the cost of program maintenance.
Python supports modules and packages, which encourages program modularity and code

37
reuse. The Python interpreter and the extensive standard library are available in source or
binary form without charge for all major platforms, and can be freely distributed.

PYTHON ARCHITECTURE (3.1)

History of Python:

Python was created in the late 1980s, and first released in 1991, by Guido van Rossum as a
successor to the ABC programming language. Python 2.0, released in 2000, introduced new
features, such as list comprehensions, and a garbage collection system with reference
counting, and was discontinued with version 2.7 in 2020. Python 3.0, released in 2008, was a
major revision of the language that is not completely backward-compatible and much Python
2 code does not run unmodified on Python 3. With Python 2's end-of-life (and pip having
dropped support in 2021), only Python 3.6 and later are supported, with older versions still
supporting e.g. Windows 7 (and old installers not restricted to 64-bit Windows).

Python interpreters are supported for mainstream operating systems and available for a
few more (and in the past supported many more). A global community of programmers
develops and maintains CPython, a free and open-source reference implementation. A non-
profit organization, the Python Software Foundation, manages and directs resources for
Python and CPython development.

38
As of January 2021, Python ranks third in TIOBE’s index of most popular programming
languages, behind C and Java, having previously gained second place and their award for the
most popularity gain for 2020.

3.2.2 Architecture

Python code:

It's often used as a “scripting language” for web applications. This means that it can
automate specific series of tasks, making it more efficient. Consequently, Python (and
languages like it) is often used in software applications, pages within a web browser, the
shells of operating systems and some games.

Syntax Checker and Translator:

A syntax checker checks for syntax errors in each statement, according to the data set type.
The syntax checker scans each line a user enters, in input mode, when the user edits a data
set. Before the syntax checker scans a record, the record is put into the data set.

A translator is a programming language processor that converts a computer program from


one language to another. It takes a program written in source code and converts it into
machine code.

Byte Code:

Python, like many interpreted languages, actually compiles source code to a set of
instructions for a virtual machine, and the Python interpreter is an implementation of that
virtual machine. This intermediate format is called "byte code”.

Python Virtual Machine (PVM):

The python virtual machine executes the byte codes. The Python interpreter performs
following tasks to execute a Python program.

39
CHAPTER 4

SYSTEM MODEL

What is the Shortest Path Algorithm?


● In graph theory, the shortest path problem is the problem of finding a path between
two vertices (or nodes) in a graph such that the sum of the weights of its constituent
edges is minimized.
● The problem of finding the shortest path between two intersections on a road map
may be modeled as a special case of the shortest path problem in graphs, where the
vertices correspond to intersections and the edges correspond to road segments, each
weighted by the length of the segment.

4.1.1 STRUCTURE:

4.1(Example)

40
4.1.2 Module Description:

4.1.2.1 Shortest Path Problem:


In data structures,
● Shortest path problem is a problem of finding the shortest path(s) between vertices of
a given graph.
● Shortest path between two vertices is a path that has the least cost as compared to all
other existing paths.

4.1.2.2 Shortest Path Algorithm:


● Shortest path algorithms are a family of algorithms used for solving the shortest path
problem.

4.1.2.3Applications:
● Google Maps
● Road Networks
● Logistics Research

4.1.2.4TYPES:

Various types of shortest path problem are-


● Single-pair shortest path problem
● Single-source shortest path problem
● Single-destination shortest path problem
● All pairs shortest path problem

41
Single-Pair Shortest Path Problem-

● It is a shortest path problem where the shortest path between a given pair of vertices is
computed.
● A* Search Algorithm is a famous algorithm used for solving single-pair shortest path
problem.

Single-Source Shortest Path Problem-

● It is a shortest path problem where the shortest path from a given source vertex to all
other remaining vertices is computed.
● Dijkstra’s Algorithm and Bellman Ford Algorithm are the famous algorithms used for
solving single-source shortest path problems.

42
Single-Destination Shortest Path Problem-

● It is a shortest path problem where the shortest path from all the vertices to a single
destination vertex is computed.
● By reversing the direction of each edge in the graph, this problem reduces to a single-
source shortest path problem.
● Dijkstra’s Algorithm is a famous algorithm adapted for solving single-destination
shortest path problems.

All Pairs Shortest Path Problem-

● It is a shortest path problem where the shortest path between every pair of vertices is
computed.
● Floyd-Warshall Algorithm and Johnson’s Algorithm are the famous algorithms used
for solving All pairs shortest path problem.

43
CHAPTER 5

SYSTEM STUDY

5.1 FEASIBILITY STUDY

The feasibility of the project is analyzed in this phase and a business proposal is put forth
with a very general plan for the project and some cost estimates. During system analysis the
feasibility study of the proposed system is to be carried out. This is to ensure that the
proposed system is not a burden to the company. For feasibility analysis, some
understanding of the major requirements for the system is essential.

Three key considerations involved in the feasibility analysis are

● Economic feasibility
● Technical feasibility
● Social feasibility

5.1.1 ECONOMICAL FEASIBILITY

This study is carried out to check the economic impact that the system will have on
the organization. The amount of funds that the company can pour into the research and
development of the system is limited. The expenditures must be justified. Thus the developed
system as well within the budget and this was achieved because most of the technologies
used are freely available. Only the customized products had to be purchased.

5.1.2 TECHNICAL FEASIBILITY

This study is carried out to check the technical feasibility, that is, the technical
requirements of the system. Any system developed must not have a high demand on the
available technical resources. This will lead to high demands on the available technical
resources. This will lead to high demands being placed on the client. The developed system
must have a modest requirement, as only minimal or null changes are required for
implementing this system.

44
5.1.3 SOCIAL FEASIBILITY

The aspect of study is to check the level of acceptance of the system by the user. This
includes the process of training the user to use the system efficiently. The user must not feel
threatened by the system, instead must accept it as a necessity. The level of acceptance by the
users solely depends on the methods that are employed to educate the user about the system
and to make him familiar with it. His level of confidence must be raised so that he is also able
to make some constructive criticism, which is welcomed, as he is the final user of the system.

45
CHAPTER 6

SYSTEM TESTING

The purpose of testing is to discover errors. Testing is the process of trying to


discover every conceivable fault or weakness in a work product. It provides a way to check
the functionality of components, sub-assemblies, assemblies and a finished product. It is the
process of exercising software with the intent of ensuring that the Software system meets its
requirements and user expectations and does not fail in an unacceptable manner. There are
various types of test. Each test type addresses a specific testing requirement.

TYPES OF TESTS
Testing is the process of trying to discover every conceivable fault or weakness in a
work product. The different type of testing is given below:

Unit Testing

Unit testing involves the design of test cases that validate that the internal program
logic is functioning properly, and that program inputs produce valid outputs. All decision
branches and internal code flow should be validated. It is the testing of individual software
units of the application .it is done after the completion of an individual unit before
integration. This is a structural testing, that relies on knowledge of its construction and is
invasive. Unit tests perform basic tests at component level and test a specific business
process, application, and/or system configuration. Unit tests ensure that each unique path of a
business process performs accurately to the documented specifications and contains clearly
defined inputs and expected results.

Integration Testing

Integration tests are designed to test integrated software components to determine if


they actually run as one program. Testing is event driven and is more concerned with the
basic outcome of screens or fields. Integration tests demonstrate that although the
components were individually satisfactory, as shown by successfully unit testing, the
combination of components is correct and consistent. Integration testing is specifically aimed
at exposing the problems that arise from the combination of components.

46
Functional Test

Functional tests provide systematic demonstrations that functions tested are available
as specified by the business and technical requirements, system documentation, and user
manuals.
Functional testing is centered on the following items:

Valid Input : identified classes of valid input must be accepted.


Invalid Input : identified classes of invalid input must be rejected.
Functions : identified functions must be exercised.
Output : identified classes of application outputs must be exercised.
Systems/ Procedures : interfacing systems or procedures must be invoked.

System Test
System testing ensures that the entire integrated software system meets requirements.
It tests a configuration to ensure known and predictable results. An example of system testing
is the configuration oriented system integration test.

White Box Testing


White Box Testing is a testing in which in which the software tester has knowledge of
the inner workings, structure and language of the software, or at least its purpose. It is
purpose. It is used to test areas that cannot be reached from a black box level.

Black Box Testing


Black Box Testing is testing the software without any knowledge of the inner
workings, structure or language of the module being tested. Black box tests, as most other
kinds of tests, must be written from a definitive source document, such as specification or
requirements document, such as specification or requirements document. It is a testing in
which the software under test is treated, as a black box.

Unit Testing
Unit testing is usually conducted as part of a combined code and unit test phase of the
software lifecycle, although it is not uncommon for coding and unit testing to be conducted as
two distinct phases.

47
Integration Testing
Software integration testing is the incremental integration testing of two or more
integrated software components on a single platform to produce failures caused by interface
defects. The task of the integration test is to check that components or software applications,
e.g. components in a software system or – one step up – software applications at the company
level – interact without error.Test Results: All the test cases mentioned above passed
successfully. No defects encountered.

Acceptance Testing
User Acceptance Testing is a critical phase of any project and requires significant
participation by the end user. It also ensures that the system meets the functional
requirements. Test Results: All the test cases mentioned above passed successfully. No
defects encountered.

48
CHAPTER 7

CONCLUSION AND FUTURE WORK

7.1 CONCLUSION:

Even though this dissertation could produce potential outcomes following the research
question, there were some limitations, which could be improved in future research. In terms
of the user’s perceptions of the bus scheduler. However, there were some issues, which were
brought up by the 51 interviewees, such as enhancing customer service and the use by elderly
people. Therefore, future research should carry out a case study based on this prototype to
examine exact perceptions from booking customers. Furthermore, this research focused on
developing a US scheduler only for the web. Thus, future research should apply system
design and source codes in this portfolio to be developed for other kinds of bus scheduler, for
example, id linking with tickets,bus gate can only open when qr code of tickets is scanned.
Moreover, implementation on another platform, such as Android or .Net, is an alternative,
which could be carried out in future research. Finally, additional features suggested by Bus
Owners and booking customers, for instance, integration with Point of Sale (POS) system and
the advertising of new promotions and also providing options for food booking during
journry could also be included in a new prototype, which should have more functionalities as
well as a study of users’ perceptions of those requirements.
Hereby I conclude my project report but with that I must confess that throughout the
journeyof converting this project into reality I have learned a lot and it has given me a face to
face exposure with the real projects in the field of information technology. I would also like
to mention that I am not going to leave this project here only. I will make sure that it is
updated according to the changes in the field of education.

7.2 FUTURE ENHANCEMENT:

In future work, the timetabling optimization, which focuses on satisfying the


regulatory constraints, using AVL-data insights for estimating the travel times, can be
expanded even further forimproving the excess waiting times of passengers at transfer stops
in order to increase the reliability of multi-modal trips. In addition, the stochastic nature of
the travel times can be incorporated in the objective function of the timetabling optimization

49
resulting in a stochastic optimization problem with the use of supervised learning methods or
by fitting the observed travel times from the archived AVL data to probability distributions.
In this way, the reliability improvement potential of stochastically optimized timetables can
be further examined. Finally, it is worth examining the potential improvement of the
proposed GA convergence rate during the timetabling optimization after incorporating in it
advanced hybridization techniques that are described in recent works related to forecasting
problems (such as the work of Lopez-Garcia et al. [31] on predicting the short-term travel
times in highways).

50
SOURCE CODE:

API Source Code

main.py: (File Name)

from flask import Flask, jsonify


from flask_cors import CORS, cross_origin
import sqlite3

app = Flask(__name__)
CORS(app)

@app.route("/bus/route/<source>/<destination>")
def helloWorld(source, destination):
routesList = []

try:
conn = sqlite3.connect('bus_details.db')
query = '''SELECT * FROM routes_list WHERE source = "''' + source + '''" and destination ="''' +
destination + '''"'''
busAndRouteDetails = conn.execute(query)
for row in busAndRouteDetails:
routes = {}
busReferenceId = row[0]
routes['sourcePlace'] = row[1]
routes['destinationPlace'] = row[2]
routes['startTime'] = row[3]
routes['endTime'] = row[4]
routes['busCharge'] = row[5]
busNameQuery = '''SELECT busname from bus_details WHERE id="''' + str(busReferenceId) + '''"'''
busId = conn.execute(busNameQuery)
for values in busId:
routes['busName'] = values[0]
routesList.append(routes)

except ConnectionError as e:
raise ConnectionError("connection error")
return jsonify(routesList)

if __name__ == "__main__":
app.run(host='0.0.0.0', port=5000, threaded=True)

51
Android Source Code:

AndroidManifest.xml (file name)

<?xml version="1.0" encoding="utf-8"?>


<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.busschedule">
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:usesCleartextTraffic="true"
android:theme="@style/Theme.BusSchedule">
<activity android:name=".ListActivity" android:parentActivityName=".ListActivity"></activity>
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />


</intent-filter>
</activity>
</application>

</manifest>

File Name: BusListVO.java

package com.example.busschedule;

public class BusListVO {


String busName;
String busCharge;
String fromTime;
String toTime;
String busSourceAndEndPoint;

public BusListVO(String busName, String busCharge, String fromTime, String toTime, String
busSourceAndEndPoint) {
this.busName = busName;
this.busCharge = busCharge;
this.fromTime = fromTime;
this.toTime = toTime;
this.busSourceAndEndPoint = busSourceAndEndPoint;
}
}

52
File Name: DatabaseHelper.java

package com.example.busschedule;

import android.content.Context;
import android.content.Intent;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class DatabaseHelper extends SQLiteOpenHelper {

private static final String DB_NAME = "busdb";


private static final int DB_VERSION = 1;
public DatabaseHelper(Context context){
super(context, DB_NAME, null, DB_VERSION);
}

@Override
public void onCreate(SQLiteDatabase sqLiteDatabase) {
sqLiteDatabase.execSQL("CREATE TABLE IF NOT EXISTS TutorialsPoint(Username VARCHAR,Password
VARCHAR);");
}

@Override
public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {

}
}

File Name: ListActivity.java


package com.example.busschedule;

import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.JsonArrayRequest;
import com.android.volley.toolbox.RequestFuture;
import com.android.volley.toolbox.Volley;

53
import org.json.JSONArray;
import org.json.JSONException;

import java.util.ArrayList;
import java.util.concurrent.TimeUnit;

public class ListActivity extends AppCompatActivity {

RecyclerView recyclerView;
ArrayList<BusListVO> busListVOS;
MyAdapter myAdapter;

BusCountVO busCountVO = new BusCountVO();

long totalNumberOfBusData = 0;
public void passData(long numberOfData){
totalNumberOfBusData = numberOfData;
System.out.println("number of data : " + totalNumberOfBusData);
}

@Override
protected void onCreate(Bundle saveInstanceState){
super.onCreate(saveInstanceState);
setContentView(R.layout.list_actvity);

Intent intent = getIntent();


String fromValue = intent.getStringExtra("from");
String toValue = intent.getStringExtra("to");

String listActivityTitle = fromValue + " to "+ toValue;


getSupportActionBar().setTitle(listActivityTitle);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_arrow_back);

recyclerView = findViewById(R.id.rvTools);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
recyclerView.setHasFixedSize(true);

busListVOS = new ArrayList<BusListVO>();


myAdapter = new MyAdapter(this, busListVOS);
recyclerView.setAdapter(myAdapter);

try {
getData(fromValue, toValue);
} catch (InterruptedException e) {
e.printStackTrace();
}

54
private void getData(String fromValue, String toValue) throws InterruptedException {

// API URL
String url = "http://192.168.70.140:5000/bus/route/"+fromValue+"/"+toValue;

RequestQueue requestQueue = Volley.newRequestQueue(this);


RequestFuture<JSONArray> future = RequestFuture.newFuture();
JsonArrayRequest objectRequest = new JsonArrayRequest(
Request.Method.GET,
url,
null,
new Response.Listener<JSONArray>() {
@Override
public void onResponse(JSONArray response) {
busCountVO.setBusCount(response.length());
try {
passData(response.length());
for(int i=0; i<response.length();i++){
String sourceEndLocation = response.getJSONObject(i).getString("sourcePlace") + " - "
+ response.getJSONObject(i).getString("destinationPlace");

// start time
String fromTimeOriginalValue = response.getJSONObject(i).getString("startTime");
String[] fromTimeSplittedVal = fromTimeOriginalValue.split(" ");
String fromTime = fromTimeSplittedVal[1].split("\\.")[0];

// end time
String toTimeOriginalValue = response.getJSONObject(i).getString("endTime");
String[] toTimeSplittedVal = toTimeOriginalValue.split(" ");
String toTime = toTimeSplittedVal[1].split("\\.")[0];

// values set to list.


BusListVO busListVO = new BusListVO("
"+response.getJSONObject(i).getString("busName")+" ",
" ₹ " +response.getJSONObject(i).getString("busCharge")+ " ",
" " +fromTime+" ",
" " +toTime+ " ",
" " + sourceEndLocation + " ");

busListVOS.add(busListVO);
}
if (response.length() >= 1){
myAdapter.notifyDataSetChanged();
}else{
AlertDialog.Builder builder = new AlertDialog.Builder(ListActivity .this);
builder.setTitle("Results From " + fromValue + " To " + toValue )
.setMessage("No Records Found! Will Keep This For Future")
.setCancelable(false)
.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
finish();

55
ListActivity.super.onBackPressed();
}
});
AlertDialog alert = builder.create();
alert.show();
}

} catch (JSONException e) {
e.printStackTrace();
}
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Log.e("Error ", error.toString());
}
}
);

requestQueue.add(objectRequest);

File Name : BuildConfig.java

/**
* Automatically generated file. DO NOT MODIFY
*/
package com.example.busschedule;

public final class BuildConfig {


public static final boolean DEBUG = Boolean.parseBoolean("true");
public static final String APPLICATION_ID = "com.example.busschedule";
public static final String BUILD_TYPE = "debug";
public static final int VERSION_CODE = 1;
public static final String VERSION_NAME = "1.0";
}

Requirements:
file name : requirement.txt

flask
flask cors
sqlite

Usage : Python3 -m pip install -r requirements.txt

56
OUTPUT:

57
58
59
REFERENCES

● Gkiotsalitis, K.; Cats, O. Reliable frequency determination: Incorporating information


on service uncertainty when setting dispatching headways. Transp. Res. Part C
Emerg. Technol. 2018, 88, 187–207.
● Chapman, R.; Michel, J. Modelling the tendency of buses to form pairs. Transp. Sci.
1978, 12, 165–175.
● Pilachowski, J.M. An Approach to Reducing Bus Bunching; University of California:
Berkeley, CA, USA, 2009.
● Gkiotsalitis, K.; Maslekar, N. Dynamic Bus Operations Optimization with REFLEX.
NEC Tech. J. 2016, 11, 1.
● Johnson, R.M.; Reiley, D.H.; Muñoz, J.C. “The War for the Fare”: How Driver
Compensation Affects Bus System Performance; Technical Report; National Bureau
of Economic Research: Cambridge, MA, USA, 2005.
● Randall, E.R.; Condry, B.J.; Trompet, M.; Campus, S.K. International bus system
benchmarking: Performance measurement development, challenges, and lessons
learned. In Proceedings of the Transportation Research Board 86th Annual Meeting,
Washington, DC, USA, 21–25 January 2007.
● Welding, P. The instability of a close-interval service. Oper. Res. Soc. 1957, 8, 133–
142.
● Eberlein, X.J. Real-time control strategies in transit operations: Models and analysis.
Transp. Res. Part A 1997, 1, 69–70.
● Hickman, M.D. An analytic stochastic model for the transit vehicle holding problem.
Transp. Sci. 2001, 35, 215–237.
● Bartholdi, J.J.; Eisenstein, D.D. A self-coördinating bus route to resist bus bunching.
Transp. Res. Part B Methodol. 2012, 46, 481–491.

60

You might also like