diff --git a/.github/dependabot.yml b/.github/dependabot.yml
index 749aa797fa1..9878d8651cc 100644
--- a/.github/dependabot.yml
+++ b/.github/dependabot.yml
@@ -4,9 +4,6 @@ updates:
directory: "/"
schedule:
interval: "daily"
- groups:
- maven:
- patterns: ["*"]
- package-ecosystem: "github-actions"
directory: "/"
diff --git a/.github/workflows/code-coverage.yaml b/.github/workflows/code-coverage.yaml
index 20ffe41971a..bdf0d7bfcde 100644
--- a/.github/workflows/code-coverage.yaml
+++ b/.github/workflows/code-coverage.yaml
@@ -15,7 +15,7 @@ jobs:
uses: actions/checkout@v4
- name: Setup Java
- uses: actions/setup-java@v3
+ uses: actions/setup-java@v4
with:
java-version: 17
distribution: 'zulu'
diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml
index 021bae1c67c..7804cbe9423 100644
--- a/.github/workflows/codeql.yml
+++ b/.github/workflows/codeql.yml
@@ -19,7 +19,7 @@ jobs:
uses: actions/checkout@v4
- name: Setup Java
- uses: actions/setup-java@v3
+ uses: actions/setup-java@v4
with:
java-version: 17
distribution: 'zulu'
@@ -27,7 +27,7 @@ jobs:
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
- uses: github/codeql-action/init@v2
+ uses: github/codeql-action/init@v3
with:
languages: 'java'
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -41,9 +41,9 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
- uses: github/codeql-action/autobuild@v2
+ uses: github/codeql-action/autobuild@v3
- name: Perform CodeQL Analysis
- uses: github/codeql-action/analyze@v2
+ uses: github/codeql-action/analyze@v3
with:
category: "/language:java"
diff --git a/.github/workflows/deploy-on-pr-merge.yaml b/.github/workflows/deploy-on-pr-merge.yaml
index 332a3dfe178..ef046e1bdb0 100644
--- a/.github/workflows/deploy-on-pr-merge.yaml
+++ b/.github/workflows/deploy-on-pr-merge.yaml
@@ -20,7 +20,7 @@ jobs:
uses: actions/checkout@v4
- name: Setup Java
- uses: actions/setup-java@v3
+ uses: actions/setup-java@v4
with:
java-version: 17
distribution: 'zulu'
diff --git a/.github/workflows/deploy-on-release-created.yaml b/.github/workflows/deploy-on-release-created.yaml
index 7c37d3c6f7d..ace4f1881fb 100644
--- a/.github/workflows/deploy-on-release-created.yaml
+++ b/.github/workflows/deploy-on-release-created.yaml
@@ -14,7 +14,7 @@ jobs:
uses: actions/checkout@v4
- name: Setup Java
- uses: actions/setup-java@v3
+ uses: actions/setup-java@v4
with:
java-version: 17
distribution: 'zulu'
diff --git a/.github/workflows/deploy-weekly.yaml b/.github/workflows/deploy-weekly.yaml
index 0861a80ff91..88e183083b7 100644
--- a/.github/workflows/deploy-weekly.yaml
+++ b/.github/workflows/deploy-weekly.yaml
@@ -15,7 +15,7 @@ jobs:
uses: actions/checkout@v4
- name: Setup Java
- uses: actions/setup-java@v3
+ uses: actions/setup-java@v4
with:
java-version: 17
distribution: 'zulu'
diff --git a/.github/workflows/full-integration.yaml b/.github/workflows/full-integration.yaml
index 57789d54a8c..e63fc75985b 100644
--- a/.github/workflows/full-integration.yaml
+++ b/.github/workflows/full-integration.yaml
@@ -1,6 +1,7 @@
name: full-integration
on:
+ workflow_dispatch:
schedule:
- cron: '30 0 * * *' # daily at 0:30 UTC
@@ -13,7 +14,7 @@ jobs:
strategy:
fail-fast: false
matrix:
- os: [ubuntu-latest, windows-latest]
+ os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- name: Prepare git
@@ -24,7 +25,7 @@ jobs:
uses: actions/checkout@v4
- name: Setup Java
- uses: actions/setup-java@v3
+ uses: actions/setup-java@v4
with:
java-version: 17
distribution: 'zulu'
diff --git a/.github/workflows/verify-push.yaml b/.github/workflows/verify-push.yaml
index 6c98df57073..a4eb837efcb 100644
--- a/.github/workflows/verify-push.yaml
+++ b/.github/workflows/verify-push.yaml
@@ -58,7 +58,6 @@ jobs:
- contribs/railsim
- contribs/roadpricing
- contribs/analysis
- - contribs/eventsBasedPTRouter
- contribs/hybridsim
- contribs/informed-mode-choice
- contribs/otfvis
@@ -85,7 +84,7 @@ jobs:
- name: Setup Java
if: ${{matrix.module != 'matsim' || steps.detect-changes.outputs.outside-contribs == 'true'}}
- uses: actions/setup-java@v3
+ uses: actions/setup-java@v4
with:
java-version: 17
distribution: 'zulu'
diff --git a/benchmark/pom.xml b/benchmark/pom.xml
index 43ee7d820b2..f8104490737 100644
--- a/benchmark/pom.xml
+++ b/benchmark/pom.xml
@@ -41,8 +41,12 @@
16.0-SNAPSHOT
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-engine
+
+
+ org.junit.jupiter
+ junit-jupiter
diff --git a/benchmark/src/main/java/org/matsim/benchmark/Benchmark.java b/benchmark/src/main/java/org/matsim/benchmark/Benchmark.java
index 9c11ff9f623..addf157f821 100644
--- a/benchmark/src/main/java/org/matsim/benchmark/Benchmark.java
+++ b/benchmark/src/main/java/org/matsim/benchmark/Benchmark.java
@@ -32,7 +32,7 @@ public class Benchmark {
public static void main(String[] args) throws IOException {
Config config = ConfigUtils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("benchmark"), "config.xml"));
Controler ctl = new Controler(config);
- ctl.getConfig().controler().setCreateGraphs(false);
+ ctl.getConfig().controller().setCreateGraphs(false);
ctl.run();
}
diff --git a/contribs/accessibility/pom.xml b/contribs/accessibility/pom.xml
index 300f8fb1bd1..45d1f56723b 100644
--- a/contribs/accessibility/pom.xml
+++ b/contribs/accessibility/pom.xml
@@ -52,7 +52,7 @@
org.openstreetmap.osmosis
osmosis-core
- 0.48.3
+ ${osmosis.version}
@@ -65,7 +65,7 @@
org.openstreetmap.osmosis
osmosis-xml
- 0.48.3
+ ${osmosis.version}
org.matsim.contrib
diff --git a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/AccessibilityComputationNairobiLandUseLocalCopy.java b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/AccessibilityComputationNairobiLandUseLocalCopy.java
index ef0f7fdc022..91e6e1c72ca 100644
--- a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/AccessibilityComputationNairobiLandUseLocalCopy.java
+++ b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/AccessibilityComputationNairobiLandUseLocalCopy.java
@@ -39,26 +39,26 @@
*/
class AccessibilityComputationNairobiLandUseLocalCopy {
public static final Logger LOG = LogManager.getLogger(AccessibilityComputationNairobiLandUseLocalCopy.class);
-
+
public static void main(String[] args) {
int tileSize_m = 500;
boolean push2Geoserver = false; // Set true for run on server
boolean createQGisOutput = true; // Set false for run on server
-
+
final Config config = ConfigUtils.createConfig(new AccessibilityConfigGroup());
-
+
Envelope envelope = new Envelope(246000, 271000, 9853000, 9863000); // Central part of Nairobi
String scenarioCRS = "EPSG:21037"; // EPSG:21037 = Arc 1960 / UTM zone 37S, for Nairobi, Kenya
-
+
config.network().setInputFile("../nairobi/data/nairobi/input/2015-10-15_network.xml");
config.facilities().setInputFile("../nairobi/data/land_use/Nairobi_LU_2010/facilities.xml");
String runId = "ke_nairobi_landuse_hexagons_" + tileSize_m;
- config.controler().setOutputDirectory("../nairobi/data/nairobi/output/" + runId + "_lcpt_par4_car_tr-7_500/");
- config.controler().setRunId(runId);
-
- config.controler().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists);
- config.controler().setLastIteration(0);
-
+ config.controller().setOutputDirectory("../nairobi/data/nairobi/output/" + runId + "_lcpt_par4_car_tr-7_500/");
+ config.controller().setRunId(runId);
+
+ config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists);
+ config.controller().setLastIteration(0);
+
AccessibilityConfigGroup acg = ConfigUtils.addOrGetModule(config, AccessibilityConfigGroup.class);
acg.setAreaOfAccessibilityComputation(AreaOfAccesssibilityComputation.fromBoundingBoxHexagons);
acg.setEnvelope(envelope);
@@ -69,17 +69,17 @@ public static void main(String[] args) {
acg.setOutputCrs(scenarioCRS);
//acg.setUseParallelization(false);
-
+
ConfigUtils.setVspDefaults(config);
-
+
final Scenario scenario = ScenarioUtils.loadScenario(config);
-
+
// final List activityTypes = Arrays.asList(new String[]{"educational", "commercial", "industrial", "recreational", "water_body"});
final List activityTypes = Arrays.asList(new String[]{"educational"});
final ActivityFacilities densityFacilities = AccessibilityUtils.createFacilityForEachLink(Labels.DENSITIY, scenario.getNetwork());
-
+
final Controler controler = new Controler(scenario);
-
+
for (String activityType : activityTypes) {
AccessibilityModule module = new AccessibilityModule();
module.setConsideredActivityType(activityType);
@@ -88,17 +88,17 @@ public static void main(String[] args) {
module.setCreateQGisOutput(createQGisOutput);
controler.addOverridingModule(module);
}
-
+
controler.run();
-
+
if (createQGisOutput) {
final Integer range = 9; // In the current implementation, this must always be 9
final Double lowerBound = -3.5; // (upperBound - lowerBound) ideally nicely divisible by (range - 2)
final Double upperBound = 3.5;
final int populationThreshold = (int) (10 / (1000/tileSize_m * 1000/tileSize_m)); // People per km^2 or roads (?)
-
+
String osName = System.getProperty("os.name");
- String workingDirectory = config.controler().getOutputDirectory();
+ String workingDirectory = config.controller().getOutputDirectory();
for (String actType : activityTypes) {
String actSpecificWorkingDirectory = workingDirectory + actType + "/";
for (Modes4Accessibility mode : acg.getIsComputingMode()) {
diff --git a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/AccessibilityComputationShutdownListener.java b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/AccessibilityComputationShutdownListener.java
index a3f82abfa44..39637e1228f 100644
--- a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/AccessibilityComputationShutdownListener.java
+++ b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/AccessibilityComputationShutdownListener.java
@@ -30,11 +30,10 @@
import org.matsim.api.core.v01.Id;
import org.matsim.api.core.v01.Scenario;
import org.matsim.api.core.v01.TransportMode;
-import org.matsim.api.core.v01.network.Node;
import org.matsim.contrib.accessibility.utils.AggregationObject;
import org.matsim.contrib.accessibility.utils.ProgressBar;
import org.matsim.core.config.ConfigUtils;
-import org.matsim.core.config.groups.PlanCalcScoreConfigGroup;
+import org.matsim.core.config.groups.ScoringConfigGroup;
import org.matsim.core.controler.events.ShutdownEvent;
import org.matsim.core.controler.listener.ShutdownListener;
import org.matsim.core.gbl.Gbl;
@@ -58,9 +57,9 @@ final class AccessibilityComputationShutdownListener implements ShutdownListener
private final ArrayList zoneDataExchangeListeners = new ArrayList<>();
private AccessibilityConfigGroup acg;
- private final PlanCalcScoreConfigGroup cnScoringGroup;
+ private final ScoringConfigGroup cnScoringGroup;
+
-
public AccessibilityComputationShutdownListener(Scenario scenario, ActivityFacilities measuringPoints, ActivityFacilities opportunities,
String outputDirectory) {
this.measuringPoints = measuringPoints;
@@ -69,7 +68,7 @@ public AccessibilityComputationShutdownListener(Scenario scenario, ActivityFacil
this.outputDirectory = outputDirectory;
this.acg = ConfigUtils.addOrGetModule(scenario.getConfig(), AccessibilityConfigGroup.GROUP_NAME, AccessibilityConfigGroup.class);
- this.cnScoringGroup = scenario.getConfig().planCalcScore();
+ this.cnScoringGroup = scenario.getConfig().scoring();
if (cnScoringGroup.getOrCreateModeParams(TransportMode.car).getMarginalUtilityOfDistance() != 0.) {
LOG.error("Marginal utility of distance for car different from zero, but not used in accessibility computations");
@@ -241,10 +240,10 @@ private void writeCSVFile(String adaptedOutputDirectory) {
writer.writeField(facility.getCoord().getX());
writer.writeField(facility.getCoord().getY());
writer.writeField(tuple.getSecond());
-
+
for (String mode : getModes() ) {
final double value = accessibilitiesMap.get(tuple).get(mode);
- if (!Double.isNaN(value)) {
+ if (!Double.isNaN(value)) {
writer.writeField(value) ;
} else {
writer.writeField(Double.NaN) ;
diff --git a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/AccessibilityFromEvents.java b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/AccessibilityFromEvents.java
index 476471ebd8c..b200e3a46f0 100644
--- a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/AccessibilityFromEvents.java
+++ b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/AccessibilityFromEvents.java
@@ -58,7 +58,7 @@ private AccessibilityFromEvents( Scenario scenario, String eventsFile, List map = new LinkedHashMap<>( ) ;
EventsManager events = EventsUtils.createEventsManager();
- for( String mode : scenario.getConfig().plansCalcRoute().getNetworkModes() ){
+ for( String mode : scenario.getConfig().routing().getNetworkModes() ){
TravelTimeCalculator.Builder builder = new TravelTimeCalculator.Builder( scenario.getNetwork() );
builder.setCalculateLinkTravelTimes( true );
builder.setCalculateLinkToLinkTravelTimes( false );
@@ -74,7 +74,7 @@ public void run() {
install( new ScenarioByInstanceModule( scenario ) ) ;
install( new TripRouterModule() ) ;
install( new TimeInterpretationModule() );
- for( String mode : getConfig().plansCalcRoute().getNetworkModes() ){
+ for( String mode : getConfig().routing().getNetworkModes() ){
addTravelTimeBinding( mode ).toInstance( map.get(mode) );
}
install( new TravelDisutilityModule() ) ;
diff --git a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/AccessibilityModule.java b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/AccessibilityModule.java
index 19c98283c02..c4677dd3fd3 100644
--- a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/AccessibilityModule.java
+++ b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/AccessibilityModule.java
@@ -139,7 +139,7 @@ public ControlerListener get() {
}
AccessibilityUtils.assignAdditionalFacilitiesDataToMeasurePoint(measuringPoints, measurePointGeometryMap, additionalFacs);
- String outputDirectory = scenario.getConfig().controler().getOutputDirectory() + "/" + activityType;
+ String outputDirectory = scenario.getConfig().controller().getOutputDirectory() + "/" + activityType;
AccessibilityComputationShutdownListener accessibilityShutdownListener = new AccessibilityComputationShutdownListener(scenario, measuringPoints, opportunities, outputDirectory);
// for (Modes4Accessibility mode : acg.getIsComputingMode()) {
@@ -150,14 +150,14 @@ public ControlerListener get() {
final TravelDisutilityFactory travelDisutilityFactory = travelDisutilityFactories.get(TransportMode.car);
Gbl.assertNotNull(travelDisutilityFactory);
calculator = new NetworkModeAccessibilityExpContributionCalculator(mode, new FreeSpeedTravelTime(), travelDisutilityFactory, scenario);
- } else if ( config.plansCalcRoute().getNetworkModes().contains( mode ) ) {
+ } else if ( config.routing().getNetworkModes().contains( mode ) ) {
final TravelTime nwModeTravelTime = travelTimes.get(mode);
Gbl.assertNotNull(nwModeTravelTime);
final TravelDisutilityFactory nwModeTravelDisutility = travelDisutilityFactories.get(mode);
Gbl.assertNotNull( nwModeTravelDisutility );
calculator = new NetworkModeAccessibilityExpContributionCalculator(mode, nwModeTravelTime, nwModeTravelDisutility, scenario);
} else if ( TransportMode.pt.equals( mode ) ){
- calculator = new SwissRailRaptorAccessibilityContributionCalculator( mode, config.planCalcScore(), scenario );
+ calculator = new SwissRailRaptorAccessibilityContributionCalculator( mode, config.scoring(), scenario );
} else if ( Modes4Accessibility.matrixBasedPt.name().equals( mode ) ) {
throw new RuntimeException("currently not supported because implementation not consistent with guice grapher. kai, sep'19") ;
// calculator = new LeastCostPathCalculatorAccessibilityContributionCalculator(
@@ -175,7 +175,7 @@ public ControlerListener get() {
if ( travelDisutilityFactory==null ) {
throw new RuntimeException("mode=" + mode + "; travelDisutilityFactory is null!") ;
}
- calculator = new TripRouterAccessibilityContributionCalculator(mode, tripRouter, config.planCalcScore(), scenario,
+ calculator = new TripRouterAccessibilityContributionCalculator(mode, tripRouter, config.scoring(), scenario,
travelTime, travelDisutilityFactory );
}
@@ -195,7 +195,7 @@ public ControlerListener get() {
}
Set additionalFacInfo = additionalFacs.keySet();
accessibilityShutdownListener.addFacilityDataExchangeListener(new GeoserverUpdater(acg.getOutputCrs(),
- config.controler().getRunId() + "_" + activityType, measurePointGeometryMap, additionalFacInfo,
+ config.controller().getRunId() + "_" + activityType, measurePointGeometryMap, additionalFacInfo,
outputDirectory, pushing2Geoserver, createQGisOutput));
}
diff --git a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/AccessibilityUtils.java b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/AccessibilityUtils.java
index 0de040c489c..db9adc47ccd 100644
--- a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/AccessibilityUtils.java
+++ b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/AccessibilityUtils.java
@@ -34,7 +34,7 @@
import org.matsim.core.config.Config;
import org.matsim.core.config.ConfigUtils;
import org.matsim.core.config.groups.NetworkConfigGroup;
-import org.matsim.core.config.groups.PlanCalcScoreConfigGroup;
+import org.matsim.core.config.groups.ScoringConfigGroup;
import org.matsim.core.gbl.Gbl;
import org.matsim.core.network.NetworkUtils;
import org.matsim.core.network.algorithms.TransportModeNetworkFilter;
@@ -65,7 +65,7 @@ public static final Map, AggregationObject> aggregat
// yyyy this method ignores the "capacities" of the facilities. kai, mar'14
// for now, we decided not to add "capacities" as it is not needed for current projects. dz, feb'16
- double walkSpeed_m_h = config.plansCalcRoute().getTeleportedModeSpeeds().get(TransportMode.walk) * 3600.;
+ double walkSpeed_m_h = config.routing().getTeleportedModeSpeeds().get(TransportMode.walk) * 3600.;
AccessibilityConfigGroup acg = ConfigUtils.addOrGetModule(config, AccessibilityConfigGroup.GROUP_NAME, AccessibilityConfigGroup.class);
LOG.info("Aggregating " + opportunities.getFacilities().size() + " opportunities with same nearest node...");
@@ -76,11 +76,11 @@ public static final Map, AggregationObject> aggregat
double distance_m = NetworkUtils.getEuclideanDistance(opportunity.getCoord(), nearestNode.getCoord());
// in MATSim this is [utils/h]: cnScoringGroup.getTravelingWalk_utils_hr() - cnScoringGroup.getPerforming_utils_hr()
- double walkBetaTT_utils_h = config.planCalcScore().getModes().get(TransportMode.walk).getMarginalUtilityOfTraveling()
- - config.planCalcScore().getPerforming_utils_hr(); // default values: -12 = (-6.) - (6.)
+ double walkBetaTT_utils_h = config.scoring().getModes().get(TransportMode.walk).getMarginalUtilityOfTraveling()
+ - config.scoring().getPerforming_utils_hr(); // default values: -12 = (-6.) - (6.)
double VjkWalkTravelTime = walkBetaTT_utils_h * (distance_m / walkSpeed_m_h);
- double expVjk = Math.exp(config.planCalcScore().getBrainExpBeta() * VjkWalkTravelTime);
+ double expVjk = Math.exp(config.scoring().getBrainExpBeta() * VjkWalkTravelTime);
// add Vjk to sum
AggregationObject jco = opportunityClusterMap.get(nearestNode.getId()); // Why "jco"?
@@ -142,16 +142,16 @@ public static Network createModeSpecificSubNetwork(Network network, String mode,
}
- public static double getModeSpecificConstantForAccessibilities(String mode, PlanCalcScoreConfigGroup planCalcScoreConfigGroup) {
+ public static double getModeSpecificConstantForAccessibilities(String mode, ScoringConfigGroup scoringConfigGroup) {
double modeSpecificConstant;
if (mode.equals(Modes4Accessibility.freespeed.name())) {
- modeSpecificConstant = planCalcScoreConfigGroup.getModes().get(TransportMode.car).getConstant();
+ modeSpecificConstant = scoringConfigGroup.getModes().get(TransportMode.car).getConstant();
} else {
- modeSpecificConstant = planCalcScoreConfigGroup.getModes().get(mode).getConstant();
+ modeSpecificConstant = scoringConfigGroup.getModes().get(mode).getConstant();
}
return modeSpecificConstant;
}
-
+
/**
* Collects all facilities of a given type that have been loaded to the sceanrio.
*/
@@ -191,8 +191,8 @@ public static List collectAllFacilityOptionTypes(Scenario scenario) {
public static void combineDifferentActivityOptionTypes(final Scenario scenario, String combinedType, final List activityOptionsToBeIncluded) {
- ActivityOption markerOption = new ActivityOptionImpl(combinedType);
-
+ ActivityOption markerOption = new ActivityOptionImpl(combinedType);
+
// Memorize all facilities that have certain activity options in a activity facilities container
final ActivityFacilities consideredFacilities = FacilitiesUtils.createActivityFacilities();
for (ActivityFacility facility : scenario.getActivityFacilities().getFacilities().values()) {
@@ -205,7 +205,7 @@ public static void combineDifferentActivityOptionTypes(final Scenario scenario,
}
}
}
-
+
// Add marker option to facilities to be considered
for (ActivityFacility facility : consideredFacilities.getFacilities().values()) {
facility.addActivityOption(markerOption);
@@ -227,16 +227,16 @@ public static final ActivityFacilities createFacilityForEachLink(String facility
public static final ActivityFacilities createFacilityFromBuildingShapefile(String shapeFileName, String identifierCaption, String numberOfHouseholdsCaption) {
ShapeFileReader shapeFileReader = new ShapeFileReader();
Collection features = shapeFileReader.readFileAndInitialize(shapeFileName);
-
+
ActivityFacilities facilities = FacilitiesUtils.createActivityFacilities("DensitiyFacilities");
ActivityFacilitiesFactory aff = facilities.getFactory();
-
+
for (SimpleFeature feature : features) {
String featureId = (String) feature.getAttribute(identifierCaption);
Integer numberOfHouseholds = Integer.parseInt((String) feature.getAttribute(numberOfHouseholdsCaption));
Geometry geometry = (Geometry) feature.getDefaultGeometry();
Coord coord = CoordUtils.createCoord(geometry.getCentroid().getX(), geometry.getCentroid().getY());
-
+
for (int i = 0; i < numberOfHouseholds; i++) {
ActivityFacility facility = aff.createActivityFacility(Id.create(featureId + "_" + i, ActivityFacility.class), coord);
facilities.addActivityFacility(facility);
@@ -255,7 +255,7 @@ public static ActivityFacilities createMeasuringPointsFromNetworkBounds(Network
double xMax = boundingBox.getXMax();
double yMin = boundingBox.getYMin();
double yMax = boundingBox.getYMax();
-
+
ActivityFacilities measuringPoints = GridUtils.createGridLayerByGridSizeByBoundingBoxV2(xMin, yMin, xMax, yMax, cellSize);
return measuringPoints;
}
@@ -263,7 +263,7 @@ public static ActivityFacilities createMeasuringPointsFromNetworkBounds(Network
/**
* Calculates the sum of the values of a given list.
- *
+ *
* @param valueList
* @return sum
*/
@@ -279,7 +279,7 @@ public static double calculateSum(List valueList) {
/**
* Calculates Gini coefficient of the values of a given values. The Gini Coefficient is equals to the half of
* the relative mean absolute difference (RMD).
- *
+ *
* @see
* @see
* @param valueList
@@ -289,7 +289,7 @@ public static double calculateGiniCoefficient(List valueList) {
int numberOfValues = valueList.size();
double sumOfValues = calculateSum(valueList);
double arithmeticMean = sumOfValues / numberOfValues;
-
+
double sumOfAbsoluteDifferences = 0.;
for (double i : valueList) {
for (double j : valueList) {
@@ -310,24 +310,24 @@ public static double calculateGiniCoefficient(List valueList) {
public static ActivityFacilities createFacilitiesFromPlans(Population population) {
ActivityFacilitiesFactory aff = new ActivityFacilitiesFactoryImpl();
ActivityFacilities facilities = FacilitiesUtils.createActivityFacilities();
-
+
for(Person person : population.getPersons().values()) {
for(Plan plan : person.getPlans()) {
Id personId = person.getId();
-
+
for (PlanElement planElement : plan.getPlanElements()) {
if (planElement instanceof Activity) {
Activity activity = (Activity) planElement;
-
+
Coord coord= activity.getCoord();
if (coord == null) {
throw new NullPointerException("Activity does not have any coordinates.");
}
-
+
String activityType = activity.getType();
-
+
// In case an agent visits the same activity location twice, create another activity facility with a modified ID
- Integer i = 1;
+ Integer i = 1;
Id facilityId = Id.create(activityType + "_" + personId.toString() + "_" + i.toString(), ActivityFacility.class);
while (facilities.getFacilities().containsKey(facilityId)) {
i++;
@@ -335,7 +335,7 @@ public static ActivityFacilities createFacilitiesFromPlans(Population population
}
ActivityFacility facility = aff.createActivityFacility(facilityId, activity.getCoord());
-
+
facility.addActivityOption(aff.createActivityOption(activityType));
facilities.addActivityFacility(facility);
// log.info("Created activity with option of type " + activityType + " and ID " + facilityId + ".");
@@ -353,7 +353,7 @@ public static String getDate() {
String monthStr = month + "";
if (month < 10)
monthStr = "0" + month;
- String date = cal.get(Calendar.YEAR) + "-"
+ String date = cal.get(Calendar.YEAR) + "-"
+ monthStr + "-" + cal.get(Calendar.DAY_OF_MONTH);
return date;
}
@@ -363,16 +363,16 @@ public static void assignAdditionalFacilitiesDataToMeasurePoint(ActivityFaciliti
Map additionalFacilityData) {
LOG.info("Start assigning additional facilities data to measure point.");
GeometryFactory geometryFactory = new GeometryFactory();
-
+
for (ActivityFacilities additionalDataFacilities : additionalFacilityData.values()) { // Iterate over all additional data collections
String additionalDataName = additionalDataFacilities.getName();
int additionalDataFacilitiesToAssign = additionalDataFacilities.getFacilities().size();
-
+
for (Id measurePointId : measurePoints.getFacilities().keySet()) { // Iterate over all measure points
ActivityFacility measurePoint = measurePoints.getFacilities().get(measurePointId);
measurePoint.getAttributes().putAttribute(additionalDataName, 0);
Geometry geometry = measurePointGeometryMap.get(measurePointId);
-
+
for (ActivityFacility facility : additionalDataFacilities.getFacilities().values()) { // Iterate over additional-data facilities
Point point = geometryFactory.createPoint(new Coordinate(facility.getCoord().getX(), facility.getCoord().getY()));
if (geometry.contains(point)) {
diff --git a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/ConstantSpeedAccessibilityExpContributionCalculator.java b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/ConstantSpeedAccessibilityExpContributionCalculator.java
index 329155e30e4..90179912f8d 100644
--- a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/ConstantSpeedAccessibilityExpContributionCalculator.java
+++ b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/ConstantSpeedAccessibilityExpContributionCalculator.java
@@ -29,7 +29,7 @@
import org.matsim.contrib.accessibility.utils.Distances;
import org.matsim.contrib.accessibility.utils.NetworkUtil;
import org.matsim.core.config.Config;
-import org.matsim.core.config.groups.PlanCalcScoreConfigGroup;
+import org.matsim.core.config.groups.ScoringConfigGroup;
import org.matsim.core.network.NetworkUtils;
import org.matsim.core.network.algorithms.TransportModeNetworkFilter;
import org.matsim.core.trafficmonitoring.FreeSpeedTravelTime;
@@ -54,14 +54,14 @@ final class ConstantSpeedAccessibilityExpContributionCalculator implements Acces
// private Network network;
private Network subNetwork;
private Scenario scenario;
-
+
private double logitScaleParameter;
-
+
private double betaModeTT; // in MATSim this is [utils/h]: cnScoringGroup.getTravelingBike_utils_hr() - cnScoringGroup.getPerforming_utils_hr()
private double betaModeTD; // in MATSim this is 0 !!! since getMonetaryDistanceCostRateBike doesn't exist:
private double constMode;
private double modeSpeed_m_h = -1;
-
+
private double betaWalkTT;
private double betaWalkTD;
private double walkSpeed_m_h;
@@ -77,27 +77,27 @@ public ConstantSpeedAccessibilityExpContributionCalculator(final String mode, fi
this.scenario = scenario;
this.config = scenario.getConfig();
- final PlanCalcScoreConfigGroup planCalcScoreConfigGroup = config.planCalcScore() ;
+ final ScoringConfigGroup scoringConfigGroup = config.scoring() ;
- if (planCalcScoreConfigGroup.getOrCreateModeParams(mode).getMonetaryDistanceRate() != 0.) {
+ if (scoringConfigGroup.getOrCreateModeParams(mode).getMonetaryDistanceRate() != 0.) {
LOG.error("Monetary distance cost rate for " + mode + " different from zero, but not used in accessibility computations");
}
- logitScaleParameter = planCalcScoreConfigGroup.getBrainExpBeta();
+ logitScaleParameter = scoringConfigGroup.getBrainExpBeta();
- if (config.plansCalcRoute().getTeleportedModeSpeeds().get(mode) == null) {
+ if (config.routing().getTeleportedModeSpeeds().get(mode) == null) {
LOG.error("No teleported mode speed for mode " + mode + " set.");
}
- this.modeSpeed_m_h = config.plansCalcRoute().getTeleportedModeSpeeds().get(mode) * 3600.;
+ this.modeSpeed_m_h = config.routing().getTeleportedModeSpeeds().get(mode) * 3600.;
- final PlanCalcScoreConfigGroup.ModeParams modeParams = planCalcScoreConfigGroup.getOrCreateModeParams(mode);
- betaModeTT = modeParams.getMarginalUtilityOfTraveling() - planCalcScoreConfigGroup.getPerforming_utils_hr();
+ final ScoringConfigGroup.ModeParams modeParams = scoringConfigGroup.getOrCreateModeParams(mode);
+ betaModeTT = modeParams.getMarginalUtilityOfTraveling() - scoringConfigGroup.getPerforming_utils_hr();
betaModeTD = modeParams.getMarginalUtilityOfDistance();
constMode = modeParams.getConstant();
- betaWalkTT = planCalcScoreConfigGroup.getModes().get(TransportMode.walk).getMarginalUtilityOfTraveling() - planCalcScoreConfigGroup.getPerforming_utils_hr();
- betaWalkTD = planCalcScoreConfigGroup.getModes().get(TransportMode.walk).getMarginalUtilityOfDistance();
- this.walkSpeed_m_h = config.plansCalcRoute().getTeleportedModeSpeeds().get(TransportMode.walk) * 3600;
+ betaWalkTT = scoringConfigGroup.getModes().get(TransportMode.walk).getMarginalUtilityOfTraveling() - scoringConfigGroup.getPerforming_utils_hr();
+ betaWalkTD = scoringConfigGroup.getModes().get(TransportMode.walk).getMarginalUtilityOfDistance();
+ this.walkSpeed_m_h = config.routing().getTeleportedModeSpeeds().get(TransportMode.walk) * 3600;
}
@@ -124,14 +124,14 @@ public void initialize(ActivityFacilities measuringPoints, ActivityFacilities op
}
-
+
@Override
public void notifyNewOriginNode(Id extends BasicLocation> fromNodeId, Double departureTime) {
this.fromNode = subNetwork.getNodes().get(fromNodeId);
this.lcptTravelDistance.calculate(subNetwork, fromNode, departureTime);
}
-
+
@Override
public double computeContributionOfOpportunity(ActivityFacility origin,
Map, AggregationObject> aggregatedOpportunities, Double departureTime) {
diff --git a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/LeastCostPathCalculatorAccessibilityContributionCalculator.java b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/LeastCostPathCalculatorAccessibilityContributionCalculator.java
index 74dbdfeffa2..ee526dafc6d 100644
--- a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/LeastCostPathCalculatorAccessibilityContributionCalculator.java
+++ b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/LeastCostPathCalculatorAccessibilityContributionCalculator.java
@@ -5,7 +5,7 @@
import org.matsim.api.core.v01.Scenario;
import org.matsim.api.core.v01.network.Node;
import org.matsim.contrib.accessibility.utils.AggregationObject;
-import org.matsim.core.config.groups.PlanCalcScoreConfigGroup;
+import org.matsim.core.config.groups.ScoringConfigGroup;
import org.matsim.core.router.util.LeastCostPathCalculator;
import org.matsim.facilities.ActivityFacilities;
import org.matsim.facilities.ActivityFacility;
@@ -18,7 +18,7 @@
*/
final class LeastCostPathCalculatorAccessibilityContributionCalculator implements AccessibilityContributionCalculator {
private final LeastCostPathCalculator leastCostPathCalculator;
- private final PlanCalcScoreConfigGroup planCalcScoreConfigGroup;
+ private final ScoringConfigGroup scoringConfigGroup;
private Node fromNode;
private Double departureTime;
private Scenario scenario;
@@ -27,8 +27,8 @@ final class LeastCostPathCalculatorAccessibilityContributionCalculator implement
Map, AggregationObject> aggregatedOpportunities;
- public LeastCostPathCalculatorAccessibilityContributionCalculator(PlanCalcScoreConfigGroup planCalcScoreConfigGroup, LeastCostPathCalculator leastCostPathCalculator, Scenario scenario) {
- this.planCalcScoreConfigGroup = planCalcScoreConfigGroup;
+ public LeastCostPathCalculatorAccessibilityContributionCalculator(ScoringConfigGroup scoringConfigGroup, LeastCostPathCalculator leastCostPathCalculator, Scenario scenario) {
+ this.scoringConfigGroup = scoringConfigGroup;
this.leastCostPathCalculator = leastCostPathCalculator;
this.scenario = scenario;
}
@@ -55,7 +55,7 @@ public double computeContributionOfOpportunity(ActivityFacility origin,
for (final AggregationObject destination : aggregatedOpportunities.values()) {
LeastCostPathCalculator.Path path = leastCostPathCalculator.calcLeastCostPath(fromNode, (Node) destination.getNearestBasicLocation(), departureTime, null, null);
- expSum += destination.getSum() * Math.exp(planCalcScoreConfigGroup.getBrainExpBeta() * path.travelCost);
+ expSum += destination.getSum() * Math.exp(scoringConfigGroup.getBrainExpBeta() * path.travelCost);
}
return expSum;
}
@@ -64,7 +64,7 @@ public double computeContributionOfOpportunity(ActivityFacility origin,
@Override
public LeastCostPathCalculatorAccessibilityContributionCalculator duplicate() {
LeastCostPathCalculatorAccessibilityContributionCalculator leastCostPathCalculatorAccessibilityContributionCalculator =
- new LeastCostPathCalculatorAccessibilityContributionCalculator(this.planCalcScoreConfigGroup, this.leastCostPathCalculator, this.scenario);
+ new LeastCostPathCalculatorAccessibilityContributionCalculator(this.scoringConfigGroup, this.leastCostPathCalculator, this.scenario);
return leastCostPathCalculatorAccessibilityContributionCalculator;
}
diff --git a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/NetworkModeAccessibilityExpContributionCalculator.java b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/NetworkModeAccessibilityExpContributionCalculator.java
index cfaf0906478..ff5aee3d9fa 100644
--- a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/NetworkModeAccessibilityExpContributionCalculator.java
+++ b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/NetworkModeAccessibilityExpContributionCalculator.java
@@ -12,7 +12,7 @@
import org.matsim.contrib.accessibility.utils.*;
import org.matsim.contrib.roadpricing.RoadPricingScheme;
import org.matsim.core.config.groups.NetworkConfigGroup;
-import org.matsim.core.config.groups.PlanCalcScoreConfigGroup;
+import org.matsim.core.config.groups.ScoringConfigGroup;
import org.matsim.core.gbl.Gbl;
import org.matsim.core.network.NetworkUtils;
import org.matsim.core.network.algorithms.TransportModeNetworkFilter;
@@ -40,7 +40,7 @@ final class NetworkModeAccessibilityExpContributionCalculator implements Accessi
private final Scenario scenario;
private final TravelDisutility travelDisutility;
- private final PlanCalcScoreConfigGroup planCalcScoreConfigGroup;
+ private final ScoringConfigGroup scoringConfigGroup;
private final NetworkConfigGroup networkConfigGroup;
private Network subNetwork;
@@ -68,7 +68,7 @@ public NetworkModeAccessibilityExpContributionCalculator(String mode, final Trav
Gbl.assertNotNull(travelDisutilityFactory);
this.travelDisutility = travelDisutilityFactory.createTravelDisutility(travelTime);
- planCalcScoreConfigGroup = scenario.getConfig().planCalcScore();
+ scoringConfigGroup = scenario.getConfig().scoring();
networkConfigGroup = scenario.getConfig().network();
RoadPricingScheme scheme = (RoadPricingScheme) scenario.getScenarioElement( RoadPricingScheme.ELEMENT_NAME );
@@ -78,9 +78,9 @@ public NetworkModeAccessibilityExpContributionCalculator(String mode, final Trav
//FastMultiNodeDijkstraFactory fastMultiNodeDijkstraFactory = new FastMultiNodeDijkstraFactory(true);
//this.multiNodePathCalculator = (MultiNodePathCalculator) fastMultiNodeDijkstraFactory.createPathCalculator(network, travelDisutility, travelTime);
- betaWalkTT = planCalcScoreConfigGroup.getModes().get(TransportMode.walk).getMarginalUtilityOfTraveling() - planCalcScoreConfigGroup.getPerforming_utils_hr();
+ betaWalkTT = scoringConfigGroup.getModes().get(TransportMode.walk).getMarginalUtilityOfTraveling() - scoringConfigGroup.getPerforming_utils_hr();
- this.walkSpeed_m_s = scenario.getConfig().plansCalcRoute().getTeleportedModeSpeeds().get(TransportMode.walk);
+ this.walkSpeed_m_s = scenario.getConfig().routing().getTeleportedModeSpeeds().get(TransportMode.walk);
}
@@ -137,7 +137,7 @@ public double computeContributionOfOpportunity(ActivityFacility origin,
double congestedCarUtilityRoad2Node = -travelDisutility.getLinkTravelDisutility(nearestLink, departureTime, null, null) * distanceFraction;
// Combine all utility components (using the identity: exp(a+b) = exp(a) * exp(b))
- double modeSpecificConstant = AccessibilityUtils.getModeSpecificConstantForAccessibilities(mode, planCalcScoreConfigGroup);
+ double modeSpecificConstant = AccessibilityUtils.getModeSpecificConstantForAccessibilities(mode, scoringConfigGroup);
for (final AggregationObject destination : aggregatedOpportunities.values()) {
@@ -151,7 +151,7 @@ public double computeContributionOfOpportunity(ActivityFacility origin,
// Pre-computed effect of all opportunities reachable from destination network node
double sumExpVjkWalk = destination.getSum();
- expSum += Math.exp(this.planCalcScoreConfigGroup.getBrainExpBeta() * (walkUtilityMeasuringPoint2Road + modeSpecificConstant
+ expSum += Math.exp(this.scoringConfigGroup.getBrainExpBeta() * (walkUtilityMeasuringPoint2Road + modeSpecificConstant
+ congestedCarUtilityRoad2Node + congestedCarUtility)) * sumExpVjkWalk;
}
return expSum;
diff --git a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/SwissRailRaptorAccessibilityContributionCalculator.java b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/SwissRailRaptorAccessibilityContributionCalculator.java
index b64c6fa7b4e..6fcd4466276 100644
--- a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/SwissRailRaptorAccessibilityContributionCalculator.java
+++ b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/SwissRailRaptorAccessibilityContributionCalculator.java
@@ -25,7 +25,7 @@
import org.matsim.api.core.v01.network.Network;
import org.matsim.contrib.accessibility.utils.AggregationObject;
import org.matsim.core.config.ConfigUtils;
-import org.matsim.core.config.groups.PlanCalcScoreConfigGroup;
+import org.matsim.core.config.groups.ScoringConfigGroup;
import org.matsim.core.gbl.Gbl;
import org.matsim.core.utils.geometry.CoordUtils;
import org.matsim.facilities.*;
@@ -44,7 +44,7 @@ class SwissRailRaptorAccessibilityContributionCalculator implements Accessibilit
private static final Logger LOG = LogManager.getLogger( SwissRailRaptorAccessibilityContributionCalculator.class );
private SwissRailRaptor raptor;
private String mode;
- private PlanCalcScoreConfigGroup planCalcScoreConfigGroup;
+ private ScoringConfigGroup scoringConfigGroup;
private Scenario scenario;
Map, ArrayList> aggregatedMeasurePoints;
@@ -58,7 +58,7 @@ class SwissRailRaptorAccessibilityContributionCalculator implements Accessibilit
Map, Collection> stopsPerAggregatedOpportunity = new LinkedHashMap<>();
- public SwissRailRaptorAccessibilityContributionCalculator(String mode, PlanCalcScoreConfigGroup planCalcScoreConfigGroup, Scenario scenario) {
+ public SwissRailRaptorAccessibilityContributionCalculator(String mode, ScoringConfigGroup scoringConfigGroup, Scenario scenario) {
this.mode = mode;
TransitSchedule schedule = scenario.getTransitSchedule();
@@ -69,12 +69,12 @@ public SwissRailRaptorAccessibilityContributionCalculator(String mode, PlanCalcS
this.raptorData = SwissRailRaptorData.create(schedule, null, raptorConfig, ptNetwork, null);
this.raptor = new SwissRailRaptor.Builder(raptorData, scenario.getConfig()).build();
- this.planCalcScoreConfigGroup = planCalcScoreConfigGroup;
+ this.scoringConfigGroup = scoringConfigGroup;
this.scenario = scenario;
- this.betaWalkTT = planCalcScoreConfigGroup.getModes().get(TransportMode.walk).getMarginalUtilityOfTraveling() - planCalcScoreConfigGroup.getPerforming_utils_hr();
+ this.betaWalkTT = scoringConfigGroup.getModes().get(TransportMode.walk).getMarginalUtilityOfTraveling() - scoringConfigGroup.getPerforming_utils_hr();
- this.walkSpeed_m_h = scenario.getConfig().plansCalcRoute().getTeleportedModeSpeeds().get(TransportMode.walk) * 3600.;
+ this.walkSpeed_m_h = scenario.getConfig().routing().getTeleportedModeSpeeds().get(TransportMode.walk) * 3600.;
}
@@ -167,8 +167,8 @@ public double computeContributionOfOpportunity(ActivityFacility origin,
//check whether direct walk time is cheaper
travelCost = Math.min(travelCost, directWalkCost);
- double modeSpecificConstant = AccessibilityUtils.getModeSpecificConstantForAccessibilities(mode, planCalcScoreConfigGroup);
- expSum += Math.exp(this.planCalcScoreConfigGroup.getBrainExpBeta() * (-travelCost + modeSpecificConstant));
+ double modeSpecificConstant = AccessibilityUtils.getModeSpecificConstantForAccessibilities(mode, scoringConfigGroup);
+ expSum += Math.exp(this.scoringConfigGroup.getBrainExpBeta() * (-travelCost + modeSpecificConstant));
}
return expSum;
}
@@ -177,7 +177,7 @@ public double computeContributionOfOpportunity(ActivityFacility origin,
@Override
public SwissRailRaptorAccessibilityContributionCalculator duplicate() {
SwissRailRaptorAccessibilityContributionCalculator swissRailRaptorAccessibilityContributionCalculator =
- new SwissRailRaptorAccessibilityContributionCalculator(this.mode, this.planCalcScoreConfigGroup, this.scenario);
+ new SwissRailRaptorAccessibilityContributionCalculator(this.mode, this.scoringConfigGroup, this.scenario);
swissRailRaptorAccessibilityContributionCalculator.aggregatedMeasurePoints = this.aggregatedMeasurePoints;
swissRailRaptorAccessibilityContributionCalculator.aggregatedOpportunities = this.aggregatedOpportunities;
swissRailRaptorAccessibilityContributionCalculator.stopsPerAggregatedOpportunity = this.stopsPerAggregatedOpportunity;
diff --git a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/TravelTimeBasedTravelDisutility.java b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/TravelTimeBasedTravelDisutility.java
index 34ee8375753..6a70a5911fa 100644
--- a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/TravelTimeBasedTravelDisutility.java
+++ b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/TravelTimeBasedTravelDisutility.java
@@ -18,30 +18,30 @@
* *********************************************************************** */
/**
- *
+ *
*/
package org.matsim.contrib.accessibility;
import org.matsim.api.core.v01.TransportMode;
import org.matsim.api.core.v01.network.Link;
import org.matsim.api.core.v01.population.Person;
-import org.matsim.core.config.groups.PlanCalcScoreConfigGroup;
+import org.matsim.core.config.groups.ScoringConfigGroup;
import org.matsim.core.router.util.TravelDisutility;
import org.matsim.core.router.util.TravelTime;
import org.matsim.vehicles.Vehicle;
/**
* A simple cost calculator which only respects time to calculate generalized costs
- * This is based on org.matsim.core.router.costcalculators.TravelTimeAndDistanceBasedTravelDisutility
+ * This is based on org.matsim.core.router.costcalculators.TravelTimeAndDistanceBasedTravelDisutility
*
* @author mrieser, thomas
*/
class TravelTimeBasedTravelDisutility implements TravelDisutility{
-
+
protected final TravelTime timeCalculator;
private final double marginalCostOfTime;
- public TravelTimeBasedTravelDisutility(final TravelTime timeCalculator, PlanCalcScoreConfigGroup cnScoringGroup) {
+ public TravelTimeBasedTravelDisutility(final TravelTime timeCalculator, ScoringConfigGroup cnScoringGroup) {
this.timeCalculator = timeCalculator;
/* Usually, the travel-utility should be negative (it's a disutility)
* but the cost should be positive. Thus negate the utility.
diff --git a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/TripRouterAccessibilityContributionCalculator.java b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/TripRouterAccessibilityContributionCalculator.java
index 0f3dece8928..2f027d9863c 100644
--- a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/TripRouterAccessibilityContributionCalculator.java
+++ b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/TripRouterAccessibilityContributionCalculator.java
@@ -38,7 +38,7 @@
import org.matsim.contrib.accessibility.utils.Distances;
import org.matsim.contrib.accessibility.utils.NetworkUtil;
import org.matsim.core.config.groups.NetworkConfigGroup;
-import org.matsim.core.config.groups.PlanCalcScoreConfigGroup;
+import org.matsim.core.config.groups.ScoringConfigGroup;
import org.matsim.core.gbl.Gbl;
import org.matsim.core.network.NetworkUtils;
import org.matsim.core.router.TripRouter;
@@ -60,7 +60,7 @@ class TripRouterAccessibilityContributionCalculator implements AccessibilityCont
private static final Logger LOG = LogManager.getLogger( TripRouterAccessibilityContributionCalculator.class );
private TripRouter tripRouter ;
private String mode;
- private PlanCalcScoreConfigGroup planCalcScoreConfigGroup;
+ private ScoringConfigGroup scoringConfigGroup;
private NetworkConfigGroup networkConfigGroup;
private Scenario scenario;
@@ -79,18 +79,18 @@ class TripRouterAccessibilityContributionCalculator implements AccessibilityCont
private final TravelTime travelTime;
- public TripRouterAccessibilityContributionCalculator(String mode, TripRouter tripRouter, PlanCalcScoreConfigGroup planCalcScoreConfigGroup, Scenario scenario,
- TravelTime travelTime, TravelDisutilityFactory travelDisutilityFactory) {
+ public TripRouterAccessibilityContributionCalculator(String mode, TripRouter tripRouter, ScoringConfigGroup scoringConfigGroup, Scenario scenario,
+ TravelTime travelTime, TravelDisutilityFactory travelDisutilityFactory) {
LOG.warn("This is currently heavliy oriented on the need of car-based computatations. Revise beofre using for other modes!");
this.mode = mode;
this.tripRouter = tripRouter;
- this.planCalcScoreConfigGroup = planCalcScoreConfigGroup;
+ this.scoringConfigGroup = scoringConfigGroup;
this.networkConfigGroup = scenario.getConfig().network();
this.scenario = scenario;
- betaWalkTT = planCalcScoreConfigGroup.getModes().get(TransportMode.walk).getMarginalUtilityOfTraveling() - planCalcScoreConfigGroup.getPerforming_utils_hr();
+ betaWalkTT = scoringConfigGroup.getModes().get(TransportMode.walk).getMarginalUtilityOfTraveling() - scoringConfigGroup.getPerforming_utils_hr();
- this.walkSpeed_m_s = scenario.getConfig().plansCalcRoute().getTeleportedModeSpeeds().get(TransportMode.walk);
+ this.walkSpeed_m_s = scenario.getConfig().routing().getTeleportedModeSpeeds().get(TransportMode.walk);
this.travelTime = travelTime;
this.travelDisutilityFactory = travelDisutilityFactory;
@@ -152,21 +152,21 @@ public double computeContributionOfOpportunity(ActivityFacility origin,
// Note: The following computation where the end link length is added is only correct once the end link is removed from the route
// in the NetworkRoutingModule (route.setDistance(RouteUtils.calcDistance(route, 1.0, 0.0, this.network));)
- if (this.planCalcScoreConfigGroup.getModes().get(leg.getMode()).getMarginalUtilityOfDistance() != 0.) {
+ if (this.scoringConfigGroup.getModes().get(leg.getMode()).getMarginalUtilityOfDistance() != 0.) {
LOG.warn("A computation including a marginal utility of distance will only be correct if the route time/distance" +
"inconsistency in the NetworkRoutingModule is solved.");
}
- utility += (leg.getRoute().getDistance() + endLinkLength) * this.planCalcScoreConfigGroup.getModes().get(leg.getMode()).getMarginalUtilityOfDistance();
- utility += (leg.getRoute().getTravelTime().seconds() + estimatedEndLinkTT) * this.planCalcScoreConfigGroup.getModes().get(leg.getMode()).getMarginalUtilityOfTraveling() / 3600.;
- utility += -(leg.getRoute().getTravelTime().seconds() + estimatedEndLinkTT) * this.planCalcScoreConfigGroup.getPerforming_utils_hr() / 3600.;
+ utility += (leg.getRoute().getDistance() + endLinkLength) * this.scoringConfigGroup.getModes().get(leg.getMode()).getMarginalUtilityOfDistance();
+ utility += (leg.getRoute().getTravelTime().seconds() + estimatedEndLinkTT) * this.scoringConfigGroup.getModes().get(leg.getMode()).getMarginalUtilityOfTraveling() / 3600.;
+ utility += -(leg.getRoute().getTravelTime().seconds() + estimatedEndLinkTT) * this.scoringConfigGroup.getPerforming_utils_hr() / 3600.;
}
// Utility based on opportunities that are attached to destination node
double sumExpVjkWalk = destination.getSum();
// exp(beta * a) * exp(beta * b) = exp(beta * (a+b))
- double modeSpecificConstant = AccessibilityUtils.getModeSpecificConstantForAccessibilities(mode, planCalcScoreConfigGroup);
- expSum += Math.exp(this.planCalcScoreConfigGroup.getBrainExpBeta() * (utility + modeSpecificConstant + walkUtilityMeasuringPoint2Road + congestedCarUtilityRoad2Node)) * sumExpVjkWalk;
+ double modeSpecificConstant = AccessibilityUtils.getModeSpecificConstantForAccessibilities(mode, scoringConfigGroup);
+ expSum += Math.exp(this.scoringConfigGroup.getBrainExpBeta() * (utility + modeSpecificConstant + walkUtilityMeasuringPoint2Road + congestedCarUtilityRoad2Node)) * sumExpVjkWalk;
}
return expSum;
@@ -176,7 +176,7 @@ public double computeContributionOfOpportunity(ActivityFacility origin,
@Override
public TripRouterAccessibilityContributionCalculator duplicate() {
TripRouterAccessibilityContributionCalculator tripRouterAccessibilityContributionCalculator =
- new TripRouterAccessibilityContributionCalculator(this.mode, this.tripRouter, this.planCalcScoreConfigGroup,
+ new TripRouterAccessibilityContributionCalculator(this.mode, this.tripRouter, this.scoringConfigGroup,
this.scenario, this.travelTime, this.travelDisutilityFactory);
tripRouterAccessibilityContributionCalculator.subNetwork = this.subNetwork;
tripRouterAccessibilityContributionCalculator.aggregatedMeasurePoints = this.aggregatedMeasurePoints;
diff --git a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/run/RunAccessibilityExample.java b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/run/RunAccessibilityExample.java
index 53d94a2c1de..7db337954bd 100644
--- a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/run/RunAccessibilityExample.java
+++ b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/run/RunAccessibilityExample.java
@@ -46,7 +46,7 @@ public static void main(String[] args) {
throw new RuntimeException("No config.xml file provided. The config file needs to reference a network file and a facilities file.") ;
}
Config config = ConfigUtils.loadConfig(args[0]);
- config.controler().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists);
+ config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists);
AccessibilityConfigGroup accConfig = ConfigUtils.addOrGetModule(config, AccessibilityConfigGroup.class ) ;
accConfig.setComputingAccessibilityForMode(Modes4Accessibility.freespeed, true);
@@ -54,11 +54,11 @@ public static void main(String[] args) {
run(scenario); // The run method is extracted so that a test can operate on it.
}
-
+
public static void run(final Scenario scenario) {
List activityTypes = AccessibilityUtils.collectAllFacilityOptionTypes(scenario);
LOG.info("The following activity types were found: " + activityTypes);
-
+
Controler controler = new Controler(scenario);
for (final String actType : activityTypes) { // Add an overriding module for each activity type.
final AccessibilityModule module = new AccessibilityModule();
diff --git a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/utils/GeoJsonPolygonFeatureWriter.java b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/utils/GeoJsonPolygonFeatureWriter.java
index c022be98067..f0e3dc08db3 100644
--- a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/utils/GeoJsonPolygonFeatureWriter.java
+++ b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/utils/GeoJsonPolygonFeatureWriter.java
@@ -1,6 +1,6 @@
package org.matsim.contrib.accessibility.utils;
-import org.json.simple.JSONValue;
+import com.google.gson.Gson;
import org.matsim.api.core.v01.Coord;
import java.util.*;
@@ -34,7 +34,7 @@ public String asGeoJson() {
featureCollectionMap.put("features", featuresList);
featureCollectionMap.put("crs", parseCRS());
featureCollectionMap.put("bbox", boundingBox.getBoundingBox());
- return JSONValue.toJSONString(featureCollectionMap);
+ return new Gson().toJson(featureCollectionMap);
}
private List
-
- com.googlecode.json-simple
- json-simple
- 1.1.1
-
-
+
+ com.google.code.gson
+ gson
+ 2.10.1
+
+
org.apache.commons
commons-math3
org.apache.httpcomponents.client5
httpclient5
- 5.2.1
+ 5.3
diff --git a/contribs/analysis/src/main/java/org/matsim/contrib/analysis/christoph/ActivitiesAnalyzer.java b/contribs/analysis/src/main/java/org/matsim/contrib/analysis/christoph/ActivitiesAnalyzer.java
index 39c5b49040b..bb4239c27c9 100644
--- a/contribs/analysis/src/main/java/org/matsim/contrib/analysis/christoph/ActivitiesAnalyzer.java
+++ b/contribs/analysis/src/main/java/org/matsim/contrib/analysis/christoph/ActivitiesAnalyzer.java
@@ -39,11 +39,11 @@
import org.matsim.core.controler.listener.StartupListener;
import org.matsim.core.utils.charts.XYLineChart;
import org.matsim.core.utils.io.IOUtils;
-import org.matsim.core.utils.io.UncheckedIOException;
import java.awt.*;
import java.io.BufferedWriter;
import java.io.IOException;
+import java.io.UncheckedIOException;
import java.util.*;
import java.util.List;
@@ -54,21 +54,21 @@
*
* @author cdobler
*/
-public class ActivitiesAnalyzer implements ActivityStartEventHandler, ActivityEndEventHandler,
+public class ActivitiesAnalyzer implements ActivityStartEventHandler, ActivityEndEventHandler,
StartupListener, BeforeMobsimListener, IterationEndsListener {
public static String defaultActivitiesFileName = "activityCounts";
-
+
private final boolean autoConfig;
-
+
private double endTime = 30*3600;
-
+
private String activitiesFileName = defaultActivitiesFileName;
private final Set observedAgents;
private boolean createGraphs;
private final Map> activityCountData = new TreeMap>();
private final LinkedList overallCount = new LinkedList();
-
+
/**
* This is how most people will probably will use this class.
* It has to be created an registered as ControlerListener.
@@ -76,56 +76,56 @@ public class ActivitiesAnalyzer implements ActivityStartEventHandler, ActivityEn
* get paths to output files, ...).
*/
public ActivitiesAnalyzer() {
-
+
this.autoConfig = true;
this.createGraphs = true;
this.observedAgents = null;
-
+
reset(0);
}
-
+
public ActivitiesAnalyzer(String activitiesFileName, Set activityTypes, boolean createGraphs) {
this(activitiesFileName, activityTypes, null, createGraphs);
}
-
+
public ActivitiesAnalyzer(String activitiesFileName, Set activityTypes, Set observedAgents, boolean createGraphs) {
-
+
this.autoConfig = false;
-
+
this.activitiesFileName = activitiesFileName;
this.createGraphs = createGraphs;
-
+
// use all activity defined in the set
for (String activityType : activityTypes) {
this.activityCountData.put(activityType, new LinkedList());
}
-
+
if (observedAgents != null) {
// make a copy to prevent people changing the set over the iterations
- this.observedAgents = new HashSet(observedAgents);
+ this.observedAgents = new HashSet(observedAgents);
} else this.observedAgents = null;
-
+
reset(0);
}
-
+
public void setCreateGraphs(boolean createGraphs) {
this.createGraphs = createGraphs;
}
-
+
public void setEndTime(double endTime) {
this.endTime = endTime;
}
-
+
@Override
public void handleEvent(ActivityEndEvent event) {
-
+
if (observedAgents != null && !observedAgents.contains(event.getPersonId())) return;
-
+
LinkedList list = this.activityCountData.get(event.getActType());
-
+
// ignore not observed activity types
if (list == null) return;
-
+
changeCount(event.getTime(), list, -1);
changeCount(event.getTime(), this.overallCount, -1);
}
@@ -133,22 +133,22 @@ public void handleEvent(ActivityEndEvent event) {
@Override
public void handleEvent(ActivityStartEvent event) {
-
+
if (observedAgents != null && !observedAgents.contains(event.getPersonId())) return;
-
+
LinkedList list = this.activityCountData.get(event.getActType());
// ignore not observed activity types
if (list == null) return;
-
+
changeCount(event.getTime(), list, 1);
changeCount(event.getTime(), this.overallCount, 1);
}
-
+
private void changeCount(double time, LinkedList list, int delta) {
-
+
ActivityData activityData = list.getLast();
-
+
/*
* If there is already another entry for the same time step, re-use it.
* Otherwise create a new one.
@@ -159,7 +159,7 @@ private void changeCount(double time, LinkedList list, int delta)
list.add(new ActivityData(time, activityData.activityCount + delta));
}
}
-
+
@Override
public void reset(final int iter) {
for (List list : this.activityCountData.values()) {
@@ -169,40 +169,40 @@ public void reset(final int iter) {
this.overallCount.clear();
this.overallCount.add(new ActivityData(0.0, 0));
}
-
+
@Override
public void notifyStartup(StartupEvent event) {
-
+
MatsimServices controler = event.getServices();
-
+
if (autoConfig) {
// use all activity types defined in the config
- Set activityTypes = new TreeSet(event.getServices().getConfig().planCalcScore().getActivityTypes());
+ Set activityTypes = new TreeSet(event.getServices().getConfig().scoring().getActivityTypes());
for (String activityType : activityTypes) {
this.activityCountData.put(activityType, new LinkedList());
}
-
+
controler.getEvents().addHandler(this);
}
}
-
+
@Override
public void notifyBeforeMobsim(BeforeMobsimEvent event) {
-
+
ActivityData overallActivityData = this.overallCount.getLast();
for (Person person : event.getServices().getScenario().getPopulation().getPersons().values()) {
-
+
if (this.observedAgents != null && !this.observedAgents.contains(person.getId())) continue;
-
+
Plan plan = person.getSelectedPlan();
Activity firstActivity = (Activity) plan.getPlanElements().get(0);
LinkedList list = activityCountData.get(firstActivity.getType());
-
+
// ignore not observed activity types
if (list == null) continue;
-
+
ActivityData activityData = list.getLast();
activityData.activityCount += 1;
overallActivityData.activityCount += 1;
@@ -211,19 +211,19 @@ public void notifyBeforeMobsim(BeforeMobsimEvent event) {
@Override
public void notifyIterationEnds(IterationEndsEvent event) {
-
+
OutputDirectoryHierarchy outputDirectoryHierarchy = event.getServices().getControlerIO();
-
+
try {
for (String activityType : this.activityCountData.keySet()) {
String fileName = outputDirectoryHierarchy.getIterationFilename(event.getIteration(), this.activitiesFileName + "_" + activityType + ".txt");
BufferedWriter activitiesWriter = IOUtils.getBufferedWriter(fileName);
-
+
activitiesWriter.write("TIME");
activitiesWriter.write("\t");
activitiesWriter.write(activityType.toUpperCase());
activitiesWriter.write("\n");
-
+
List list = this.activityCountData.get(activityType);
for (ActivityData activityData : list) {
activitiesWriter.write(String.valueOf(activityData.time));
@@ -231,18 +231,18 @@ public void notifyIterationEnds(IterationEndsEvent event) {
activitiesWriter.write(String.valueOf(activityData.activityCount));
activitiesWriter.write("\n");
}
-
+
activitiesWriter.flush();
activitiesWriter.close();
}
} catch (IOException e) {
throw new UncheckedIOException(e);
}
-
+
if (this.createGraphs) {
// create chart when data of more than one iteration is available.
XYLineChart chart;
-
+
/*
* number of performed activities
*/
@@ -250,7 +250,7 @@ public void notifyIterationEnds(IterationEndsEvent event) {
for (String activityType : this.activityCountData.keySet()) {
List list = this.activityCountData.get(activityType);
int length = list.size();
-
+
double[] times = new double[length * 2 - 1];
double[] counts = new double[length * 2 - 1];
Iterator iter = list.iterator();
@@ -287,13 +287,13 @@ public void notifyIterationEnds(IterationEndsEvent event) {
i += 2;
}
chart.addSeries("overall", times, counts);
-
+
NumberAxis domainAxis = (NumberAxis) chart.getChart().getXYPlot().getDomainAxis();
domainAxis.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 11));
domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
domainAxis.setAutoRange(false);
domainAxis.setRange(0, endTime / 3600.0);
-
+
chart.addMatsimLogo();
String fileName = outputDirectoryHierarchy.getIterationFilename(event.getIteration(), this.activitiesFileName + ".png");
chart.saveAsPng(fileName, 800, 600);
@@ -301,7 +301,7 @@ public void notifyIterationEnds(IterationEndsEvent event) {
}
private static class ActivityData {
-
+
public final double time;
public int activityCount;
@@ -311,4 +311,4 @@ public ActivityData(double time, int activityCount) {
}
}
-}
\ No newline at end of file
+}
diff --git a/contribs/analysis/src/main/java/org/matsim/contrib/analysis/christoph/TripsAnalyzer.java b/contribs/analysis/src/main/java/org/matsim/contrib/analysis/christoph/TripsAnalyzer.java
index e5ad1a32205..390adb131b9 100644
--- a/contribs/analysis/src/main/java/org/matsim/contrib/analysis/christoph/TripsAnalyzer.java
+++ b/contribs/analysis/src/main/java/org/matsim/contrib/analysis/christoph/TripsAnalyzer.java
@@ -22,6 +22,7 @@
import java.io.BufferedWriter;
import java.io.IOException;
+import java.io.UncheckedIOException;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
@@ -45,7 +46,6 @@
import org.matsim.core.controler.listener.StartupListener;
import org.matsim.core.utils.charts.XYLineChart;
import org.matsim.core.utils.io.IOUtils;
-import org.matsim.core.utils.io.UncheckedIOException;
/**
* Calculates:
@@ -53,7 +53,7 @@
* - average leg travel time over all modes
* - number of trips per mode
* - number of trips over all modes
- *
+ *
* @author cdobler
*/
public class TripsAnalyzer implements PersonDepartureEventHandler, PersonArrivalEventHandler,
@@ -63,23 +63,23 @@ public class TripsAnalyzer implements PersonDepartureEventHandler, PersonArrival
public static String defaultDurationsFileName = "tripDurations";
private final boolean autoConfig;
-
+
private final Set sortedModes = new TreeSet();
private final Set observedAgents;
private final Map departureTimes = new HashMap();
private final Map> legTravelTimes = new HashMap>();
-
+
private String tripsFileName;
private String durationsFileName;
private boolean createGraphs;
-
+
private BufferedWriter tripsWriter;
private BufferedWriter durationWriter;
-
+
private double[][] tripsHistory;
private double[][] durationHistory;
private int minIteration;
-
+
/**
* This is how most people will probably will use this class.
* It has to be created an registered as ControlerListener.
@@ -87,47 +87,47 @@ public class TripsAnalyzer implements PersonDepartureEventHandler, PersonArrival
* get paths to output files, ...).
*/
public TripsAnalyzer() {
-
+
this.autoConfig = true;
this.createGraphs = true;
-
+
// modes which are analyzed by default
this.sortedModes.add(TransportMode.bike);
this.sortedModes.add(TransportMode.car);
this.sortedModes.add(TransportMode.pt);
this.sortedModes.add(TransportMode.ride);
this.sortedModes.add(TransportMode.walk);
-
+
this.observedAgents = null;
}
-
+
public TripsAnalyzer(String tripsFileName, String durationsFileName, Set modes, boolean createGraphs) {
this(tripsFileName, durationsFileName, modes, null, createGraphs);
}
-
+
public TripsAnalyzer(String tripsFileName, String durationsFileName, Set modes, Set observedAgents, boolean createGraphs) {
this.autoConfig = false;
-
+
this.tripsFileName = tripsFileName;
this.durationsFileName = durationsFileName;
this.sortedModes.addAll(modes);
if (observedAgents != null) {
// make a copy to prevent people changing the set over the iterations
- this.observedAgents = new HashSet(observedAgents);
+ this.observedAgents = new HashSet(observedAgents);
} else this.observedAgents = null;
this.createGraphs = createGraphs;
}
-
+
public void setCreateGraphs(boolean createGraphs) {
this.createGraphs = createGraphs;
}
-
+
public Set getModes() {
return this.sortedModes;
}
-
+
@Override
public void reset(int iteration) {
for(List modeTravelTime : legTravelTimes.values()) {
@@ -137,12 +137,12 @@ public void reset(int iteration) {
@Override
public void handleEvent(PersonArrivalEvent event) {
-
+
if (observedAgents != null && !observedAgents.contains(event.getPersonId())) return;
-
+
Double departureTime = departureTimes.remove(event.getPersonId());
if (departureTime == null) throw new RuntimeException("No departure time for agent " + event.getPersonId() + " was found!");
-
+
double travelTime = event.getTime() - departureTime;
String mode = event.getLegMode();
List modeTravelTimes = legTravelTimes.get(mode);
@@ -159,16 +159,16 @@ public void handleEvent(PersonDepartureEvent event) {
public void notifyStartup(final StartupEvent event) {
MatsimServices controler = event.getServices();
- this.minIteration = controler.getConfig().controler().getFirstIteration();
- int maxIter = controler.getConfig().controler().getLastIteration();
+ this.minIteration = controler.getConfig().controller().getFirstIteration();
+ int maxIter = controler.getConfig().controller().getLastIteration();
int iterations = maxIter - this.minIteration;
this.tripsHistory = new double[this.sortedModes.size() + 1][iterations + 1];
- this.durationHistory = new double[this.sortedModes.size() + 1][iterations + 1];
-
+ this.durationHistory = new double[this.sortedModes.size() + 1][iterations + 1];
+
if (autoConfig) {
this.tripsFileName = event.getServices().getControlerIO().getOutputFilename(defaultTripsFileName);
this.durationsFileName = event.getServices().getControlerIO().getOutputFilename(defaultDurationsFileName);
-
+
controler.getEvents().addHandler(this);
}
@@ -183,7 +183,7 @@ public void notifyStartup(final StartupEvent event) {
this.tripsWriter.write(mode.toUpperCase());
this.durationWriter.write("\t");
this.durationWriter.write(mode.toUpperCase());
-
+
this.legTravelTimes.put(mode, new LinkedList());
}
this.tripsWriter.write("\t");
@@ -192,12 +192,12 @@ public void notifyStartup(final StartupEvent event) {
this.durationWriter.write("\t");
this.durationWriter.write("OVERALL");
this.durationWriter.write("\n");
-
+
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
-
+
@Override
public void notifyIterationEnds(IterationEndsEvent event) {
try {
@@ -205,7 +205,7 @@ public void notifyIterationEnds(IterationEndsEvent event) {
this.tripsWriter.write(String.valueOf(iteration));
this.durationWriter.write(String.valueOf(iteration));
int index = iteration - this.minIteration;
-
+
int i = 0;
int overallTrips = 0;
double overallTravelTime = 0.0;
@@ -213,7 +213,7 @@ public void notifyIterationEnds(IterationEndsEvent event) {
List modeTravelTimes = legTravelTimes.get(mode);
double sumTravelTimes = 0.0;
for (double travelTime : modeTravelTimes) sumTravelTimes += travelTime;
-
+
int modeTrips = modeTravelTimes.size();
overallTrips += modeTrips;
overallTravelTime += sumTravelTimes;
@@ -221,19 +221,19 @@ public void notifyIterationEnds(IterationEndsEvent event) {
double averageTravelTime = sumTravelTimes / modeTrips;
this.tripsHistory[i][index] = modeTrips;
this.durationHistory[i][index] = averageTravelTime;
-
+
this.tripsWriter.write("\t");
this.tripsWriter.write(String.valueOf(modeTrips));
this.durationWriter.write("\t");
this.durationWriter.write(String.valueOf(averageTravelTime));
-
+
i++;
}
-
+
double averageTravelTime = overallTravelTime / overallTrips;
this.tripsHistory[sortedModes.size()][index] = overallTrips;
this.durationHistory[sortedModes.size()][index] = averageTravelTime;
-
+
this.tripsWriter.write("\t");
this.tripsWriter.write(String.valueOf(overallTrips));
this.tripsWriter.write("\n");
@@ -250,26 +250,26 @@ public void notifyIterationEnds(IterationEndsEvent event) {
} catch (IOException e) {
throw new RuntimeException(e);
}
-
+
if (this.createGraphs && event.getIteration() != this.minIteration) {
int index = event.getIteration() - this.minIteration;
// create chart when data of more than one iteration is available.
XYLineChart chart;
-
+
double[] iterations = new double[index + 1];
for (int i = 0; i <= index; i++) {
iterations[i] = i + this.minIteration;
}
double[] values = new double[index + 1];
-
+
int i;
-
+
/*
* average leg duration
*/
chart = new XYLineChart("Average Leg Travel Times Statistics", "iteration", "time");
-
+
i = 0;
for (String mode : sortedModes) {
System.arraycopy(this.durationHistory[i], 0, values, 0, index + 1);
@@ -278,15 +278,15 @@ public void notifyIterationEnds(IterationEndsEvent event) {
}
System.arraycopy(this.durationHistory[i], 0, values, 0, index + 1);
chart.addSeries("overall", iterations, values);
-
+
chart.addMatsimLogo();
chart.saveAsPng(this.durationsFileName + ".png", 800, 600);
-
+
/*
* number of trips
*/
chart = new XYLineChart("Number of Trips per Mode Statistics", "iteration", "number of trips");
-
+
i = 0;
for (String mode : sortedModes) {
System.arraycopy(this.tripsHistory[i], 0, values, 0, index + 1);
@@ -295,7 +295,7 @@ public void notifyIterationEnds(IterationEndsEvent event) {
}
System.arraycopy(this.tripsHistory[i], 0, values, 0, index + 1);
chart.addSeries("overall", iterations, values);
-
+
chart.addMatsimLogo();
chart.saveAsPng(this.tripsFileName + ".png", 800, 600);
}
@@ -306,7 +306,7 @@ public void notifyShutdown(ShutdownEvent event) {
try {
if (this.tripsWriter != null) {
this.tripsWriter.flush();
- this.tripsWriter.close();
+ this.tripsWriter.close();
}
if (this.durationWriter != null) {
this.durationWriter.flush();
diff --git a/contribs/analysis/src/main/java/org/matsim/contrib/analysis/kai/KNAnalysisEventsHandler.java b/contribs/analysis/src/main/java/org/matsim/contrib/analysis/kai/KNAnalysisEventsHandler.java
index 3bde897e73c..ad1e9cfe938 100644
--- a/contribs/analysis/src/main/java/org/matsim/contrib/analysis/kai/KNAnalysisEventsHandler.java
+++ b/contribs/analysis/src/main/java/org/matsim/contrib/analysis/kai/KNAnalysisEventsHandler.java
@@ -43,13 +43,13 @@
import org.matsim.core.router.TripStructureUtils.Trip;
import org.matsim.core.utils.geometry.CoordUtils;
import org.matsim.core.utils.io.IOUtils;
-import org.matsim.core.utils.io.UncheckedIOException;
import org.matsim.utils.objectattributes.ObjectAttributes;
import org.matsim.utils.objectattributes.ObjectAttributesXmlWriter;
import org.matsim.vehicles.Vehicle;
import java.io.BufferedWriter;
import java.io.IOException;
+import java.io.UncheckedIOException;
import java.util.*;
import java.util.Map.Entry;
@@ -100,7 +100,7 @@ enum StatType {
private Vehicle2DriverEventHandler delegate = new Vehicle2DriverEventHandler() ;
- // general trip counter. Would, in theory, not necessary to do this per StatType, but I find it too brittle
+ // general trip counter. Would, in theory, not necessary to do this per StatType, but I find it too brittle
// to avoid under- or over-counting with respect to loops.
// private final Map legCount = new TreeMap() ;
diff --git a/contribs/analysis/src/main/java/org/matsim/contrib/analysis/kai/RunKNEventsAnalyzer.java b/contribs/analysis/src/main/java/org/matsim/contrib/analysis/kai/RunKNEventsAnalyzer.java
index 205cf58ba3b..462943c36f4 100644
--- a/contribs/analysis/src/main/java/org/matsim/contrib/analysis/kai/RunKNEventsAnalyzer.java
+++ b/contribs/analysis/src/main/java/org/matsim/contrib/analysis/kai/RunKNEventsAnalyzer.java
@@ -37,70 +37,70 @@
public class RunKNEventsAnalyzer {
public static void main(String[] args) {
-
+
if ( args.length < 3 ) {
System.out.println("Usage: cmd eventsFile popFile netFile [popAttrFile] [tollFile] [futureTollFile]. Aborting ..." ) ;
System.exit(-1);
}
-
+
String eventsFilename = args[0] ;
String populationFilename = args[1] ;
String networkFilename = args[2] ;
-
+
String popAttrFilename = null ;
if ( args.length > 3 && args[3]!=null ) {
popAttrFilename = args[3] ;
}
-
+
String tollFilename = null ;
if ( args.length > 4 && args[4]!=null ) {
tollFilename = args[4] ;
}
-
+
String otherLinksFilename = null ;
if ( args.length > 5 && args[5]!=null ) {
otherLinksFilename = args[5] ;
}
-
+
// ===
Config config = ConfigUtils.createConfig() ;
-
+
String[] modes ={"car","commercial"};
config.qsim().setMainModes( Arrays.asList(modes) );
- config.plansCalcRoute().setNetworkModes(Arrays.asList(modes));
-
+ config.routing().setNetworkModes(Arrays.asList(modes));
+
config.network().setInputFile( networkFilename );
config.plans().setInputFile( populationFilename );
config.plans().setInputPersonAttributeFile( popAttrFilename );
ConfigUtils.addOrGetModule(config, RoadPricingConfigGroup.GROUP_NAME, RoadPricingConfigGroup.class).setTollLinksFile(tollFilename);
// ===
-
+
Scenario scenario = ScenarioUtils.loadScenario(config) ;
// ((ScenarioImpl)scenario).createVehicleContainer() ;
// GautengControler_subpopulations.createVehiclePerPerson(scenario);
-
+
// ===
-
+
EventsManager events = new EventsManagerImpl() ;
-
+
Vehicle2DriverEventHandler vehicle2Driver = new Vehicle2DriverEventHandler();
events.addHandler(vehicle2Driver);
-
+
final KNAnalysisEventsHandler.Builder builder = new KNAnalysisEventsHandler.Builder(scenario) ;
builder.setOtherTollLinkFile( otherLinksFilename );
final KNAnalysisEventsHandler calcLegTimes = builder.build();
-
+
events.addHandler( calcLegTimes );
-
+
new MatsimEventsReader(events).readFile(eventsFilename) ;
-
-// String myDate = date.getYear() + "-" + date.getMonthOfYear() + "-" + date.getDayOfMonth() + "-" +
+
+// String myDate = date.getYear() + "-" + date.getMonthOfYear() + "-" + date.getDayOfMonth() + "-" +
// date.getHourOfDay() + "h" + minute ;
String myDate = "" ;
-
+
calcLegTimes.writeStats(myDate + "_stats_");
}
diff --git a/contribs/analysis/src/main/java/org/matsim/contrib/analysis/vsp/traveltimedistance/GoogleMapRouteValidator.java b/contribs/analysis/src/main/java/org/matsim/contrib/analysis/vsp/traveltimedistance/GoogleMapRouteValidator.java
index b8aa76c34e1..7d35886428d 100644
--- a/contribs/analysis/src/main/java/org/matsim/contrib/analysis/vsp/traveltimedistance/GoogleMapRouteValidator.java
+++ b/contribs/analysis/src/main/java/org/matsim/contrib/analysis/vsp/traveltimedistance/GoogleMapRouteValidator.java
@@ -1,11 +1,11 @@
package org.matsim.contrib.analysis.vsp.traveltimedistance;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParser;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
-import org.json.simple.JSONArray;
-import org.json.simple.JSONObject;
-import org.json.simple.parser.JSONParser;
-import org.json.simple.parser.ParseException;
import org.matsim.api.core.v01.Coord;
import org.matsim.core.utils.collections.Tuple;
import org.matsim.core.utils.geometry.CoordinateTransformation;
@@ -20,6 +20,7 @@
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.Locale;
+import java.util.Optional;
public class GoogleMapRouteValidator implements TravelTimeDistanceValidator {
private static final Logger log = LogManager.getLogger(GoogleMapRouteValidator.class);
@@ -51,9 +52,6 @@ public Tuple getTravelTime(NetworkTrip trip) {
@Override
public Tuple getTravelTime(Coord fromCoord, Coord toCoord, double departureTime, String tripId) {
- long travelTime = 0;
- long distance = 0;
-
double adjustedDepartureTime = calculateGoogleDepartureTime(departureTime);
Coord from = ct.transform(fromCoord);
Coord to = ct.transform(toCoord);
@@ -71,32 +69,46 @@ public Tuple getTravelTime(Coord fromCoord, Coord toCoord, doubl
"&origins=" + df.format(from.getY()) + "%2C" + df.format(from.getX()) +
"&key=" + apiAccessKey;
+ log.info(urlString);
+
+ Optional> result;
try {
- log.info(urlString);
URL url = new URL(urlString);
- try (BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()))) {
- JSONParser jp = new JSONParser();
- JSONObject jsonObject = (JSONObject) jp.parse(in);
- JSONArray rows = (JSONArray) jsonObject.get("rows");
- if (!rows.isEmpty()) {
- JSONArray elements = (JSONArray) ((JSONObject) rows.get(0)).get("elements");
- JSONObject results = (JSONObject) elements.get(0);
- if (results.containsKey("distance")) {
- JSONObject distanceResults = (JSONObject) results.get("distance");
- distance = (long) distanceResults.get("value");
- }
- if (results.containsKey("duration_in_traffic")) {
- JSONObject timeResults = (JSONObject) results.get("duration_in_traffic");
- travelTime = (long) timeResults.get("value");
- }
- }
- }
- } catch (IOException | ParseException e) {
+ BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
+ result = readFromJson(in);
+ } catch (IOException e) {
log.error("The contents on the URL cannot be read properly. Please check your API or check the contents on URL manually", e);
+ result = Optional.empty();
}
- return new Tuple<>((double) travelTime, (double) distance);
+ return result.orElse(new Tuple<>(0.0, 0.0));
}
+ Optional> readFromJson(BufferedReader reader) throws IOException {
+ JsonElement jsonElement = JsonParser.parseReader(reader);
+ if(!jsonElement.isJsonObject()){
+ return Optional.empty();
+ }
+ JsonObject jsonObject = jsonElement.getAsJsonObject();
+ JsonArray rows = jsonObject.getAsJsonArray("rows");
+
+ if (rows.isEmpty()) {
+ return Optional.empty();
+ }
+
+ JsonObject results = rows.get(0).getAsJsonObject().get("elements").getAsJsonArray().get(0).getAsJsonObject();
+
+ if (!results.has("distance") && !results.has("duration_in_traffic")) {
+ return Optional.empty();
+ }
+
+ JsonObject distanceResults = results.get("distance").getAsJsonObject();
+ double distance = distanceResults.get("value").getAsDouble();
+ JsonObject timeResults = results.get("duration_in_traffic").getAsJsonObject();
+ double travelTime = timeResults.get("value").getAsDouble();
+
+ return Optional.of(new Tuple<>(travelTime, distance));
+ }
+
private double calculateGoogleDepartureTime(double departureTime) {
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
LocalDate googleDate0 = LocalDate.parse("1970-01-01", dateTimeFormatter);
diff --git a/contribs/analysis/src/main/java/org/matsim/contrib/analysis/vsp/traveltimedistance/HereMapsRouteValidator.java b/contribs/analysis/src/main/java/org/matsim/contrib/analysis/vsp/traveltimedistance/HereMapsRouteValidator.java
index 9af9cff72c9..b437d7dffb8 100644
--- a/contribs/analysis/src/main/java/org/matsim/contrib/analysis/vsp/traveltimedistance/HereMapsRouteValidator.java
+++ b/contribs/analysis/src/main/java/org/matsim/contrib/analysis/vsp/traveltimedistance/HereMapsRouteValidator.java
@@ -28,13 +28,14 @@
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.util.Locale;
+import java.util.Optional;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParser;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
-import org.json.simple.JSONArray;
-import org.json.simple.JSONObject;
-import org.json.simple.parser.JSONParser;
-import org.json.simple.parser.ParseException;
import org.matsim.api.core.v01.Coord;
import org.matsim.core.utils.collections.Tuple;
import org.matsim.core.utils.geometry.CoordinateTransformation;
@@ -91,9 +92,6 @@ public Tuple getTravelTime(NetworkTrip trip) {
@Override
public Tuple getTravelTime(Coord fromCoord, Coord toCoord, double departureTime, String tripId) {
- long travelTime = 0;
- long distance = 0;
-
Coord from = transformation.transform(fromCoord);
Coord to = transformation.transform(toCoord);
@@ -110,36 +108,48 @@ public Tuple getTravelTime(Coord fromCoord, Coord toCoord, doubl
log.info(urlString);
+ Optional> result;
try {
URL url = new URL(urlString);
BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
- JSONParser jp = new JSONParser();
- JSONObject jsonObject = (JSONObject) jp.parse(in);
- JSONArray routes = (JSONArray) jsonObject.get("routes");
-
- if (!routes.isEmpty()) {
- JSONObject route = (JSONObject) routes.get(0);
- JSONArray sections = (JSONArray) route.get("sections");
- JSONObject section = (JSONObject) sections.get(0);
- JSONObject summary = (JSONObject) section.get("summary");
- travelTime = (long) summary.get("duration");
- distance = (long) summary.get("length");
- if (writeDetailedFiles) {
- String filename = outputPath + "/" + tripId + ".json.gz";
- BufferedWriter bw = IOUtils.getBufferedWriter(filename);
- bw.write(jsonObject.toString());
- bw.flush();
- bw.close();
- }
- }
-
- in.close();
+ result = readFromJson(in, tripId);
} catch (MalformedURLException e) {
log.error("URL is not working. Please check your API key", e);
- } catch (IOException | ParseException e) {
+ result = Optional.empty();
+ } catch (IOException e) {
log.error("Cannot read the content on the URL properly. Please manually check the URL", e);
+ result = Optional.empty();
}
- return new Tuple((double) travelTime, (double) distance);
+ return result.orElse(new Tuple<>(0.0, 0.0));
}
+ Optional> readFromJson(BufferedReader reader, String tripId) throws IOException {
+ JsonElement jsonElement = JsonParser.parseReader(reader);
+ if(!jsonElement.isJsonObject()){
+ return Optional.empty();
+ }
+ JsonObject jsonObject = jsonElement.getAsJsonObject();
+ JsonArray routes = jsonObject.getAsJsonArray("routes");
+
+ if(routes.isEmpty()){
+ return Optional.empty();
+ }
+
+ JsonObject route = routes.get(0).getAsJsonObject();
+ JsonArray sections = route.get("sections").getAsJsonArray();
+ JsonObject section = sections.get(0).getAsJsonObject();
+ JsonObject summary = section.get("summary").getAsJsonObject();
+ double travelTime = summary.get("duration").getAsDouble();
+ double distance = summary.get("length").getAsDouble();
+ if (writeDetailedFiles) {
+ String filename = outputPath + "/" + tripId + ".json.gz";
+ BufferedWriter bw = IOUtils.getBufferedWriter(filename);
+ bw.write(jsonObject.toString());
+ bw.flush();
+ bw.close();
+ }
+ reader.close();
+ return Optional.of(new Tuple<>(travelTime, distance));
+ }
+
}
diff --git a/contribs/analysis/src/main/java/org/matsim/contrib/travelsummary/events2traveldiaries/RunEventsToTravelDiaries.java b/contribs/analysis/src/main/java/org/matsim/contrib/travelsummary/events2traveldiaries/RunEventsToTravelDiaries.java
index 403f4d0bdb5..436cb4c800f 100644
--- a/contribs/analysis/src/main/java/org/matsim/contrib/travelsummary/events2traveldiaries/RunEventsToTravelDiaries.java
+++ b/contribs/analysis/src/main/java/org/matsim/contrib/travelsummary/events2traveldiaries/RunEventsToTravelDiaries.java
@@ -51,7 +51,7 @@ public static void main(String[] args) {
printHelp();
try {
config = ConfigUtils.loadConfig(args[0]);
- outputDirectory = config.controler().getOutputDirectory();
+ outputDirectory = config.controller().getOutputDirectory();
eventsFileName = args[1];
diff --git a/contribs/analysis/src/test/java/org/matsim/contrib/analysis/filters/population/PersonIntersectAreaFilterTest.java b/contribs/analysis/src/test/java/org/matsim/contrib/analysis/filters/population/PersonIntersectAreaFilterTest.java
index 2c856118e92..aed33926f02 100644
--- a/contribs/analysis/src/test/java/org/matsim/contrib/analysis/filters/population/PersonIntersectAreaFilterTest.java
+++ b/contribs/analysis/src/test/java/org/matsim/contrib/analysis/filters/population/PersonIntersectAreaFilterTest.java
@@ -20,13 +20,13 @@
package org.matsim.contrib.analysis.filters.population;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.HashMap;
-import org.junit.Rule;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
import org.matsim.api.core.v01.Coord;
import org.matsim.api.core.v01.Id;
import org.matsim.api.core.v01.TransportMode;
@@ -51,11 +51,12 @@
*/
public class PersonIntersectAreaFilterTest {
- @Rule
- public MatsimTestUtils utils = new MatsimTestUtils();
+ @RegisterExtension
+ private MatsimTestUtils utils = new MatsimTestUtils();
- @Test public void testFilter() throws Exception {
+ @Test
+ void testFilter() throws Exception {
/* create a simple network where agents can drive from the lower left
* to the upper right */
Network network = NetworkUtils.createNetwork();
@@ -113,25 +114,25 @@ public class PersonIntersectAreaFilterTest {
aoi.clear();
aoi.put(link2.getId(), link2);
filter = new PersonIntersectAreaFilter(null, aoi, network);
- assertTrue("test route through aoi", filter.judge(person));
+ assertTrue(filter.judge(person), "test route through aoi");
// test departure link
aoi.clear();
aoi.put(link0.getId(), link0);
filter = new PersonIntersectAreaFilter(null, aoi, network);
- assertTrue("test departure link as aoi", filter.judge(person));
+ assertTrue(filter.judge(person), "test departure link as aoi");
// test arrival link
aoi.clear();
aoi.put(link5.getId(), link5);
filter = new PersonIntersectAreaFilter(null, aoi, network);
- assertTrue("test arrival link as aoi", filter.judge(person));
+ assertTrue(filter.judge(person), "test arrival link as aoi");
// test route outside aoi
aoi.clear();
aoi.put(link4.getId(), link4);
filter = new PersonIntersectAreaFilter(null, aoi, network);
- assertFalse("test route outside aoi", filter.judge(person));
+ assertFalse(filter.judge(person), "test route outside aoi");
// prepare bee-line tests
leg.setMode(TransportMode.walk);
@@ -141,21 +142,21 @@ public class PersonIntersectAreaFilterTest {
aoi.clear();
aoi.put(link2.getId(), link2);
filter = new PersonIntersectAreaFilter(null, aoi, network);
- assertFalse("test bee-line without alternative aoi", filter.judge(person));
+ assertFalse(filter.judge(person), "test bee-line without alternative aoi");
// test bee-line with too small alternative aoi
aoi.clear();
aoi.put(link2.getId(), link2);
filter = new PersonIntersectAreaFilter(null, aoi, network);
filter.setAlternativeAOI(new Coord((double) 100, (double) 0), 20.0);
- assertFalse("test bee-line with too small alternative aoi", filter.judge(person));
+ assertFalse(filter.judge(person), "test bee-line with too small alternative aoi");
// test bee-line with big enough alternative aoi
aoi.clear();
aoi.put(link2.getId(), link2);
filter = new PersonIntersectAreaFilter(null, aoi, network);
filter.setAlternativeAOI(new Coord((double) 100, (double) 0), 80.0);
- assertTrue("test bee-line with big enough alternative aoi", filter.judge(person));
+ assertTrue(filter.judge(person), "test bee-line with big enough alternative aoi");
}
diff --git a/contribs/analysis/src/test/java/org/matsim/contrib/analysis/filters/population/RouteLinkFilterTest.java b/contribs/analysis/src/test/java/org/matsim/contrib/analysis/filters/population/RouteLinkFilterTest.java
index 01f4b00a334..c434dca8a24 100644
--- a/contribs/analysis/src/test/java/org/matsim/contrib/analysis/filters/population/RouteLinkFilterTest.java
+++ b/contribs/analysis/src/test/java/org/matsim/contrib/analysis/filters/population/RouteLinkFilterTest.java
@@ -20,11 +20,11 @@
package org.matsim.contrib.analysis.filters.population;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-import org.junit.Rule;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
import org.matsim.api.core.v01.Id;
import org.matsim.api.core.v01.Scenario;
import org.matsim.api.core.v01.TransportMode;
@@ -50,11 +50,12 @@
public class RouteLinkFilterTest {
- @Rule
- public MatsimTestUtils utils = new MatsimTestUtils();
+ @RegisterExtension
+ private MatsimTestUtils utils = new MatsimTestUtils();
- @Test public void testRouteLinkFilter() {
+ @Test
+ void testRouteLinkFilter() {
// used to set the default dtd-location
utils.loadConfig((String)null);
Population population = getTestPopulation();
diff --git a/contribs/analysis/src/test/java/org/matsim/contrib/analysis/kai/KNAnalysisEventsHandlerTest.java b/contribs/analysis/src/test/java/org/matsim/contrib/analysis/kai/KNAnalysisEventsHandlerTest.java
index 8d6e64b29f9..67352fcabbf 100644
--- a/contribs/analysis/src/test/java/org/matsim/contrib/analysis/kai/KNAnalysisEventsHandlerTest.java
+++ b/contribs/analysis/src/test/java/org/matsim/contrib/analysis/kai/KNAnalysisEventsHandlerTest.java
@@ -22,12 +22,12 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Rule;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
import org.matsim.api.core.v01.Coord;
import org.matsim.api.core.v01.Id;
import org.matsim.api.core.v01.Scenario;
@@ -55,10 +55,10 @@
public class KNAnalysisEventsHandlerTest {
- @Rule
- public MatsimTestUtils utils = new MatsimTestUtils();
+ @RegisterExtension
+ public MatsimTestUtils utils = new MatsimTestUtils();
- // yy this test is probably not doing anything with respect to some of the newer statistics, such as money. kai, mar'14
+ // yy this test is probably not doing anything with respect to some of the newer statistics, such as money. kai, mar'14
public static final String BASE_FILE_NAME = "stats_";
public final Id DEFAULT_PERSON_ID = Id.create(123, Person.class);
@@ -68,7 +68,7 @@ public class KNAnalysisEventsHandlerTest {
private Population population = null ;
private Network network = null ;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
scenario = ScenarioUtils.createScenario(ConfigUtils.createConfig());
@@ -101,15 +101,15 @@ public void setUp() throws Exception {
this.network.addLink(link);
}
- @After
+ @AfterEach
public void tearDown() throws Exception {
this.population = null;
this.network = null;
}
- @Test
- @Ignore
- public void testNoEvents() {
+ @Test
+ @Disabled
+ void testNoEvents() {
KNAnalysisEventsHandler testee = new KNAnalysisEventsHandler(this.scenario);
@@ -121,10 +121,10 @@ public void testNoEvents() {
this.runTest(testee);
}
- @Test
- @Ignore
- public void testAveraging() {
- // yy this test is probably not doing anything with respect to some of the newer statistics, such as money. kai, mar'14
+ @Test
+ @Disabled
+ void testAveraging() {
+ // yy this test is probably not doing anything with respect to some of the newer statistics, such as money. kai, mar'14
KNAnalysisEventsHandler testee = new KNAnalysisEventsHandler(this.scenario);
@@ -172,7 +172,7 @@ protected void runTest(KNAnalysisEventsHandler calcLegTimes) {
LogManager.getLogger(this.getClass()).info( "comparing " + str );
final long expectedChecksum = CRCChecksum.getCRCFromFile(utils.getInputDirectory() + str);
final long actualChecksum = CRCChecksum.getCRCFromFile(utils.getOutputDirectory() + str);
- Assert.assertEquals("Output files differ.", expectedChecksum, actualChecksum);
+ Assertions.assertEquals(expectedChecksum, actualChecksum, "Output files differ.");
}
}
diff --git a/contribs/analysis/src/test/java/org/matsim/contrib/analysis/spatial/GridTest.java b/contribs/analysis/src/test/java/org/matsim/contrib/analysis/spatial/GridTest.java
index a3253515666..804de493d3a 100644
--- a/contribs/analysis/src/test/java/org/matsim/contrib/analysis/spatial/GridTest.java
+++ b/contribs/analysis/src/test/java/org/matsim/contrib/analysis/spatial/GridTest.java
@@ -1,17 +1,17 @@
package org.matsim.contrib.analysis.spatial;
-import static org.junit.Assert.assertEquals;
-
import java.util.Collection;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
import org.locationtech.jts.geom.Coordinate;
import org.locationtech.jts.geom.GeometryFactory;
public class GridTest {
- @Test
- public void initializeSquareGrid() {
+ @Test
+ void initializeSquareGrid() {
final String testValue = "Test-value";
Grid grid = new SquareGrid<>(2, () -> testValue, SpatialTestUtils.createRect(10, 10));
@@ -23,8 +23,8 @@ public void initializeSquareGrid() {
values.forEach(value -> assertEquals(testValue, value.getValue()));
}
- @Test
- public void initializeHexagonalGrid() {
+ @Test
+ void initializeHexagonalGrid() {
final String testValue = "test-value";
Grid grid = new HexagonalGrid<>(2, () -> testValue, SpatialTestUtils.createRect(10, 10));
@@ -38,8 +38,8 @@ public void initializeHexagonalGrid() {
values.forEach(value -> assertEquals(testValue, value.getValue()));
}
- @Test
- public void getArea_squareGrid() {
+ @Test
+ void getArea_squareGrid() {
final double horizontalDistance = 2;
final double expected = 2 * 2; // area of square is d^2
@@ -49,8 +49,8 @@ public void getArea_squareGrid() {
assertEquals(expected, grid.getCellArea(), 0.0001);
}
- @Test
- public void getArea_HexagonalGrid() {
+ @Test
+ void getArea_HexagonalGrid() {
// actually area of hexagon is r^2 * sqrt(3)/2
final double horizontalDistance = 2;
@@ -65,8 +65,8 @@ public void getArea_HexagonalGrid() {
assertEquals(expected5, grid5.getCellArea(), 0.0001);
}
- @Test
- public void getValue_withExactCoord() {
+ @Test
+ void getValue_withExactCoord() {
final String testValue = "initialValue";
final Coordinate expectedCoordinate = new Coordinate(2, 1+Math.sqrt(3));
@@ -77,8 +77,8 @@ public void getValue_withExactCoord() {
assertEquals(expectedCoordinate, result.getCoordinate());
}
- @Test
- public void getValue_closeCoordinate() {
+ @Test
+ void getValue_closeCoordinate() {
final String testValue = "initialValue";
Grid grid = new HexagonalGrid<>(2, () -> testValue, SpatialTestUtils.createRect(10, 10));
@@ -89,8 +89,8 @@ public void getValue_closeCoordinate() {
assertEquals(new Coordinate(2, 1+Math.sqrt(3)), result.getCoordinate());
}
- @Test
- public void getValue_coordOutsideOfGrid() {
+ @Test
+ void getValue_coordOutsideOfGrid() {
final String testValue = "initialValue";
Grid grid = new HexagonalGrid<>(2, () -> testValue, SpatialTestUtils.createRect(10, 10));
@@ -100,8 +100,8 @@ public void getValue_coordOutsideOfGrid() {
assertEquals(new Coordinate(8, 1 + 5*Math.sqrt(3)), result.getCoordinate());
}
- @Test
- public void getValues() {
+ @Test
+ void getValues() {
final String testValue = "initialValue";
Grid grid = new HexagonalGrid<>(2, () -> testValue, SpatialTestUtils.createRect(10, 10));
diff --git a/contribs/analysis/src/test/java/org/matsim/contrib/analysis/spatial/SpatialInterpolationTest.java b/contribs/analysis/src/test/java/org/matsim/contrib/analysis/spatial/SpatialInterpolationTest.java
index 49e3f8e4a8a..1fe102d3534 100644
--- a/contribs/analysis/src/test/java/org/matsim/contrib/analysis/spatial/SpatialInterpolationTest.java
+++ b/contribs/analysis/src/test/java/org/matsim/contrib/analysis/spatial/SpatialInterpolationTest.java
@@ -1,15 +1,14 @@
package org.matsim.contrib.analysis.spatial;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.*;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.locationtech.jts.geom.Coordinate;
public class SpatialInterpolationTest {
- @Test
- public void calculateWeightFromLine() {
+ @Test
+ void calculateWeightFromLine() {
final Coordinate from = new Coordinate(1, 1);
final Coordinate to = new Coordinate(4, 5);
@@ -22,33 +21,37 @@ public void calculateWeightFromLine() {
assertEquals(0.0011109434390476694, weight, 0.001);
}
- @Test(expected = IllegalArgumentException.class)
- public void calculateWeightFromLine_invalidSmoothingRadius() {
+ @Test
+ void calculateWeightFromLine_invalidSmoothingRadius() {
+ assertThrows(IllegalArgumentException.class, () -> {
- final Coordinate from = new Coordinate(0, 1);
- final Coordinate to = new Coordinate(10, 1);
- final Coordinate cellCentroid = new Coordinate(5, 1);
- final double smoothingRadius = 0;
+ final Coordinate from = new Coordinate(0, 1);
+ final Coordinate to = new Coordinate(10, 1);
+ final Coordinate cellCentroid = new Coordinate(5, 1);
+ final double smoothingRadius = 0;
- double weight = SpatialInterpolation.calculateWeightFromLine(from, to, cellCentroid, smoothingRadius);
+ double weight = SpatialInterpolation.calculateWeightFromLine(from, to, cellCentroid, smoothingRadius);
- fail("smoothing radius <= 0 should cause exception");
- }
+ fail("smoothing radius <= 0 should cause exception");
+ });
+ }
- @Test(expected = IllegalArgumentException.class)
- public void calculateWeightFromPoint_invalidSmoothingRadius() {
+ @Test
+ void calculateWeightFromPoint_invalidSmoothingRadius() {
+ assertThrows(IllegalArgumentException.class, () -> {
- final Coordinate source = new Coordinate(10, 10);
- final Coordinate centroid = new Coordinate(10, 10);
- final double smoothingRadius = 0;
+ final Coordinate source = new Coordinate(10, 10);
+ final Coordinate centroid = new Coordinate(10, 10);
+ final double smoothingRadius = 0;
- double weight = SpatialInterpolation.calculateWeightFromPoint(source, centroid, smoothingRadius);
+ double weight = SpatialInterpolation.calculateWeightFromPoint(source, centroid, smoothingRadius);
- fail("smoothing radius <= 0 should cause exception");
- }
+ fail("smoothing radius <= 0 should cause exception");
+ });
+ }
- @Test
- public void calculateWeightFromPoint() {
+ @Test
+ void calculateWeightFromPoint() {
final Coordinate point = new Coordinate(5, 5);
final Coordinate cell = new Coordinate (9, 5);
diff --git a/contribs/analysis/src/test/java/org/matsim/contrib/analysis/time/TimeBinMapTest.java b/contribs/analysis/src/test/java/org/matsim/contrib/analysis/time/TimeBinMapTest.java
index a15b076f567..13e5e7f291c 100644
--- a/contribs/analysis/src/test/java/org/matsim/contrib/analysis/time/TimeBinMapTest.java
+++ b/contribs/analysis/src/test/java/org/matsim/contrib/analysis/time/TimeBinMapTest.java
@@ -1,15 +1,15 @@
package org.matsim.contrib.analysis.time;
-import org.junit.Test;
-
import java.util.Map;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
+
+import org.junit.jupiter.api.Test;
public class TimeBinMapTest {
- @Test
- public void getTimeBin() {
+ @Test
+ void getTimeBin() {
TimeBinMap