I searched around for this, but couldn't find an answer.
In the CVRPTW, from my understanding, the objective function being minimized is the distance/time and number of vehicles used. Is it possible to change the objective function so that we're trying to minimize the amount of time each passenger spends in the vehicle?
I would like to do this because in my current implementation, there are cases where the vehicle is "waiting" with a passenger on board before picking another passenger up, leading to a passenger spending too long to reach their destination.
Any help appreciated!
I had a similar problem once---passengers picked up and then forced to wait.
My solution approach (in Python) was to apply an external constraint, that the travel time for each passenger was less than some bound. Basically, if the passenger was traveling from A to B, then I know from my mapping service that the straight line travel time is T(A,B). So you can set up some logic rules based on that time, for example, set the longest in-vehicle time to be 1.1*T(A,B), with a maximum of T(A,B)+45minutes, say.
Then you set up a constraint, something like (pseudo code):
for p in passengers:
pickup_index = manager.NodeToIndex(p.origin)
delivery_index = manager.NodeToIndex(p.destination)
optimal_time = get_travel_time(p.origin,p.destination)
max_allowed_time = some_crazy_allowed_time_function(optimal_time, p)
routing.solver().Add(
time_dimension.CumulVar(delivery_index) <=
time_dimension.CumulVar(pickup_index) + max_allowed_time )
Straight up minimizing time of passengers in vehicle is probably not what you want if you are trying to model a shared-use service, because that will tend to assign one person per vehicle (no shared trips). By modeling it as a maximum allowed deviation, you can achieve your goal (avoiding needless waits) while still enabling shared use of vehicles and deviations from the ideal route to serve another passenger. Research shows that people may not care about a small delay, say 10 minutes, but they will care increasingly more about longer and longer delays as a percentage of what they perceive the straight line travel distance should be. The goal should be to impose upon customers just as much as they are willing to put up with, so as to maximize the utility of your vehicles.
Most helpful comment
I had a similar problem once---passengers picked up and then forced to wait.
My solution approach (in Python) was to apply an external constraint, that the travel time for each passenger was less than some bound. Basically, if the passenger was traveling from A to B, then I know from my mapping service that the straight line travel time is T(A,B). So you can set up some logic rules based on that time, for example, set the longest in-vehicle time to be 1.1*T(A,B), with a maximum of T(A,B)+45minutes, say.
Then you set up a constraint, something like (pseudo code):
Straight up minimizing time of passengers in vehicle is probably not what you want if you are trying to model a shared-use service, because that will tend to assign one person per vehicle (no shared trips). By modeling it as a maximum allowed deviation, you can achieve your goal (avoiding needless waits) while still enabling shared use of vehicles and deviations from the ideal route to serve another passenger. Research shows that people may not care about a small delay, say 10 minutes, but they will care increasingly more about longer and longer delays as a percentage of what they perceive the straight line travel distance should be. The goal should be to impose upon customers just as much as they are willing to put up with, so as to maximize the utility of your vehicles.