Skip to content

Commit

Permalink
Merge pull request #3426 from steffenaxer/ShiftScheduler
Browse files Browse the repository at this point in the history
DRT: Bypass Fleet object in schedule interface
  • Loading branch information
steffenaxer authored Aug 23, 2024
2 parents 03c1cb1 + 4a6f095 commit c9c868a
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.google.common.collect.ImmutableMap;
import org.matsim.api.core.v01.Id;
import org.matsim.contrib.drt.extension.operations.shifts.shift.*;
import org.matsim.contrib.dvrp.fleet.Fleet;

import java.util.Collections;
import java.util.List;
Expand Down Expand Up @@ -32,7 +33,7 @@ public DefaultShiftScheduler(DrtShiftsSpecification shiftsSpecification) {
this.shiftsSpecification = shiftsSpecification;
}
@Override
public List<DrtShift> schedule(double time) {
public List<DrtShift> schedule(double time, Fleet fleet) {
return Collections.emptyList();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public void dispatch(double timeStep) {
if (timeStep % (drtShiftParams.updateShiftEndInterval) == 0) {
updateShiftEnds(timeStep);
}
scheduleShifts(timeStep);
scheduleShifts(timeStep, this.fleet);
assignShifts(timeStep);
startShifts(timeStep);
checkBreaks();
Expand Down Expand Up @@ -172,8 +172,8 @@ private void checkBreaks() {
}


private void scheduleShifts(double timeStep) {
List<DrtShift> scheduled = shiftScheduler.schedule(timeStep);
private void scheduleShifts(double timeStep, Fleet fleet) {
List<DrtShift> scheduled = shiftScheduler.schedule(timeStep, fleet);
unAssignedShifts.addAll(scheduled);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@
import org.matsim.contrib.drt.extension.operations.shifts.shift.DrtShiftsSpecification;

import jakarta.inject.Provider;
import org.matsim.contrib.dvrp.fleet.Fleet;

import java.util.List;

/**
* @author nkuehnel / MOIA
*/
public interface ShiftScheduler extends Provider<DrtShiftsSpecification> {

List<DrtShift> schedule(double time);
List<DrtShift> schedule(double time, Fleet fleet);
ImmutableMap<Id<DrtShift>, DrtShift> initialSchedule();

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.matsim.contrib.drt.optimizer.rebalancing.mincostflow.MinCostFlowRebalancingStrategyParams;
import org.matsim.contrib.drt.run.DrtConfigGroup;
import org.matsim.contrib.drt.run.MultiModeDrtConfigGroup;
import org.matsim.contrib.dvrp.fleet.Fleet;
import org.matsim.contrib.dvrp.run.AbstractDvrpModeModule;
import org.matsim.contrib.dvrp.run.DvrpConfigGroup;
import org.matsim.contrib.zone.skims.DvrpTravelTimeMatrixParams;
Expand Down Expand Up @@ -182,7 +183,7 @@ public DrtShiftsSpecification get() {
}

@Override
public List<DrtShift> schedule(double time) {
public List<DrtShift> schedule(double time, Fleet fleet) {
List<DrtShiftSpecification> shifts = new ArrayList<>();
if (time > 4 * 3600 && time < 15 * 3600 && time % 3600 == 0) {
for (int i = 0; i < iteration + 1 ; i++) {
Expand Down

0 comments on commit c9c868a

Please sign in to comment.