forked from matsim-org/matsim-libs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #112 from moia-oss/master
Update MATSim CW35
- Loading branch information
Showing
46 changed files
with
2,598 additions
and
1,768 deletions.
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
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
44 changes: 44 additions & 0 deletions
44
...in/java/org/matsim/contrib/drt/extension/operations/shifts/analysis/RegularShiftDump.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,44 @@ | ||
package org.matsim.contrib.drt.extension.operations.shifts.analysis; | ||
|
||
import com.google.inject.Provider; | ||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
import org.matsim.contrib.drt.extension.operations.shifts.io.DrtShiftsWriter; | ||
import org.matsim.contrib.drt.extension.operations.shifts.shift.DrtShiftsSpecification; | ||
import org.matsim.core.controler.OutputDirectoryHierarchy; | ||
import org.matsim.core.controler.events.IterationEndsEvent; | ||
import org.matsim.core.controler.listener.IterationEndsListener; | ||
|
||
|
||
/** | ||
* | ||
* @author nkuehnel / MOIA | ||
*/ | ||
final public class RegularShiftDump implements IterationEndsListener { | ||
private static final Logger log = LogManager.getLogger( RegularShiftDump.class ); | ||
|
||
private final Provider<DrtShiftsSpecification> shifts; | ||
|
||
private final OutputDirectoryHierarchy controlerIO; | ||
|
||
public RegularShiftDump(Provider<DrtShiftsSpecification> shifts, OutputDirectoryHierarchy controlerIO) { | ||
this.shifts = shifts; | ||
this.controlerIO = controlerIO; | ||
} | ||
|
||
private void dumpShiftPans(int iteration) { | ||
try { | ||
if ( this.shifts!=null){ | ||
new DrtShiftsWriter(shifts.get()).writeFile(this.controlerIO.getIterationFilename(iteration, "output_shifts.xml.gz")); | ||
} | ||
} catch ( Exception ee ) { | ||
log.error("Exception writing shifts.", ee); | ||
} | ||
} | ||
|
||
|
||
@Override | ||
public void notifyIterationEnds(IterationEndsEvent event) { | ||
dumpShiftPans(event.getIteration()); | ||
} | ||
} |
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
52 changes: 52 additions & 0 deletions
52
.../org/matsim/contrib/drt/extension/operations/shifts/dispatcher/DefaultShiftScheduler.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,52 @@ | ||
package org.matsim.contrib.drt.extension.operations.shifts.dispatcher; | ||
|
||
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; | ||
import java.util.function.Function; | ||
|
||
/** | ||
* @author nkuehnel / MOIA | ||
*/ | ||
public final class DefaultShiftScheduler implements ShiftScheduler { | ||
|
||
private final DrtShiftsSpecification shiftsSpecification; | ||
public static Function<DrtShiftSpecification, DrtShift> createShiftFromSpec = spec -> { | ||
DefaultShiftBreakImpl shiftBreak = null; | ||
DrtShiftBreakSpecification breakSpec = spec.getBreak().orElse(null); | ||
if (breakSpec != null) { | ||
shiftBreak = new DefaultShiftBreakImpl( | ||
breakSpec.getEarliestBreakStartTime(), | ||
breakSpec.getLatestBreakEndTime(), | ||
breakSpec.getDuration()); | ||
} | ||
return (DrtShift) new DrtShiftImpl(spec.getId(), spec.getStartTime(), spec.getEndTime(), | ||
spec.getOperationFacilityId().orElse(null), spec.getDesignatedVehicleId().orElse(null), | ||
shiftBreak); | ||
}; | ||
|
||
public DefaultShiftScheduler(DrtShiftsSpecification shiftsSpecification) { | ||
this.shiftsSpecification = shiftsSpecification; | ||
} | ||
@Override | ||
public List<DrtShift> schedule(double time, Fleet fleet) { | ||
return Collections.emptyList(); | ||
} | ||
|
||
@Override | ||
public ImmutableMap<Id<DrtShift>, DrtShift> initialSchedule() { | ||
return shiftsSpecification.getShiftSpecifications().values() | ||
.stream() | ||
.map(createShiftFromSpec) | ||
.collect(ImmutableMap.toImmutableMap(DrtShift::getId, s -> s)); | ||
} | ||
|
||
@Override | ||
public DrtShiftsSpecification get() { | ||
return shiftsSpecification; | ||
} | ||
} |
Oops, something went wrong.