diff --git a/input/v6.1/berlin-v6.1-vehicleTypes.xml b/input/v6.1/berlin-v6.1-vehicleTypes.xml index 9a241cae..84ef8b72 100644 --- a/input/v6.1/berlin-v6.1-vehicleTypes.xml +++ b/input/v6.1/berlin-v6.1-vehicleTypes.xml @@ -38,6 +38,18 @@ + + + 1 + serial + 1 + + + + + + + diff --git a/input/v6.1/berlin-v6.1.config.xml b/input/v6.1/berlin-v6.1.config.xml index a7fbb600..3f42d45b 100644 --- a/input/v6.1/berlin-v6.1.config.xml +++ b/input/v6.1/berlin-v6.1.config.xml @@ -176,7 +176,7 @@ - + diff --git a/src/main/java/org/matsim/prepare/ReprojectNetwork.java b/src/main/java/org/matsim/prepare/ReprojectNetwork.java index 5983447b..6f29df22 100644 --- a/src/main/java/org/matsim/prepare/ReprojectNetwork.java +++ b/src/main/java/org/matsim/prepare/ReprojectNetwork.java @@ -2,12 +2,14 @@ import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.network.Link; +import org.matsim.api.core.v01.network.Node; import org.matsim.application.MATSimAppCommand; import org.matsim.application.options.CrsOptions; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; import org.matsim.core.network.NetworkUtils; import org.matsim.core.scenario.ScenarioUtils; +import org.matsim.core.utils.geometry.CoordUtils; import org.matsim.pt.transitSchedule.api.TransitScheduleWriter; import picocli.CommandLine; @@ -56,6 +58,10 @@ public Integer call() throws Exception { // Scenario loader does the reprojection for the network Scenario scenario = ScenarioUtils.loadScenario(config); + for (Node node : scenario.getNetwork().getNodes().values()) { + node.setCoord(CoordUtils.round(node.getCoord())); + } + if (!remapModes.isEmpty()) { for (Link link : scenario.getNetwork().getLinks().values()) { Set modes = new HashSet<>(link.getAllowedModes()); diff --git a/src/main/java/org/matsim/prepare/RunOpenBerlinCalibration.java b/src/main/java/org/matsim/prepare/RunOpenBerlinCalibration.java index 99595ab4..a8379dd6 100644 --- a/src/main/java/org/matsim/prepare/RunOpenBerlinCalibration.java +++ b/src/main/java/org/matsim/prepare/RunOpenBerlinCalibration.java @@ -35,7 +35,8 @@ import org.matsim.core.replanning.choosers.ForceInnovationStrategyChooser; import org.matsim.core.replanning.choosers.StrategyChooser; import org.matsim.core.replanning.strategies.DefaultPlanStrategiesModule; -import org.matsim.core.router.RoutingModeMainModeIdentifier; +import org.matsim.core.router.DefaultAnalysisMainModeIdentifier; +import org.matsim.core.router.MainModeIdentifier; import org.matsim.core.router.TripStructureUtils; import org.matsim.core.scoring.ScoringFunction; import org.matsim.core.scoring.ScoringFunctionFactory; @@ -301,7 +302,7 @@ protected void prepareScenario(Scenario scenario) { log.info("Converting all agents to car plans."); - RoutingModeMainModeIdentifier mmi = new RoutingModeMainModeIdentifier(); + MainModeIdentifier mmi = new DefaultAnalysisMainModeIdentifier(); for (Person person : scenario.getPopulation().getPersons().values()) { for (Plan plan : person.getPlans()) { @@ -309,17 +310,28 @@ protected void prepareScenario(Scenario scenario) { final List trips = TripStructureUtils.getTrips(plan); for (TripStructureUtils.Trip trip : trips) { + final List fullTrip = planElements.subList( planElements.indexOf(trip.getOriginActivity()) + 1, planElements.indexOf(trip.getDestinationActivity())); + String mode = mmi.identifyMainMode(fullTrip); + + // Already car, nothing to do + if (Objects.equals(mode, TransportMode.car) || Objects.equals(mode, TransportMode.truck)) + continue; + double dist = CoordUtils.calcEuclideanDistance(getCoord(scenario, trip.getOriginActivity()), getCoord(scenario, trip.getDestinationActivity())); - // very short trips remain walk - String desiredMode = dist <= 100 ? TransportMode.walk : TransportMode.car; + // short bike and walk trips are not changed + if (dist <= 500 && (Objects.equals(mode, TransportMode.walk) || Objects.equals(mode, TransportMode.bike))) + continue; + + // rest of the trips is set to walk if below threshold, car otherwise + String desiredMode = dist <= 500 ? TransportMode.walk : TransportMode.car; - if (!Objects.equals(mmi.identifyMainMode(fullTrip), desiredMode)) { + if (!Objects.equals(mode, desiredMode)) { fullTrip.clear(); Leg leg = PopulationUtils.createLeg(desiredMode); TripStructureUtils.setRoutingMode(leg, desiredMode);