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

allowDetourBeforeArrivalThreshold time for drt dropoffs #2455

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

nkuehnel
Copy link
Member

proposal:
usually, customers do not like being diverted shortly before their arrival, even though their time window would permit.
This PR introduces a hard constraint to the default DRT algorithm to allow setting a time from which it is no longer allowed to divert for new requests if a boarded passenger is very close to dropoff. By default it is set to 0 (as before).

Feedback / reviews welcome
@michalmac

@nkuehnel nkuehnel requested a review from michalmac March 17, 2023 16:19
// there is an existing stop following the new insertion
if(nextWaypoint instanceof Waypoint.Stop && nextWaypoint != insertion.pickup.newWaypoint) {
// passengers are being dropped off == may be close to arrival
if(!((Waypoint.Stop) nextWaypoint).task.getDropoffRequests().isEmpty()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if the second next waypoint is dropping off and is within the defined time limit?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good point. This means we need to iterate over all scheduled stops!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... all scheduled stops within the fixedApproachTime horizon

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @michalmac
I updated the code to check for all scheduled stops and check whether the actual detour caused is >0 (in some configurations it could also be that the new insertion is after the next stop and only adds an additional passenger to an existing stop without increasing stop duration, in which case there wouldn't be any additional detour)

"3 minutes away from her destination, even though her time window would allow it." +
" Delayed detour just before arrival are usually perceived very negatively.")
@PositiveOrZero // used only for stopbased DRT scheme
public double fixedApproachTime = 0;// [m];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixedApproachTime is too general. It will be very hard to memorise what it means. I think we need a name that would be more expressive.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about "allowDetourBeforeArrivalThreshold"?

@nkuehnel nkuehnel changed the title fixed approach time for drt dropoffs allowDetourBeforeArrivalThreshold time for drt dropoffs Mar 25, 2023
@nkuehnel nkuehnel marked this pull request as ready for review March 25, 2023 11:51
@nkuehnel
Copy link
Member Author

added a small test as well

@michalmac
Copy link
Member

@nkuehnel Let me know when it's ready for re-review. Thanks!

@nkuehnel
Copy link
Member Author

@michalmac it is, I guess :)

Copy link
Member

@michalmac michalmac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a few comments. Please consider them.

@@ -55,6 +60,32 @@ public double calculate(DrtRequest drtRequest, Insertion insertion, DetourTimeIn
return INFEASIBLE_SOLUTION_COST;
}

// all stops after the new (potential) pickup but before the new dropoff
// are delayed by pickupDetourTimeLoss
double detour = detourTimeInfo.pickupDetourInfo.pickupTimeLoss;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

detour -> timeLoss?

if(vEntry.stops != null) {
for (int s = insertion.pickup.index; s < vEntry.stops.size(); s++) {
Waypoint.Stop stop = vEntry.stops.get(s);
// passengers are being dropped off == may be close to arrival
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should limit the loop to the stops within the the time threshold:

if (nextArrival - departureTime >= drtConfigGroup.allowDetourBeforeArrivalThreshold) {
    break;
}

double nextArrival = stop.getArrivalTime();
double departureTime = insertion.vehicleEntry.start.getDepartureTime();
//arrival is very soon
if (nextArrival - departureTime < drtConfigGroup.allowDetourBeforeArrivalThreshold &&
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The condition nextArrival - departureTime < drtConfigGroup.allowDetourBeforeArrivalThreshold can be removed if the other if is added (see comment above).

detour > 0) {
return INFEASIBLE_SOLUTION_COST;
} else {
// all following stops are above the threshold
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this is correct if detour == 0 and we are still within the time threshold.

If this is indeed incorrect, consider adding such a case to your tests (BTW. Nice that you have already added some tests!).

}
if (s == insertion.dropoff.index) {
// all stops after the new (potential) dropoff are delayed by totalTimeLoss
detour = detourTimeInfo.getTotalTimeLoss();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding:

if (detour == 0) {
    break;
}

"3 minutes away from her destination, even though her time window would allow it." +
" Delayed detours just before arrival are usually perceived very negatively.")
@PositiveOrZero
public double allowDetourBeforeArrivalThreshold = 0; // [s];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This name is much better than the previous one!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants