-
Notifications
You must be signed in to change notification settings - Fork 456
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
Add DRT detour constraints (based on PR #2834) #2997
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
1b402e1
Add DRT detour constraints
luchengqi7 091e97e
Merge branch 'master' into drt-max-detour-constraint
luchengqi7 da6308b
Merge branch 'master' into drt-max-detour-constraint
luchengqi7 fe2a429
Consolidate two classes
luchengqi7 5c9a46e
Update SharingFactorTest.java
luchengqi7 529acd9
Merge branch 'master' into drt-max-detour-constraint
luchengqi7 2e48c44
Update expected outputs
luchengqi7 550a85c
Merge branch 'master' into drt-max-detour-constraint
luchengqi7 4107e7e
Unimportant commit
luchengqi7 144d77a
Merge branch 'master' into drt-max-detour-constraint
luchengqi7 d69429b
temporarily disable check
luchengqi7 dc0fe55
Update some naming and description
luchengqi7 9f252bf
Minor refactoring
luchengqi7 2f66229
Revert "temporarily disable check"
michalmac 65d6b46
taxi: update expected output plans in tests
michalmac 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 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
33 changes: 33 additions & 0 deletions
33
...ain/java/org/matsim/contrib/drt/optimizer/insertion/MaxDetourInsertionCostCalculator.java
This file contains 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,33 @@ | ||
package org.matsim.contrib.drt.optimizer.insertion; | ||
|
||
import org.matsim.contrib.drt.passenger.DrtRequest; | ||
|
||
/** | ||
* This insertion cost calculator performs additional check on the maximum ride duration, on top of the original InsertionCostCalculator | ||
* @author: Nico Kühnel (nkuehnel), Chengqi Lu (luchengqi7) | ||
* | ||
* The function is now implemented in the DefaultInsertionCostCalculator | ||
* */ | ||
@Deprecated | ||
public class MaxDetourInsertionCostCalculator implements InsertionCostCalculator { | ||
private final InsertionCostCalculator delegate; | ||
|
||
public MaxDetourInsertionCostCalculator(InsertionCostCalculator delegate) { | ||
this.delegate = delegate; | ||
} | ||
|
||
@Override | ||
public double calculate(DrtRequest drtRequest, InsertionGenerator.Insertion insertion, InsertionDetourTimeCalculator.DetourTimeInfo detourTimeInfo) { | ||
if (violatesDetour(drtRequest, detourTimeInfo)) { | ||
return INFEASIBLE_SOLUTION_COST; | ||
} | ||
return delegate.calculate(drtRequest, insertion, detourTimeInfo); | ||
} | ||
|
||
private boolean violatesDetour(DrtRequest drtRequest, InsertionDetourTimeCalculator.DetourTimeInfo detourTimeInfo) { | ||
// Check if the max travel time constraint for the newly inserted request is violated | ||
double rideDuration = detourTimeInfo.dropoffDetourInfo.arrivalTime - detourTimeInfo.pickupDetourInfo.departureTime; | ||
return drtRequest.getMaxRideDuration() < rideDuration; | ||
} | ||
|
||
} |
This file contains 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 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 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
23 changes: 23 additions & 0 deletions
23
contribs/drt/src/main/java/org/matsim/contrib/drt/passenger/MaxDetourOfferAcceptor.java
This file contains 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,23 @@ | ||
package org.matsim.contrib.drt.passenger; | ||
|
||
import java.util.Optional; | ||
|
||
public class MaxDetourOfferAcceptor implements DrtOfferAcceptor{ | ||
private final double maxAllowedPickupDelay; | ||
|
||
public MaxDetourOfferAcceptor(double maxAllowedPickupDelay) { | ||
this.maxAllowedPickupDelay = maxAllowedPickupDelay; | ||
} | ||
|
||
@Override | ||
public Optional<AcceptedDrtRequest> acceptDrtOffer(DrtRequest request, double departureTime, double arrivalTime) { | ||
double updatedLatestStartTime = Math.min(departureTime | ||
+ maxAllowedPickupDelay, request.getLatestStartTime()); | ||
return Optional.of(AcceptedDrtRequest | ||
.newBuilder() | ||
.request(request) | ||
.earliestStartTime(request.getEarliestStartTime()) | ||
.latestArrivalTime(Math.min(updatedLatestStartTime + request.getMaxRideDuration(), request.getLatestArrivalTime())) | ||
.latestStartTime(updatedLatestStartTime).build()); | ||
} | ||
} |
This file contains 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 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 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 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
Oops, something went wrong.
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.
I am not sure if we should use
unsharedRideTime + drtCfg.maxAbsoluteDetour
in bothgetMaxTravelTime()
andgetMaxRideTime()
.Imposing this constraint on
maxTravelTime
implies it is also imposed onmaxRideTime
, becausemaxTravelTime >= maxRideTime
.