From d69c1aaf73b7f3087155a06ebe14b46f2207fe00 Mon Sep 17 00:00:00 2001 From: cllorca1 Date: Mon, 2 Dec 2019 15:30:17 +0100 Subject: [PATCH] fix handling of initial travel times for mito_matsim --- .../java/de/tum/bgu/msm/matsim/MatsimTransportModel.java | 8 ++++++-- .../main/java/de/tum/bgu/msm/data/TravelTimesWrapper.java | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/extensions/matsim2silo/src/main/java/de/tum/bgu/msm/matsim/MatsimTransportModel.java b/extensions/matsim2silo/src/main/java/de/tum/bgu/msm/matsim/MatsimTransportModel.java index 928685b28..b7c46bc3e 100644 --- a/extensions/matsim2silo/src/main/java/de/tum/bgu/msm/matsim/MatsimTransportModel.java +++ b/extensions/matsim2silo/src/main/java/de/tum/bgu/msm/matsim/MatsimTransportModel.java @@ -27,6 +27,7 @@ import de.tum.bgu.msm.data.travelTimes.TravelTimes; import de.tum.bgu.msm.models.transportModel.TransportModel; import de.tum.bgu.msm.properties.Properties; +import de.tum.bgu.msm.properties.modules.TransportModelPropertiesModule; import org.apache.log4j.Logger; import org.locationtech.jts.geom.Geometry; import org.matsim.api.core.v01.Coord; @@ -148,7 +149,8 @@ private void runTransportModel(int year) { logger.warn("Running MATSim transport model for year " + year + "."); Scenario assembledScenario; TravelTimes travelTimes = dataContainer.getTravelTimes(); - if (year == properties.main.baseYear){ + if (year == properties.main.baseYear && + properties.transportModel.transportModelIdentifier == TransportModelPropertiesModule.TransportModelIdentifier.MATSIM){ //if using the SimpleCommuteModeChoiceScenarioAssembler, we need some intial travel times (this will use an unlodaded network) TravelTime myTravelTime = SiloMatsimUtils.getAnEmptyNetworkTravelTime(); TravelDisutility myTravelDisutility = SiloMatsimUtils.getAnEmptyNetworkTravelDisutility(); @@ -270,7 +272,9 @@ private void updateTravelTimes(TravelTime travelTime, TravelDisutility disutilit if (mainTravelTimes != this.internalTravelTimes && mainTravelTimes instanceof SkimTravelTimes) { ((SkimTravelTimes) mainTravelTimes).updateSkimMatrix(internalTravelTimes.getPeakSkim(TransportMode.car), TransportMode.car); - ((SkimTravelTimes) mainTravelTimes).updateSkimMatrix(internalTravelTimes.getPeakSkim(TransportMode.pt), TransportMode.pt); + if ((properties.transportModel.transportModelIdentifier == TransportModelPropertiesModule.TransportModelIdentifier.MATSIM)) { + ((SkimTravelTimes) mainTravelTimes).updateSkimMatrix(internalTravelTimes.getPeakSkim(TransportMode.pt), TransportMode.pt); + } ((SkimTravelTimes) mainTravelTimes).updateRegionalTravelTimes(dataContainer.getGeoData().getRegions().values(), dataContainer.getGeoData().getZones().values()); } diff --git a/siloCore/src/main/java/de/tum/bgu/msm/data/TravelTimesWrapper.java b/siloCore/src/main/java/de/tum/bgu/msm/data/TravelTimesWrapper.java index 39636e144..85077fa90 100644 --- a/siloCore/src/main/java/de/tum/bgu/msm/data/TravelTimesWrapper.java +++ b/siloCore/src/main/java/de/tum/bgu/msm/data/TravelTimesWrapper.java @@ -78,7 +78,7 @@ public void endSimulation() { } private void updateSkims(int year) { - if (properties.transportModel.transportModelIdentifier == TransportModelPropertiesModule.TransportModelIdentifier.NONE) { + if (properties.transportModel.transportModelIdentifier != TransportModelPropertiesModule.TransportModelIdentifier.MATSIM) { TravelTimeUtil.updateCarSkim((SkimTravelTimes) delegate, year, properties); TravelTimeUtil.updateTransitSkim((SkimTravelTimes) delegate, year, properties); ((SkimTravelTimes) delegate).updateRegionalTravelTimes(geoData.getRegions().values(), geoData.getZones().values());