taxi service strategy optimization with data clustering ... · with data clustering and markov...

54
Taxi Service Strategy Optimization with Data Clustering and Markov Decision Processes Kexin Zhang A report submitted for the course COMP4650 Advanced Computing Project Supervised by: Dr. Sid Chi-Kin Chau The Australian National University October 2019 c Kexin Zhang 2019

Upload: others

Post on 24-Aug-2020

8 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Taxi Service Strategy Optimization with Data Clustering ... · with Data Clustering and Markov Decision Processes Kexin Zhang A report submitted for the course COMP4650 Advanced Computing

Taxi Service Strategy Optimizationwith Data Clustering

and Markov Decision Processes

Kexin Zhang

A report submitted for the courseCOMP4650 Advanced Computing Project

Supervised by: Dr. Sid Chi-Kin ChauThe Australian National University

October 2019c© Kexin Zhang 2019

Page 2: Taxi Service Strategy Optimization with Data Clustering ... · with Data Clustering and Markov Decision Processes Kexin Zhang A report submitted for the course COMP4650 Advanced Computing

Except where otherwise indicated, this report is my own original work.

Kexin Zhang25 October 2019

Page 3: Taxi Service Strategy Optimization with Data Clustering ... · with Data Clustering and Markov Decision Processes Kexin Zhang A report submitted for the course COMP4650 Advanced Computing

Acknowledgments

My sincere gratitude firstly goes to my supervisor Dr. Sid Chi-Kin Chau. His guid-ance, inspiration, and advice support me to overcome all the difficulties and finishthis thesis. Then, I want to express my profound gratitude to my family, especiallymy parents, for their selfless support and unfailing encouragement throughout myhonours year. Every time when I feel upset or hesitated, they always stand with me.Finally, I would like to say thank you to my dear friends, who always receive andreply my messages late at night. Thanks for every day we spent together.

iii

Page 4: Taxi Service Strategy Optimization with Data Clustering ... · with Data Clustering and Markov Decision Processes Kexin Zhang A report submitted for the course COMP4650 Advanced Computing
Page 5: Taxi Service Strategy Optimization with Data Clustering ... · with Data Clustering and Markov Decision Processes Kexin Zhang A report submitted for the course COMP4650 Advanced Computing

Abstract

Taxi drivers hope to pick up the next passenger as quickly as possible after drop-ping off previous passengers in order to improve working efficiency and profitability.However, most of them set their passenger-seeking strategies depending on theirpersonal experiences and preferences rather than employing fixed strategies. How-ever, conventional taxi drivers nowadays are keen to employ better strategies andtherefore increase their profit margin since they are facing competition with driversfrom Internet-based ride-hailing service providers like Uber and Lyft. In this thesis,we would like to provide taxi drivers with better passenger-seeking strategies thatmaximize their expected revenue based on data clustering results.

This thesis analysed the trip data of New York City (NYC) yellow taxis [NYCTLC,2014b]. Firstly, we divide the geographical locations of the study area into small trafficzones by applying K-Means clustering algorithm novelly. We then classify clusters bytheir primary function (i.e., residential area, office building, transportation junctions,entertainment places, and facilities), and construct a passenger transition network.By doing so, we could have a clear insight into urban human mobility through thecity. Then we model optimal passenger-seeking strategies by employing MarkovDecision Process (MDP) frameworks. For each possible state of the taxi, the modelwill generate a strategy that maximizes the total expected revenue. The effectivenessof the strategies is evaluated by comparing it with the historical income data of NYCtaxi drivers.

v

Page 6: Taxi Service Strategy Optimization with Data Clustering ... · with Data Clustering and Markov Decision Processes Kexin Zhang A report submitted for the course COMP4650 Advanced Computing

vi

Page 7: Taxi Service Strategy Optimization with Data Clustering ... · with Data Clustering and Markov Decision Processes Kexin Zhang A report submitted for the course COMP4650 Advanced Computing

Contents

Acknowledgments iii

Abstract v

1 Introduction 11.1 Background and Motivation . . . . . . . . . . . . . . . . . . . . . . . . . . 11.2 Problem Formulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.3 Project Scope . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.4 Report Outline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

2 Literature Review 5

3 Data 73.1 Dataset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73.2 Data Pre-processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

3.2.1 Study Area: The island area of Manhattan . . . . . . . . . . . . . 73.2.2 Outlier Detection . . . . . . . . . . . . . . . . . . . . . . . . . . . 83.2.3 General Data Pre-processing . . . . . . . . . . . . . . . . . . . . . 8

3.3 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

4 Traffic Zones 94.1 Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94.2 Methodology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

4.2.1 K-Means . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94.2.2 Optimal K . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

4.3 Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114.3.1 K value . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114.3.2 Comparison with Other Partition Methods . . . . . . . . . . . . . 12

4.4 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

5 Traffic Flows 135.1 Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135.2 Methodology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

5.2.1 DBSCAN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135.2.2 Traffic Zone Labeling . . . . . . . . . . . . . . . . . . . . . . . . . 14

5.3 Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155.3.1 Labeling Result . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155.3.2 Traffic Flows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

vii

Page 8: Taxi Service Strategy Optimization with Data Clustering ... · with Data Clustering and Markov Decision Processes Kexin Zhang A report submitted for the course COMP4650 Advanced Computing

viii Contents

5.4 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

6 Markov Decision Process 176.1 MDP Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176.2 MDP Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

6.2.1 Time Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206.2.2 Probability Parameters . . . . . . . . . . . . . . . . . . . . . . . . . 216.2.3 Reward Calculation . . . . . . . . . . . . . . . . . . . . . . . . . . 22

6.3 Evaluation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226.3.1 Comparison with Historical Income Data . . . . . . . . . . . . . . 236.3.2 Comparison with Other Strategies . . . . . . . . . . . . . . . . . . 23

6.4 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25

7 Conclusion 277.1 Future Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28

Bibliography 29

Appendix 1 33

Appendix 2 35

Appendix 3 39

Appendix 4 41

Page 9: Taxi Service Strategy Optimization with Data Clustering ... · with Data Clustering and Markov Decision Processes Kexin Zhang A report submitted for the course COMP4650 Advanced Computing

List of Figures

3.1 Heat maps of pick-up and drop-off events in NYC. . . . . . . . . . . . . 8

4.1 Three cluster validity measures applied to determine the optimal k. . . 114.2 Cluster heads with different K . . . . . . . . . . . . . . . . . . . . . . . . 12

5.1 Traffic zones, hot spots, and labeling results . . . . . . . . . . . . . . . . 155.2 Typical Traffic Flows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

6.1 An illustration of the state transition process. . . . . . . . . . . . . . . . . 186.2 Traffic speed network. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206.3 Hourly revenue for different durations. . . . . . . . . . . . . . . . . . . . 236.4 Hourly revenue for different durations. . . . . . . . . . . . . . . . . . . . 246.5 Expected revenue. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25

ix

Page 10: Taxi Service Strategy Optimization with Data Clustering ... · with Data Clustering and Markov Decision Processes Kexin Zhang A report submitted for the course COMP4650 Advanced Computing

x LIST OF FIGURES

Page 11: Taxi Service Strategy Optimization with Data Clustering ... · with Data Clustering and Markov Decision Processes Kexin Zhang A report submitted for the course COMP4650 Advanced Computing

List of Tables

3.1 Attributes used in this project. . . . . . . . . . . . . . . . . . . . . . . . . 7

xi

Page 12: Taxi Service Strategy Optimization with Data Clustering ... · with Data Clustering and Markov Decision Processes Kexin Zhang A report submitted for the course COMP4650 Advanced Computing

xii LIST OF TABLES

Page 13: Taxi Service Strategy Optimization with Data Clustering ... · with Data Clustering and Markov Decision Processes Kexin Zhang A report submitted for the course COMP4650 Advanced Computing

Chapter 1

Introduction

In this chapter, we first introduce the background and motivations of this project.Then, we briefly describe the problem formulation and the scope of this project,including three essential parts of the implementation and some main challenges. Wefinally provide a roadmap for this thesis.

1.1 Background and Motivation

Taxi, one of the most common forms of urban traffic, supports a large number ofpeople traveling through the city every day. Compared with other forms of trans-portation, taxi is of high availability, flexibility, and efficiency. In rapidly expandingmetropolitan cities like New York City (NYC), taxi plays an increasingly importantrole in the public transportation system. According to NYC TLC, there are morethan 450,000 passengers taking medallion taxi per day, which equals to about 180million trips per year [NYCTLC, 2014a]. Due to the great demands of taxi service,the number of licensed taxis has been increasing stably for years. However, it is be-coming harder for conventional taxi drivers to survive in this market in recent yearssince they are facing the pressure from both the increasing price of medallion licenseand the competition with Internet-based ride-hailing companies, like Uber and Lyft.Conventional taxis drivers are now in urgent need of better working strategies inorder to adapt themselves to such a competitive market.

Taxi strategies mainly refer to passenger-delivering strategy and passenger-seekingstrategy here, which are vital factors that might influence drivers’ revenue. It is be-lieved that better strategies could reduce unnecessary time consumption and fuelcost for drivers, and therefore improve their working efficiency and revenue. Nowa-days, passenger-delivering strategies are mostly dominated by navigation softwarelike Google Maps, while the passenger-seeking strategies of conventional drivers arestill of vast difference with that of drivers from Uber and other ride-hailing serviceproviders. Unlikely passenger-oriented Uber drivers, conventional taxi drivers haveto cruise on the road and search for the next passenger. Most of them operate de-pending on their personal experiences and preferences rather than settled strategies,which makes them less competitive than those ride-sourcing drivers. Thus, we believethat taxi drivers must adopt some more reasonable and reliable passenger-seeking

1

Page 14: Taxi Service Strategy Optimization with Data Clustering ... · with Data Clustering and Markov Decision Processes Kexin Zhang A report submitted for the course COMP4650 Advanced Computing

2 Introduction

strategies that could improve their working efficiency as well as profitability.In this research, we would like to provide conventional taxi drivers with optimal

passenger-seeking strategies. The strategies will be given in two stages. In the firststage, we would like to figure out hot spots of pick-ups at different times of a daythrough traffic flow extractions. However, this could only provide drivers with moreimmediate opportunities for finding a passenger but not guarantee that they couldearn more money in the long run. Thus, we develop the second stage of strategies,providing optimal strategies aiming at maximum expected revenue. The MarkovDecision Process (MDP) frameworks are adopted in this stage.

1.2 Problem Formulation

The main objective of this project is to identify operational strategies for taxi driversthat could improve their profitability. There are several questions that we need totake into consideration before modelling the optimal strategies.

1. How to partition traffic zones?

Traffic zones are the basis of the strategy-modelling part. The size of eachtraffic zone cannot be too large or too small. If the zone is too large (e.g., aneighborhood), drivers may feel confused about where to go. Otherwise, if thezone is too small (e.g., a junction), drivers may receive updated instructionsfrequently. In addition to that, we hope that zones are aggregations of pick-upsand drop-offs points. Thus, we need to take both theory and practicality intoconsideration when partitioning the traffic zones. K-Means clustering approachis applied to solve this problem novelly.

2. Immediate profit or long-term profit?

Some taxi drivers tend to roam at regions where they are more likely to find apassenger, so-called "popular regions", after dropping the previous passenger.They believe that going to popular regions may increase their profits by pickingup the next passenger quickly. Thus, we generate the first-stage strategy thatleads them to regions with high pick-up probability.

However, we do not know whether going to popular regions could also improvethe long-term profit. Hence, we generate a second-stage strategy that aims ata higher revenue. These two strategies will be evaluated together by theirlong-term revenue in this thesis.

3. Why use MDP?

The taxi roaming process can be reduced to a simplified Markov DecisionProcess (MDP).

MDP is a stochastic model that consists of a set of states and a set of possibleactions for each state. The state of the agent will be updated every time when ittakes an action with a certain reward.

Page 15: Taxi Service Strategy Optimization with Data Clustering ... · with Data Clustering and Markov Decision Processes Kexin Zhang A report submitted for the course COMP4650 Advanced Computing

§1.3 Project Scope 3

In this case, the taxi is the agent. Its state could be simplified and then describedby two factors, i.e., its location and the current time. The possible action forit is to go to one of the neighbour regions or roam in the current region. Theupdated state of the taxi (i.e., the new location, the time it finishes the action)will totally depend on its previous state and the action it chose, which followsthe Markov property. The details of MDP will be introduced in Chapter 6.

4. How to solve the MDP?

The aim of the model is to generate optimal passenger-seeking strategies for taxidrivers with the maximum expected revenue, which is the sum of the immediaterevenue of the action and the downstream expected revenue. Considering thatthe expected revenue for a taxi is related to not only the current state, butalso the downstream actions, we employ dynamic programming to calculatethe expected revenue for each pair of state and action from the ending of theworking duration backward to the beginning.

1.3 Project Scope

The critical parts of implementation are listed as follows: traffic zones partition, trafficflows extraction, and optimal strategies modelling using MDP.

The first part, traffic zone partition, is the basis of the following two parts. Inthis part, we novelly apply the K-Means clustering to divide geographic locationsof the study area into many small zones. All suggestions for drivers (i.e., where togo to search for passengers) will base on these traffic zones. The main challenge ofthis part is how to determine the optimal value of K. Three cluster validity measures,Silhouettes Coefficient, Calinski-Harabasz Index, and Sum of Squared Errors (SSE)are used to help us make the decision.

The second part is to extract traffic flows from trip data. We firstly build apassenger transition network and then extract the most popular traffic flows. Byunderstanding passengers’ mobility patterns, drivers could infer the hot spots tofind passengers at different times (e.g., residences at weekday mornings, offices atweekday evenings, etc.). The main challenge of this part is how to classify regions.Here we adopt density-based clustering methods to select the most popular junctionsand label them by their primary functions. Then, each traffic zone is classified basedon labelled junctions within it.

In the last part, the passenger-seeking problem is modeled as an MDP of whichparameters are extracted from the taxi trip data. Optimal strategies are computedusing dynamic programming. The effectiveness of optimal strategies is evaluated bycomparing its expected revenue with historical income data of taxi drivers. The mainchallenge of this part is how to construct MDP parameters (e.g., passenger pick-upprobabilities, passenger transition probabilities, objective function, etc.) from the rawdata, where a large amount of computation is needed.

Page 16: Taxi Service Strategy Optimization with Data Clustering ... · with Data Clustering and Markov Decision Processes Kexin Zhang A report submitted for the course COMP4650 Advanced Computing

4 Introduction

1.4 Report Outline

The remainder of this thesis is organised as follows. Chapter 2 reviews related re-searches. Chapter 3 introduces the NYC taxi dataset. Chapter 4 partitions trafficzones. Chapter 5 classifies clusters and build the passenger transition network. Chap-ter 6 proposes the Markov Decision Process model. Chapter 7 concludes this thesis,discusses limitations and future works.

Page 17: Taxi Service Strategy Optimization with Data Clustering ... · with Data Clustering and Markov Decision Processes Kexin Zhang A report submitted for the course COMP4650 Advanced Computing

Chapter 2

Literature Review

In this chapter, we review some related works of this project.

Taxis in urban areas are mostly equipped with GPS sensors, which collect a greatamount of taxi location data. A number of researches aim at investigating hot spotsof pick-up and drop-off events and exploring human mobility patterns by mining thetaxi trajectories. Clustering approaches are mostly employed to detect hot spots ofcities [Andrienko et al., 2009; Pei et al., 2015; Rajput et al., 2017; Zhao et al., 2017].Based on the hot spots detection results, some researches move forwards to miningtrip patterns and analysing drivers’ strategies. Li et al. first extracted popular areasof pick-ups and drop-offs and then studied the dynamic flows of passengers in theseareas. They also classified existing passenger-seeking strategies by their efficiency andeffectiveness [Li et al., 2011]. Chen et al. constructed taxi optional networks of whichnodes were all popular pick-up locations extracted from Chicago taxi trip data. Theyanalysed the relation between the supply and demand of taxis based on the network.They also observed the behaviours of taxis and attempted to link drivers’ workingperformance to their behaviour patterns [Chen et al., 2018]. However, these researchesmostly focus on classifying drivers’ strategies and predicting their performance ratherthan giving out practical suggestions to them.

Modelling efficient taxi service strategies (i.e., where they are likely to find the nextpassenger, how to seek and deliver passengers efficiently) is another popular topic.Liu et al. attempted to find out preferred pick-up locations from those successfuldrivers’ behaviour patterns [Liu et al., 2009]. Rong et al. attempted to optimize drivers’passenger-searching strategies based on their hot spots detection results [Rong et al.,2017]. Powell et al. suggested that taxi drivers need to reduce their cruising distancefor better profitability [Powell et al., 2011] , while Yuan et al. focused on not onlycruising distance but also roaming times. They found that drivers with relativelyhigher working efficiency (i.e., shortening their waiting time and miles) would bemore likely to gain a higher profit [Yuan et al., 2012]. We notice that shorteningroaming time is regarded as a critical point in a number of researches, so the roamingtime will also be paid special attention to in our research. We also notice that all theseresearches depend heavily on the behaviour patterns of those successful drivers, butwe would like to develop a method that depends on all trip data but not data of aspecific group of drivers.

5

Page 18: Taxi Service Strategy Optimization with Data Clustering ... · with Data Clustering and Markov Decision Processes Kexin Zhang A report submitted for the course COMP4650 Advanced Computing

6 Literature Review

We finally adopt MDP frameworks to solve the vacant taxi routing problem aimingat maximizing the total expected revenue. One challenge here is how to decide theaction sets. In some previous works, some researchers divided the study area intoa number of grids equally, and taxis would move between grids [Rong et al., 2016;Li et al., 2017]. However, this partitioning method is of little semantic meaning.Other researches use road segments or OpenStreetMap nodes to represent actions[Tseng et al., 2019; Tang et al., 2013], but the suggested action is considered to be toodetailed. The problem is that if the action area is too large (e.g., district zones), thetaxi may spend extra time roaming. Otherwise, if the action region is too small (e.g.,intersections), the suggested region will be updated frequently. Thus, we will payspecial attention to the partition problem in our research.

Page 19: Taxi Service Strategy Optimization with Data Clustering ... · with Data Clustering and Markov Decision Processes Kexin Zhang A report submitted for the course COMP4650 Advanced Computing

Chapter 3

Data

In this chapter, we will give a brief introduction to the dataset and the process of howwe pre-processed the data.

3.1 Dataset

This research is based on the yellow taxi trip dataset collected by NYC TLC. Thedataset records medallion, hack license, vendor ID, rate code, pick-up time and drop-off time, the number of passengers, trip time in seconds, driving distance, pick-upand drop-off locations for each trip [NYCTLC, 2014b]. Table 3.1 presents attributesthat are used in this research:

Table 3.1: Attributes used in this project.

Attribute Description

Medallion Distinct ID for each taxi.

Pick-up time/Drop-off Time Data and time when the trip starts/ ends.

Trip Distance Distance of the trip in miles.

Pick-up/Drop-off Location GPS coordinates of pick-up/drop-off locations.

We use the data of March when there is no big event or public holiday thatmight influence passengers’ trip patterns significantly. 13,455 taxis’ trajectory data isinvolved in this research.

3.2 Data Pre-processing

3.2.1 Study Area: The island area of Manhattan

The heat maps of pick-up and drop-off locations in NYC are presented in Figure 3.1.Although yellow taxis are free to search for passengers anywhere in all boroughs inthe city, about 90% of pick-ups and more than 75% of drop-offs are operated in theManhattan island. Considering we need enough data to extract MDP parameters

7

Page 20: Taxi Service Strategy Optimization with Data Clustering ... · with Data Clustering and Markov Decision Processes Kexin Zhang A report submitted for the course COMP4650 Advanced Computing

8 Data

(e.g., the driving speed network) later, we would like to focus on where pick-ups anddrop-offs are denser, which is the island area of Manhattan.

Figure 3.1: Heat maps of pick-up and drop-off events in NYC.

To extract trip data of Manhattan from all data of NYC, we allocate each data pointto its nearest OpenStreetMap (OSM) node in NYC. Then we check if this node belongsto the map of Manhattan. Therefore, we obtained the data of trips in Manhattan.

3.2.2 Outlier Detection

We notice that there are some outliers located outside the map. These errors arepossibly caused by satellite positioning, equipment failures, and operational mistakes.It is necessary to remove these outliers to improve the data quality. Our solution isto divide the NYC into many 100m * 100m grids. Then, we allocate all OSM nodesof Manhattan into these grids. For each recorded location, we firstly find the grid itbelongs to by its GPS coordinates. If there is no OSM node in that grid, it could beregarded as an outlier, and then the row containing this point will be discarded. Bydoing so, we removed most of the outliers.

3.2.3 General Data Pre-processing

Some general data pre-processing operations are taken. The pick-up/drop-off time isconverted to an integer from 0 to 1439 for each day. The location is described by a pairof coordinates of latitude and longitude in six decimal places. Rows with irregularities(e.g., missing attribute values, values in wrong data type) are also filtered out.

3.3 Summary

In this chapter, we introduce the taxi trip dataset and the pre-processing operationsthat are applied. Clustering approaches will be implemented on the pre-processeddata in the next chapter.

Page 21: Taxi Service Strategy Optimization with Data Clustering ... · with Data Clustering and Markov Decision Processes Kexin Zhang A report submitted for the course COMP4650 Advanced Computing

Chapter 4

Traffic Zones

In this chapter, we divide the island area of Manhattan into a number of small trafficzones by applying the K-Means algorithm.

4.1 Design

The study area (i.e., Manhattan island) will be divided into many small zones, whichare the basis of the following strategy-modelling sections. The size of these zonescannot be too small or too large. The reason is that small traffic zones, like theoriginal meter-level coordinates or OSM nodes, are too detailed, and therefore couldhardly lead us to some comprehensive conclusions of traffic patterns. On the otherhand, strategies based on large zones, like district zones, might confuse drivers. Forexample, drivers might be confused about where to go when they are suggested togo to the Financial District. Thus, we need to take both theory and practicality intoconsideration when dividing the traffic zones.

We propose clustering approaches to partition traffic zones. Both the centroidmodel (i.e., K-Means) and density model (i.e., DBSCAN) are tested. The advantage ofK-Means clustering methods is that it considers all data points, while extra efforts areneeded to find the optimal K. By contract, density-based clustering will select onlypopular regions, but it fails to consider data points without clusters. Given that thereare not absolute hot spots, we decide to apply K-Means clustering here.

4.2 Methodology

4.2.1 K-Means

The objective of the K-Means algorithm is to partition the input samples into Kclusters [Macqueen, 1967]. The cluster centroid is defined as the mean of data pointswithin this cluster. There are three steps of the algorithm. Firstly, initialize the clustercentroids randomly. Secondly, assign all input samples to their nearest centroids.Thirdly, recalculate the centroid of each cluster. The second and third steps will berepeated until the value of the objective function is lower than a certain tolerance orall iterations are completed.

9

Page 22: Taxi Service Strategy Optimization with Data Clustering ... · with Data Clustering and Markov Decision Processes Kexin Zhang A report submitted for the course COMP4650 Advanced Computing

10 Traffic Zones

In a formal way, the K-Means procedure can be presented as follow:

Algorithm 1 Basic K-Means Algorithm

1: Initialize k centroids randomly.2: Repeat3: Assign each data point to its nearest cluster.4: for Each cluster Cj do5: Update the cluster centroid by the mean of data points within Cj.6: end for7: Until Converged.

4.2.2 Optimal K

The main challenge of implementing the K-Means is how to determine the value of K.We assume that regions with highly dense data points are separated by those of lowerdensity, and therefore we hope to valid the tightness with clusters and separation levelbetween clusters [Liu et al., 2010]. Three cluster validity measures (i.e., SilhouetteCoefficient, Calinski-Harabasz Index, Sum of Squared Errors) are used to find theappropriate K value.

• Silhouette Coefficient

Silhouette Coefficient is a method to measure the consistency of points within acluster defined by [Rousseeuw, 1987]. For each data point i , a certain silhouettevalue is calculated by

s(i) =b(i)− a(i)

max[a(i), b(i)]

where a(i) represents the dissimilarity between i and other objects within the samecluster and b(i) represents the similarity between i and neighbor clusters. And theSilhouette Coefficient is calculated by the mean of silhouette values. The dissimilaritybetween i and the other objects within the cluster could be calculated as follows:

a(i) =1

|Ci| − 1 ∑j∈Ci(i 6=j)

dist(i, j)

and the similarity between i and neighbor clusters could be calculated as follows:

b(i) = min1|Ck| ∑

j∈Ck

dist(i, j)

where dist(i, j) represents the distance between data point i and j.The Silhouette Coefficient is expected to be as large as possible in the range

between -1 and 1, which means that data points of the same cluster are more similar.

• Calinski-Harabasz Index

Page 23: Taxi Service Strategy Optimization with Data Clustering ... · with Data Clustering and Markov Decision Processes Kexin Zhang A report submitted for the course COMP4650 Advanced Computing

§4.3 Results 11

Calinski-Harabasz Index is another clustering validation measure that emphasizeboth compactness and separation [Calinski and JA, 1974]. It is calculated by the traceof Between-Cluster Scatter Matrix (BCSM) and that of Within-Cluster Scatter Matrix(WCSM) as follows:

CHk =tr(BCSM)

k− 1· n− k

tr(WCBM)

=∑k

k0=1 ∑c0∈Ckdist(c0, ck)

2

k− 1· n− k

∑kk0=1 nkdist(c0, ck)2

(4.1)

where n is the number of inputs, k is the number of clusters, and ck is the centroid ofcluster Ck. Larger values are preferred for better clustering results.

• Sum of Squared Errors (SSE)

We also calculate Sum of Squared Errors (SSE) to evaluate different values of K.Although SSE, i.e., SSE = ∑k

k0=1 ∑c0∈Ckdist(c0, ck)

2, is calculated as a part of Calinski-Harabasz Index, we still evaluate it separately as it could show the quality of clus-tering directly as the cost function of K-Means. According to the Elbow method, weare suggested to choose the K value so that adding more clusters does not give muchbetter results [Ketchen and Shook, 1996].

4.3 Results

4.3.1 K value

Figure 4.1 presents scores of three methods with the value of K ranging from 100 to600 with an interval of 50. K values larger than 350 are acceptable with the slowinggrowth of Silhouette Coefficient, and the preferred values indicated by the Calinski-Harabasz Index are larger than 450. The SSE indicates that K values larger than500 are acceptable since the curve tends to be flat. Taking all three criterions intoconsideration, we set the K value as 500.

Figure 4.1: Three cluster validity measures applied to determine the optimal k.

Page 24: Taxi Service Strategy Optimization with Data Clustering ... · with Data Clustering and Markov Decision Processes Kexin Zhang A report submitted for the course COMP4650 Advanced Computing

12 Traffic Zones

4.3.2 Comparison with Other Partition Methods

As mentioned in Chapter 2, previous researches mostly use grids, OSM nodes, androad segments as action units. The gird partition method is the easiest and the mostcommon-used one, but it fails to consider semantic meaning. An aggregation ofpick-up locations is possibly separated into two grids roughly. On the other hand,the latter two methods attempt to take the road connectivity into consideration, butthey are likely to give over-detailed instructions. For example, the shortest distancebetween two nodes in OSM is about 10 metres. It is meaningless for a taxi to drive toa region that only 10 metres away to find a passenger in real life.

Compared with above three methods, K-Means clustering takes both semanticmeaning and practicality into account. Figure 4.2 presents the execution results of theK-Means procedure with k ranging from 100 to 500 with an interval of 100. We caninfer that the clusters are more likely to be dense in the zones where the pick-up anddrop-off events are active (e.g., Lower Manhattan). This would be beneficial to ourresearch since the instructions for drivers would be more detailed in high-demandareas, but give drivers more space to roam in low-demand areas. Therefore we adoptthe results of K-Means clustering for traffic zone partition.

Figure 4.2: Cluster heads with different K

Clustering results are of great occasionality since the initial cluster centroids arechosen randomly. To reduce the occasionality as much as possible, we implementK-Means 10 times with the same input data and retain the result with the lowest SSE.

4.4 Summary

In this chapter, we apply the K-Means algorithm to partition the Manhattan island into500 small clusters based on geographic locations. Clusters will be used to constructthe passenger transition network in the next chapter.

Page 25: Taxi Service Strategy Optimization with Data Clustering ... · with Data Clustering and Markov Decision Processes Kexin Zhang A report submitted for the course COMP4650 Advanced Computing

Chapter 5

Traffic Flows

It is common knowledge that people mostly travel from their home to workplacesin the morning and go back home after working, but we can hardly affirm that taxipassengers also follow this pattern without research. In this section, I first constructtime-dependent passenger transition networks and extract some popular traffic flows.Then I classify each traffic zone by its primary usage. Thus, we could figure outthe semantic meanings of those flows, and infer the passenger mobility patterns. Inaddition to that, we could provide taxi drivers with suggestions about where they aremore likely to find a passenger at a given time based on the transition networks.

5.1 Design

Firstly, we construct time-dependent passenger transition networks, where each noderepresents a traffic zone. Then, we attempt to extract the most popular regions andtraffic flows. However, we can hardly figure out the semantic meanings of theseflows without knowing the primary function of these zones. Labelling these zonesis the main challenger of this part. In this case, each traffic zone covers at least twoblocks and a number of buildings of various usages, so it would be hard for us tolabel them directly. The solution is to select the most popular spots by applyingDensity-Based Spatial Clustering of Applications with Noise (DBSCAN) and labelthem with their main usages (i.e., residence, office, facilities, transportation junctions,and entertainment places). This would be much easier than labeling a region directlysince we only need to think about the usage of one or two buildings. After that, eachregion is classified based on the labeled hot spots within it.

5.2 Methodology

5.2.1 DBSCAN

We select hot spots by applying DBSCAN. The algorithm assumes that clusters arehighly dense regions in space separated by regions of lower density. It works byfinding dense areas first and expanding them recursively to build shaped clusters[Ester et al., 1996]. Here we use pick-up and drop-off locations as input samples, set

13

Page 26: Taxi Service Strategy Optimization with Data Clustering ... · with Data Clustering and Markov Decision Processes Kexin Zhang A report submitted for the course COMP4650 Advanced Computing

14 Traffic Flows

the distance threshold, eps, at a relatively small value and the minimum number ofdata points required for forming a cluster, minp, at a relatively high large value. Forlarge clusters, DBSCAN will be implemented again within the cluster. Therefore wecould get separate spots with high-density of data points.

The algorithm could be presented in a formal way as follow[Ester et al., 1996]:

Algorithm 2 DBSCAN

1: for Each unvisited data point p ∈ dataset D do2: Mark p as visited.3: N ← Neighbors(p, eps)4: if | N | < minp then5: Label p as a noise point.6: else

C ← { x }7: for each point p′ ∈ N do8: N ← N p′

9: if p′ has not been visited then10: Mark p′ as visited11: N′ ← Neighbors(p′, eps)12: if |N | ≥ minp then13: N ← N

⋃N′

14: end if15: end if16: if p′ does not belong to any cluster then17: C ← C

⋃p′

18: end if19: end for20: end if21: end for

5.2.2 Traffic Zone Labeling

All hot spots selected in 5.2.1 will be labeled by their main function as follows:

1. Residential area: apartments and residences.

2. Offices: Office buildings.

3. Facilities: hospitals, schools, libraries, etc.

4. Entertainment places: shopping malls, clubs, theatres, etc.

5. Transportation junctions: train stations, bus terminals, etc.

I classify the cluster by the labelled hot spots within it. Firstly, I assign each hotspot to the cluster it belongs to. For each cluster, I calculate the relative proportion of

Page 27: Taxi Service Strategy Optimization with Data Clustering ... · with Data Clustering and Markov Decision Processes Kexin Zhang A report submitted for the course COMP4650 Advanced Computing

§5.3 Results 15

each type (i.e., the proportion of that type within the cluster divided by the overallproportion of that type). Clusters will be labelled by the dominant type.

5.3 Results

5.3.1 Labeling Result

We apply the DBSCAN algorithm iteratively, select 1038 hot spots, and label themby their primary function. Figure 5.1(b) indicates that most office buildings are laidin Lower Manhattan, especially, Demand District and Financial District, which arebusy areas of business and social activities. Residences are most in Upper Manhattanand around Central Park. Red regions, standing for transportation junctions, indicatesome well-known transportation junctions, like Pennsylvania Station. Based on thesehot spots, we classify the traffic zones, and the classification result is shown in thethird diagram.

Figure 5.1: Traffic zones, hot spots, and labeling results

5.3.2 Traffic Flows

Combined the labelling results and passenger transition networks, we could extractthe most popular traffic flows to see the passenger mobility patterns at different timesof a day. Understanding these patterns could help taxi drivers to find passengerswith fewer efforts. I select three peak durations, weekday morning, weekday eveningand weekend evening , for research.

Page 28: Taxi Service Strategy Optimization with Data Clustering ... · with Data Clustering and Markov Decision Processes Kexin Zhang A report submitted for the course COMP4650 Advanced Computing

16 Traffic Flows

Figure 5.2 presents the top 50 flows of different durations. Nodes on both sides ofthe Sankey diagram represent the traffic zones, and the color of the node representsthe type of that zone. The linking edges indicated trips, directed from left to right,with the weight of each edge representing the number of trips.

Figure 5.2: Typical Traffic Flows

In the weekday morning peak, pick-up events are frequent around residentialareas, and offices are the most popular destinations, which is due to the high demandfor commuting in the morning. Transportation junctions are popular and will bealways popular at all three durations.

In contrast, offices tend to be origins, while residential areas tend to be destina-tions in the weekday evening peak. Trips around transportation junctions are not aspopular as in the morning, but they are also in the top 50 traffic flows.

On weekend evenings, offices are not likely to be popular. Almost all these fre-quent routes are around residential areas, transportation junctions, and entertainmentplaces. The pick-up and drop-off events around entertainment places take a largerproportion during this duration.

Understanding the route patterns can help taxi drivers to find appropriate loca-tions to seek passengers (e.g., going to a business area rather than residences in theevening peak) in real world. These patterns are almost the same as the commonknowledge, but give out more specific locations. In addition to that, we could gen-erate the first-stage strategy for taxi drivers based on passenger transition networks,which is to going to the neighbour region with the highest pick-up probability. Theperformance of this strategy will be evaluated along with the optimal strategy ofMDP later in section 6.3.

5.4 Summary

In this chapter, we construct time-dependent passenger transition networks, whichcould provide drivers with guidance to locally popular regions. We extract the mosttraffic flows to see passenger mobility patterns. The passenger transition networksextracted would also be an essential parameter in the MDP model.

Page 29: Taxi Service Strategy Optimization with Data Clustering ... · with Data Clustering and Markov Decision Processes Kexin Zhang A report submitted for the course COMP4650 Advanced Computing

Chapter 6

Markov Decision Process

In this chapter, we model the optimal taxi passenger-seeking strategies by MarkovDecision Process (MDP). The objective of this model is to provide taxi drivers withstrategies that are likely to increase their long-term revenue. Then we evaluate thecomputerized strategies with historical profit data.

6.1 MDP Model

MDP is a stochastic model that consists of a set of states (S) and a set of possibleactions (A) for each state. The agent’s state will be updated every time when it takesan action, and it will also receive a reward for the action. The collection of optimalactions that could lead agent to a maximum total reward is called policy π. Theobjective of our model is to select optimal action for each possible state of the taxi aswell as generate the optimal policy with maximum total reward.

A. StatesThe state of a taxi could be simplified and described by two essential factors, the

location of the taxi and the current time.

• Location of the taxi l ∈ L = {0, 1, ..., k − 1.}: the traffic zones we partitionedusing the K-Means algorithm. K is set at 500 in this case.

• Current time t ∈ T = {0, 1, ..., n.}: Each time slot is one minute.

The state of the taxi is described by s = (l, t), and the set of all possible states forthe taxi is described by S.

B. Action SetThe possible action for a taxi is either roaming at the current zone or going to one

of the neighbour zones within the given distance, τ km. For example, a taxi in zone i,where i has 5 neighbour regions within τ km, has 6 possible actions. The action fromzone i to zone j is described by a = (i→ j), and the collection of all possible actions,when taxi is in region i at time t, is represented by A(i, t).

17

Page 30: Taxi Service Strategy Optimization with Data Clustering ... · with Data Clustering and Markov Decision Processes Kexin Zhang A report submitted for the course COMP4650 Advanced Computing

18 Markov Decision Process

C. State Transition Function

State transition function is used to describe the change of system state after anaction is taken. For example, the taxi’s state s = (i, t) will change to s′ = (j, t + Ti→j)after taxi taking an action a = (i → j) where ti→j is the time consumption of takingthis action. There are two possible outcomes of action a:

Figure 6.1: An illustration of the state transition process.

(1) The taxi picks up a passenger in region j with a certain possibility Ppick(j, t +Ti→j). Then the taxi will aim at the passenger’s destination k after picking up with apossibility Ptrans(j, k, t + Ti→j) . The state of the taxi will be updated again, after drop-ping off passengers, to s′′ = (k, t + Ti→j + Tj→k), where Tj→k is the time consumptionof traveling from j to k. And the reward for the driver is r = (j, k, t + Ti→j). The taxiwill start to deciding again at region k.

(2) The taxi fails to find a passenger in region j with possibility 1− Ppick(j, t+ Ti→j),then it will start to seek passengers again from region j at the current state s′ with adifferent action set A′(s′).

D. Objective Function

The agent in the MDP model chooses the action that maximizes the total expectedreward given its state. In this case, the taxi will take action that leads to higherexpected total revenue which is the sum of the immediate profit and the expecteddownstream profits. The objective function for a taxi at state s = (i, t) with an actiona is indicated in Eqn.6.1.

Page 31: Taxi Service Strategy Optimization with Data Clustering ... · with Data Clustering and Markov Decision Processes Kexin Zhang A report submitted for the course COMP4650 Advanced Computing

§6.1 MDP Model 19

R(s, a) = [1− Ppick(j, t + Ti→j)] ·maxRa′∈A′(s′)(s′, a′)

+ Ppick(j, t + Ti→j) ·∑l∈L

Ptrans(j, k, t + Ti→j) · [r(j, k, t + Ti→j + Tj→k) + maxRa′′∈A′′(s′′)(s′′, a′′)]

− Gcost(i, j)(6.1)

where

(1) s = (i, t), s′ = (j, t + Ti→j), s′′ = (l, t + Ti→j + Tj→k).

(2) Gcost(i, j) is the gas cost of driving from i to j.

E. Dynamic Programming Solution

Dynamic programming is adopted to calculate the rewards given state of the taxi.Then we can devise the optimal policy (i.e., a sequence of a finite number of strate-gies given the taxi state), π∗. The algorithm starts from the last minute of the givenduration (i.e., 2 hours in this case) and then traces backward to the first minute. Thealgorithm is listed formally in Algorithm 3.

Algorithm 3 Dynamic Programming Solution for MDP

1: for t = tend to t = 0 do2: for each region (i ∈ L) do3: ActSet← NeighborRegions(i)4: for each (j ∈ ActSet) do5: a∗max ← a with maximum R(s, a)6: π∗ ← a∗max7: R(s, a)∗ ← R(s, a∗max)8: end for9: end for

10: end for11: return π∗

F. Assumptions

The assumptions of the optimal taxi routing problems are:

(1) The optimal strategy is applicable for a single or a small number of taxis,which would not lead to intensified competition.

(2) When a taxi is occupied, the fuel cost and time consumption of the trip fromorigin to destination could be estimated from historical data.

(3) The time consumption of pick-up and drop-off processes will not be counted.

(4) Drivers always choose the shortest path regardless of occupied or not.

Page 32: Taxi Service Strategy Optimization with Data Clustering ... · with Data Clustering and Markov Decision Processes Kexin Zhang A report submitted for the course COMP4650 Advanced Computing

20 Markov Decision Process

6.2 MDP Parameters

In this section, we will introduce three kinds of parameters that are required in thisMDP model, namely time parameters, probability parameters and reward.

6.2.1 Time Parameters

To estimate the time consumption of driving between two locations, we need firstconstruct a time-dependent driving speed network based on historical trip data. Then,the driving time parameters, including actual driving time and idling time, can beestimated.

A. Driving Speed NetworkThe driving time consumption is highly dependent on the location and the time.

For example, the traffic condition in the city centre is likely to be poorer than that inthe outer city, and the average driving speed seems to be lower in rush hours in themorning or evening. Thus, we need to build a time-dependent driving speed networkto estimate driving time for taxis. One of the challenges that we are facing is that wedo not have the traces of taxis but only the origin and destination locations. Thus, weneed to model both the driving path and driving time consumption for each trip.

Figure 6.2: Traffic speed network.

We first model the driving path for each trip. We assume that the taxi will alwayschoose the shortest paths for higher delivering efficiency. Spatialite database andOpen Street Map (OSM) data are employed. For each pair of origin and destination,we assign them to their nearest OSM node. Then we can extract the shortest path

Page 33: Taxi Service Strategy Optimization with Data Clustering ... · with Data Clustering and Markov Decision Processes Kexin Zhang A report submitted for the course COMP4650 Advanced Computing

§6.2 MDP Parameters 21

between two nearest nodes, which is described by a list of road segments. We compareit with the distance of the trip recorded in the dataset. If the difference between thelength of the computed path and the recorded distance is significant, this record willbe discarded since the driver seems to take another path. Then, we assign the averagespeed calculated by the given distance and driving time to each road segment.

After enumerating all trip records in a one-hour time slot, each road segmentwill have a list of average speeds. The mean value of all average speeds is used todescribe the travel speed of that segment. Notice that different from the probabilitycalculation, the time slot we use to generate time parameters is one hour.

B. Driving Time ConsumptionAfter constructing the driving speed network, we could calculate three parameters

for each pair of origin node and destination nodes:

• Actual driving time Tact(Np → Nq, t)

This parameter is fully from the original data. In one hour, there might be severaltrips from between these two OSM nodes. The driving time is denoted by the meantravel time.

• Estimated driving time Test(Np → Nq, t)

For each pair of origin and destination nodes, we extract the shortest path betweenthem. And the estimated driving time is calculated by the sum of time consumptionfor passing all road segments in the shortest path. That is: Test(Np → Nq, t) =

∑seg∈path seg.length/seg.speed.

• Idling time Tidling(Np → Nq, t)

The idling time is calculated by the driving time minus the estimated driving time.This parameter is useful when calculating the fare of trips.

In consideration that this MDP is zone-based rather than node-based, we need tocalculate time parameters, i.e., actual driving time, estimated driving time, and idlingtime, for each pair of traffic zones. All origin and destination locations are firstlyassigned to their corresponding clusters. Then, for each pair of clusters, we have a listof actual driving time and a list of estimated driving time if there are trips betweenthem. The actual driving time between two clusters is denoted by the median of thelist of actual driving time. The estimated driving time follows a similar pattern.

6.2.2 Probability Parameters

A. Passenger Pick-up ProbabilityPassenger pick-up probability Ppick(i, t) is the probability of a taxi could find a

passenger in region i at time t. It can calculated by the number of pick-ups (i.e.,demand) divided by the total number of available taxis (i.e., supply) in nearby areas.

Page 34: Taxi Service Strategy Optimization with Data Clustering ... · with Data Clustering and Markov Decision Processes Kexin Zhang A report submitted for the course COMP4650 Advanced Computing

22 Markov Decision Process

Considering that in more than 50% cases, drivers spend less than three minutes roam-ing, the pick-up probability is calculated with a three-minute time slot. Therefore,itcan be denoted by:

Ppick(i, t) =Npick(i)

t:t+2

Npick(i)t:t+2 + Np

drop(i)t−2:t+2

where(1) Npick(i)

t:t+2 is the total number of pick-ups in region i between time t and t + 2.

(2) Ndrop(i)t−2:t+2 is the number of drop-offs in region i and its neighbour regions from

time t− 2 to t + 2.The pick-up probability is estimated by the pick-ups and drop-offs of the histor-

ical data, but fails to take taxis’ real-time traces into consideration, so it could beimproved if we have more accurate data.

B. Passenger Transition ProbabilityPassenger transition probability Ptran(i, j, t) describe the probability that a passen-

ger travels from i to j at time t. The transition probability matrix could be extractedfrom the passenger transition network in Chapter 5.

6.2.3 Reward Calculation

A. Gas CostThe gas cost Gcost is the cost of gas consumed from region i to j. It is estimated by

the driving distance, average speed and the gas price.

B. Immediate RewardThe reward r(i, j, t) is the profit of the trip from region i to j at time t. It is

calculated by subtracting the gas cost, Gcost(i, j), from the received fare, Fare(i, j, t),where the received fare is estimated following the surcharge rules of NYC taxi.

r(i, j, t) = Fare(i, j, t)− Gcost(i, j)

= 2.5 + Dist(i, j) · 2.5 + Tidling(i→ j, t) · 0.5 + scgt − Gcost(i, j)(6.2)

where(1) Dist(i, j) is distance of driving from region i to region j.(2) scgt is the time-dependent surcharge.

6.3 Evaluation

In this section, two approaches are used to evaluate the MDP model. The first oneis to compare the expected revenue calculated by the MDP model with the historical

Page 35: Taxi Service Strategy Optimization with Data Clustering ... · with Data Clustering and Markov Decision Processes Kexin Zhang A report submitted for the course COMP4650 Advanced Computing

§6.3 Evaluation 23

income data of taxi drivers. Another one is to compare it with the expected revenueof the other two strategies.

6.3.1 Comparison with Historical Income Data

In this part, we first calculate the hourly revenue of taxi drivers from the historicaldata. The hourly revenue for peak hours (i.e., weekday morning, weekday evening,and weekend evening) is higher than that for the whole day. Taking weekday eveningas an example, the median of hourly revenue for this duration is USD$27.33, whilethat for the whole day is USD$23.76. The possible reason is that the demand is largeduring peak hours, and taxi drivers are more likely to find a passenger. Thus, wecould infer that the revenue of this duration is necessary for the whole day profit.Therefore, we generate optimal strategies by MDP for these three durations, expectingit could lead drivers to higher revenue.

Figure 6.3 presents the distribution of hourly revenue for the three durations,where the blue line presents the median hourly profit of drivers, and the red onepresents the expected revenue of drivers following MDP strategies. We observe thatmore than 60% of taxi drivers earn USD$15 to USD$35 per hour during the peakhours, but the expected revenue would likely increase to the top 5% if they werefollowing the optimal strategies.

Figure 6.3: Hourly revenue for different durations.

However, in the real world, many factors may influence taxi drivers’ performance.Thus, we attempt to evaluate the performance of the optimal MDP strategy with otherstrategies.

6.3.2 Comparison with Other Strategies

In this part, we model the behaviors of drivers following three different strategies,which are random run, going to popular zone, MDP optimal strategies.

1. Random Run. The taxi driver chooses one of the neighbour regions (includingthe current region) randomly. The taxi driver could also be regarded withoutany fixed strategies.

Page 36: Taxi Service Strategy Optimization with Data Clustering ... · with Data Clustering and Markov Decision Processes Kexin Zhang A report submitted for the course COMP4650 Advanced Computing

24 Markov Decision Process

2. Popular Zone. The popular zone is defined as the region with the highest pick-up probability among all neighbour regions. The popular zone may be changedalong with time.

3. MDP Optimal Strategy. For each possible state, there is an specific instructionfor the taxi. The taxi always follows the strategies given by the MDP model.

There is no fixed action in the random run strategy, but in the other two strategies(i.e., going to popular zone and MDP optimal strategy), there is only one suggestedaction for each possible state. We first generate the suggested action for each possiblestate in these two strategies, respectively. Then, we model the actions of drivers. Ifmore than 70% of actions of a driver are the same with the suggested actions in goingto popular zone or MDP optimal strategy, he will be classified as drivers followingthat strategy. Otherwise, he will be classified as drivers following a random runpolicy.

Figure 6.4: Hourly revenue for different durations.

Figure 6.4 presents the the revenue distribution of drivers following differenttypes of strategies. Although there are lucky drivers in all three groups who earnmuch more than the median, the overall performance of drivers following the MDPstrategies is better than that of the other two groups. Therefore, we can infer that forthose taxi drivers want to any of the pure strategies, it would be better to follow theMDP optimal strategy.

We also observe that taxi drivers who prefer popular zones earn almost the samewith drivers without fixed strategies. In the real-life, a large number of drivers tendto go to popular regions to search for passengers, believing that they would makemore money by picking up quickly. However, this may be an illusion. This methodmay increase the immediate profit by finding passengers quickly, but little evidenceshows that it could benefit in the long run. In addition to that, we also present theexpected revenue calculated by the MDP model (See Figure 6.5). We can see thatthe popular regions in lower Manhattan are not outstanding regarding the expectedrevenue. By contrast, some regions in Upper Manhattan are likely to lead drivers tohigher revenue. Thus, we can infer that there is no necessary connection betweengoing to popular regions and higher revenue. Drivers are suggested to follow theoptimal strategies.

Page 37: Taxi Service Strategy Optimization with Data Clustering ... · with Data Clustering and Markov Decision Processes Kexin Zhang A report submitted for the course COMP4650 Advanced Computing

§6.4 Summary 25

Figure 6.5: Expected revenue.

However, there is a critical assumption of this model, that the number of taxisfollowing the optimal policy is not very large. Otherwise, they are likely to rushinto the same region at one time, which is not realistic. This will also influence therelation between the demand and supply of taxis in that region, and then the pick-upprobability will change, and the expected revenue will change as well. Therefore, itis assumed that the number of taxis following the MDP strategies is not so large thatit might influence the pick-up probability of that region.

6.4 Summary

In this chapter, we build an MDP model. All parameters used to build this model isextracted from the historical trip data. Dynamic programming is applied to extractthe optimal policy for MDP. For each pair of state and action, we calculated theexpected revenue, and therefore we could obtain the suggested strategy for eachpossible state. The result of MDP model is evaluated in two approaches; one isto compare the expected revenue of MDP with the historical income data of taxidrivers, and the other is to compare its performance with that of other strategies. Thecomparison results indicate that following the optimal policy of MDP could indeedincrease drivers’ revenue. In addition to that, it performs better than the other twostrategies (i.e., going to popular regions, random run). Moreover, going to popularregions could only increase the immediate profit but not be beneficial in the long run.

Page 38: Taxi Service Strategy Optimization with Data Clustering ... · with Data Clustering and Markov Decision Processes Kexin Zhang A report submitted for the course COMP4650 Advanced Computing

26 Markov Decision Process

Page 39: Taxi Service Strategy Optimization with Data Clustering ... · with Data Clustering and Markov Decision Processes Kexin Zhang A report submitted for the course COMP4650 Advanced Computing

Chapter 7

Conclusion

In this thesis, we study the taxi passenger-searching strategy optimization problem.A case study based on the NYC yellow taxi trip dataset is implemented in this thesis.We attempt to provide taxi drivers with better passenger-seeking strategies. Theoptimal strategies are given in two stages. In the first stage, we figure out somepopular regions and traffic flows. We find that different kinds of functional regionsare popular at different times of the day (e.g., residences at weekday mornings,offices at weekday evenings, etc.), and we are also able to lead taxi drivers to highpick-up probability regions based on passenger transition networks. However, thesestrategies may not lead to higher long-term profits for drivers. Thus, we employ theMDP framework to model the optimal strategies aiming at higher expected revenue.

The implementation of this project mainly consists of three parts, i.e., trafficzone partition, traffic flow extraction, and optimal strategies modelling. In the firstpart, We novelly apply K-Means clustering to partition the study area into 500 smallzones. The optimal K value, 500, is determined after we employ three criterions (i.e.,Silhouette Coefficient, Calinski-Harabasz Index, Sum of Squared Errors) to measurethe clustering quality. In the second part, we build a passenger transition network andextract the most popular traffic flows. We infer some mobility patterns of passengers,which are almost the same with our common knowledge. However, following thesestrategies could lead taxi drivers to higher pick-up probability rather than higher totalrevenue. Therefore, we adopt the MDP framework to model the optimal strategies.Dynamic programming is applied to extract the optimal strategies for MDP. For eachpair of state and action, we calculated the expected revenue, and therefore we couldobtain the optimal strategy for each possible state. The results of the MDP model isevaluated in two approaches; one is to compare the expected revenue of the optimalMDP policy with the historical profit data of taxi drivers, and the other is to compareit with other strategies. The comparison results indicate that following the optimalpolicy of MDP could increase drivers’ revenue. In addition to that, it performs betterthan the other two strategies (i.e., going to popular regions, random run).

27

Page 40: Taxi Service Strategy Optimization with Data Clustering ... · with Data Clustering and Markov Decision Processes Kexin Zhang A report submitted for the course COMP4650 Advanced Computing

28 Conclusion

7.1 Future Work

As we mentioned above, one of the most important assumptions of this model isthat the number of taxi drivers who follow the optimal strategies cannot be too large,which means that only a small number of drivers could be benefited by the optimalstrategies currently. Therefore, the future direction of this project is to solve themulti-taxi routing problem.

This problem could be solved by two approaches. The first one is to build adynamic MDP model that adopting the real-time data. Thus, the optimal strategieswill be updated frequently with some parameters, like pick-up probability, beingupdated. Another direction is to employ neural network models to learn the patternsof demand and supply of taxis from historical data, then predict the future demandsand provide guidance to drivers.

Page 41: Taxi Service Strategy Optimization with Data Clustering ... · with Data Clustering and Markov Decision Processes Kexin Zhang A report submitted for the course COMP4650 Advanced Computing

Bibliography

Andrienko, G.; Andrienko, N.; Rinzivillo, S.; Nanni, M.; Pedreschi, D.; and

Giannotti, F., 2009. Interactive visual clustering of large collections of trajectories.In 2009 IEEE Symposium on Visual Analytics Science and Technology, 3–10. doi:10.1109/VAST.2009.5332584. (cited on page 5)

Calinski, T. and JA, H., 1974. A dendrite method for cluster analysis. Communicationsin Statistics - Theory and Methods, 3 (01 1974), 1–27. doi:10.1080/03610927408827101.(cited on page 11)

Chen, Y.; Hyland, M. E.; Wilbur, M. P.; and Mahmassani, H. S., 2018. Characteri-zation of taxi fleet operational networks and vehicle efficiency: Chicago case study:.(cited on page 5)

Ester, M.; Kriegel, H.-P.; Sander, J.; and Xu, X., 1996. A density-based algorithmfor discovering clusters in large spatial databases with noise. 226–231. AAAI Press.(cited on pages 13 and 14)

Ketchen, D. J. and Shook, C. L., 1996. The application of cluster analysis in strategicmanagement research: An analysis and critique. Strategic Management Journal, 17, 6(1996), 441–458. http://www.jstor.org/stable/2486927. (cited on page 11)

Li, B.; Zhang, D.; Sun, L.; Chen, C.; Li, S.; Qi, G.; and Yang, Q., 2011. Hunting orwaiting? discovering passenger-finding strategies from a large-scale real-world taxidataset. In 2011 IEEE International Conference on Pervasive Computing and Communi-cations Workshops (PERCOM Workshops), 63–68. doi:10.1109/PERCOMW.2011.5766967.(cited on page 5)

Li, P.; Bhulai, S.; and van Essen, J., 2017. Optimization of the revenue of thenew york city taxi service using markov decision processes. In 6th InternationalConference on Data Analytics, Barcelona (Spain), November 12-16, 47–52. IARIA. (citedon page 6)

Liu, L.; Andris, C.; Biderman, A.; and Ratti, C., 2009. Revealing taxi driver’smobility intelligence through his trace. IEEE Pervasive Computing, 160 (01 2009),1–17. doi:10.4018/978-1-61520-769-5.ch007. (cited on page 5)

Liu, Y.; Li, Z.; Xiong, H.; Gao, X.; and Wu, J., 2010. Understanding of internalclustering validation measures. In 2010 IEEE International Conference on Data Mining,911–916. doi:10.1109/ICDM.2010.35. (cited on page 10)

29

Page 42: Taxi Service Strategy Optimization with Data Clustering ... · with Data Clustering and Markov Decision Processes Kexin Zhang A report submitted for the course COMP4650 Advanced Computing

30 Bibliography

Macqueen, J., 1967. Some methods for classification and analysis of multivariateobservations. In In 5-th Berkeley Symposium on Mathematical Statistics and Probability,281–297. (cited on page 9)

NYCTLC, 2014a. New york city taxi factbook. Website. https://www1.nyc.gov/assets/tlc/downloads/pdf/2014_tlc_factbook.pdf. (cited on page 1)

NYCTLC, 2014b. New york city yellow taxi trip data. Website. https://data.cityofnewyork.us/browse?q=yellow+taxi. (cited on pages v and 7)

Pei, T.; Wang, W.; Zhang, H.; Ma, T.; du, Y.; and Zhou, C., 2015. Density-based clus-tering for data containing two types of points. International Journal of GeographicalInformation Science, 29 (03 2015), 1–19. doi:10.1080/13658816.2014.955027. (cited onpage 5)

Powell, J. W.; Huang, Y.; Bastani, F.; and Ji, M., 2011. Towards reducing taxicabcruising time using spatio-temporal profitability maps. In Advances in Spatial andTemporal Databases, 242–260. Springer Berlin Heidelberg, Berlin, Heidelberg. (citedon page 5)

Rajput, P.; Toshniwal, D.; and Agggarwal, A., 2017. Improving infrastructure fortransportation systems using clustering. In Big Data Analytics, 129–143. SpringerInternational Publishing, Cham. (cited on page 5)

Rong, H.; Wang, Z.; Zheng, H.; Hu, C.; Peng, L.; Ai, Z.; and Sangaiah, A. K., 2017.Mining efficient taxi operation strategies from large scale geo-location data. IEEEAccess, 5 (2017), 25623–25634. doi:10.1109/ACCESS.2017.2732947. (cited on page 5)

Rong, H.; Zhou, X.; Yang, C.; Shafiq, Z.; and Liu, A., 2016. The rich and the poor:A markov decision process approach to optimizing taxi driver revenue efficiency.2329–2334. doi:10.1145/2983323.2983689. (cited on page 6)

Rousseeuw, P., 1987. Rousseeuw, p.j.: Silhouettes: A graphical aid to the interpre-tation and validation of cluster analysis. comput. appl. math. 20, 53-65. Journal ofComputational and Applied Mathematics, 20 (11 1987), 53–65. doi:10.1016/0377-0427(87)90125-7. (cited on page 10)

Tang, H.; Kerber, M.; Huang, Q.; and Guibas, L., 2013. Locating lucrative passen-gers for taxicab drivers. In Proceedings of the 21st ACM SIGSPATIAL InternationalConference on Advances in Geographic Information Systems, SIGSPATIAL’13 (Orlando,Florida, 2013), 504–507. ACM, New York, NY, USA. doi:10.1145/2525314.2525471.http://doi.acm.org/10.1145/2525314.2525471. (cited on page 6)

Tseng, C.; Chau, S. C.; and Liu, X., 2019. Improving viability of electric taxisby taxi service strategy optimization: A big data study of new york city. IEEETransactions on Intelligent Transportation Systems, 20, 3 (March 2019), 817–829. doi:10.1109/TITS.2018.2839265. (cited on page 6)

Page 43: Taxi Service Strategy Optimization with Data Clustering ... · with Data Clustering and Markov Decision Processes Kexin Zhang A report submitted for the course COMP4650 Advanced Computing

Bibliography 31

Yuan, N.; Zheng, Y.; Zhang, L.; and Xie, X., 2012. T-finder: A recommender systemfor finding passengers and vacant taxis. Knowledge and Data Engineering, IEEETransactions on, 25 (01 2012). doi:10.1109/TKDE.2012.153. (cited on page 5)

Zhao, P.; Liu, X.; Shen, j.; and Chen, M., 2017. A network distance and graph-partitioning-based clustering method for improving the accuracy of urban hotspotdetection. Geocarto International, (10 2017). doi:10.1080/10106049.2017.1404140.(cited on page 5)

Page 44: Taxi Service Strategy Optimization with Data Clustering ... · with Data Clustering and Markov Decision Processes Kexin Zhang A report submitted for the course COMP4650 Advanced Computing

32 Bibliography

Page 45: Taxi Service Strategy Optimization with Data Clustering ... · with Data Clustering and Markov Decision Processes Kexin Zhang A report submitted for the course COMP4650 Advanced Computing

Appendix

Appendix 1

Here is the copy of the description of my project.

33

Page 46: Taxi Service Strategy Optimization with Data Clustering ... · with Data Clustering and Markov Decision Processes Kexin Zhang A report submitted for the course COMP4650 Advanced Computing

34 Appendix 1

Page 47: Taxi Service Strategy Optimization with Data Clustering ... · with Data Clustering and Markov Decision Processes Kexin Zhang A report submitted for the course COMP4650 Advanced Computing

Appendix

Appendix 2

Here is the scanned copy of my contract. The project scope is adjusted through theconsultation with Dr. Chau.

35

Page 48: Taxi Service Strategy Optimization with Data Clustering ... · with Data Clustering and Markov Decision Processes Kexin Zhang A report submitted for the course COMP4650 Advanced Computing

36 Appendix 2

Page 49: Taxi Service Strategy Optimization with Data Clustering ... · with Data Clustering and Markov Decision Processes Kexin Zhang A report submitted for the course COMP4650 Advanced Computing

37

Page 50: Taxi Service Strategy Optimization with Data Clustering ... · with Data Clustering and Markov Decision Processes Kexin Zhang A report submitted for the course COMP4650 Advanced Computing

38 Appendix 2

Page 51: Taxi Service Strategy Optimization with Data Clustering ... · with Data Clustering and Markov Decision Processes Kexin Zhang A report submitted for the course COMP4650 Advanced Computing

Appendix

Appendix 3

Here is the copy of the description of how my prototype produced.

39

Page 52: Taxi Service Strategy Optimization with Data Clustering ... · with Data Clustering and Markov Decision Processes Kexin Zhang A report submitted for the course COMP4650 Advanced Computing

40 Appendix 3

Page 53: Taxi Service Strategy Optimization with Data Clustering ... · with Data Clustering and Markov Decision Processes Kexin Zhang A report submitted for the course COMP4650 Advanced Computing

Appendix

Appendix 4

Here is the copy of the description of my documentation.

41

Page 54: Taxi Service Strategy Optimization with Data Clustering ... · with Data Clustering and Markov Decision Processes Kexin Zhang A report submitted for the course COMP4650 Advanced Computing

42 Appendix 4