Skip to content

Commit

Permalink
chore: update to MATSim 16
Browse files Browse the repository at this point in the history
  • Loading branch information
sebhoerl committed Nov 27, 2023
1 parent d354656 commit 165bec0
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,22 @@ public int getCandidateVehiclesPerRequest() {
public void setCandidateVehiclesPerRequest(int value) {
this.candidateVehiclesPerRequest = value;
}

private final static String PLANNING_HORIZON = "planningHorizon";
private final static String PLANNING_HORIZON_COMMENT = "Defines how much in advance requests are considered for scheduling";

@PositiveOrZero
private double planningHorizon = 0.0;

@StringGetter(PLANNING_HORIZON)
public double getPlanningHorizon() {
return planningHorizon;
}

@StringSetter(PLANNING_HORIZON)
public void setPlanningHorizon(double value) {
this.planningHorizon = value;
}

@Override
public Map<String, String> getComments() {
Expand All @@ -252,6 +268,7 @@ public Map<String, String> getComments() {
comments.put(VIOLATION_OFFSET, VIOLATION_OFFSET_COMMENT);
comments.put(PREFER_NON_VIOLATION, PREFER_NON_VIOLATION_COMMENT);
comments.put(CANDIDATE_VEHICLES_PER_REQUEST, CANDIDATE_VEHICLES_PER_REQUEST_COMMENT);
comments.put(PLANNING_HORIZON, PLANNING_HORIZON_COMMENT);
return comments;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@
import org.matsim.contrib.drt.run.DrtConfigGroup;
import org.matsim.contrib.drt.schedule.DrtStayTaskEndTimeCalculator;
import org.matsim.contrib.drt.schedule.DrtTaskFactory;
import org.matsim.contrib.drt.schedule.StopDurationEstimator;
import org.matsim.contrib.drt.scheduler.DrtScheduleInquiry;
import org.matsim.contrib.drt.scheduler.EmptyVehicleRelocator;
import org.matsim.contrib.drt.stops.StopTimeCalculator;
import org.matsim.contrib.dvrp.fleet.Fleet;
import org.matsim.contrib.dvrp.path.VrpPaths;
import org.matsim.contrib.dvrp.run.AbstractDvrpModeQSimModule;
Expand Down Expand Up @@ -333,7 +333,7 @@ protected void configureQSim() {
bindModal(Constraint.class).toInstance(new NoopConstraint());

bindModal(StayTaskEndTimeCalculator.class).toProvider(modalProvider(getter -> {
return new DrtStayTaskEndTimeCalculator(getter.getModal(StopDurationEstimator.class));
return new DrtStayTaskEndTimeCalculator(getter.getModal(StopTimeCalculator.class));
}));

bindModal(AlonsoMoraScheduler.class).toProvider(modalProvider(getter -> {
Expand Down Expand Up @@ -409,7 +409,7 @@ protected void configureQSim() {
getter.getModal(QSimScopeForkJoinPoolHolder.class).getPool(), //
getter.getModal(LeastCostPathCalculator.class), //
getter.getModal(TravelTime.class), //
drtConfig.advanceRequestPlanningHorizon, //
amConfig.getPlanningHorizon(), //
getter.getModal(InformationCollector.class) //
);
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ private void updateRequestsBeforeAssignment(Collection<AlonsoMoraRequest> newReq

for (DrtRequest drtRequest : request.getDrtRequests()) {
eventsManager.processEvent(new PassengerRequestRejectedEvent(now, mode, drtRequest.getId(),
drtRequest.getPassengerId(), "queue time exeeded"));
drtRequest.getPassengerIds(), "queue time exeeded"));
}

numberOfRejectedRequests++;
Expand Down Expand Up @@ -480,7 +480,7 @@ private void processAssignedRequests(Solution solution, double now, Information
/* For each DRT request, we create a scheduling event */
for (AcceptedDrtRequest drtRequest : request.getAcceptedDrtRequests()) {
eventsManager.processEvent(new PassengerRequestScheduledEvent(now, mode, drtRequest.getId(),
drtRequest.getPassengerId(), trip.getVehicle().getVehicle().getId(), expectedPickupTime,
drtRequest.getPassengerIds(), trip.getVehicle().getVehicle().getId(), expectedPickupTime,
expectedDropoffTime));
}
}
Expand Down
20 changes: 10 additions & 10 deletions core/src/main/java/org/matsim/alonso_mora/example/RunNewYork.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@
import org.matsim.core.config.CommandLine;
import org.matsim.core.config.Config;
import org.matsim.core.config.ConfigUtils;
import org.matsim.core.config.groups.PlanCalcScoreConfigGroup.ActivityParams;
import org.matsim.core.config.groups.PlanCalcScoreConfigGroup.ModeParams;
import org.matsim.core.config.groups.QSimConfigGroup.StarttimeInterpretation;
import org.matsim.core.config.groups.StrategyConfigGroup.StrategySettings;
import org.matsim.core.config.groups.ReplanningConfigGroup.StrategySettings;
import org.matsim.core.config.groups.ScoringConfigGroup.ActivityParams;
import org.matsim.core.config.groups.ScoringConfigGroup.ModeParams;
import org.matsim.core.controler.Controler;
import org.matsim.core.controler.OutputDirectoryHierarchy.OverwriteFileSetting;
import org.matsim.core.scenario.ScenarioUtils;
Expand Down Expand Up @@ -165,9 +165,9 @@ static public void main(String[] args) throws CommandLine.ConfigurationException
}

// Set up config
config.controler().setOutputDirectory(outputPath);
config.controler().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists);
config.controler().setLastIteration(0);
config.controller().setOutputDirectory(outputPath);
config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists);
config.controller().setLastIteration(0);

config.qsim().setNumberOfThreads(Math.min(12, threads));
config.global().setNumberOfThreads(threads);
Expand All @@ -181,20 +181,20 @@ static public void main(String[] args) throws CommandLine.ConfigurationException
config.qsim().setEndTime(endTime);

ModeParams modeParams = new ModeParams("drt");
config.planCalcScore().addModeParams(modeParams);
config.scoring().addModeParams(modeParams);

ActivityParams genericParams = new ActivityParams("generic");
genericParams.setScoringThisActivityAtAll(false);
config.planCalcScore().addActivityParams(genericParams);
config.scoring().addActivityParams(genericParams);

ActivityParams interactionParams = new ActivityParams("drt interaction");
interactionParams.setScoringThisActivityAtAll(false);
config.planCalcScore().addActivityParams(interactionParams);
config.scoring().addActivityParams(interactionParams);

StrategySettings keepSettings = new StrategySettings();
keepSettings.setStrategyName("BestScore");
keepSettings.setWeight(1.0);
config.strategy().addStrategySettings(keepSettings);
config.replanning().addStrategySettings(keepSettings);

DvrpConfigGroup dvrpConfig = new DvrpConfigGroup();
config.addModule(dvrpConfig);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ private void rebalanceFleet() {
for (Relocation r : relocations) {
Link currentLink = ((DrtStayTask) r.vehicle.getSchedule().getCurrentTask()).getLink();
if (currentLink != r.link) {
relocator.relocateVehicle(r.vehicle, r.link);
relocator.relocateVehicle(r.vehicle, r.link, EmptyVehicleRelocator.RELOCATE_VEHICLE_TASK_TYPE);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import org.matsim.contrib.drt.run.DrtConfigGroup;
import org.matsim.contrib.drt.schedule.DrtStayTaskEndTimeCalculator;
import org.matsim.contrib.drt.schedule.DrtTaskFactory;
import org.matsim.contrib.drt.schedule.StopDurationEstimator;
import org.matsim.contrib.drt.stops.StopTimeCalculator;
import org.matsim.contrib.dvrp.run.AbstractDvrpModeQSimModule;
import org.matsim.contrib.dvrp.schedule.ScheduleTimingUpdater;
import org.matsim.contrib.dvrp.schedule.ScheduleTimingUpdater.StayTaskEndTimeCalculator;
Expand Down Expand Up @@ -44,7 +44,7 @@ protected void configureQSim() {
// TODO: This can become a general binding in DRT
bindModal(StayTaskEndTimeCalculator.class).toProvider(modalProvider(getter -> {
return new ShiftDrtStayTaskEndTimeCalculator(shiftConfig,
new DrtStayTaskEndTimeCalculator(getter.getModal(StopDurationEstimator.class)));
new DrtStayTaskEndTimeCalculator(getter.getModal(StopTimeCalculator.class)));
}));

bindModal(OperationalVoter.class).toProvider(modalProvider(getter -> {
Expand Down
8 changes: 4 additions & 4 deletions core/src/test/java/org/matsim/alonso_mora/DiversionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ public void testRepeatedSameDestinationDiversions() {
{
/* Create some necessary configuration for the test */

config.controler().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists);
config.controler().setLastIteration(0);
config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists);
config.controller().setLastIteration(0);

config.qsim().setStartTime(0.0);
config.qsim().setSimStarttimeInterpretation(StarttimeInterpretation.onlyUseStarttime);
Expand Down Expand Up @@ -454,8 +454,8 @@ public void testRepeatedDiversionToDifferentDestinationRightBeforeLastLink() {
{
/* Create some necessary configuration for the test */

config.controler().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists);
config.controler().setLastIteration(0);
config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists);
config.controller().setLastIteration(0);

config.qsim().setStartTime(0.0);
config.qsim().setSimStarttimeInterpretation(StarttimeInterpretation.onlyUseStarttime);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ public void testRunAlonsoMora() {
AlonsoMoraConfigGroup amConfig = new AlonsoMoraConfigGroup();
MultiModeAlonsoMoraConfigGroup.get(config).addParameterSet(amConfig);

config.controler().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists);
config.controler().setOutputDirectory(utils.getOutputDirectory());
config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists);
config.controller().setOutputDirectory(utils.getOutputDirectory());

// Remove DRT rebalancer as we want to use AM rebalancer
DrtConfigGroup drtConfig = MultiModeDrtConfigGroup.get(config).getModalElements().iterator().next();
Expand All @@ -125,9 +125,9 @@ public void testRunAlonsoMora() {
var expectedStats = Stats.newBuilder() //
.rejectionRate(0.2) //
.rejections(78) //
.waitAverage(215.88) //
.inVehicleTravelTimeMean(347.02) //
.totalTravelTimeMean(562.9) //
.waitAverage(215.41) //
.inVehicleTravelTimeMean(346.55) //
.totalTravelTimeMean(561.97) //
.build();

verifyDrtCustomerStatsCloseToExpectedStats(utils.getOutputDirectory(), expectedStats);
Expand All @@ -143,8 +143,8 @@ public void testRunAlonsoMoraWithShifts() {
AlonsoMoraConfigGroup amConfig = new AlonsoMoraConfigGroup();
MultiModeAlonsoMoraConfigGroup.get(config).addParameterSet(amConfig);

config.controler().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists);
config.controler().setOutputDirectory(utils.getOutputDirectory());
config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists);
config.controller().setOutputDirectory(utils.getOutputDirectory());

// Remove DRT rebalancer as we want to use AM rebalancer
DrtWithOperationsConfigGroup drtConfig = (DrtWithOperationsConfigGroup) MultiModeDrtConfigGroup.get(config).getModalElements().iterator().next();
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ to the MATSim framework.</description>
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<matsim.version>15.0</matsim.version>
<matsim.version>16.0-PR2966</matsim.version>
</properties>

<repositories>
Expand Down

0 comments on commit 165bec0

Please sign in to comment.