Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minimizing time spent by each passenger in vehicle as objective function #1388

Closed
sanwer0 opened this issue Jul 1, 2019 · 1 comment
Closed
Assignees
Labels
Help Needed Modeling/Usage problem Solver: Routing Uses the Routing library and the original CP solver
Milestone

Comments

@sanwer0
Copy link

sanwer0 commented Jul 1, 2019

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!

@jmarca
Copy link
Contributor

jmarca commented Jul 17, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Help Needed Modeling/Usage problem Solver: Routing Uses the Routing library and the original CP solver
Projects
None yet
Development

No branches or pull requests

4 participants