From d0fd6dc73dde91e70d4680eb451470ecd8da2692 Mon Sep 17 00:00:00 2001 From: Kai Martins-Turner Date: Mon, 16 Sep 2024 12:50:02 +0200 Subject: [PATCH 1/3] setInsistingOnDeprecatedConfigVersion to "false", when creating a new config or reading in a config in the current version. --- matsim/src/main/java/org/matsim/core/config/ConfigReader.java | 3 +++ matsim/src/main/java/org/matsim/core/config/ConfigUtils.java | 1 + .../java/org/matsim/core/config/groups/GlobalConfigGroup.java | 3 +++ 3 files changed, 7 insertions(+) diff --git a/matsim/src/main/java/org/matsim/core/config/ConfigReader.java b/matsim/src/main/java/org/matsim/core/config/ConfigReader.java index f35d8adc593..82b21a0cd68 100644 --- a/matsim/src/main/java/org/matsim/core/config/ConfigReader.java +++ b/matsim/src/main/java/org/matsim/core/config/ConfigReader.java @@ -102,6 +102,9 @@ protected void setDoctype(final String doctype) { } else if ( CONFIG_V2.equals( doctype ) ) { this.delegate = new ConfigReaderMatsimV2( this.config ); + config.global().setInsistingOnDeprecatedConfigVersion(false); + // Currently, V2 is the current version. + // IMO: The default should be "false". -> Change in {@link GlobalConfigGroup}. kmt, Aug'24 log.info( "using config_v2-reader" ); } else { diff --git a/matsim/src/main/java/org/matsim/core/config/ConfigUtils.java b/matsim/src/main/java/org/matsim/core/config/ConfigUtils.java index df396f15b1a..2d09a278ed7 100644 --- a/matsim/src/main/java/org/matsim/core/config/ConfigUtils.java +++ b/matsim/src/main/java/org/matsim/core/config/ConfigUtils.java @@ -55,6 +55,7 @@ public static Config createConfig(URL context) { public static Config createConfig() { Config config = new Config(); config.addCoreModules(); + config.global().setInsistingOnDeprecatedConfigVersion(false); // IMO: The default should be "false". -> Change in {@link GlobalConfigGroup}. kmt, Aug'24 return config; } diff --git a/matsim/src/main/java/org/matsim/core/config/groups/GlobalConfigGroup.java b/matsim/src/main/java/org/matsim/core/config/groups/GlobalConfigGroup.java index f778b0b9229..6b811924ce6 100644 --- a/matsim/src/main/java/org/matsim/core/config/groups/GlobalConfigGroup.java +++ b/matsim/src/main/java/org/matsim/core/config/groups/GlobalConfigGroup.java @@ -108,6 +108,9 @@ public void setCoordinateSystem(final String coordinateSystem) { // --- private boolean insistingOnDeprecatedConfigVersion = true ; // yyyy this should be set to false eventually. kai, aug'18 + // IMO: Yes, false would be the default and if read in an older version, set it to true. + // That would also avoid the setting to "false" in ConfigUtils. This should not be needed, because creating + // a new Config should always result in the newest version. // kmt, Aug'24 private static final String INSITING_ON_DEPRECATED_CONFIG_VERSION = "insistingOnDeprecatedConfigVersion" ; @StringGetter( INSITING_ON_DEPRECATED_CONFIG_VERSION ) public final boolean isInsistingOnDeprecatedConfigVersion() { return this.insistingOnDeprecatedConfigVersion ; } From c9fd6a4bd1193736697e914b4c1d07665f4473ed Mon Sep 17 00:00:00 2001 From: Kai Martins-Turner Date: Mon, 16 Sep 2024 13:07:37 +0200 Subject: [PATCH 2/3] deactivate it when reading in a config, because it creates issues with configs, that are read by the V2 reader, but the ScoringConfigGroup detects a deprecated syntax... --- .../main/java/org/matsim/core/config/ConfigReader.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/matsim/src/main/java/org/matsim/core/config/ConfigReader.java b/matsim/src/main/java/org/matsim/core/config/ConfigReader.java index 82b21a0cd68..7c69bc833b4 100644 --- a/matsim/src/main/java/org/matsim/core/config/ConfigReader.java +++ b/matsim/src/main/java/org/matsim/core/config/ConfigReader.java @@ -102,9 +102,13 @@ protected void setDoctype(final String doctype) { } else if ( CONFIG_V2.equals( doctype ) ) { this.delegate = new ConfigReaderMatsimV2( this.config ); - config.global().setInsistingOnDeprecatedConfigVersion(false); - // Currently, V2 is the current version. - // IMO: The default should be "false". -> Change in {@link GlobalConfigGroup}. kmt, Aug'24 +// config.global().setInsistingOnDeprecatedConfigVersion(false); +// // Currently, V2 is the current version. +// // IMO: The default should be "false". -> Change in {@link GlobalConfigGroup}. +// This cannot be activated here, because mny tests, e.g. in DRT fails, because ScoringConfigGroup detects a deprecated syntax and then +// aborts, because of the following check -- so this must be cleaned up first. : +// usesDeprecatedSyntax && !config.global().isInsistingOnDeprecatedConfigVersion()) +// kmt, Aug'24 log.info( "using config_v2-reader" ); } else { From 4540556a2a8ffaa308aaeedce928a9cd7d22f3e7 Mon Sep 17 00:00:00 2001 From: Kai Martins-Turner Date: Mon, 16 Sep 2024 13:23:19 +0200 Subject: [PATCH 3/3] fix one failing test that used the old scoring syntax. --- .../matrixbasedptrouter/MatrixBasedPtRouterIT.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/contribs/matrixbasedptrouter/src/test/java/org/matsim/contrib/matrixbasedptrouter/MatrixBasedPtRouterIT.java b/contribs/matrixbasedptrouter/src/test/java/org/matsim/contrib/matrixbasedptrouter/MatrixBasedPtRouterIT.java index 6553e8c813a..b71237f3dd9 100644 --- a/contribs/matrixbasedptrouter/src/test/java/org/matsim/contrib/matrixbasedptrouter/MatrixBasedPtRouterIT.java +++ b/contribs/matrixbasedptrouter/src/test/java/org/matsim/contrib/matrixbasedptrouter/MatrixBasedPtRouterIT.java @@ -41,6 +41,7 @@ import org.matsim.contrib.matrixbasedptrouter.utils.CreateTestPopulation; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; +import org.matsim.core.config.groups.ScoringConfigGroup; import org.matsim.core.controler.Controler; import org.matsim.core.controler.OutputDirectoryHierarchy; import org.matsim.core.network.io.NetworkWriter; @@ -106,11 +107,8 @@ void testIntegration() throws IOException { config.plans().setInputFile(path+"plans.xml"); //add home and work activity to plansCalcScoreConfigGroup - config.scoring().addParam("activityType_0", "home"); - config.scoring().addParam("activityTypicalDuration_0", "43200"); - config.scoring().addParam("activityType_1", "work"); - config.scoring().addParam("activityTypicalDuration_1", "28800"); - + config.scoring().addActivityParams(new ScoringConfigGroup.ActivityParams("home").setTypicalDuration(43200)); + config.scoring().addActivityParams(new ScoringConfigGroup.ActivityParams("work").setTypicalDuration(28800)); Scenario scenario = ScenarioUtils.loadScenario(config); BoundingBox nbb = BoundingBox.createBoundingBox(network);