Skip to content

Commit

Permalink
Merge pull request matsim-org#3021 from moia-oss/tekuhlen_fix_shiftRe…
Browse files Browse the repository at this point in the history
…movalWhenStartTime<Timestep

DRT: add maxShiftStartDelay and log message when a shift is deleted due to…
  • Loading branch information
nkuehnel authored Dec 28, 2023
2 parents 7e682d9 + 2196635 commit f8d7750
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import org.matsim.core.config.ConfigGroup;

import java.net.URL;
import java.util.Map;

/**
* @author nkuehnel / MOIA
Expand All @@ -30,6 +29,10 @@ public class ShiftsParams extends ReflectiveConfigGroupWithConfigurableParameter
@Comment("changeover duration in [seconds]")
public double changeoverDuration = 900;

@Parameter
@Comment("maximum delay of shift assignment after start time has passed in [seconds]. If a shift can not be assigned to a vehicle until the planned start of the shift plus the defined max delay, the shift is discarded. Defaults to 0")
public double maxUnscheduledShiftDelay = 0;

@Parameter
@Comment("Time of shift assignment (i.e. which vehicle carries out a specific shift) before start of shift in [seconds]")
public double shiftScheduleLookAhead = 1800;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,13 @@ private void startShifts(double timeStep) {

private void assignShifts(double timeStep) {
// Remove elapsed shifts
unscheduledShifts.removeIf(shift -> shift.getStartTime() < timeStep);
unscheduledShifts.removeIf(shift -> {
if (shift.getStartTime() + drtShiftParams.maxUnscheduledShiftDelay < timeStep ) {
logger.warn("Shift with ID " + shift.getId() + " could not be assigned and is being removed as start time is longer in the past than defined by maxUnscheduledShiftDelay.");
return true;
}
return false;
});

// Assign shifts
Set<DrtShift> assignableShifts = new LinkedHashSet<>();
Expand Down

0 comments on commit f8d7750

Please sign in to comment.