-
Notifications
You must be signed in to change notification settings - Fork 453
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
13 changed files
with
218 additions
and
9 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
...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,30 @@ | ||
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) | ||
* */ | ||
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 promisedPickupTimeWindow; | ||
|
||
public MaxDetourOfferAcceptor(double promisedPickupTimeWindow) { | ||
this.promisedPickupTimeWindow = promisedPickupTimeWindow; | ||
} | ||
|
||
@Override | ||
public Optional<AcceptedDrtRequest> acceptDrtOffer(DrtRequest request, double departureTime, double arrivalTime) { | ||
double updatedPickupTimeWindow = Math.min(departureTime | ||
+ promisedPickupTimeWindow, request.getLatestStartTime()); | ||
return Optional.of(AcceptedDrtRequest | ||
.newBuilder() | ||
.request(request) | ||
.earliestStartTime(request.getEarliestStartTime()) | ||
.latestArrivalTime(Math.min(updatedPickupTimeWindow + request.getMaxRideDuration(), request.getLatestArrivalTime())) | ||
.latestStartTime(updatedPickupTimeWindow).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.