Real-Time Carpooling Application based on k-NN Algorithm: A Case Study in Hashemite University

The current revolution of mobile technology in different aspects of community directs the researchers and scientists to employ this technology to identify practical solutions for daily life problems using mobiles. One of the major challenges in our developing countries is the public transportation system. Public transportation system is an essential requirement for the welfare of modern society and has a critical impact on the people productivities and thus on the entire economic development process. Therefore, different solutions had been investigated to find applicable solutions. “Carpooling” is one of the initiative solutions that based on the usage of a single shared car by a group of people heading to the same location on a daily basis. In addition, carpooling can be considered as an efficient alternative to overcome the limitations of the conventional transportation system with an easier, quicker and more environmentally friendly car journeys. This paper presents an intelligent carpooling mobile app to commute students of the Hashemite University. The proposed solution is founded on using data mining technique, and more specifically the k-NearestNeighbour (k-NN) technique. Keywords—Mobile Application; Carpooling; Data mining; Classification; k-NN algorithms


I. INTRODUCTION
Jordan as many countries is effected by the increasing number of vehicles on streets. The enormous number of vehicles causes environmental pollution, social problems, traffic congestion and not enough parking spaces. The extensive number of vehicles on roads is a natural result for the inefficient public transportation system that leads to vehicle dependency and ownership.
Transportation Demand Management is a collection of strategies and administrative regulations to encourage efficient traffic patterns to reduce travel demand and to reorganize mobility in space and time. Transportation Demand Management provides several solutions for traffic congestion. One solution to reduce the increasing number of vehicles on streets is car sharing. Car sharing is also known as carpooling. Carpooling is involved with a group of people who have similar time slots and going to the same office or school such that they share a vehicle owned by the driver [1].
Information and Communication Technology (ICT) play a major role for bringing potential carpoolers together and encourage carpooling. ICT contribute to establish communication with potential passengers, and make it available to a large number of potential users with enough variation in demographic and trip characteristics (e.g. timing, geography, etc.).
Many algorithms were used in Carpooling systems to calculate the best route, shortest path and find potential passengers. Carpooling systems use algorithms and data mining techniques to allow both passengers and drivers to find a convenient trip route and to support a billing system. Examples of these mining algorithms are Dijkstra's algorithm, Bellman Ford's algorithm, Floyd-Warshall's Algorithm and k-Nearest Neighbor algorithm [2]. However, one of the most popular machine learning algorithms is the k-Nearest Neighbor algorithm (k-NN). Generally speaking, k-NN is an efficient, simple and easy-to-implement supervised machine learning algorithm that can be used to solve different classification and regression problems [3].
The University is located in city of Zarqa in Jordan. Students and employees of the Hashemite University (HU) have critical difficulties during their daily journey to the campus because of the poor public transportation. The lack and delay in public transportation system while travelling from different locations such as Amman, Zarqa and Irbid to campus motivate us to develop a carpooling application that directed mainly to students. Obviously, the proposed carpooling app is directed to a particular class of users --the students of the Hashemite University where the idea is to provide them with a reliable, safe and rapid ride to the campus with minimum fees. The proposed carpooling app based on the well-known k-NN algorithm and the novelty of our application comes from its simplicity where the app use the same recognized road to the university with predetermining stopping points to pick the student from or drop them in. Therefore, the k-NN is employed to identify the closest drivers at certain time. Taking into consideration that eligible drivers only are sent to passengers to select the most suitable one. The Deanship of Student Affairs at the Hashemite University determines the eligibility with accordance to its policy to assure the safety of the students.
Our main goals of developing carpooling app are: (i) to minimize the overall travel cost and distance from students' houses to HU campus that is located in ZARQA city, (ii) to reduce pollution and traffic jam and (iii) to help students to be comfortable and satisfied with their ride to the university and this would absolutely has a positive impact on the students productivity. Furthermore, an ethical value added since this app highlights the initiatives and high responsibilities towards community problems. Being initiatives and part of the suggested solution would raise the value of the team work as well to face different types of life problems. www.ijacsa.thesai.org The main contribution of the presented work is to use the k-NN algorithm in generating an intelligent carpooling application for the students of the Hashemite University.
The paper is organized as follows: Section II presents a solid background and a general overview of related work. The proposed mobile application is discussed in Section III in terms of the Architecture specifications and the employed k-Nearest-Neighbour (k-NN) Algorithm and the functionality of the application. Section IV demonstrates the implementation and interface of the mobile app. Finally, Section V presents a summary and some directions for future work.

II. RELATED WORK
Carpooling usually consists of two to four persons shuttling with a driver [4]. Carpooling is involved with a group of people who have similar time slots and going to the same office or school such that they share a vehicle owned by the driver [1].
Many studies were conducted to conclude the benefits and advantages of using carpooling service. There are benefits for individuals and the entire community. For individuals; the most important reason to use carpooling is to reduce transportation expenses and reduce travel time [4]. Researchers found that the most important reason to use carpooling is to decrease expenses of car fuel and transportation fees [5] [1] [6]. Carpooling is considered to be a good alternative to public transportation and taxi services.
Furthermore, riding with a group of people with similar interest is a good way to spend the travel time. It is a good way to reduce the total travelling time and driving stress [7]. The work presented in [6] noted that being able to ride and socially interact with others rather than to drive is a cause for carpooling. The study of using carpooling in Massachusetts Institute of Technology campus showed that travel distance was reduced 9% to 27% [11].
For communities; carpooling is a mean to reduce traffic congestion and pollution. Some studies identified environmental responsibility as a motivation for carpooling [6]. However, others pointed the benefits of carpooling from a social point perspective; less fuel consumption, less CO2 production, less traffic congestion and more social interaction [7]. Gargiulo et al. showed how applying carpooling in Dublin would decrease the amount of CO2 in the air [8]. The case study proposed by [4] showed the efficiency of carpooling in moderating congestion in Delhi.
On the other hand; carpooling is affected by transportation policies. Legal restrictions in some countries do not allow carpooling, such that a vehicle will get a traffic violation ticket, if it is used as a carpooling. Additionally, in case of traffic accidents, insurance coverage policies will not cover the damages and hits that might occur to passengers [9] [1].
Moreover, travel schedule in carpooling is strict and does not allow personal freedom mobility during work day neither allows to change route or to stop during the trip [12]. In addition, it is hard to connect with an appropriate carpooling schedule with unknown passengers. Today, Information and Communications Technology (ICT) is used to enhance carpooling services. Technology plays an important role in carpool creation [10]. Online map services are available and used in carpooling systems, such as: Google Maps Directions API that calculates directions between locations using HTTP requests and Bing Map which calculates and display directions and routes on the map with direction API module or with Bing Map Rest services.
The use of smart phone devices with internet connectivity and GPS navigation technology ease the way to connect potential carpoolers together and arrange travel route. Most of the developed carpooling systems use algorithms and data mining techniques to allow both passengers and drivers to find a convenient trip route, in addition to support a billing system to manage fees and payment [2]. Nourineja et al. presented a centralized (binary integer programming) and decentralized (dynamic auction-based multi-agent) optimization algorithms to match passengers and drivers [13]. Montes et al. developed an online community for car sharing called Teranga Go!. Teranga GO! is a multi-criteria decision making system using Hesitant Fuzzy Linguistic terms to present judgment of both drivers and passengers [14].
To the best of our knowledge, extensive works and researches have been conducted to produce a carpooling app for general purpose where the machine learning and data mining techniques were employed to find the "best" and the most optimal route to the desired destination. However, identifying the optimal and shortest route present a neat solution but with high complexity. For instance, Bicocchi et al. developed an application for ride sharing based on the extraction of suitable information from mobility traces and use a clustering algorithm that is applied to labeled trajectories [15]. An android carpool application was developed to allow passengers to collaborate, plan for their journey and share expenses [16]. In [7], author presented two applications; the SplitCar application and the Buddy application for shared-use mobility in the metropolitan area of Bacău, Romania. The authors integrated different computing languages, standards and technologies. Mallus et al. developed CLACSOON application; a dynamic carpooling services in urban areas for real time carpooling service using multi-objective route matching algorithm [17]. The carpooling app employs the k-NN in order to queries are launched based on location/region. Menaka et al. proposed carpooling system with three modules; user module, LBS module and route saver module [18]. The authors used k-NN to find intermediate route for the destination point and display the reservation chart of the vehicle allotted to the user.
Our proposed mobile carpooling application aims to generate a simple intelligent carpooling app that help students and employees of the Hashemite University (HU) to find the most nearby drivers that match the passenger's preferences (i.e. gender) and thus to serve the ultimate goal of minimizing the overall travel distance, effort and the waiting time from students' homes to HU campus located in ZARQA city. www.ijacsa.thesai.org

III. PROPOSED MOBILE APP
In this section, the proposed carpooling apps are presented in terms of architecture and design in Section A. The k-Nearest-Neighbour (k-NN) Algorithm and its functionality are demonstrated in Section B and Section C, respectively.

A. Architecture Overview and Design
The architecture of the proposed system comprises of the following components (as shown in Fig. 1): 1) Users: Three types of users are involved in the proposed system: driver, passenger and system administrator. Passengera student requesting carpooling Services while Driver-the student providing carpooling Services using his own car. Typically, drivers and passengers are students who are registered in the current academic semester. However, the system administrator is a staff member of the Computer Centre (CC) of the Hashemite University.
2) Carpooling System: A web based system developed by the computer centre of the Hashemite University to manage, support and control all administration tasks. It is the most substantial component and considered as the heart of our proposed mobile application. The system encompasses of: a) System administratora staff member who is responsible for controlling and managing the system. The main administration tasks include (but not limited to): (i) accept new drivers' requests, (ii) accept new passengers' requests, (iii) give the students (drivers and passengers) their account details to start using the system and (iv) generate reports about the registered drivers and all related information about their cars (i.e., car brand, colour, and seat availability).
b) Databasecontains the actual database for all employees and students of the Hashemite University.
c) Computer Centre Web Server (CC server)this type of server contains the actual desired database of the registered and activated users necessary to operate the mobile application. Registered users are eligible drivers and/or passenger, but the activated users are those drivers who are currently ready to start a trip and commute passengers.
1) Stop pointswell-known predetermined meeting points (stations) located along the way to the Hashemite University to pick-up and drop-off the passengers from. Normally, the passenger chooses the nearest stop points to wait the driver.
2) Wi-Fi networkmaintains and supports the connection of drivers, passengers and the carpooling system.
It is worth to mention that the eligibility requirement for the drivers are summarised in two main points; the driver should: (i) be a legal registered student in the current academic semester and (ii) provide the university with a qualified driving behaviour report obtained from the Central Traffic Department of the Public Security Directorate. This report shows the traffic offences and used as a safety indicator. The steps of the proposed system are illustrated below based on the system architecture: 1) Initially, the legal drivers and passengers apply for the carpooling system by sending a request to join the carpooling mobile application.
2) Once the administrator assures the eligibility, especially for the drivers, the accounts are created and the details are provided to students to start using the carpooling mobile application.
3) With respect to driver, the driver log in to the mobile app and determine the start-up time (time to be in the nearest stop point), end-time (time to leave the university) and the seat availability.
4) With respect to passenger, the passenger sends a request that determines the pick-up time, stop point (meeting station) and the preferred gender of the driver (optional).

5)
Once the passenger request arrives to the carpooling system, the k-NN algorithm is applied on the available drivers to provide the passenger with the "best"matched drivers (i.e. top five drivers). The k value of the k-NN algorithm reflects the available active drivers. In our case, the value of the best available driver is set to three drivers (k=3) 1 . Typically, the value is set by the system administrator. The passenger is informed with the set of the best-matched drivers obtained by the k-NN. The set of the best-matched drivers are shown as coloured cars on the map (pink car stands for female drivers and blue cars stands for male drivers). Then he/she selects the driver/s so that the request is forwarded to them. 6) Finally, the system sends a confirmation note contains the driver details, pick-up time and stop point.

7)
The system provides the drivers with the suitable passenger requests fit the driver start-up and end-time. Also, the seat availability is considered. The driver can check the details of the passenger easily and accept the desired requests.
8) For each accepted passenger, the number of the available seats is decreased automatically. Consequently, if the available seats become zero then the driver cannot be www.ijacsa.thesai.org nominated to other passengers and no new request will be forwarded. 9) Finally, the carpooling system will generate a small notification (report) with the stop points along with the number of passengers should be collected from each.
The default case of the proposed system assumes all the students are passengers until the eligibility of the driver requirements are met and satisfied.

B. An overview of the k-Nearest-Neighbour (k-NN)
Algorithm applied in the carpooling The k-NN is one of the most popular machine learning algorithms and it is considered an attractive classification algorithm because it is very simple, flexible and highly efficient algorithm. The k-NN is a non-parametric learning algorithm. The term "non-parametric" term means that the complexity of the model cultivates with an increasing amount of data. Moreover, the boundary of the k-NN decision occurs on any form and it makes no assumption about the data distribution, which makes the flexibility of k-NN's decision boundary an enormous advantage. Since there is no previous information available in k-NN, the decision of k-NN is highly reliant on the distance metrics. Therefore, the k-NN algorithm was adopted with respect to carpooling problem to support making a decision as shown in Algorithm 1.
In the context of carpooling problem, the k-NN produces encouraging results as it does not lose any details since it scans all registered drivers, calculates the distance between each driver d i and the passenger P and compares the obtained results to make a decision to select the nearest drivers (to determine the "best"matched drivers).
Algorithm 1: k-NN for carpooling system (P, DR) { Input: P:passenger request details that contains the coordinate, pick-up time (t) and gender (g) DR: the set of active registered drivers where each driver d i contains t i : pick-up time and g i : gender (if determined) Output: S: The set of three nearest matched-drivers 1. S= θ; L= θ; 2. For each d i ∈ DR 3. If d i (t i , g i ) == P(t, g) then 4. Calculate dist i (x i , y i ): the distance between d i and P; 5. L = ADD (d i , dist i ) 6. Endif 7. 10. End for 8. S=arrange L in descending order with respect to dist i . 9. Return S 10. } With respect to the presented work, the adopted form of the distance metric dist(x, y) is the Euclidean distance, which is calculated as: When computing Euclidean distance, it is important to mention that the weighs of the passengers and drivers are the same to the total distance. Each data point (passengers/drivers) is represented by its latitude and longitude values. However, the Euclidean distance does not make sense when it is calculated from latitudes and longitudes, which are not coordinates in a Cartesian coordinate system. In order to calculate the distance between two points on the earth, given by latitudes and longitudes points it proceeds in two phases: i) calculate the Euclidean distance between two points by computing the Cartesian coordinates of the points from their latitudes and longitudes then ii) convert this distance to one measured along the surface of the earth.
Thus, suppose we are given two points P1 and P2 determined by their latitudes and longitudes values: P1(α1, β1) and P2 (α2, β2). The Euclidean distance dist in Cartesian coordinates is computed as: Where and Taking into consideration that R is the average radius of the earth, which is equal to approximately 6.371 x 10 6 m according to NASA's Goddard Space Flight Centre. Next, convert the distance d in Cartesian coordinates to the distance D measured along the surface of the earth, which is defined by the following formula:

C. System Functionality
As previously mentioned, the carpooling app provides a set of services to the registered students; passengers and drivers. In order to describe each service, the details of each functional requirement (FR) are listed below using Cockburn template [20] [19].
Typically, the student is set as "passenger" once the account is created. However, the student is transformed to "driver" when he provides the necessary documents such as driving licence and driving offences report to the Deanship of student affairs in the Hashemite University. Fig. 2 shows the use case diagram of the main functionalities for each type of users: Passenger, Driver and Admin.  Trigger: The driver need to hand in the report to admin.

Main success scenario:
1) Driver obtain the safety report from the Central Traffic Department 2) Driver hand in the report to the admin at the Deanship of Student Affairs at the Hashemite University 3) Admin receives and checks the report 4) Admin register the student as legal "Driver" Extensions:

1) If the safety report is not received and considered by the Deanship of Student Affairs
a) The students accounts registered as "Passenger" Only FR3: Request Driver including the following: 1) The passenger request is not forwarded to the selected drivers a) Passenger needs to roll back and sends the request again 1) Driver does not accept the request a) Passenger is informed after a predefined time stamp. Passenger needs to select another driver www.ijacsa.thesai.org

IV. APPLICATION IMPLEMENTATION AND INTERFACE
With respect to implementation specifications for the proposed application, the app encompasses of the following main components: 1) Server-Side: uses Java language including .NET and JavaScript is mainly used to develop the server-side part, especially the k-NN algorithm. Furthermore, when passenger submits queries and asks for available driver, the server will operate the k-NN algorithm on the activated registered students stored on the database and forward the best matched result back to the passenger. Moreover, PHP was used to generate an interface with the database. The PHP scripts are invoked to handle the applications requests for a data manipulation. Finally, the specifications of the CC server are: 6th generation Intel Octa Core i7 3.4 GHz processor, sixteen GB SDRAM and one TB SSD hard disk.
2) Database: In order to handle the database manipulations smoothly and efficiently Firebase real time database technology was adopted. Firebase depends on the concepts of using JavaScript Object Notation (JSON) where Data is stored as a node with reference key. In addition, NoSQL is adopted for the proposed carpooling application as it provides a flexible supported way for scalable database than the traditional relational SQL (the attributes of an object may be created on fly if there is a need, so space is not taken if an attribute is empty). Moreover, NoSQL enhance the performance as it formats data in the same way of using JSON so there is no need to reformat data. 3) Client-Side: includes the developing of the Android SDK application which will be installed later on the students' mobiles. Firebase Cloud Messaging (FCM) which is an improved version of the Google Cloud Messaging was adopted to handle the messages between server applications and mobile client apps in a more easy and efficient way as the FCM is built on Google Play Services. A wide range of mobile devices were used such as: Sony Xperia, Samsung Galaxy S4, Samsung Galaxy S6, and LG G2. The application worked smoothly and properly on the different devices. 4) Others: Google Maps API and Google Maps directions API are used to download and display maps in order to show passenger and driver locations, available drivers to select one of them. Moreover, APIs allow user interaction with the map (zoom, rotate, scale the map and open the map in full screen mode) easily and effectively.
The screenshots in Fig. 3 shows the app log in page and Fig. 4 illustrates the main services provided by the carpooling app. Transportation difficulties becoming more serious challenge, day after day. The pollution, fuel consumption, congestion, travelling cost and stress have a great impact on our daily lives. Therefore, an intelligent carpooling app is proposed in this paper as a solution for the aforementioned mentioned problems. The ultimate goal is to provide the students of the Hashemite University with an applicable, portable and easy to use mobile application for the transportation problem. An intelligent and reliable carpooling solution aids not only the students but also enrich the societal benefits in terms of strengthen the social relationship. The intelligent carpooling system app is based on the data mining techniques and more specifically the k-NN technique. Preliminary model have been designed and developed where the drivers are evaluated using the k-NN and a list of best match drivers are provided to passenger taking into consideration their preferences. Also a set of services are provided and included in the app such as: (i) a simple rating technique was used to give a feedback about the drivers and (ii) chat service between the drivers and passengers was activated once the driver accept the request of the ride. In addition, the traffic offences reports for drivers are checked on regular base to offer safe and sound rides.
The Hashemite University is satisfied with the initial values obtained from applying the carpooling app as the transportation problems eliminated and reduced for the student without any additional resources or cost. A set of suggestion are listed below to give a significant addition to the current version of the carpooling app is considered to be the next step for our future work:  Employ other machine learning algorithms such as Convolution Neural Network (CNN).
 Operate the proposed app by the Ministry of Higher Education in Jordan to cover other universities in this application. Taking into consideration that there are two more universities located on the same road of the Hashemite University; Al Bayet University and Private Zarqa University.
 Integrate the app with Public Security Directorate-Traffic Department (Drivers and vehicles Licensing Department). This type of cooperation would easily control and manage different drivers services support the safety concerns such as traffic offenses and license queries.