Uber: Pricing and ETA

video locked
Enroll to watch

20 mins

Chapters
About
Discussion0
Notes
Be the first to start a conversation!

Static Pricing of Rides

Static pricing gives a rider a price for a trip from a source to a destination, computed by a rule engine from stored weights.

The app sends the server the user ID, the source, the destination and metadata such as the time of day. A rider who waits for a price drops off, so the price is needed fast as well as accurate.

  1. A machine learning algorithm on the request takes time.
  2. A cache of prices from region to region is fast. A region that is too big averages high demand with low demand, so the price is inaccurate. One change in a rule makes hundreds of updates in the cache.
  3. A rule engine runs through the request's parameters and sets the price.

The initial price is the distance into a weight of distance, plus the time taken into a weight of time. The weights come from historical prices, the cost of fuel and the cost of a driver's time.

Rules raise or lower the price against thresholds, such as the demand at the source.

Calculating Estimated Time of Arrival

The estimated time of arrival is the time taken to get from A to B along the roads.

Quad trees and blocks of squares fail here, because what matters is whether there is a road from A to B. The map is stored as a graph: nodes as points and edges as roads.

  1. Breadth-first search minimizes the number of edges, and one edge is 10 minutes while another is three hours.
  2. A star search works on cost. For each reachable node it adds the real cost from the source to an approximate cost to the destination, given by a heuristic function. A priority queue expands the node with the lowest estimated cost next.

The points, connections and weights go in a graph database. The points stored are the interesting points, where a turn is possible, each with its adjacent points.

An edge's weight is the historical average: the total time taken by all riders divided by the number of rides. The driver sends the location by simple polling every three seconds.