1 Introduction

Finite oil supplies, rising gas prices, traffic congestion and environmental concerns have recently increased the interest in services that allow people to use personal automobiles more wisely, while the occupancy rate of private vehicles is quite low. It is reported that driving to work accounts for nearly 94% of the commuting trips in the USA; however, just 10% commuters would like to choose ridesharing, which means about 84% of the commuting trips are driving alone. With now nearly 75% of the mobile phone subscribers owning a smart phone, P2P ridesharing presents a promising opportunity in mitigating traffic congestion, conserving fuel and reducing air pollution [1]. Recently, many new companies, like Lyft, UberX and DiDi, have emerged in both the USA and China that offer mobile phone applications that help match up drivers and riders.

P2P ridesharing fundamentally differs those on-demand transportation services as those offered by Uber. With those on-demand for profit transportation services, additional trips are expected to be generated, since drivers will likely cruise around looking for customers. In a P2P ridesharing system, drivers are not for profit, but for cost-saving purposes. The drivers in a P2P ridesharing system use their own vehicles to carry passengers and do not work as agency employees. A ride-match is deemed successful when the match provides benefits to both drivers and riders. P2P ridesharing provides transportation services that focus on single, non-recurring trips which do not require long-term commitments between people to travel together for a particular purpose.

In this paper, we consider a P2P ridesharing system setting where potential participants place trip announcements as a rider or a driver, at a time close to their desired trip departure times. A trip announcement specifies an origin and a destination location, and additional information that specifies its potential time windows. With this information, the ridesharing system provider automatically establishes ride-matches for potential drivers and riders. Some potential participants may remain unmatched.

P2P ridesharing has been considered in recent research efforts [2], and most researches aim to maximize the system-wide benefits, which is expressed as minimizing total travel distances, maximizing total travel distance savings [3] and matching success rates [4]. However, in practice, each participant is a dependent selfish individual; if a ride-match solution aimed at maximizing the system-wide benefits cannot necessarily maximize the cost savings of each individual participant, the participants will reject the proposed matches to form their own matches. The degradation of system performance due to selfish behavior of participants is exactly an example of the price of anarchy.

This paper considers the participants as rational individuals and builds a single-driver multiple-rider two-sided stable matching model based on the research of Vate [23], in which we take the system providers into consideration. For the one-to-many problem in two-sided matching problem, we propose a recursive algorithm to transform the feasible rides into a series of feasible sets of riders. To solve the two-sided stable match model effectively, delete operator is proposed. Finally, programs are written by C++ and Cplex for the stable model, which finds that the algorithm proposed by this paper is efficient.

The rest of this paper proceeds as follows: Related works are provided in Sect. 2. Section 3 introduces our research framework and methodology. In Sect. 4, we evaluate the performance of the proposed algorithm through a case study. Section 5 concludes this paper.

2 Related works

Ridesharing is receiving more and more attention from the transportation optimization community. Agatz et al. [5] and Furuhata et al. [6] provide an overview and different classifications of the various types of ridesharing systems encountered in practice. The number of riders and drivers that are involved in a ride-match is one important dimension.

Several studies have been published that tackle the single-driver single-rider (SDSR) ridesharing matching problem. Agatz et al. [2] represent the single-rider, single-driver ridesharing matching problem by a max-weight bipartite matching problem. They explore different approaches to match drivers and riders in real time and investigate the impact of different service characteristics of the system. Boyacı et al. [7] develop and solve a multi-objective MILP model for planning one-way vehicle-sharing systems taking into account vehicle relocation and electric vehicle charging requirements. Wang et al. [8] extend this analysis by investigating the trade-offs between system-wide optimal matching and individual optimal matching. They introduce the concept of stable matches in the ridesharing setting.

Some drivers may be willing to provide rides to several riders on a trip, either one after the other or simultaneously for portions of the time, which is called as single-driver multiple-rider (SDMR) ridesharing matching problem. There are several studies about SDMR ridesharing matching problem in the literature. Baldacci et al. [9] address the to-work variant of the carpool problem separately from the return-from-work variant. They propose both an exact and heuristic method to solve the problem based on two integer programming formulations. Calvo et al. [10] study the problem using a model that allows different network travel times at different periods of time of the day. They develop a heuristic approach to solve the problem based on construction and local search. Recently, Stiglic et al. [11] introduce a notion of meeting point which allows a driver to be matched with multiple riders without increasing the number of stops the driver needs to make. They design and implement an algorithm that optimally matches drivers and riders in large-scale ridesharing systems. Furthermore, some scholars show interest in multiple-driver multiple-rider ridesharing matching problem, in which a rider has access to transfer between potential driver vehicles [12,13,14].

Most literature above formulate the P2P ridesharing problem from the perspective of system-wide optimal, and few studies take the ridesharing participants as rational individuals. In the existing literature, there is only one paper that formulates the P2P ridesharing problem as a stable match problem [8], but in Wang’s paper, they average the cost savings between driver and rider in ride-matches, which is not a fair cost allocation method. And they do not take the system providers into consideration, who will participate in the cost-saving distribution. Moreover, the stable match model proposed by Wang just be applicable for SDSR ridesharing matching problem. In this paper, we will adopt a more reasonable cost allocation method and build a stable match model for SDMR ridesharing problem.

In this paper, we will introduce the theory of two-sided matching to solve the ridesharing stable matching problem. The two-sided matching problem has been firstly proposed by Gale and Shapley in 1962. Later, more and more scholars have paid attentions on two-sided matching problem [15, 16]. In this paper, we consider a problem of matching riders to drivers for shared rides, and in our context, there are often riders who cannot be feasibly matched with certain drivers; thus, participants may have incomplete preferences. Furthermore, in the P2P ridesharing system, there are also cases that a driver (rider) may receive identical benefit for a match with rider (driver), which means the participants do not strictly prefer on match to the other. Thus, the stable matching problem with incomplete preference lists and non-strict preferences is urgently needed to settle. Manlove et al. [17] show interestingly that in such two-sided matching problems with both incomplete preference lists and also non-strict preferences. Roth et al. [18] have built mathematical programming for the stable matching problem with incomplete preference lists, which will be used in this paper.

3 Methodology

Let \(P = D \cup R\) as the set of participants, \(D\) and \(R\), respectively, represent the set of drivers and riders. \(i(i = 1,2, \ldots ,n)\) and \(j(j = 1,2, \ldots ,m)\), respectively, represent the set of drivers and riders. For anyone \(p \in P\), \(p^{ + }\) and \(p^{ - }\), respectively, denote the picking-up points and dropping-off points.

\(ed_{p}\) and \(la_{p}\), respectively, denote the earliest departure time and latest arrival time. Let \(t_{{p^{ + } ,p^{ - } }}\) be the traveling time from origin of participant \(p\) to its destination, then it can be deduced that the latest departure time \(ld_{p}\) is \(la_{p} - t_{{p^{ + } ,p^{ - } }}\). Then, the flexible time of participant \(p\) can be calculated by \(F_{p} = la_{p} - ed_{p} - t_{{p^{ + } ,p^{ - } }}\).

3.1 Vehicle routing model

In this paper, we try to model SDMR ridesharing problem, where the drivers are willing to match with multiple riders, and then how to pick up and drop off the riders are important issues to make the total travel cost minimum.

For convenient, we assume that the riders can only take one driver’s vehicle. \(q_{j}\) denotes the number of seats required from rider \(j\). The number of passengers each driver is willing to carry is limited, denoted as \(Q_{i}\); let \(V = \{ j^{ + } ,j^{ - } |j \in R\}\) denote the set of the riders’ origins and destinations, and \(W = V \cup \{ i^{ + } ,i^{ - } |i \in D\}\) denote set of the all participant’ origins and destinations. \(q_{w}\) denotes the number of riders picked up/dropped off at point \(w\), when \(w\) is rider’s picking point, \(q_{w} > 0\); when \(w\) is rider’s dropping-off point, \(q_{w} < 0\); when \(w\) denotes the origin/destination of driver, \(q_{w} = 0\).

Use \(S_{i} = \{ u_{1} ,u_{2} , \ldots ,u_{z} \}\) to represent the travel route of driver \(i\), which is ranked from the sequence of the driver’s arrival. In the route \(S_{i}\), the first point \(u_{1}\) represents the origin of driver \(i\), which is also denoted as \(i^{ + }\); similarly, the last point \(u_{z}\) is the destination \(i^{ - }\), and the rest points are the riders’ picking-up and dropping-off points. If rider \(j\) is matched with driver \(i\), \(j^{ + } ,j^{ - }\) must be located in \(S_{i}\), and \(j^{ + }\) is in front of \(j^{ - }\). Let \(x_{u,m}^{i} = 1\) represent \(m\) is the next stop of \(u\) in \(S_{i}\), \(h_{u,m}\) denote the distance between \(u\) and \(m\), and \(t_{u,m}\) denote the time from \(u\) to \(m\).

Let \(t_{{u_{k} }}^{i}\) be the service starting time at point \(u_{v}\) in \(S_{i}\), then \(t_{{u_{1} }}^{i} = ed_{i}\); i.e., the service starting time at the first point is just the earliest departure time of driver \(i\). Moreover, when \(v > 1\), \(t_{{u_{v} }}^{i} \ge t_{{u_{v - 1} }}^{i} + t_{{u_{v - 1} ,u_{v} }}^{i}\); when \(u_{v}\) is origin, denoted as \(x^{ + }\), then \(t_{{u_{v} }}^{i} \ge ed_{x}\); when \(u_{v}\) is destination, denoted as \(x^{ - }\), then \(t_{{u_{v} }}^{i} \le la_{x}\). Let \(y_{{u_{v} }}^{i}\) denote the number of riders remaining after driver \(i\) passes by \(u_{v}\), then, when \(v > 1\), \(y_{{u_{v} }}^{i} = y_{{u_{v - 1} }}^{i} + q_{{u_{v} }}\) and \(y_{{u_{v} }}^{i}\) must be less than the maximum seating capacity \(Q_{i}\). Let \(kr_{i}\) be the points set of riders matched with the driver \(i\).

Based on the existed studies, the driver’s routing problem is traveling salesman problem with time windows and precedence constraints (TSP-TWPC), which can be formulated as a mixed integer programming model.

$$\begin{aligned} \hbox{min} & \sum\limits_{{u,m \in kr_{i} }} {h_{u,m} x_{u,m} } \\ & s.t.\left\{ {\begin{array}{*{20}l} {\sum\limits_{{m \in kr_{i} }} {x_{{j^{ + } ,m}} \le 1,\quad } \forall j \in kr_{i} ,} \hfill \\ {\sum\limits_{{m \in kr_{i} }} {x_{{i^{ + } ,m}} = 1,} } \hfill \\ {\sum\limits_{{m \in kr_{i} }} {x_{{m,i^{ - } }} = 1,} } \hfill \\ {\sum\limits_{{m \in kr_{i} }} {x_{u,m} - \sum\limits_{{m \in kr_{i} }} {x_{m,u} = 0,} \quad } \forall u \in kr_{i} } \hfill \\ {\sum\limits_{{m \in kr_{i} }} {x_{{j^{ + } ,m}} - \sum\limits_{{m \in kr_{i} }} {x_{{m,j^{ - } }} = 0,} } \quad \forall j \in kr_{i} } \hfill \\ {y_{{i^{ + } }} = 0;0 \le y_{m} \le Q_{i} ,\quad \forall m \in kr_{i} ,} \hfill \\ {x_{u,m} = 1 \Rightarrow y_{u} + q_{m} = y_{m} ,\quad \forall u,m \in kr_{i} ,} \hfill \\ {ed_{i} \le t_{{i^{ + } }} \le t_{{i^{ - } }} \le la_{i} ,\quad \forall u,m \in kr_{i} } \hfill \\ {ed_{j} \le t_{{j^{ + } }} \le t_{{j^{ - } }} \le la_{j} ,\quad \forall j \in kr_{i} } \hfill \\ {x_{u,m} = 1 \Rightarrow t_{u} + t_{u,m} \le t_{m} ,\quad \forall u,m \in kr_{i} } \hfill \\ \end{array} } \right. \\ \end{aligned}$$
(1)

TSP-TWPC is a NP-complete problem [19,20,21]; while in this paper, the seating capacity \(Q_{i}\) is a very small number, in practical, private vehicles can provide no more than four seats. Thus, the model above can be solved quickly.

3.2 P2P ridesharing stable match problem

  1. 1.

    Feasible matching sets

In this section, we will introduce two rules which are proposed by Arslan et al. [3] to search the feasible matching sets.

Rule 1 A match \((i,k)\) is feasible if and only if the matches \((i,k^{\prime})\) are all feasible, where \(k\) denotes a set of riders, and \(k^{\prime}\) denotes a subset of \(k\).

For feasibility of the matches between driver and riders, two aspects will be considered.

Time feasibility, if \((i,k)\) is a feasible match, \(k_{i}\) is the set of points of riders in \(k\), \(S\) is the route set which covers all the points in \(k_{i}\), and then for any \(s \in S\), there exist following formulas:

$$t_{s} (i^{ + } ,i^{ - } ) \le la_{i} - ed_{i}$$
(2)
$$t_{s} (j^{ + } ,j^{ - } ) \le la_{j} - ed_{j}$$
(3)
$$\hbox{max} [ed_{j} ,ed_{i} + t_{s} (i^{ + } ,j^{ + } )] \le \hbox{min} [la_{i} - t_{s} (i^{ + } ,i^{ - } ),la_{j} - t_{s} (i^{ + } ,j^{ - } )]$$
(4)

No matter which route the driver \(i\) chooses, total traveling time must be less than the driver’s maximum available time \(la_{i} - ed_{i}\); moreover, driver \(i\) has to arrive the riders’ origins before their latest departure time and reach riders’ destinations before their latest arrival time.

Cost feasibility—all the riders who matched with driver \(i\) must have cost savings. In this paper, we assume that the participants’ travel cost is proportion to their cost by driving alone. The ratio denotes as \(\rho_{p} ,p \in D \cup R\) and can be formulated as:

$$\rho_{p} = \frac{{h_{{p^{ + } ,p^{ - } }} }}{{h_{{i^{ + } ,i^{ - } }} + \sum\nolimits_{j} {h_{{j^{ + } ,j^{ - } }} } }}$$
(5)

where \(h_{{p^{ + } ,p^{ - } }}\) denotes the travel distance from the origin of rider \(p\) to his/her destination. Then, the travel cost of participant \(p \in D \cup R\) can be represented by

$$C(p) = \rho_{p} \times \alpha \times h_{s} (i^{ + } ,i^{ - } )$$
(6)

where \(\alpha\) denotes cost of unit distance, and \(h_{s} (i^{ + } ,i^{ - } )\) denotes distance from the origin of driver \(i\) to his/her destination through route \(s\). In this paper, we assume that all the participants are cost-rational, so there exists following constraints:

$$\rho_{p} \times h_{s} (i^{ + } ,i^{ - } ) - h_{{(p^{ + } ,p^{ - } )}} \ge 0$$
(7)

Rule 2 A route \(s\) is feasible if and only if anyone subroute \(s^{\prime} \subset s\) is feasible. A subroute can be obtained by removing one or more riders from the original route.

Based on these two rules, all feasible riders with respect to the driver \(i \in D\) can be determined by using a recursive algorithm. Naturally, the recursion starts with determining the feasible rider set with single rider and combining these single riders to make riders of two, three riders, and so on.

Then, the system-wide optimal model can be formulated as follows:

$$\begin{aligned} f_{SO} & = \hbox{max} \sum\limits_{i = 1}^{m} {\sum\limits_{k = 1}^{{n^{\prime}}} {x_{ij} s_{ik} } } \\ & \quad \left\{ {\begin{array}{*{20}l} {t_{s} (i^{ + } ,i^{ - } ) \le la_{i} - ed_{i} } \hfill \\ {t_{s} (j^{ + } ,j^{ - } ) \le la_{j} - ed_{j} } \hfill \\ {\hbox{max} \left[ {ed_{j} ,ed_{i} + t_{s} (i^{ + } ,j^{ + } )} \right] \le \hbox{min} \left[ {la_{i} - t_{s} (i^{ + } ,i^{ - } ),la_{j} - t_{s} (i^{ + } ,j^{ - } )} \right]} \hfill \\ {\sum\limits_{i = 1}^{m} {x_{ik} \le 1,\quad \forall k} } \hfill \\ {\sum\limits_{k = 1}^{{n^{\prime}}} {x_{ik} \le 1,\quad \forall i} } \hfill \\ {x_{ik} \in \{ 0,1\} ,\quad \forall i,k} \hfill \\ \end{array} } \right. \\ \end{aligned}$$
(8)
  1. 2.

    Utility function

For the cost of ridesharing participants, it consists of travel distance cost, travel time cost and time opportunity cost [22]. While we believe that the travel time cost can equate to travel distance cost, in this section, the cost of ridesharing participants is formed by two parts: travel distance cost and time opportunity cost.

Let \((i,k)\) be a ride-match of stable solution, \(wt_{i} = \omega * [t_{s} (i^{ + } ,i^{ - } ) - t_{{i^{ + } ,i^{ - } }} ]\) denote the time opportunity cost of driver \(i\), and \(wt_{j}\) denote the time opportunity cost of rider \(j \in k\), where \(wt_{j} = \omega * \hbox{max} (0,t_{{i^{ + } }} + t_{s} (i^{ + } ,j^{ + } ) - t_{{j^{ + } }} )\) and \(\omega\) denotes wages of unit time. Let \(u_{i} (i,k)\) and \(u_{j} (i,k)\), respectively, represent the cost utility of driver \(i\) and rider \(j\) in ride-match \((i,k)\), and the formulas are as follows:

$$u_{i} (i,k) = \alpha *[h_{{i^{ + } ,i^{ - } }} - h_{s} (i^{ + } ,i^{ - } )] + Pay(i,k) - wt_{i}$$
(9)
$$u_{j} (i,j) = \alpha *h_{{j^{ + } ,j^{ - } }} - Pay(i,j) - wt_{j}$$
(10)

where \(\alpha\) denotes the cost of unit distance, and \(Pay(i,j)\) denotes the fair paid by rider to driver. For different cost allocation methods, the values of \(Pay(i,j)\) are different. In this paper, cost savings are divided proportionally between driver and rider based on the lengths of their original trips. It is easy to know that the distance savings of ride-match \((i,k)\) through route \(s\) are

$$s_{ik} = h_{{i^{ + } ,i^{ - } }} + \sum\limits_{j = 1}^{{Q_{i} }} {h_{{j^{ + } ,j^{ - } }} } - h_{s} (i^{ + } ,i^{ - } )$$
(11)

The fare paid by rider \(j\) to driver \(i\) can be formulated as:

$${\text{Pay}}(i,j) = \alpha *(h_{{j^{ + } ,j^{ - } }} - \rho_{j} s_{ik} )$$
(12)
$${\text{Pay}}(i,k) = \alpha *\sum\limits_{j = 1}^{{Q_{i} }} {(h_{{j^{ + } ,j^{ - } }} - \rho_{j} s_{ik} )}$$
(13)
  1. 3.

    Preference lists

If the participant \(p \in D \cup K\) fails to build a ride-match with the other, he/she will drive alone, and the value of his/her utility will be zero, which is denoted as \(u(p,p) = 0\), which means the participants \(p\) do not receive any benefits from the ridesharing system.

In this paper, we consider there are only two cases for all the participants in the ridesharing system: (1) There are feasible matches, and the matches between drivers and rider sets are successful; the utility is denoted as \(u_{e} (e,l) > 0\,\&\, u_{l} (e,l) > 0,\forall e \in I,l \in J\), and the participants’ sets are denoted as \(I(k) \in I\) and \(J(i) \in J\); (2) there are feasible matches, but the matches fail or there is not any feasible matches; in this case, the value of utility is negative, i.e., \(\neg (u_{e} (e,l) > 0\,\&\, u_{l} (e,l) > 0),\forall e \in I,l \in J\), and the participants sets are denoted as \(\{ i\}\) and \(\{ k\}\); this kind of participants will be deleted in the preference lists. Then, the preference list of participants \(p\) can be expressed as

$$\pi (p) = ([1_{l} ],[2_{e} ], \ldots ,[n_{p} ],p),p \in P$$
(14)

where \(\pi (p)\) is a preference list which comes from ranking the utility of participant \(p\) with the other. Now, we will explain the meanings of the symbol in Eq. (10). For example, \(\pi (k) = ([1_{l} ],[2_{e} ], \ldots ,[n_{i} ],k)\) denotes the preference list of rider set \(k\). Then, \([1_{l} ]\) represents driver \(l \in I\) rows in the first place in the preference list of rider set \(k\); i.e., driver \(l\) is the best matching choice for rider set \(k\); \([n_{i} ]\) denotes the feasible matching objective lying on the \(n{\text{th}}\) place in the preference list, and at the same time, \(n\) also denotes the number of feasible matching objectives. Let \(k \succ_{i} k^{\prime}\) represent driver \(i\) prefers rider set \(k\) to \(k^{\prime}\) strictly; similarly, \(i \succ_{k} i^{\prime}\) represents rider set \(k\) prefers driver \(i\) to \(i^{\prime}\). If the relationship between driver \(i\) and rider set \(k\) satisfies \(i \succ_{k} k\), then rider \(k\) is a potential matching objective for driver \(i\), which is similar to \(k \succ_{i} i\). If \(i \succ_{k} k\) and \(k \succ_{i} i\), then \((i,k)\) is a feasible match.

Let \(M = I(k) \cup \{ k\}\) denote strategy set of rider set \(k,k \in K\) and \(W = J(i) \cup \{ i\}\) denote strategy set of driver \(i,i \in I\). \(\psi\) denotes the set of feasible matches \((i,k)\), where \(i \in M\), \(k \in K\).

  1. 4.

    P2P ridesharing stable match model

For participants in P2P ridesharing system, one participant may receive identical benefit for a match with other participants; i.e., there are multiple matching objectives with same preferences, which means the preference is non-strict.

\(k \,\succcurlyeq_{i}\, k^{\prime}\) denotes driver \(i\) prefers rider set \(k\) to rider set \(k^{\prime}\) non-strictly, similar to \(i \,\succcurlyeq_{k} \, i^{\prime}\). Moreover, in a solution \(\mu\), \(M(i)\) denotes the participant that driver \(i\) is matched with. \(W(k)\) denotes the participant that rider set \(k\) is matched with. So we introduce the notion of week stable match.

Week stable matching For all the participants, if a matching satisfies the following two conditions, it will be called week stable matching.

① There are no pair unmatched participants (driver \(i\) and rider set \(k\)) that satisfy that driver \(i\) exists in the preference list of rider set \(k\) and rider set \(k\) exists in the preference list of driver \(i\).

② There is no pair \((i,j)\) makes \(k \,\succcurlyeq_{i}\, M(i)\) and \(i \,\succcurlyeq _{k}\, W(k)\).

To formulate the P2P ridesharing stable match problem, we introduce the model proposed by Vate [23] and Roth et al. [18], and the P2P ridesharing stable match (SM) model is established as follows:

$$\begin{aligned} f_{\text{sta1}} & = \hbox{max} \sum\limits_{i \in M} {\sum\limits_{k \in W} {x_{ik} s_{ik} } } \\ & \quad \left\{ {\begin{array}{*{20}l} {\sum\limits_{i \in M} {x_{ik} = 1,\quad \forall k \in W} } \hfill \\ {\sum\limits_{k \in W} {x_{ik} = 1,\quad \forall i \in I} } \hfill \\ {\sum\limits_{{i^{\prime} \pm_{k} i}} {x_{{i^{\prime}k}} + \sum\limits_{{k^{\prime} \pm_{i} k}} {x_{{ik^{\prime}}} + x_{ik} \ge 1,\quad \forall i \in M,k \in W} } } \hfill \\ {x_{ik} \ge 0,\quad \forall i \in M,k \in W} \hfill \\ \end{array} } \right. \\ \end{aligned}$$
(15)

3.3 Solving the P2P ridesharing stable match problem

To solve the SDMR ridesharing stable match problem, it is necessary to search the feasible rider set firstly; in this paper, we borrow the methods proposed by Arslan et al.

  1. 1.

    A recursive algorithm for searching feasible rider sets

The recursive algorithm is described in detail in Table 1. In Table 1, it forms a for-loop structure by line 1 to line 21 and repeatedly generates feasible rider sets and routes for each driver. Line 4 to line 14 construct a for loop, which is used to judge the feasibility if a new rider is added into the feasible rider set. If it is feasible, the route will be found out and stored in route set \(S_{i}\). As for \(SUBFEAS(k,j,i)\), it is a function used to judge the original feasible rider set \(k\) whether still be feasible if a new rider \(j\) is added into the set; i.e., set \(k \cup j\) is feasible or not. FINDROUTES function is proposed to obtain the route of the set. For the detailed description of the functions \(SUBFEAS(k,j,i)\) and \(FINDROUTES\), refer to the research of Arslan et al. [3].

Table 1 Recursive algorithm
  1. 2.

    Delete operator

For small-scale ridesharing stable match problem, SM model can be directly solved by Cplex. However, it is time-consuming when the scale of the participants becomes large, which is hard to apply in practice. So we try to decrease the size of decision feasible region in order to improve the model solving speed.

Injection The matching of single driver and single rider can be regarded as an injection from participant complete set to participant complete set, i.e., \(\mu :M \cup W \to M \cup W\), \(\forall\)\(i \in M\) and \(j \in W\) satisfies the following relations:

\(\mu (i) = j\) holds when and only when \(\mu (j) = i\), and at this time, \(i\) and \(j\) is a ride-match pair, denoted as \((i,j)\);

② If \(\mu (i) \notin M\), then \(\mu (i) = i\), and \(i\) failed to match, denoted as \((i,i)\);

③ If \(\mu (j) \notin W\), then \(\mu (j) = j\), and \(j\) failed to match, denoted as \((j,j)\).

Blocking pair For one-to-one matching \(\mu :M \cup W \to M \cup W\), \(\forall i \in I\) and \(j \in J\). If \(i\) and \(j\) satisfy \(i \succ_{j} \mu (j)\) and \(j \succ_{i} \mu (i)\), the pair \((i,j)\) is called a blocking pair of matching \(\mu\).

Lemma 1

Assume\(\varUpsilon\)and\(\varUpsilon^{\prime}\)are preference structures that satisfy\(\varUpsilon^{\prime}{ \succcurlyeq }_{I} \varUpsilon\). Let\(\mu\)and\(\mu^{\prime}\)be the corresponding stable matchings, \(M_{\mu }\) (\(M_{{\mu^{\prime}}}\)) represent sets of drivers that\(\mu\)is superior to\(\mu^{\prime}\)(\(\mu^{\prime}\)is superior to\(\mu\)), which is similar to\(W_{\mu }\) (\(W_{{\mu^{\prime}}}\)). Then, there exists a bijection between\(\mu^{\prime}\)(\(\mu\)) and\(M_{{\mu^{\prime}}}\)(\(W_{\mu }\)).

Proof

Suppose \(i \in I_{{\mu^{\prime}}}\). Because \(\mu^{\prime} \succ_{i} \mu\), then \(\mu^{\prime}(i) \succ_{i} \mu (i) \succ_{i} i\), so \(\mu^{\prime}(i) \in W\). Let \(j = \mu^{\prime}(i)\), because \(\mu ,\mu^{\prime}\) are stable matchings, there will not be any blocking pairs \((i,j)\) in matchings \(\mu ,\mu^{\prime}\); i.e., \(\mu^{\prime}(j) \succ_{j} \mu (j)\) can not be established, and thus \(j \in W_{\mu }\), \(\mu^{\prime}(M_{{\mu^{\prime}}} ) \subset W_{\mu }\).

On the other side, assuming \(j \in W_{\mu }\), there also exists \(\mu (j) \succ_{j} \mu^{\prime}(j) \succ_{j} j\), and thus \(\mu (j) \in M\). Let \(\mu (j) = i\), because \(\mu ,\mu^{\prime}\) are stable matchings, there will not be any blocking pairs \((i,j)\) in matchings \(\mu ,\mu^{\prime}\); i.e., \(\mu (i) \succ_{i} \mu^{\prime}(i)\) can not be established, because \(i \in M_{{\mu^{\prime}}}\), \(\mu (W_{\mu } ) \subset M_{{\mu^{\prime}}}\).

Because matchings \(\mu ,\mu^{\prime}\) are both injective, and \(M_{{\mu^{\prime}}}\) and \(W_{\mu }\) are both finite sets, it is easy to deduce that there exists a bijection between \(\mu^{\prime}\)(\(\mu\)) and \(M_{{\mu^{\prime}}}\)(\(W_{\mu }\)).□

Lemma 2

\(\mu\)is an arbitrary stable matching, \(S(\mu )\)denotes the sets of riders which have been matched with the drivers, and \(n(\mu )\)denotes the number of successful matched riders. Then, \(\forall \mu \in \varUpsilon\), and all the\(S(\mu )\) and \(n(\mu )\)are identical.

Proof

Contradiction is adopted. It is assumed that the preference structures \(\varUpsilon\) and \(\varUpsilon^{\prime}\) satisfy \(\varUpsilon^{\prime} = \varUpsilon\), and driver \(i\) has been matched in matching \(\mu^{\prime}\), but not been matched in matching \(\mu\).

Then, \(i \in M_{{\mu^{\prime}}}\) holds, and according to Theorem 1, it is known that \(\mu (W_{\mu } ) \subset M_{{\mu^{\prime}}}\); i.e., \(W_{\mu }\) maps an injection with \(M_{{\mu^{\prime}}}\) through \(\mu\); in other words, driver \(i\) has been matched in matching \(\mu\) inevitably, which appears to contradict assumption. Thus, Lemma 2 is true.□

Lemma 3

Let\(\mu\)be a stable matching obtained by driver-optimal deferred acceptance (DODA) algorithm, and\((i,j)\)is one pair of\(\mu\); the preference list of rider\(j\)can be expressed as\(\pi (j) = ([1], \ldots ,[i],[i] + 1, \ldots ,[k],[n_{j} ],j)\). It has no effects on the matching if the elements between\([i] + 1\)and\([n_{j} ] + 1\) are deleted from the preference lists of rider\(j\). Similarly, let\(\mu^{\prime}\)be a stable matching obtained by rider-optimal deferred acceptance (RODA) algorithm, and it also has no effects on the matching if the preference lists of driver\(i\) are retrenched.

Proof

Contradiction is adopted. It is assumed that cutting the preference lists of rider \(j\) has effect on the matchings; from Lemma 1 and Lemma 2, it is known that if a participant has been matched successfully in anyone matching \(\mu\), the participant will be matched successfully in any other matchings. That means there are at least one stable matching \(\mu^{\prime}\), which makes \((k,j)\) and \((i,l)\) simultaneously existing. Because in the preference lists of \(j\), the position of driver \(k\) is behind the position of driver \(i\), then \(i \succ_{j} k\); moreover, the matching is calculated by DODA algorithm, and then \(u \succ_{i} u^{\prime}\), i.e., \(j \succ_{i} l\), while \((i,j)\) will be a blocking pair of matching \(\mu^{\prime}\), which appears to contradict assumption. The proposition holds. Vice versa, the proposition holds as well.□

Deferred acceptance is the core of delete operator, which can cut the preference lists of drivers and riders (Fig. 1). Let \(\pi (p)_{gs}\) denote an element of preference lists that have been deleted. \(pl(d)\) denotes the preference list of \(d\), \(pl(d) = [\pi (1);\pi (2); \ldots ;\pi (i); \ldots ;\pi (m)],i \in I\). Similarly, \(pl(r) = [\pi (1);\pi (2); \ldots ;\pi (j); \ldots ;\pi (n)],j \in J\) denotes the preference lists of rider \(r\). An example of cutting the preference lists has been given in Fig. 2. First step, MODA algorithm is used to solve the P2P ridesharing problem, and it is found that \(d_{3}\) and \(r_{5}\) is a ride-match; according to Lemma 1, it is known that cutting the elements behind the position of \(r_{5}\) in the preference list of \(d_{3}\) has no effects on the matchings. That means it is impossible to establish ride-matches between \(d_{3}\) and the riders behind the position of \(r_{5}\). In reverse, drivers \(d_{2}\) and \(d_{6}\) are impossible to match with \(r_{5}\), which means \(r_{5}\) also can be deleted from the preference list of \(d_{2}\) and \(d_{6}\) without influence, and the rest can be done in the same. In the second step, MODA algorithm is used to solve the P2P ridesharing problem, and \((r_{4} ,d_{3} )\) is a pair of the stable matching. Similarly, according to Lemma 1, it is known that cutting the elements behind the position of \(d_{3}\) in the preference list of \(r_{4}\) has no effects on the matchings. Furthermore, \(d_{3}\) also can be deleted from the preference list of \(r_{8} ,r_{7}\) and \(r_{6}\).

Fig. 1
figure 1

Mechanism of delete operator

Fig. 2
figure 2

Recursive algorithm solution time varies with the number of participants

After performing the delete operator, a trimming of preference list will be obtained, which is represented as \(pl(p)_{gs} = [\pi (1)_{gs} ;\pi (2)_{gs} ; \ldots ;\pi (j)_{gs} ; \ldots ;\pi (n)_{gs} ],p \in P\). \(M_{gs}\) and \(W_{gs}\) denote, respectively, the sets of potential acceptable drivers and riders after performing the delete operator.

  1. 3.

    Modification of P2P ridesharing stable match model

After downsizing the preference lists of participants, the SM model can transform into following model.

$$\begin{aligned} f_{sta} & = \sum\limits_{{i \in M_{gs} }} {\sum\limits_{{k \in W_{gs} }} {x_{ik} s_{ik} } } \\ & \quad s.t.\left\{ {\begin{array}{*{20}l} {\sum\limits_{{i \in M_{gs} }} {x_{ik} \le 1,\quad \forall k \in W} } \hfill \\ {\sum\limits_{{k \in W_{gs} }} {x_{ik} \le 1,\quad \forall i \in I} } \hfill \\ {\sum\limits_{{i^{\prime}{ \succcurlyeq }_{k} i}} {x_{{i^{\prime}j}} + \sum\limits_{{k{ \succcurlyeq }_{i} k}} {x_{{ik^{\prime}}} + x_{ik} \ge 1,\quad \forall i \in M_{gs} ,k \in W_{gs} } } } \hfill \\ {x_{ik} \ge 0,\quad \forall i \in M_{gs} ,k \in W_{gs} } \hfill \\ \end{array} } \right. \\ \end{aligned}$$
(16)

Lemma 4

Model (15) must have an optimal solution.

Proof

In P2P ridesharing system, there are two matching ways: matching with potential acceptable participants or matching with themselves, which means the size of the \(M_{gs}\) and \(W_{gs}\) will be far less than the total number of participants, i.e., \((m + n)\). That means the number of variables of model (12) is less than \((m + n)\), so the number of feasible solutions will be less than \(2^{{(m + n)^{2} }}\), which means the number of feasible solutions is limited. According the property of DA algorithm, the P2P ridesharing problem must exist stable matching solution; i.e., model (12) has at least one feasible solution. Thus, model (12) must have an optimal solution.□

4 Results and discussion

The simulation environment is based on an urban region, which is a square with side length of 20 km, and in this region the vehicle speed is 30 km/h. All the nodes are randomly distributed in the region. We draw the latest departure time from a normal distribution with mean 7:30 a.m. and standard deviation 45 min to model a typical morning peak. The latest arrival time is \(la_{p} = ld_{p} + t_{p}\). \({\text{FT}}_{p}\) denotes flexible time, which is the redundant time excluding the directly driving time from the origin to destination, \({\text{FT}}_{p} = ld_{p} - ed_{p} = la_{p} - ea_{p}\). We assume the flexible time follows a normal distribution with mean \(FT\) min and standard deviation 4 min. For the sake of calculation, let \(\alpha\),\(\eta\) be constant. And the coefficient of time opportunity cost \(\omega\) can be calculated by formula \(\omega_{p} = w/(12*30*8*60)\), where \(w\) denotes the wage. In this paper, we take Beijing as an example \(\omega \approx 0.645\).

4.1 Evaluation criteria

To evaluate the effectiveness of the proposed algorithm, this paper constructs the following criteria.

1. Success rate (\({\text{Suc}}\)): ratio of the number of successful matched participants and the total number of participants.

$${\text{Suc}} = \frac{{N_{r}^{s} + N_{d}^{s} }}{{N_{d} + N_{r} }} \times 100\%$$

where \(N_{d}^{s}\) denotes the number of successful matched drivers, \(N_{r}^{s}\) denotes the number of successful matched riders, and \(N_{d}\) and \(N_{r}\) denote number of drivers and riders post-announcement in the system. Moreover, the success rate of drivers and riders can be formulated as \({\text{Suc}}_{d} = {{N_{d}^{s} } \mathord{\left/ {\vphantom {{N_{d}^{s} } {N_{d} }}} \right. \kern-0pt} {N_{d} }} \times 100\%\) and \({\text{Suc}}_{r} = {{N_{r}^{s} } \mathord{\left/ {\vphantom {{N_{r}^{s} } {N_{r} }}} \right. \kern-0pt} {N_{r} }} \times 100\%\).

2. Total distance savings rate (\({\text{Sav}}\)): ratio of total vehicle distance savings from stable match and the total vehicle distances that participants drive alone to their destinations.

$${\text{Sav}} = \frac{{f_{\text{sta}} }}{{\sum\nolimits_{{i \in N_{d} }} {h_{{i^{ + } ,i^{ - } }} } + \sum\nolimits_{{j \in N_{r} }} {h_{{j^{ + } ,j^{ - } }} } }} \times 100\%$$

3. Average participants individual distance savings rate (\(Si\)): average value of ratio of individual distance savings and distances driving alone.

$$Si = \frac{{\sum\nolimits_{i,k} {x_{ik} \left( {\frac{{h_{{i^{ + } ,i^{ - } }} - \rho_{i} h_{s} (i^{ + } ,i^{ - } )}}{{h_{{i^{ + } ,i^{ - } }} }}} \right) + \sum\nolimits_{j \in k} {x_{ik} \left( {\frac{{h_{{j^{ + } ,j^{ - } }} - \rho_{j} h_{s} (i^{ + } ,i^{ - } )}}{{h_{{j^{ + } ,j^{ - } }} }}} \right)} } }}{{N_{r}^{s} + N_{d}^{s} }} \times 100\%$$

4. Price of anarchy (\({\text{POA}}\)): \(f_{\text{so}}\) denotes the value of SO model, \(f_{\text{sta}}\) denotes the value of SM model, and the expression of \({\text{POA}}\) is

$${\text{POA}} = \frac{{f_{\text{so}} - f_{\text{sta}} }}{{f_{\text{so}} }} \times 100\%$$

4.2 Results analysis

In order to verify the effectiveness of the models and algorithms, this paper will do experiments study from ratio of participants’ roles, number of participants, flexible time, time opportunity cost. All experiments were made in an Intel(R) Core(TM) i5-5200U, 2.4 Ghz, with 8 Gb of memory, using Windows 10.

  1. 1.

    Effectiveness of recursive algorithm

To verify the effectiveness of the recursive algorithm acted on obtaining the feasible rider set, this paper shows the trend of program solution time along with the number of participants increasing, which can be found in Fig. 2. In this section, it is assumed that one driver can no more than match with two riders, and the ratio of drivers to riders is 1:2.

In Fig. 2, when the number of participants reach 3000, the program solution time is just 138.204 s, which means the algorithm can be applied to large-scale ridesharing match problem.

  1. 2.

    The influence on participants’ success rate from ratio of drivers to riders

Let us set the number of participants in the service region is 1200, and all the participants are randomly distributed; one driver can only no more than take two riders, i.e., \(Q = 2,\;\alpha = 2.\).

Figure 3 shows the success rate variation with the ratio of drivers to riders, which ranges from 0.1 to 0.9. With the increasing of proportion of drivers in participants, the driver’s success rate \({\text{Suc}}_{d}\) keeps falling, while the rider’s success rate \({\text{Suc}}_{r}\) keeps growing. When proportion of the driver is small, most of the drivers will be in busy to service riders, and drivers will be in short supply. Although the riders will be in a state of oversupply, with the number of drivers increasing, the demands from riders are being met.

Fig. 3
figure 3

Influence on participants’ success rate from ratio of drivers to riders

Figure 4 shows that when the ratio of drivers to riders ranges from 0.1 to 0.3, the success rate \({\text{Suc}}\), system total savings \({\text{Sav}}\) and average individual savings have an upward trend along with the increasing of the ratio of drivers to riders. When the ratio of drivers to riders ranges from 0.4 to 0.9, the success rate \({\text{Suc}}\), system total savings \({\text{Sav}}\) and average individual savings have a downward trend. This phenomenon illustrates that if the number of drivers in the ridesharing system is much larger/less than the number of riders, the success rate will be affected significantly and then will make a bad effect on the participants’ satisfaction.

Fig. 4
figure 4

Influence on success rate, system savings and individual saving by ratio of drivers to riders

  1. 3.

    The influence on ridesharing match from the number of participants

The number of participants in the service region ranges from 300 to 1800, and the ratio of drivers to riders is 1:2. The flexible time follows a normal distribution with mean \(FT = 60\) min and standard deviation 4 min. Cost of unit distance \(\alpha = 2\).

From Fig. 5, it is obvious that the success rate rising with the increasing of number of participants. When the number of participants is 300, the success rate is just 76%, and when the number of participants rises to 1800, success rate climes to 82.5%. It is similar to the trend of total system savings \({\text{Sav}}\) and average individual savings \(Si\). It is worth noting that the methods proposed by this paper are relatively stable, and the fluctuation between the system-wide optimal value and stable value is small, which ranges from 6.3 to 7.7%.

Fig. 5
figure 5

Influence of number of participants

  1. 4.

    The influence on ridesharing match from flexible time

In this section, the number of participants is set as 1200 and the ratio of drivers to riders is 1:2. The flexible time of the participants ranges from 10 to 60 min. The detailed results are drawn in Fig. 6. Along with the rising of flexible time, the number of successful matched participants increases significantly. When FT = 10 min, the success rate is just 48.5%. When FT ranges from 10 to 45 min, the upward trend of success rate is obvious. When FT ranges from 45 to 60 min, the upward trend of success rate is gentle. That means when FT exceeds a certain value, the effect of flexible time on ridesharing match is getting smaller and smaller. Sav curve and Si Curve have a similar trend with \({\text{Suc}}\) curve. This phenomenon results from the region limitation in the simulation data, which is limited in a 20 km*20 km square region. And in this paper, the speed of vehicles is set to 30 km/h, which means vehicle can arrive anywhere in the square region in 1 h. Moreover, the fluctuation between the system-wide optimal value and stable value is small, which ranges from 6.1 to 7.9%.

Fig. 6
figure 6

Influence of participants’ flexible time

5 Conclusion

This paper models single-driver multiple-rider (SDMR) ridesharing match problem from the views of system-wide optimal and stable. We first introduce a recursive algorithm to search all the feasible rider sets to transform the one-to-many problem into one-to-one problem, which is to match the single driver with single rider set. Then, for the one-to-one matching problem, we propose a delete operator based on DA algorithm to short the participants’ preference lists, which reduces the model solution time greatly. Finally, we analyze the influence factors of the ridesharing matching problem and find that when the ratio of drivers to riders has been set, \({\text{Suc}}\), \({\text{Sav}}\) and \({\text{Si}}\) have an upward trend along with the increasing of number of participants and \({\text{Suc}}\), \({\text{Sav}}\) and \({\text{Si}}\) also have an upward trend along with the increasing of participants’ flexible time. When the number of participants in the ridesharing system has been set, the driver’s success rate declines with the ratio of drivers to riders rising. Moreover, we find that the algorithm is relatively fast, it can be used in large-scale ridesharing matching problem.