-
Notifications
You must be signed in to change notification settings - Fork 471
feat(drt): explicit max ride constraints in drt #3922
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
Open
nkuehnel
wants to merge
5
commits into
matsim-org:main
Choose a base branch
from
moia-oss:drt-explicitMaxRideConstraints
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
606c608
drt - explicit ride duration constraints
nkuehnel 83957b5
Merge branch 'main' into drt-explicitMaxRideConstraints
nkuehnel 48719f4
fix compilation issue
nkuehnel 861df4c
fix tests, use correct timing updater bindings, use max ride constrai…
nkuehnel e9e28d3
fix tests, use correct timing updater bindings,
nkuehnel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
contribs/drt/src/main/java/org/matsim/contrib/drt/schedule/DrtScheduleTimingUpdater.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | @@ -0,0 +1,69 @@ |
---|---|---|
package org.matsim.contrib.drt.schedule; | ||
|
||
import org.matsim.contrib.drt.passenger.AcceptedDrtRequest; | ||
import org.matsim.contrib.drt.stops.PassengerStopDurationProvider; | ||
import org.matsim.contrib.dvrp.fleet.DvrpVehicle; | ||
import org.matsim.contrib.dvrp.schedule.Schedule; | ||
import org.matsim.contrib.dvrp.schedule.ScheduleTimingUpdater; | ||
import org.matsim.contrib.dvrp.schedule.Task; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Drt specific timing updater that also updates current timing estimates on accepted requests. | ||
*/ | ||
public class DrtScheduleTimingUpdater implements ScheduleTimingUpdater { | ||
|
||
private final ScheduleTimingUpdater delegate; | ||
private final PassengerStopDurationProvider stopDurationProvider; | ||
|
||
public DrtScheduleTimingUpdater(ScheduleTimingUpdater delegate, | ||
PassengerStopDurationProvider stopDurationProvider) { | ||
this.delegate = delegate; | ||
this.stopDurationProvider = stopDurationProvider; | ||
} | ||
|
||
@Override | ||
public void updateBeforeNextTask(DvrpVehicle vehicle) { | ||
if (vehicle.getSchedule().getStatus() != Schedule.ScheduleStatus.STARTED) { | ||
return; | ||
} | ||
delegate.updateBeforeNextTask(vehicle); | ||
updatePuDoTimes(vehicle, vehicle.getSchedule().getCurrentTask().getTaskIdx()); | ||
} | ||
|
||
@Override | ||
public void updateTimings(DvrpVehicle vehicle) { | ||
if (vehicle.getSchedule().getStatus() != Schedule.ScheduleStatus.STARTED) { | ||
return; | ||
} | ||
delegate.updateTimings(vehicle); | ||
updatePuDoTimes(vehicle, vehicle.getSchedule().getCurrentTask().getTaskIdx()); | ||
} | ||
|
||
|
||
@Override | ||
public void updateTimingsStartingFromTaskIdx(DvrpVehicle vehicle, int startIdx, double newBeginTime) { | ||
delegate.updateTimingsStartingFromTaskIdx(vehicle, startIdx, newBeginTime); | ||
updatePuDoTimes(vehicle, startIdx); | ||
} | ||
|
||
private void updatePuDoTimes(DvrpVehicle vehicle, int startIdx) { | ||
|
||
Schedule schedule = vehicle.getSchedule(); | ||
List<? extends Task> tasks = schedule.getTasks(); | ||
|
||
for (int i = startIdx; i < tasks.size(); i++) { | ||
if(tasks.get(i) instanceof DrtStopTask stopTask) { | ||
for (AcceptedDrtRequest pickup : stopTask.getPickupRequests().values()) { | ||
double expectedPickupTime = Math.max(stopTask.getBeginTime(), pickup.getEarliestStartTime()); | ||
expectedPickupTime += stopDurationProvider.calcPickupDuration(vehicle, pickup.getRequest()); | ||
pickup.setPickupTime(expectedPickupTime); | ||
} | ||
for (AcceptedDrtRequest dropoff : stopTask.getDropoffRequests().values()) { | ||
dropoff.setDropoffTime(stopTask.getBeginTime() + stopDurationProvider.calcDropoffDuration(vehicle, dropoff.getRequest())); | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Does this LATE_DIVERSION_VIOLATION_PENALTY also correspond to the latest arrival time?
A note based on a chat with Michal several years ago: these values are chosen as the initial values. And it may not be the ideal one, but it works for now.
Uh oh!
There was an error while loading. Please reload this page.
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.
@luchengqi7
The latest arrival time still has its own penalty, these are all the penalties we have now:
MAX_WAIT_TIME_VIOLATION_PENALTY = 1;// 1 second of penalty per 1 second of late departure
MAX_TRAVEL_TIME_VIOLATION_PENALTY = 10;// 10 seconds of penalty per 1 second of late arrival
MAX_RIDE_TIME_VIOLATION_PENALTY = 10;// 10 seconds of penalty per 1 second of exceeded detour
LATE_DIVERSION_VIOLATION_PENALTY = 10;// 1 second of penalty per 1 second of late diversion of onboard requests
LATE_DIVERSION_VIOLATION_PENALTY = 10;// 10 second of penalty per 1 second of late diversion of onboard requests
The late diversion can be configured so that x seconds before the expected dropoff, passengers may not be detoured anymore, even if it would fit into the initial time window contract. However, this was introduced in an earlier PR and should not be affected by this one
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.
Ah and I havent had the chance to really test performance impacts. I can do that before merging
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 did some informal checking on performance and at least in one scenario it was progressing noticeably faster, but this was likely due to increased rejections. A more correct assessment of performance would be to verify it in an test case where rejections are exactly the same before/after this change..