diff --git a/Makefile b/Makefile index da960e2a..0b4f4608 100644 --- a/Makefile +++ b/Makefile @@ -273,6 +273,7 @@ eval-opt: $p/berlin-initial-$V-25pct.experienced_plans.xml.gz --config $p/berlin-$V-base-calib.config.xml +# TODO: these needs to be renamed to plans-initial, because they are uncalibrated at this stage # These depend on the output of optimization runs $p/berlin-$V-25pct.plans.xml.gz: $p/berlin-$V-facilities.xml.gz $p/berlin-$V-network.xml.gz $p/berlin-goodsTraffic-$V-25pct.plans.xml.gz $p/berlin-longHaulFreight-$V-25pct.plans.xml.gz $(sc) prepare filter-relevant-agents\ @@ -298,6 +299,17 @@ $p/berlin-$V-25pct.plans.xml.gz: $p/berlin-$V-facilities.xml.gz $p/berlin-$V-net --sample-size 0.25\ --samples 0.1 0.01 0.001\ +clean-plans: + $(sc) prepare clean-population\ + --plans mode-choice-final-25pct/runs/004/004.output_plans.xml.gz\ + --remove-unselected-plans\ + --output mode-choice-final-25pct/runs/004/berlin-$V-25pct.plans.xml.gz + + $(sc) prepare clean-population\ + --plans mode-choice-final/runs/004/004.output_plans.xml.gz\ + --remove-unselected-plans\ + --output mode-choice-final/runs/004/berlin-$V-10pct.plans.xml.gz + prepare-calibration: $p/berlin-cadyts-input-$V-25pct.plans.xml.gz $p/berlin-$V-network-with-pt.xml.gz $p/berlin-$V-counts-car-vmz.xml.gz echo "Done" diff --git a/input/v6.0/berlin-v6.0-base-calib.config.xml b/input/v6.0/berlin-v6.0-base-calib.config.xml deleted file mode 100644 index e0b5ac99..00000000 --- a/input/v6.0/berlin-v6.0-base-calib.config.xml +++ /dev/null @@ -1,162 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/input/v6.0/berlin-v6.0-counts-car-vmz.xml.gz b/input/v6.0/berlin-v6.0-counts-car-vmz.xml.gz new file mode 100644 index 00000000..4654b360 Binary files /dev/null and b/input/v6.0/berlin-v6.0-counts-car-vmz.xml.gz differ diff --git a/input/v6.0/berlin-v6.0-counts-hgv-vmz.xml.gz b/input/v6.0/berlin-v6.0-counts-hgv-vmz.xml.gz new file mode 100644 index 00000000..93fec607 Binary files /dev/null and b/input/v6.0/berlin-v6.0-counts-hgv-vmz.xml.gz differ diff --git a/input/v6.0/berlin-v6.0-base-calib_prices2022.config.xml b/input/v6.0/berlin-v6.0.config.xml similarity index 62% rename from input/v6.0/berlin-v6.0-base-calib_prices2022.config.xml rename to input/v6.0/berlin-v6.0.config.xml index c6b97211..922e0ff0 100644 --- a/input/v6.0/berlin-v6.0-base-calib_prices2022.config.xml +++ b/input/v6.0/berlin-v6.0.config.xml @@ -2,13 +2,13 @@ - + - - + + @@ -19,10 +19,10 @@ - + - + @@ -30,13 +30,13 @@ value="https://svn.vsp.tu-berlin.de/repos/public-svn/matsim/scenarios/countries/de/berlin/berlin-v5.5-10pct/input/berlin-v5-mode-vehicle-types.xml"/> - + - + - + @@ -81,6 +81,15 @@ --> + + + + + + + + + @@ -94,7 +103,6 @@ - @@ -107,41 +115,59 @@ - - - - - + + + + + + + - + + + + - - - - - + + - - - - - - - - + - + + + + + + - - - + + + + + + + - - + + + + + + + + + + + + + + + + diff --git a/pom.xml b/pom.xml index c6879b10..e76cb2b0 100644 --- a/pom.xml +++ b/pom.xml @@ -113,58 +113,12 @@ ${matsim.version} - - com.github.kit-ifv - actitopp - 1.9.1 - - - - org.eclipse.jetty - jetty-server - 11.0.15 - - - org.eclipse.jetty - jetty-servlet - 11.0.15 - - - - org.optaplanner - optaplanner-core - 9.41.0.Final - - - - org.apache.poi - poi-ooxml - 5.2.3 - - - - de.topobyte - osm4j-pbf - 1.3.0 - - - de.topobyte - osm4j-geometry - 1.3.0 - - org.matsim.contrib common ${matsim.version} - - org.matsim.contrib - analysis - ${matsim.version} - - org.matsim.contrib bicycle @@ -202,12 +156,6 @@ 0d94df59ec - - com.github.matsim-vsp - matsim-analysis - 23bfbfc865 - - com.github.matsim-vsp pt-extensions @@ -256,6 +204,47 @@ + + + + com.github.kit-ifv + actitopp + 1.9.1 + + + + org.eclipse.jetty + jetty-server + 11.0.15 + + + org.eclipse.jetty + jetty-servlet + 11.0.15 + + + + org.optaplanner + optaplanner-core + 9.41.0.Final + + + + org.apache.poi + poi-ooxml + 5.2.3 + + + + de.topobyte + osm4j-pbf + 1.3.0 + + + de.topobyte + osm4j-geometry + 1.3.0 + @@ -276,6 +265,15 @@ test + + + org.matsim + matsim + test-jar + ${matsim.version} + test + + diff --git a/src/main/java/org/matsim/legacy/analysis/RunPersonTripAnalysis.java b/src/main/java/org/matsim/legacy/analysis/RunPersonTripAnalysis.java deleted file mode 100644 index 14c4768c..00000000 --- a/src/main/java/org/matsim/legacy/analysis/RunPersonTripAnalysis.java +++ /dev/null @@ -1,228 +0,0 @@ -/* *********************************************************************** * - * project: org.matsim.* - * * - * *********************************************************************** * - * * - * copyright : (C) 2014 by the members listed in the COPYING, * - * LICENSE and WARRANTY file. * - * email : info at matsim dot org * - * * - * *********************************************************************** * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * See also COPYING, LICENSE and WARRANTY file * - * * - * *********************************************************************** */ - -package org.matsim.legacy.analysis; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.matsim.analysis.*; -import org.matsim.api.core.v01.Scenario; -import org.matsim.core.config.Config; -import org.matsim.core.config.ConfigUtils; -import org.matsim.core.scenario.ScenarioUtils; -import org.matsim.core.utils.geometry.transformations.TransformationFactory; - -public class RunPersonTripAnalysis { - private static final Logger log = LogManager.getLogger(RunPersonTripAnalysis.class); - - public static void main(String[] args) throws IOException { - - String runDirectory = null; - String runId = null; - String runDirectoryToCompareWith = null; - String runIdToCompareWith = null; - String visualizationScriptInputDirectory = null; - String scenarioCRS = null; - String shapeFileZones = null; - String zonesCRS = null; - String zoneId = null; - String homeActivityPrefix = null; - int scalingFactor; - String modesString = null; - String analysisOutputDirectory = null; - - if (args.length > 0) { - if (!args[0].equals("null")) runDirectory = args[0]; - log.info("Run directory: " + runDirectory); - - if (!args[1].equals("null")) runId = args[1]; - log.info("Run Id: " + runDirectory); - - if (!args[2].equals("null")) runDirectoryToCompareWith = args[2]; - log.info("Run directory to compare with: " + runDirectoryToCompareWith); - - if (!args[3].equals("null")) runIdToCompareWith = args[3]; - log.info("Run Id to compare with: " + runDirectory); - - if (!args[4].equals("null")) scenarioCRS = args[4]; - log.info("Scenario CRS: " + scenarioCRS); - - if (!args[5].equals("null")) shapeFileZones = args[5]; - log.info("Shape file zones: " + shapeFileZones); - - if (!args[6].equals("null")) zonesCRS = args[6]; - log.info("Zones CRS: " + zonesCRS); - - if (!args[7].equals("null")) zoneId = args[7]; - log.info("Zones Id: " + zonesCRS); - - if (!args[8].equals("null")) homeActivityPrefix = args[8]; - log.info("Home activity prefix: " + homeActivityPrefix); - - scalingFactor = Integer.valueOf(args[9]); - log.info("Scaling factor: " + scalingFactor); - - if (!args[10].equals("null")) visualizationScriptInputDirectory = args[10]; - log.info("Visualization script input directory: " + visualizationScriptInputDirectory); - - if (!args[11].equals("null")) modesString = args[11]; - log.info("modes: " + modesString); - - } else { - -// runDirectory = "https://svn.vsp.tu-berlin.de/repos/public-svn/matsim/scenarios/countries/de/berlin/berlin-v5.4-1pct/output-berlin-v5.4-1pct/"; -// runId = "berlin-v5.4-1pct"; -// runDirectoryToCompareWith = null; -// runIdToCompareWith = null; -// -// visualizationScriptInputDirectory = null; -// -// scenarioCRS = TransformationFactory.DHDN_GK4; -// -// shapeFileZones = "https://svn.vsp.tu-berlin.de/repos/public-svn/matsim/scenarios/countries/de/berlin/projects/avoev/shp-files/shp-bezirke/bezirke_berlin.shp"; -// zonesCRS = TransformationFactory.DHDN_GK4; -// zoneId = "SCHLUESSEL"; -// -// homeActivityPrefix = "home"; -// scalingFactor = 100; -// -// modesString = "car,pt,bicycle,walk,ride"; -// -// analysisOutputDirectory = "./scenarios/berlin-v5.5-1pct/"; - - runDirectory = "/Users/dominik/Workspace/runs-svn/open_berlin_scenario/v5.5-bicycle/bc-23/output"; - - runId = "berlin-v5.5-1pct-22b"; - runDirectoryToCompareWith = null; - runIdToCompareWith = null; - - visualizationScriptInputDirectory = null; - - scenarioCRS = TransformationFactory.DHDN_GK4; - - shapeFileZones = "https://svn.vsp.tu-berlin.de/repos/public-svn/matsim/scenarios/countries/de/berlin/projects/avoev/shp-files/shp-bezirke/bezirke_berlin.shp"; - zonesCRS = TransformationFactory.DHDN_GK4; - zoneId = "SCHLUESSEL"; - - homeActivityPrefix = "home"; - scalingFactor = 100; - - modesString = "car,pt,bicycle,walk,ride"; - - analysisOutputDirectory = "/Users/dominik/Workspace/runs-svn/open_berlin_scenario/v5.5-bicycle/bc-23/output/analysis"; - } - - Scenario scenario1 = loadScenario(runDirectory, runId, null); - Scenario scenario0 = loadScenario(runDirectoryToCompareWith, runIdToCompareWith, null); - - List agentFilters = new ArrayList<>(); - - AgentAnalysisFilter agentFilter1 = new AgentAnalysisFilter("A"); - agentFilter1.setSubpopulation("person"); - agentFilter1.setPersonAttribute("berlin"); - agentFilter1.setPersonAttributeName("home-activity-zone"); - agentFilter1.preProcess(scenario1); - agentFilters.add(agentFilter1); - - AgentAnalysisFilter agentFilter2 = new AgentAnalysisFilter("B"); - agentFilter2.preProcess(scenario1); - agentFilters.add(agentFilter2); - - AgentAnalysisFilter agentFilter3 = new AgentAnalysisFilter("C"); - agentFilter3.setSubpopulation("person"); - agentFilter3.setPersonAttribute("brandenburg"); - agentFilter3.setPersonAttributeName("home-activity-zone"); - agentFilter3.preProcess(scenario1); - agentFilters.add(agentFilter3); - - final List tripFilters = new ArrayList<>(); - - TripAnalysisFilter tripFilter1a = new TripAnalysisFilter("A"); - tripFilter1a.preProcess(scenario1); - tripFilters.add(tripFilter1a); - - TripAnalysisFilter tripFilter1b = new TripAnalysisFilter("B"); - tripFilter1b.setZoneInformation(shapeFileZones, zonesCRS); - tripFilter1b.preProcess(scenario1); - tripFilters.add(tripFilter1b); - - List modes = new ArrayList<>(); - for (String mode : modesString.split(",")) { - modes.add(mode); - } - - MatsimAnalysis analysis = new MatsimAnalysis(); - - analysis.setScenario1(scenario1); - analysis.setScenario0(scenario0); - - analysis.setAgentFilters(agentFilters); - analysis.setTripFilters(tripFilters); - - analysis.setScenarioCRS(scenarioCRS); - analysis.setZoneInformation(shapeFileZones, zonesCRS, zoneId); - - analysis.setModes(modes); - analysis.setVisualizationScriptInputDirectory(visualizationScriptInputDirectory); - analysis.setHomeActivityPrefix(homeActivityPrefix); - analysis.setScalingFactor(scalingFactor); - - analysis.setAnalysisOutputDirectory(analysisOutputDirectory); - - analysis.run(); - } - - private static Scenario loadScenario(String runDirectory, String runId, String personAttributesFileToReplaceOutputFile) { - log.info("Loading scenario..."); - - if (runDirectory == null || runDirectory.equals("") || runDirectory.equals("null")) { - return null; - } - - if (!runDirectory.endsWith("/")) runDirectory = runDirectory + "/"; - - String networkFile; - String populationFile; - String configFile; - - configFile = runDirectory + runId + ".output_config.xml"; - networkFile = runId + ".output_network.xml.gz"; - populationFile = runId + ".output_plans.xml.gz"; - - Config config = ConfigUtils.loadConfig(configFile); - - if (!runId.equals(config.controler().getRunId())) throw new RuntimeException("Given run ID " + runId + " doesn't match the run ID given in the config file. Aborting..."); - - config.controler().setOutputDirectory(runDirectory); - config.plans().setInputFile(populationFile); - config.network().setInputFile(networkFile); - config.vehicles().setVehiclesFile(null); - config.transit().setTransitScheduleFile(null); - config.transit().setVehiclesFile(null); - - return ScenarioUtils.loadScenario(config); - } - -} - - diff --git a/src/main/java/org/matsim/legacy/run/RunBerlinScenario.java b/src/main/java/org/matsim/legacy/run/RunBerlinScenario.java index fe67a589..0d02ebae 100644 --- a/src/main/java/org/matsim/legacy/run/RunBerlinScenario.java +++ b/src/main/java/org/matsim/legacy/run/RunBerlinScenario.java @@ -25,7 +25,6 @@ import com.google.inject.TypeLiteral; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.matsim.legacy.analysis.RunPersonTripAnalysis; import org.matsim.analysis.linkpaxvolumes.LinkPaxVolumesAnalysisModule; import org.matsim.analysis.personMoney.PersonMoneyEventsAnalysisModule; import org.matsim.analysis.pt.stop2stop.PtStop2StopAnalysisModule; @@ -294,12 +293,8 @@ public static void runAnalysis(Controler controler) { modesString }; - try { - RunPersonTripAnalysis.main(args); - } catch (IOException e) { - log.error(e.getStackTrace()); - throw new RuntimeException(e.getMessage()); - } + // Removed so that the dependency could be dropped + // RunPersonTripAnalysis.main(args); } private static void downsample( final Map, ? extends Person> map, final double sample ) { diff --git a/src/main/java/org/matsim/prepare/RunOpenBerlinCalibration.java b/src/main/java/org/matsim/prepare/RunOpenBerlinCalibration.java index e1741bba..92a5049e 100644 --- a/src/main/java/org/matsim/prepare/RunOpenBerlinCalibration.java +++ b/src/main/java/org/matsim/prepare/RunOpenBerlinCalibration.java @@ -113,7 +113,7 @@ public class RunOpenBerlinCalibration extends MATSimApplication { private Integer planIndex; public RunOpenBerlinCalibration() { - super("input/v6.0/berlin-v6.0-base-calib.config.xml"); + super("input/v6.0/berlin-v6.0.config.xml"); } /** @@ -154,10 +154,6 @@ protected Config prepareConfig(Config config) { SimWrapperConfigGroup sw = ConfigUtils.addOrGetModule(config, SimWrapperConfigGroup.class); - sw.defaultParams().mapCenter = "13.39,52.51"; - sw.defaultParams().mapZoomLevel = 9.1; - sw.defaultParams().shp = "./area/area.shp"; - if (sample.isSet()) { double sampleSize = sample.getSample(); diff --git a/src/main/java/org/matsim/run/RunOpenBerlinScenario.java b/src/main/java/org/matsim/run/RunOpenBerlinScenario.java index aba79ba6..2f6260c3 100644 --- a/src/main/java/org/matsim/run/RunOpenBerlinScenario.java +++ b/src/main/java/org/matsim/run/RunOpenBerlinScenario.java @@ -19,17 +19,17 @@ import java.util.List; @CommandLine.Command(header = ":: Open Berlin Scenario ::", version = RunOpenBerlinScenario.VERSION, mixinStandardHelpOptions = true) -@MATSimApplication.Prepare() public class RunOpenBerlinScenario extends MATSimApplication { + private static final Logger log = LogManager.getLogger(RunOpenBerlinCalibration.class); + public static final String VERSION = "6.0"; public static final String CRS = "EPSG:25832"; - private static final Logger log = LogManager.getLogger(RunOpenBerlinCalibration.class); @CommandLine.Mixin private final SampleOptions sample = new SampleOptions(25, 10, 1); public RunOpenBerlinScenario() { - super(String.format("input/v%s/berlin-v%s-base-calib.config.xml", VERSION, VERSION)); + super(String.format("input/v%s/berlin-v%s.config.xml", VERSION, VERSION)); } public static void main(String[] args) { @@ -41,10 +41,6 @@ protected Config prepareConfig(Config config) { SimWrapperConfigGroup sw = ConfigUtils.addOrGetModule(config, SimWrapperConfigGroup.class); - sw.defaultParams().mapCenter = "13.39,52.51"; - sw.defaultParams().mapZoomLevel = 9.1; - sw.defaultParams().shp = "./area/area.shp"; - if (sample.isSet()) { double sampleSize = sample.getSample(); @@ -56,6 +52,7 @@ protected Config prepareConfig(Config config) { sw.defaultParams().sampleSize = sampleSize; config.controler().setRunId(sample.adjustName(config.controler().getRunId())); + config.controler().setOutputDirectory(sample.adjustName(config.controler().getOutputDirectory())); config.plans().setInputFile(sample.adjustName(config.plans().getInputFile())); } diff --git a/src/test/java/org/matsim/run/RunOpenBerlinScenarioTest.java b/src/test/java/org/matsim/run/RunOpenBerlinScenarioTest.java new file mode 100644 index 00000000..e353c1cb --- /dev/null +++ b/src/test/java/org/matsim/run/RunOpenBerlinScenarioTest.java @@ -0,0 +1,27 @@ +package org.matsim.run; + +import org.junit.Rule; +import org.junit.Test; +import org.matsim.application.MATSimApplication; +import org.matsim.testcases.MatsimTestUtils; + +import static org.assertj.core.api.Assertions.assertThat; + +public class RunOpenBerlinScenarioTest { + + @Rule + public MatsimTestUtils utils = new MatsimTestUtils(); + + @Test + public void pct1() { + + int code = MATSimApplication.execute(RunOpenBerlinScenario.class, + "--1pct", + "--output", utils.getOutputDirectory(), + "--iterations", "2" + ); + + assertThat(code).isEqualTo(0); + + } +}