App-based transportation service system, such as Uber and Didi, has brought a new transportation mode to users, who are able to make reservations using mobile apps conveniently. However, one of the fundamental challenges in app-based transportation system is the inefficiency and unreliability of the vehicle routing plans caused by complex topology of urban road network and unpredictable traffic conditions. A common way to tackle this problem is repositioning pickup or delivery locations via the coordination between drivers and passengers. This paper studies an on-demand ridesharing problem that determines the optimal ride-share matching strategy and vehicle routing plan with respect to flexible pickup and delivery locations. By introducing ...