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
base: master
Are you sure you want to change the base?
Conversation
contribs/drt/src/main/java/org/matsim/contrib/drt/run/DrtConfigGroup.java
Outdated
Show resolved
Hide resolved
contribs/drt/src/main/java/org/matsim/contrib/drt/run/DrtConfigGroup.java
Outdated
Show resolved
Hide resolved
// 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()) { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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]; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about "allowDetourBeforeArrivalThreshold"?
...src/main/java/org/matsim/contrib/drt/optimizer/insertion/DefaultInsertionCostCalculator.java
Outdated
Show resolved
Hide resolved
added a small test as well |
@nkuehnel Let me know when it's ready for re-review. Thanks! |
@michalmac it is, I guess :) |
There was a problem hiding this 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; |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 && |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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]; |
There was a problem hiding this comment.
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!
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