Skip to content

Commit

Permalink
chore: update MATSim to PR3380 (#37)
Browse files Browse the repository at this point in the history
* update to matsim 2025-3380

* use java 21 in gh action

* update glpk test
  • Loading branch information
nkuehnel authored Jul 23, 2024
1 parent 2d2fc34 commit c1f18fa
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 60 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v1
with:
java-version: 17
java-version: 21
- name: Install GLPK and CBC
run: sudo apt install glpk-utils coinor-cbc libglpk-java
- name: Run tests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
import org.matsim.alonso_mora.travel_time.HybridTravelTimeEstimator;
import org.matsim.alonso_mora.travel_time.MatrixTravelTimeEstimator;
import org.matsim.alonso_mora.travel_time.RoutingTravelTimeEstimator;
import org.matsim.contrib.common.util.ReflectiveConfigGroupWithConfigurableParameterSets;
import org.matsim.contrib.drt.run.DrtConfigGroup;
import org.matsim.contrib.drt.run.MultiModeDrtConfigGroup;
import org.matsim.contrib.util.ReflectiveConfigGroupWithConfigurableParameterSets;
import org.matsim.core.config.Config;
import org.matsim.core.config.ReflectiveConfigGroup;

Expand Down
21 changes: 14 additions & 7 deletions core/src/main/java/org/matsim/alonso_mora/example/RunNewYork.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import org.matsim.api.core.v01.network.Link;
import org.matsim.api.core.v01.network.Node;
import org.matsim.api.core.v01.population.Person;
import org.matsim.contrib.drt.optimizer.constraints.DefaultDrtOptimizationConstraintsSet;
import org.matsim.contrib.drt.optimizer.constraints.DrtOptimizationConstraintsSet;
import org.matsim.contrib.drt.optimizer.insertion.extensive.ExtensiveInsertionSearchParams;
import org.matsim.contrib.drt.routing.DrtRoute;
import org.matsim.contrib.drt.routing.DrtRouteFactory;
Expand All @@ -43,10 +45,9 @@
import org.matsim.core.controler.Controler;
import org.matsim.core.controler.OutputDirectoryHierarchy.OverwriteFileSetting;
import org.matsim.core.scenario.ScenarioUtils;
import org.opengis.referencing.FactoryException;

public class RunNewYork {
static public void main(String[] args) throws CommandLine.ConfigurationException, FactoryException {
static public void main(String[] args) throws CommandLine.ConfigurationException {
CommandLine cmd = new CommandLine.Builder(args).requireOptions( //
"demand-path", "network-path", "output-path", //
"use-alonso-mora" //
Expand Down Expand Up @@ -204,15 +205,21 @@ static public void main(String[] args) throws CommandLine.ConfigurationException

DrtConfigGroup modeConfig = new DrtConfigGroup();
modeConfig.mode = TransportMode.drt;
modeConfig.maxTravelTimeAlpha = detourFactor;
modeConfig.maxTravelTimeBeta = stopDuration;
modeConfig.maxWaitTime = maximumWaitingTime + stopDuration;
modeConfig.rejectRequestIfMaxWaitOrTravelTimeViolated = true;

DefaultDrtOptimizationConstraintsSet constraintsSet =
(DefaultDrtOptimizationConstraintsSet) modeConfig
.addOrGetDrtOptimizationConstraintsParams()
.addOrGetDefaultDrtOptimizationConstraintsSet();
constraintsSet.maxTravelTimeAlpha = detourFactor;
constraintsSet.maxTravelTimeBeta = stopDuration;
constraintsSet.maxWaitTime = maximumWaitingTime + stopDuration;
constraintsSet.rejectRequestIfMaxWaitOrTravelTimeViolated = true;
constraintsSet.maxWalkDistance = 1000.0;

modeConfig.useModeFilteredSubnetwork = false;
modeConfig.idleVehiclesReturnToDepots = false;
modeConfig.operationalScheme = DrtConfigGroup.OperationalScheme.door2door;
modeConfig.plotDetailedCustomerStats = true;
modeConfig.maxWalkDistance = 1000.0;
modeConfig.numberOfThreads = threads;

modeConfig.addParameterSet(new ExtensiveInsertionSearchParams());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import org.matsim.alonso_mora.algorithm.AlonsoMoraVehicle;
import org.matsim.api.core.v01.network.Link;
import org.matsim.api.core.v01.network.Network;
import org.matsim.contrib.drt.extension.operations.shifts.schedule.WaitForShiftStayTask;
import org.matsim.contrib.drt.extension.operations.shifts.schedule.WaitForShiftTask;
import org.matsim.contrib.drt.passenger.AcceptedDrtRequest;
import org.matsim.contrib.drt.schedule.DrtDriveTask;
import org.matsim.contrib.drt.schedule.DrtStayTask;
Expand Down Expand Up @@ -472,7 +472,7 @@ public void schedule(AlonsoMoraVehicle vehicle, double now) {

if (currentTask instanceof DrtStayTask) {
currentTask.setEndTime(Math.max(currentTask.getEndTime(), vehicle.getVehicle().getServiceEndTime()));
} else if (currentTask instanceof WaitForShiftStayTask) {
} else if (currentTask instanceof WaitForShiftTask) {
if (currentTask.getEndTime() == now) {
// if the shift just started, re-create the stay task
StayTask stayTask = taskFactory.createStayTask(dvrpVehicle, currentTask.getEndTime(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import org.matsim.api.core.v01.network.Network;
import org.matsim.contrib.drt.extension.operations.shifts.schedule.ShiftBreakTask;
import org.matsim.contrib.drt.extension.operations.shifts.schedule.ShiftChangeOverTask;
import org.matsim.contrib.drt.extension.operations.shifts.schedule.WaitForShiftStayTask;
import org.matsim.contrib.drt.extension.operations.shifts.schedule.WaitForShiftTask;
import org.matsim.contrib.drt.passenger.AcceptedDrtRequest;
import org.matsim.contrib.drt.schedule.DrtDriveTask;
import org.matsim.contrib.drt.schedule.DrtStayTask;
Expand Down Expand Up @@ -497,7 +497,7 @@ public void schedule(AlonsoMoraVehicle vehicle, double now) {

if (currentTask instanceof DrtStayTask) {
currentTask.setEndTime(Math.max(currentTask.getEndTime(), vehicle.getVehicle().getServiceEndTime()));
} else if (currentTask instanceof WaitForShiftStayTask) {
} else if (currentTask instanceof WaitForShiftTask) {
if (currentTask.getEndTime() == now) {
// if the shift just started, re-create the stay task
StayTask stayTask = taskFactory.createStayTask(dvrpVehicle, currentTask.getEndTime(),
Expand Down
4 changes: 2 additions & 2 deletions core/src/test/java/org/matsim/alonso_mora/DiversionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ protected void configureQSim() {
};
}));

bindModal(VehicleType.class).toInstance(VehicleUtils.getDefaultVehicleType());
bindModal(VehicleType.class).toInstance(VehicleUtils.createDefaultVehicleType());
}
}

Expand Down Expand Up @@ -537,7 +537,7 @@ protected void configureQSim() {
testTracker);
})).in(Singleton.class);

bindModal(VehicleType.class).toInstance(VehicleUtils.getDefaultVehicleType());
bindModal(VehicleType.class).toInstance(VehicleUtils.createDefaultVehicleType());
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@
import org.matsim.api.core.v01.Id;
import org.matsim.api.core.v01.Scenario;
import org.matsim.api.core.v01.network.Link;
import org.matsim.contrib.common.zones.systems.grid.square.SquareGridZoneSystemParams;
import org.matsim.contrib.drt.extension.DrtWithExtensionsConfigGroup;
import org.matsim.contrib.drt.extension.operations.DrtOperationsParams;
import org.matsim.contrib.drt.extension.operations.DrtWithOperationsConfigGroup;
import org.matsim.contrib.drt.extension.operations.operationFacilities.OperationFacilitiesParams;
import org.matsim.contrib.drt.extension.operations.operationFacilities.OperationFacilitiesQSimModule;
import org.matsim.contrib.drt.extension.operations.operationFacilities.OperationFacilitiesSpecification;
Expand Down Expand Up @@ -95,7 +96,9 @@ public class AlonsoMoraExamplesIT {
public void testRunAlonsoMora() {
Id.resetCaches();
URL configUrl = IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("mielec"), "mielec_drt_config.xml");
Config config = ConfigUtils.loadConfig(configUrl, new MultiModeDrtConfigGroup(), new DvrpConfigGroup(),
DvrpConfigGroup dvrpConfigGroup = new DvrpConfigGroup();
dvrpConfigGroup.getTravelTimeMatrixParams().addParameterSet(new SquareGridZoneSystemParams());
Config config = ConfigUtils.loadConfig(configUrl, new MultiModeDrtConfigGroup(), dvrpConfigGroup,
new MultiModeAlonsoMoraConfigGroup(), new OTFVisConfigGroup());

AlonsoMoraConfigGroup amConfig = new AlonsoMoraConfigGroup();
Expand Down Expand Up @@ -139,7 +142,9 @@ public void testRunAlonsoMora() {
public void testRunAlonsoMoraWithDeterministicTravelTimesCheck() {
Id.resetCaches();
URL configUrl = IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("mielec"), "mielec_drt_config.xml");
Config config = ConfigUtils.loadConfig(configUrl, new MultiModeDrtConfigGroup(), new DvrpConfigGroup(),
DvrpConfigGroup dvrpConfigGroup = new DvrpConfigGroup();
dvrpConfigGroup.getTravelTimeMatrixParams().addParameterSet(new SquareGridZoneSystemParams());
Config config = ConfigUtils.loadConfig(configUrl, new MultiModeDrtConfigGroup(), dvrpConfigGroup,
new MultiModeAlonsoMoraConfigGroup(), new OTFVisConfigGroup());

AlonsoMoraConfigGroup amConfig = new AlonsoMoraConfigGroup();
Expand Down Expand Up @@ -197,8 +202,10 @@ public void testRunAlonsoMoraWithDeterministicTravelTimesCheck() {
public void testRunAlonsoMoraWithShifts() {
Id.resetCaches();
URL configUrl = IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("mielec"), "mielec_drt_config.xml");
DvrpConfigGroup dvrpConfigGroup = new DvrpConfigGroup();
dvrpConfigGroup.getTravelTimeMatrixParams().addParameterSet(new SquareGridZoneSystemParams());
Config config = ConfigUtils.loadConfig(configUrl,
new MultiModeDrtConfigGroup(DrtWithOperationsConfigGroup::new), new DvrpConfigGroup(),
new MultiModeDrtConfigGroup(DrtWithExtensionsConfigGroup::new), dvrpConfigGroup,
new MultiModeAlonsoMoraConfigGroup(), new OTFVisConfigGroup());

AlonsoMoraConfigGroup amConfig = new AlonsoMoraConfigGroup();
Expand All @@ -208,7 +215,7 @@ public void testRunAlonsoMoraWithShifts() {
config.controller().setOutputDirectory(utils.getOutputDirectory());

// Remove DRT rebalancer as we want to use AM rebalancer
DrtWithOperationsConfigGroup drtConfig = (DrtWithOperationsConfigGroup) MultiModeDrtConfigGroup.get(config)
DrtWithExtensionsConfigGroup drtConfig = (DrtWithExtensionsConfigGroup) MultiModeDrtConfigGroup.get(config)
.getModalElements().iterator().next();
drtConfig.removeParameterSet(drtConfig.getRebalancingParams().get());

Expand Down Expand Up @@ -431,7 +438,9 @@ public Stats build() {
public void testRunAlonsoMoraWithPrebooking() {
Id.resetCaches();
URL configUrl = IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("mielec"), "mielec_drt_config.xml");
Config config = ConfigUtils.loadConfig(configUrl, new MultiModeDrtConfigGroup(), new DvrpConfigGroup(),
DvrpConfigGroup dvrpConfigGroup = new DvrpConfigGroup();
dvrpConfigGroup.getTravelTimeMatrixParams().addParameterSet(new SquareGridZoneSystemParams());
Config config = ConfigUtils.loadConfig(configUrl, new MultiModeDrtConfigGroup(), dvrpConfigGroup,
new MultiModeAlonsoMoraConfigGroup(), new OTFVisConfigGroup());

AlonsoMoraConfigGroup amConfig = new AlonsoMoraConfigGroup();
Expand Down
46 changes: 11 additions & 35 deletions glpk/src/test/java/org/matsim/alonso_mora/glpk/GlpkExamplesIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,53 +19,18 @@

package org.matsim.alonso_mora.glpk;

import static org.junit.jupiter.api.Assertions.assertEquals;

import java.io.IOException;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.stream.Collectors;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.matsim.alonso_mora.AlonsoMoraConfigGroup;
import org.matsim.alonso_mora.AlonsoMoraConfigurator;
import org.matsim.alonso_mora.MultiModeAlonsoMoraConfigGroup;
import org.matsim.alonso_mora.shifts.ShiftAlonsoMoraModule;
import org.matsim.api.core.v01.Id;
import org.matsim.api.core.v01.Scenario;
import org.matsim.api.core.v01.network.Link;
import org.matsim.contrib.drt.extension.operations.DrtOperationsParams;
import org.matsim.contrib.drt.extension.operations.DrtWithOperationsConfigGroup;
import org.matsim.contrib.drt.extension.operations.operationFacilities.OperationFacilitiesParams;
import org.matsim.contrib.drt.extension.operations.operationFacilities.OperationFacilitiesQSimModule;
import org.matsim.contrib.drt.extension.operations.operationFacilities.OperationFacilitiesSpecification;
import org.matsim.contrib.drt.extension.operations.operationFacilities.OperationFacilitiesSpecificationImpl;
import org.matsim.contrib.drt.extension.operations.operationFacilities.OperationFacility;
import org.matsim.contrib.drt.extension.operations.operationFacilities.OperationFacilitySpecificationImpl;
import org.matsim.contrib.drt.extension.operations.operationFacilities.OperationFacilityType;
import org.matsim.contrib.drt.extension.operations.shifts.config.ShiftsParams;
import org.matsim.contrib.drt.extension.operations.shifts.run.ShiftDrtModeModule;
import org.matsim.contrib.drt.extension.operations.shifts.run.ShiftDrtModeOptimizerQSimModule;
import org.matsim.contrib.drt.extension.operations.shifts.run.ShiftDvrpFleetQsimModule;
import org.matsim.contrib.drt.extension.operations.shifts.shift.DrtShift;
import org.matsim.contrib.drt.extension.operations.shifts.shift.DrtShiftBreakSpecificationImpl;
import org.matsim.contrib.drt.extension.operations.shifts.shift.DrtShiftSpecificationImpl;
import org.matsim.contrib.drt.extension.operations.shifts.shift.DrtShiftsSpecification;
import org.matsim.contrib.drt.extension.operations.shifts.shift.DrtShiftsSpecificationImpl;
import org.matsim.contrib.drt.routing.DrtRoute;
import org.matsim.contrib.drt.routing.DrtRouteFactory;
import org.matsim.contrib.drt.run.DrtConfigGroup;
import org.matsim.contrib.drt.run.DrtModeQSimModule;
import org.matsim.contrib.drt.run.MultiModeDrtConfigGroup;
import org.matsim.contrib.drt.run.MultiModeDrtModule;
import org.matsim.contrib.dvrp.run.AbstractDvrpModeModule;
import org.matsim.contrib.dvrp.run.DvrpConfigGroup;
import org.matsim.contrib.dvrp.run.DvrpModule;
import org.matsim.contrib.dvrp.run.DvrpQSimComponents;
Expand All @@ -79,6 +44,17 @@
import org.matsim.testcases.MatsimTestUtils;
import org.matsim.vis.otfvis.OTFVisConfigGroup;

import java.io.IOException;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import static org.junit.jupiter.api.Assertions.assertEquals;

/**
* @author sebhoerl
*/
Expand Down
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
to the MATSim framework.</description>

<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<matsim.version>16.0-PR3096</matsim.version>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<matsim.version>2025.0-PR3380</matsim.version>
<junit.version>5.10.1</junit.version>
</properties>

Expand Down

0 comments on commit c1f18fa

Please sign in to comment.