8000 feat(drt): explicit max ride constraints in drt by nkuehnel · Pull Request #3922 · matsim-org/matsim-libs · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

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
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import org.matsim.contrib.drt.prebooking.PrebookingActionCreator;
import org.matsim.contrib.drt.run.DrtConfigGroup;
import org.matsim.contrib.drt.schedule.DrtRoutingDriveTaskUpdater;
import org.matsim.contrib.drt.schedule.DrtScheduleTimingUpdater;
import org.matsim.contrib.drt.schedule.DrtTaskFactory;
import org.matsim.contrib.drt.scheduler.DefaultRequestInsertionScheduler;
import org.matsim.contrib.drt.scheduler.DrtScheduleInquiry;
Expand All @@ -55,6 +56,7 @@
import org.matsim.contrib.dvrp.run.DvrpModes;
import org.matsim.contrib.dvrp.schedule.DriveTaskUpdater;
import org.matsim.contrib.dvrp.schedule.ScheduleTimingUpdater;
import org.matsim.contrib.dvrp.schedule.ScheduleTimingUpdaterImpl;
import org.matsim.contrib.dvrp.vrpagent.VrpAgentLogic;
import org.matsim.contrib.dvrp.vrpagent.VrpLegFactory;
import org.matsim.contrib.ev.charging.ChargingStrategy;
Expand Down Expand Up @@ -198,9 +200,9 @@ public EmptyVehicleRelocator get() {
}

bindModal(ScheduleTimingUpdater.class).toProvider(modalProvider(
getter -> new ScheduleTimingUpdater(getter.get(MobsimTimer.class),
getter -> new DrtScheduleTimingUpdater(new ScheduleTimingUpdaterImpl(getter.get(MobsimTimer.class),
new EDrtStayTaskEndTimeCalculator(getter.getModal(StopTimeCalculator.class)),
getter.getModal(DriveTaskUpdater.class)))).asEagerSingleton();
getter.getModal(DriveTaskUpdater.class)), getter.getModal(PassengerStopDurationProvider.class)))).asEagerSingleton();

bindModal(VrpLegFactory.class).toProvider(modalProvider(getter -> {
DvrpConfigGroup dvrpCfg = getter.get(DvrpConfigGroup.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ public Optional<AcceptedDrtRequest> acceptDrtOffer(DrtRequest request, double de

return Optional
.of(AcceptedDrtRequest.newBuilder().request(request).earliestStartTime(request.getEarliestStartTime())
.latestArrivalTime(updatedDropoffTimeWindow).latestStartTime(updatedPickupTimeWindow).build());
.latestArrivalTime(updatedDropoffTimeWindow).maxRideDuration(request.getMaxRideDuration()).latestStartTime(updatedPickupTimeWindow).build());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@
import org.matsim.contrib.drt.optimizer.rebalancing.RebalancingStrategy;
import org.matsim.contrib.drt.prebooking.PrebookingActionCreator;
import org.matsim.contrib.drt.run.DrtConfigGroup;
import org.matsim.contrib.drt.schedule.DrtScheduleTimingUpdater;
import org.matsim.contrib.drt.schedule.DrtStayTaskEndTimeCalculator;
import org.matsim.contrib.drt.schedule.DrtTaskFactory;
import org.matsim.contrib.drt.schedule.DrtTaskFactoryImpl;
import org.matsim.contrib.drt.scheduler.DrtScheduleInquiry;
import org.matsim.contrib.drt.scheduler.EmptyVehicleRelocator;
import org.matsim.contrib.drt.stops.PassengerStopDurationProvider;
import org.matsim.contrib.drt.stops.StopTimeCalculator;
import org.matsim.contrib.drt.vrpagent.DrtActionCreator;
import org.matsim.contrib.dvrp.fleet.DvrpVehicleImpl;
Expand All @@ -46,6 +48,7 @@
import org.matsim.contrib.dvrp.run.DvrpModes;
import org.matsim.contrib.dvrp.schedule.DriveTaskUpdater;
import org.matsim.contrib.dvrp.schedule.ScheduleTimingUpdater;
import org.matsim.contrib.dvrp.schedule.ScheduleTimingUpdaterImpl;
import org.matsim.contrib.dvrp.tracker.OnlineTrackerListener;
import org.matsim.contrib.dvrp.vrpagent.VrpAgentLogic;
import org.matsim.contrib.dvrp.vrpagent.VrpLegFactory;
Expand Down Expand Up @@ -126,11 +129,11 @@ shiftsParams, new DefaultShiftStartLogic(), getter.getModal(AssignShiftToVehicle
bindModal(DrtScheduleInquiry.class).to(ShiftDrtScheduleInquiry.class).asEagerSingleton();

bindModal(ScheduleTimingUpdater.class).toProvider(modalProvider(
getter -> new ScheduleTimingUpdater(getter.get(MobsimTimer.class),
getter -> new DrtScheduleTimingUpdater(new ScheduleTimingUpdaterImpl(getter.get(MobsimTimer.class),
new ShiftDrtStayTaskEndTimeCalculator(shiftsParams,
new DrtStayTaskEndTimeCalculator(getter.getModal(StopTimeCalculator.class))),
getter.getModal(DriveTaskUpdater.class)))
).asEagerSingleton();
getter.getModal(DriveTaskUpdater.class)), getter.getModal(PassengerStopDurationProvider.class))
)).asEagerSingleton();

// see DrtModeOptimizerQSimModule
bindModal(VrpLegFactory.class).toProvider(modalProvider(getter -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,8 @@
import org.matsim.api.core.v01.network.Network;
import org.matsim.contrib.drt.optimizer.DrtOptimizer;
import org.matsim.contrib.drt.run.DrtConfigGroup;
import org.matsim.contrib.drt.schedule.DrtRoutingDriveTaskUpdater;
import org.matsim.contrib.drt.schedule.DrtStayTaskEndTimeCalculator;
import org.matsim.contrib.drt.schedule.DrtTaskFactory;
import org.matsim.contrib.drt.schedule.DrtTaskFactoryImpl;
import org.matsim.contrib.drt.schedule.*;
import org.matsim.contrib.drt.stops.PassengerStopDurationProvider;
import org.matsim.contrib.drt.stops.StopTimeCalculator;
import org.matsim.contrib.drt.vrpagent.DrtActionCreator;
import org.matsim.contrib.dvrp.fleet.Fleet;
Expand All @@ -35,6 +33,7 @@
import org.matsim.contrib.dvrp.run.DvrpConfigGroup;
import org.matsim.contrib.dvrp.schedule.DriveTaskUpdater;
import org.matsim.contrib.dvrp.schedule.ScheduleTimingUpdater;
import org.matsim.contrib.dvrp.schedule.ScheduleTimingUpdaterImpl;
import org.matsim.contrib.dvrp.tracker.OnlineTrackerListener;
import org.matsim.contrib.dvrp.vrpagent.VrpAgentLogic;
import org.matsim.contrib.dvrp.vrpagent.VrpLegFactory;
Expand Down Expand Up @@ -100,8 +99,8 @@ protected void configureQSim() {
}

bindModal(ScheduleTimingUpdater.class).toProvider(modalProvider(
getter -> new ScheduleTimingUpdater(getter.get(MobsimTimer.class),
getter -> new DrtScheduleTimingUpdater(new ScheduleTimingUpdaterImpl(getter.get(MobsimTimer.class),
new DrtStayTaskEndTimeCalculator(getter.getModal(StopTimeCalculator.class)),
getter.getModal(DriveTaskUpdater.class)))).asEagerSingleton();
getter.getModal(DriveTaskUpdater.class)), getter.getModal(PassengerStopDurationProvider.class)))).asEagerSingleton();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import org.matsim.contrib.drt.run.DrtConfigGroup;
import org.matsim.contrib.drt.run.DrtModeRoutingModule;
import org.matsim.contrib.drt.stops.DefaultStopTimeCalculator;
import org.matsim.contrib.drt.stops.PassengerStopDurationProvider;
import org.matsim.contrib.drt.stops.StaticPassengerStopDurationProvider;
import org.matsim.contrib.drt.stops.StopTimeCalculator;
import org.matsim.contrib.dvrp.fleet.FleetModule;
import org.matsim.contrib.dvrp.load.DvrpLoadType;
Expand Down Expand Up @@ -78,6 +80,10 @@ public void install() {

install(new DrtModeRoutingModule(drtCfg));

bindModal(PassengerStopDurationProvider.class).toProvider(modalProvider(getter -> {
return StaticPassengerStopDurationProvider.of(drtCfg.getStopDuration(), 0.0);
}));

drtCfg.getDrtFareParams()
.ifPresent(params -> addEventHandlerBinding().toInstance(new DrtFareHandler(getMode(), params)));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import org.matsim.contrib.dvrp.load.DvrpLoadType;
import org.matsim.contrib.dvrp.run.AbstractDvrpModeQSimModule;
import org.matsim.contrib.dvrp.schedule.ScheduleTimingUpdater;
import org.matsim.contrib.dvrp.schedule.ScheduleTimingUpdaterImpl;
import org.matsim.contrib.dvrp.vrpagent.VrpAgentLogic;
import org.matsim.core.mobsim.framework.MobsimTimer;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,7 @@
import org.matsim.contrib.drt.passenger.DrtOfferAcceptor;
import org.matsim.contrib.drt.prebooking.PrebookingActionCreator;
import org.matsim.contrib.drt.run.DrtConfigGroup;
import org.matsim.contrib.drt.schedule.DrtRoutingDriveTaskUpdater;
import org.matsim.contrib.drt.schedule.DrtStayTaskEndTimeCalculator;
import org.matsim.contrib.drt.schedule.DrtTaskFactory;
import org.matsim.contrib.drt.schedule.DrtTaskFactoryImpl;
import org.matsim.contrib.drt.schedule.*;
import org.matsim.contrib.drt.scheduler.DefaultRequestInsertionScheduler;
import org.matsim.contrib.drt.scheduler.DrtScheduleInquiry;
import org.matsim.contrib.drt.scheduler.EmptyVehicleRelocator;
Expand All @@ -61,6 +58,7 @@
import org.matsim.contrib.dvrp.run.DvrpModes;
import org.matsim.contrib.dvrp.schedule.DriveTaskUpdater;
import org.matsim.contrib.dvrp.schedule.ScheduleTimingUpdater;
import org.matsim.contrib.dvrp.schedule.ScheduleTimingUpdaterImpl;
import org.matsim.contrib.dvrp.tracker.OnlineTrackerListener;
import org.matsim.contrib.dvrp.vrpagent.VrpAgentLogic;
import org.matsim.contrib.dvrp.vrpagent.VrpLegFactory;
Expand Down Expand Up @@ -185,9 +183,9 @@ public EmptyVehicleRelocator get() {
}

bindModal(ScheduleTimingUpdater.class).toProvider(modalProvider(
getter -> new ScheduleTimingUpdater(getter.get(MobsimTimer.class),
getter -> new DrtScheduleTimingUpdater(new ScheduleTimingUpdaterImpl(getter.get(MobsimTimer.class),
new DrtStayTaskEndTimeCalculator(getter.getModal(StopTimeCalculator.class)),
getter.getModal(DriveTaskUpdater.class)))).asEagerSingleton();
getter.getModal(DriveTaskUpdater.class)), getter.getModal(PassengerStopDurationProvider.class)))).asEagerSingleton();

bindModal(VrpLegFactory.class).toProvider(modalProvider(getter -> {
DvrpConfigGroup dvrpCfg = getter.get(DvrpConfigGroup.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.util.ArrayList;
import java.util.List;

import org.matsim.contrib.drt.passenger.AcceptedDrtRequest;
import org.matsim.contrib.drt.schedule.DrtStopTask;
import org.matsim.contrib.drt.schedule.DrtCapacityChangeTask;
import org.matsim.contrib.dvrp.fleet.DvrpVehicle;
Expand Down Expand Up @@ -118,20 +119,40 @@ public VehicleEntry create(DvrpVehicle vehicle, double currentTime) {
ImmutableList.copyOf(stops), slackTimes, precedingStayTimes, currentTime);
}

static double[] computeSlackTimes(DvrpVehicle vehicle, double now, Waypoint.Stop[] stops, Waypoint.Stop start, List<Double> precedingStayTimes) {
static double[] computeSlackTimes(DvrpVehicle vehicle, double now, Waypoint.Stop[] stops, Waypoint.Stop start,
List<Double> precedingStayTimes) {
double[] slackTimes = new double[stops.length + 2];

//vehicle
double slackTime = calcVehicleSlackTime(vehicle, now);
slackTimes[stops.length + 1] = slackTime;

List<AcceptedDrtRequest> ArrayList<>();

//stops
for (int i = stops.length - 1; i >= 0; i--) {

var stop = stops[i];

onboard.addAll(stop.task.getDropoffRequests().values());

slackTime = Math.min(stop.latestArrivalTime - stop.task.getBeginTime(), slackTime);
slackTime = Math.min(stop.latestDepartureTime - stop.task.getEndTime(), slackTime);

for (AcceptedDrtRequest req : onboard) {
double plannedPickupTime = req.getPickupTime().orElseThrow(()
-> new IllegalStateException("Accepted request should have a (planned) pickup time at this point."));
double plannedDropoffTime = req.getDropoffTime().orElseThrow(()
-> new IllegalStateException("Accepted request should have a (planned) dropoff time at this point."));
double currentRideDuration = plannedDropoffTime - plannedPickupTime;
double currentRideSlack = Math.max(0, req.getMaxRideDuration() - currentRideDuration);
slackTime = Math.min(slackTime, currentRideSlack);
}

slackTime += precedingStayTimes.get(i); // reset slack before prebooked request
slackTimes[i + 1] = slackTime;

onboard.removeAll(stop.task.getPickupRequests().values());
}

// start
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ public abstract class DrtOptimizationConstraintsSet extends ReflectiveConfigGrou
+ " violates one of the constraints is allowed, but its cost is increased by additional penalty to make"
+ " it relatively less attractive). Penalisation of insertions can be customised by injecting a customised"
+ " InsertionCostCalculator.PenaltyCalculator")
private boolean rejectRequestIfMaxWaitOrTravelTimeViolated = true;//TODO consider renaming maxWalkDistance to max access/egress distance (or even have 2 separate params)
public boolean rejectRequestIfMaxWaitOrTravelTimeViolated = true;


//TODO consider renaming maxWalkDistance to max access/egress distance (or even have 2 separate params)
@Parameter
@Comment(
"Maximum beeline distance (in meters) to next stop location in stopbased system for access/egress walk leg to/from drt."
Expand Down
Copy link
Collaborator

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.

Copy link
Member Author
@nkuehnel nkuehnel May 7, 2025

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

Copy link
Member Author

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

Copy link
Collaborator

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..

Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class DiscourageSoftConstraintViolations implements CostCalculationStrategy {
static final double MAX_WAIT_TIME_VIOLATION_PENALTY = 1;// 1 second of penalty per 1 second of late departure
static final double MAX_TRAVEL_TIME_VIOLATION_PENALTY = 10;// 10 seconds of penalty per 1 second of late arrival
static final double MAX_RIDE_TIME_VIOLATION_PENALTY = 10;// 10 seconds of penalty per 1 second of exceeded detour
static final double LATE_DIVERSION_VIOLATION_PENALTY = 10;// 1 second of penalty per 1 second of late diversion of onboard requests
static final double LATE_DIVERSION_VIOLATION_PENALTY = 10;// 10 second of penalty per 1 second of late diversion of onboard requests

@Override
public double calcCost(DrtRequest request, InsertionGenerator.Insertion insertion,
Expand Down Expand Up @@ -114,7 +114,7 @@ public double calcCost(DrtRequest request, InsertionGenerator.Insertion insertio
return MAX_WAIT_TIME_VIOLATION_PENALTY * waitTimeViolation
+ MAX_TRAVEL_TIME_VIOLATION_PENALTY * travelTimeViolation
+ MAX_RIDE_TIME_VIOLATION_PENALTY * detourViolation
+ MAX_RIDE_TIME_VIOLATION_PENALTY * lateDiversionViolation
+ LATE_DIVERSION_VIOLATION_PENALTY * lateDiversionViolation
+ totalTimeLoss;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,19 +142,21 @@ private void scheduleUnplannedRequest(DrtRequest req, Map<Id<DvrpVehicle>, Vehic
var vehicle = insertion.insertion.vehicleEntry.vehicle;
var pickupDropoffTaskPair = insertionScheduler.scheduleRequest(acceptedRequest.get(), insertion);

VehicleEntry newVehicleEntry = vehicleEntryFactory.create(vehicle, now);
if (newVehicleEntry != null) {
vehicleEntries.put(vehicle.getId(), newVehicleEntry);
} else {
vehicleEntries.remove(vehicle.getId());
}

double expectedPickupTime = pickupDropoffTaskPair.pickupTask.getBeginTime();
expectedPickupTime = Math.max(expectedPickupTime, acceptedRequest.get().getEarliestStartTime());
expectedPickupTime += stopDurationProvider.calcPickupDuration(vehicle, req);
acceptedRequest.get().setPickupTime(expectedPickupTime);

double expectedDropoffTime = pickupDropoffTaskPair.dropoffTask.getBeginTime();
expectedDropoffTime += stopDurationProvider.calcDropoffDuration(vehicle, req);
acceptedRequest.get().setDropoffTime(expectedDropoffTime);

VehicleEntry newVehicleEntry = vehicleEntryFactory.create(vehicle, now);
if (newVehicleEntry != null) {
vehicleEntries.put(vehicle.getId(), newVehicleEntry);
} else {
vehicleEntries.remove(vehicle.getId());
}

eventsManager.processEvent(
new PassengerRequestScheduledEvent(now, mode, req.getId(), req.getPassengerIds(), vehicle.getId(),
Expand Down
10000
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.matsim.contrib.dvrp.optimizer.Request;

import java.util.List;
import java.util.Optional;

/**
* @author Michal Maciejewski (michalm)
Expand All @@ -50,6 +51,12 @@ public static AcceptedDrtRequest createFromOriginalRequest(DrtRequest request) {
private final double latestArrivalTime;
private final double maxRideDuration;

// allow null to ensure we realize it hasn't been set
private Double pickupTime = null;

// allow null to ensure we realize it hasn't been set
private Double dropoffTime = null;

private AcceptedDrtRequest(Builder builder) {
request = builder.request;
earliestStartTime = builder.earliestStartTime;
Expand Down Expand Up @@ -119,6 +126,22 @@ public String getMode() {
return request.getMode();
}

public void setPickupTime(double pickupTime) {
this.pickupTime = pickupTime;
}

public Optional<Double> getPickupTime() {
return Optional.ofNullable(pickupTime);
}

public void setDropoffTime(double dropoffTime) {
this.dropoffTime = dropoffTime;
}

public Optional<Double> getDropoffTime() {
return Optional.ofNullable(dropoffTime);
}

@Override
public String toString() {
return MoreObjects.toStringHelper(this)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public Optional<AcceptedDrtRequest> acceptDrtOffer(DrtRequest request, double de
.request(request)
.earliestStartTime(request.getEarliestStartTime())
.maxRideDuration(request.getMaxRideDuration())
.latestArrivalTime(Math.min(updatedLatestStartTime + request.getMaxRideDuration(), request.getLatestArrivalTime()))
.latestArrivalTime(request.getLatestArrivalTime())
.latestStartTime(updatedLatestStartTime)
.build());
}
Expand Down
< DCE2 tr data-position="0">
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()));
}
}
}
}
}
Loading
0