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 43420197e8e..1ed755c12b6 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 @@ -20,6 +20,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.geotools.api.feature.simple.SimpleFeature; import org.locationtech.jts.geom.Coordinate; import org.locationtech.jts.geom.Geometry; import org.locationtech.jts.geom.GeometryFactory; @@ -41,7 +42,6 @@ import org.matsim.core.utils.geometry.CoordUtils; import org.matsim.core.utils.gis.GeoFileReader; import org.matsim.facilities.*; -import org.opengis.feature.simple.SimpleFeature; import java.util.*; import java.util.concurrent.ConcurrentHashMap; diff --git a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/FeatureSHP.java b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/FeatureSHP.java index 9ff4d3711ed..2e5cee46039 100644 --- a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/FeatureSHP.java +++ b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/FeatureSHP.java @@ -24,11 +24,11 @@ import java.util.HashSet; import java.util.Set; -import org.geotools.data.DataStore; -import org.geotools.data.FileDataStoreFinder; +import org.geotools.api.data.DataStore; +import org.geotools.api.data.FileDataStoreFinder; +import org.geotools.api.data.SimpleFeatureSource; +import org.geotools.api.feature.simple.SimpleFeature; import org.geotools.data.simple.SimpleFeatureIterator; -import org.geotools.data.simple.SimpleFeatureSource; -import org.opengis.feature.simple.SimpleFeature; /** * Utility class for reading shape (.shp) files. diff --git a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/GridUtils.java b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/GridUtils.java index b8cfc04417f..6e5aa187364 100644 --- a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/GridUtils.java +++ b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/GridUtils.java @@ -20,7 +20,6 @@ import org.matsim.facilities.ActivityFacility; import org.matsim.facilities.FacilitiesUtils; import org.matsim.utils.gis.shp2matsim.ShpGeometryUtils; -import org.opengis.feature.simple.SimpleFeature; public final class GridUtils { // used from outside, e.g. in vsp playgrounds diff --git a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/VoronoiExample.java b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/VoronoiExample.java index 382e13b68f7..d1fe1df43d7 100644 --- a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/VoronoiExample.java +++ b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/VoronoiExample.java @@ -22,6 +22,7 @@ import java.util.Collection; import java.util.List; +import org.geotools.api.feature.simple.SimpleFeature; import org.locationtech.jts.geom.Coordinate; import org.locationtech.jts.geom.Geometry; import org.locationtech.jts.geom.GeometryFactory; @@ -29,7 +30,6 @@ import org.locationtech.jts.triangulate.VoronoiDiagramBuilder; import org.matsim.contrib.matrixbasedptrouter.utils.BoundingBox; import org.matsim.core.utils.gis.GeoFileWriter; -import org.opengis.feature.simple.SimpleFeature; /** * @author dziemke diff --git a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/VoronoiGeometryUtils.java b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/VoronoiGeometryUtils.java index 76e7273fd87..bcf0edc7b73 100644 --- a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/VoronoiGeometryUtils.java +++ b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/VoronoiGeometryUtils.java @@ -27,6 +27,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.geotools.api.feature.simple.SimpleFeature; +import org.geotools.api.feature.simple.SimpleFeatureType; import org.geotools.feature.simple.SimpleFeatureBuilder; import org.geotools.feature.simple.SimpleFeatureTypeBuilder; import org.locationtech.jts.geom.Coordinate; @@ -40,8 +42,6 @@ import org.matsim.core.utils.geometry.CoordUtils; import org.matsim.facilities.ActivityFacilities; import org.matsim.facilities.ActivityFacility; -import org.opengis.feature.simple.SimpleFeature; -import org.opengis.feature.simple.SimpleFeatureType; /** * @author dziemke diff --git a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/gis/CRSUtils.java b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/gis/CRSUtils.java index a7171739b6a..92f3d94c5b8 100644 --- a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/gis/CRSUtils.java +++ b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/gis/CRSUtils.java @@ -24,18 +24,18 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.geotools.api.metadata.Identifier; +import org.geotools.api.referencing.FactoryException; +import org.geotools.api.referencing.NoSuchAuthorityCodeException; +import org.geotools.api.referencing.crs.CRSAuthorityFactory; +import org.geotools.api.referencing.crs.CoordinateReferenceSystem; +import org.geotools.api.referencing.operation.MathTransform; +import org.geotools.api.referencing.operation.TransformException; import org.geotools.referencing.CRS; import org.locationtech.jts.geom.Coordinate; import org.locationtech.jts.geom.Geometry; import org.locationtech.jts.geom.GeometryFactory; import org.locationtech.jts.geom.Point; -import org.opengis.metadata.Identifier; -import org.opengis.referencing.FactoryException; -import org.opengis.referencing.NoSuchAuthorityCodeException; -import org.opengis.referencing.crs.CRSAuthorityFactory; -import org.opengis.referencing.crs.CoordinateReferenceSystem; -import org.opengis.referencing.operation.MathTransform; -import org.opengis.referencing.operation.TransformException; /** * Utility-class providing functionality related to coordinate reference @@ -94,7 +94,7 @@ public static int getSRID(CoordinateReferenceSystem crs) { /* * Randomly get one identifier. */ - Identifier identifier = (Identifier) (crs.getIdentifiers().iterator().next()); + Identifier identifier = crs.getIdentifiers().iterator().next(); if (identifier == null) { return 0; } else { @@ -118,7 +118,7 @@ public static MathTransform findTransform(Geometry source, Geometry target) { CoordinateReferenceSystem targetCRS = getCRS(target.getSRID()); try { - return CRS.findMathTransform(sourceCRS, targetCRS); + return CRS.findMathTransform(sourceCRS, targetCRS); } catch (FactoryException e) { e.printStackTrace(); return null; diff --git a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/gis/ZoneLayer.java b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/gis/ZoneLayer.java index c39948b714f..28bc2c41059 100644 --- a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/gis/ZoneLayer.java +++ b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/gis/ZoneLayer.java @@ -24,13 +24,13 @@ import java.util.List; import java.util.Set; +import org.geotools.api.referencing.FactoryException; +import org.geotools.api.referencing.crs.CoordinateReferenceSystem; +import org.geotools.api.referencing.operation.MathTransform; import org.geotools.referencing.CRS; import org.locationtech.jts.geom.Point; import org.locationtech.jts.index.SpatialIndex; import org.locationtech.jts.index.quadtree.Quadtree; -import org.opengis.referencing.FactoryException; -import org.opengis.referencing.crs.CoordinateReferenceSystem; -import org.opengis.referencing.operation.MathTransform; /** * Representation of a spatial index containing zones backed by a quadtree. diff --git a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/osm/CombinedOsmSink.java b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/osm/CombinedOsmSink.java index f7e39f4b588..7c5c1bcf2d2 100644 --- a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/osm/CombinedOsmSink.java +++ b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/osm/CombinedOsmSink.java @@ -22,6 +22,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.geotools.api.feature.simple.SimpleFeature; import org.locationtech.jts.geom.Coordinate; import org.locationtech.jts.geom.Geometry; import org.locationtech.jts.geom.GeometryFactory; @@ -41,7 +42,6 @@ import org.matsim.facilities.ActivityOption; import org.matsim.facilities.FacilitiesUtils; import org.matsim.utils.objectattributes.ObjectAttributes; -import org.opengis.feature.simple.SimpleFeature; import org.openstreetmap.osmosis.core.container.v0_6.BoundContainer; import org.openstreetmap.osmosis.core.container.v0_6.EntityContainer; import org.openstreetmap.osmosis.core.container.v0_6.EntityProcessor; @@ -89,7 +89,7 @@ class CombinedOsmSink implements Sink { private Map typeCount = new HashMap<>(); - private List landUseAreas = new ArrayList (); + private List landUseAreas = new ArrayList<>(); private int featureErrorCounter = 0; private int buildingErrorCounter = 0; diff --git a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/osm/LandUseBuildingSink.java b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/osm/LandUseBuildingSink.java index 0a5989ad5e8..3b55793e0d6 100644 --- a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/osm/LandUseBuildingSink.java +++ b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/osm/LandUseBuildingSink.java @@ -22,6 +22,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.geotools.api.feature.simple.SimpleFeature; import org.locationtech.jts.geom.Coordinate; import org.locationtech.jts.geom.Geometry; import org.locationtech.jts.geom.GeometryFactory; @@ -40,7 +41,6 @@ import org.matsim.facilities.ActivityOption; import org.matsim.facilities.FacilitiesUtils; import org.matsim.utils.objectattributes.ObjectAttributes; -import org.opengis.feature.simple.SimpleFeature; import org.openstreetmap.osmosis.core.container.v0_6.BoundContainer; import org.openstreetmap.osmosis.core.container.v0_6.EntityContainer; import org.openstreetmap.osmosis.core.container.v0_6.EntityProcessor; @@ -69,11 +69,11 @@ class LandUseBuildingSink implements Sink { private Map relationMap; private ActivityFacilities facilities; private ObjectAttributes facilityAttributes; - private Map landUseTypeMap = new HashMap<>(); - private Map buildingTypeMap = new HashMap<>(); + private final Map landUseTypeMap; + private Map buildingTypeMap; private Map typeCount = new HashMap<>(); - private List features = new ArrayList (); + private List features = new ArrayList<>(); private double buildingTypeFromVicinityRange; private String[] tagsToIgnoreBuildings; diff --git a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/utils/GeoserverUpdater.java b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/utils/GeoserverUpdater.java index a5799e30983..d489d7ca811 100644 --- a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/utils/GeoserverUpdater.java +++ b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/utils/GeoserverUpdater.java @@ -28,9 +28,11 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.geotools.data.DataStore; -import org.geotools.data.DataStoreFinder; -import org.geotools.data.simple.SimpleFeatureStore; +import org.geotools.api.data.DataStore; +import org.geotools.api.data.DataStoreFinder; +import org.geotools.api.data.SimpleFeatureStore; +import org.geotools.api.feature.simple.SimpleFeature; +import org.geotools.api.feature.simple.SimpleFeatureType; import org.geotools.feature.DefaultFeatureCollection; import org.geotools.feature.simple.SimpleFeatureBuilder; import org.geotools.feature.simple.SimpleFeatureTypeBuilder; @@ -49,8 +51,6 @@ import org.matsim.core.utils.geometry.transformations.TransformationFactory; import org.matsim.core.utils.gis.GeoFileWriter; import org.matsim.facilities.ActivityFacility; -import org.opengis.feature.simple.SimpleFeature; -import org.opengis.feature.simple.SimpleFeatureType; public class GeoserverUpdater implements FacilityDataExchangeInterface { diff --git a/contribs/accidents/src/main/java/org/matsim/contrib/accidents/runExample/AccidentsNetworkModification.java b/contribs/accidents/src/main/java/org/matsim/contrib/accidents/runExample/AccidentsNetworkModification.java index 7388ce718d5..0cd56b5fd7f 100644 --- a/contribs/accidents/src/main/java/org/matsim/contrib/accidents/runExample/AccidentsNetworkModification.java +++ b/contribs/accidents/src/main/java/org/matsim/contrib/accidents/runExample/AccidentsNetworkModification.java @@ -28,10 +28,11 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.geotools.data.DataStore; -import org.geotools.data.FileDataStoreFinder; +import org.geotools.api.data.DataStore; +import org.geotools.api.data.FileDataStoreFinder; +import org.geotools.api.data.SimpleFeatureSource; +import org.geotools.api.feature.simple.SimpleFeature; import org.geotools.data.simple.SimpleFeatureIterator; -import org.geotools.data.simple.SimpleFeatureSource; import org.locationtech.jts.geom.Coordinate; import org.locationtech.jts.geom.Geometry; import org.locationtech.jts.geom.GeometryFactory; @@ -45,7 +46,6 @@ import org.matsim.core.utils.geometry.geotools.MGC; import org.matsim.core.utils.geometry.transformations.TransformationFactory; import org.matsim.core.utils.gis.GeoFileReader; -import org.opengis.feature.simple.SimpleFeature; /** * @author mmayobre, ikaddoura diff --git a/contribs/analysis/pom.xml b/contribs/analysis/pom.xml index f52ca14e894..74a32b64c03 100644 --- a/contribs/analysis/pom.xml +++ b/contribs/analysis/pom.xml @@ -23,7 +23,7 @@ com.google.code.gson gson - 2.10.1 + 2.11.0 org.apache.commons diff --git a/contribs/analysis/src/main/java/org/matsim/contrib/analysis/christoph/TravelTimesWriter.java b/contribs/analysis/src/main/java/org/matsim/contrib/analysis/christoph/TravelTimesWriter.java index c1f1f9ea36e..12b9efdcffb 100644 --- a/contribs/analysis/src/main/java/org/matsim/contrib/analysis/christoph/TravelTimesWriter.java +++ b/contribs/analysis/src/main/java/org/matsim/contrib/analysis/christoph/TravelTimesWriter.java @@ -28,6 +28,8 @@ import java.util.Map; import java.util.Map.Entry; +import org.geotools.api.feature.simple.SimpleFeature; +import org.geotools.api.referencing.crs.CoordinateReferenceSystem; import org.locationtech.jts.geom.Coordinate; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.network.Link; @@ -43,8 +45,6 @@ import org.matsim.core.utils.gis.PolylineFeatureFactory; import org.matsim.core.utils.gis.GeoFileWriter; import org.matsim.core.utils.io.IOUtils; -import org.opengis.feature.simple.SimpleFeature; -import org.opengis.referencing.crs.CoordinateReferenceSystem; /** * Analyzes the average link travel times and writes them to files (absolute and diff --git a/contribs/application/pom.xml b/contribs/application/pom.xml index 95ea86036d9..70a548c2dc7 100644 --- a/contribs/application/pom.xml +++ b/contribs/application/pom.xml @@ -87,7 +87,7 @@ com.github.matsim-org gtfs2matsim - master-33809c4f0f-1 + fc8b13954d @@ -117,7 +117,7 @@ info.picocli picocli - 4.7.5 + 4.7.6 it.unimi.dsi diff --git a/contribs/application/src/main/java/org/matsim/application/options/CsvOptions.java b/contribs/application/src/main/java/org/matsim/application/options/CsvOptions.java index 1b2d6575450..74c25f3a96b 100644 --- a/contribs/application/src/main/java/org/matsim/application/options/CsvOptions.java +++ b/contribs/application/src/main/java/org/matsim/application/options/CsvOptions.java @@ -23,7 +23,7 @@ public final class CsvOptions { @CommandLine.Option(names = "--csv-format", description = "CSV Format", defaultValue = "Default") private CSVFormat.Predefined csvFormat; - @CommandLine.Option(names = "--csv-delimiter", description = "CSV Delimiter", required = false) + @CommandLine.Option(names = "--csv-delimiter", description = "CSV Delimiter") private Character csvDelimiter; @CommandLine.Option(names = "--csv-charset", description = "CSV input encoding", defaultValue = "UTF8") @@ -56,24 +56,48 @@ public CsvOptions(CSVFormat.Predefined csvFormat, Character csvDelimiter, Charse */ public static Character detectDelimiter(String path) throws IOException { try (BufferedReader reader = IOUtils.getBufferedReader(path)) { - String firstLine = reader.readLine(); + int[] comma = new int[5]; + int[] semicolon = new int[5]; + int[] tab = new int[5]; + String[] lines = new String[5]; + +// check five first lines for separator chars. It might be that the csv file has additional info in the first x lines (e.g. EPSG) + for (int i = 0; i < 5; i++) { + lines[i] = reader.readLine(); + if (lines[i] == null) { + comma[i] = 0; + semicolon[i] = 0; + tab[i] = 0; + } else { + comma[i] = StringUtils.countMatches(lines[i], ","); + semicolon[i] = StringUtils.countMatches(lines[i], ";"); + tab[i] = StringUtils.countMatches(lines[i], "\t"); + } + } - int comma = StringUtils.countMatches(firstLine, ","); - int semicolon = StringUtils.countMatches(firstLine, ";"); - int tab = StringUtils.countMatches(firstLine, "\t"); + Integer index = null; - if (comma == 0 && semicolon == 0 && tab == 0) { - throw new IllegalArgumentException("No delimiter found in the first line of the file."); + for (int i = 0; i < comma.length - 1; i++) { +// only check next index if line with separators was not found + if (index == null) { + if (!(comma[i] == 0 && semicolon[i] == 0 && tab[i] == 0)) { + index = i; + } + } } - // Comma is preferred as the more likely format - if (comma >= semicolon && comma >= tab) { - return ','; - } else if (tab >= semicolon) - return '\t'; - else - return ';'; - } + if (index == null) { + throw new IllegalArgumentException("No delimiter found in the first line of the file."); + } else { + // Comma is preferred as the more likely format + if (comma[index] >= semicolon[index] && comma[index] >= tab[index]) { + return ','; + } else if (tab[index] >= semicolon[index]) + return '\t'; + else + return ';'; + } + } } /** diff --git a/contribs/application/src/main/java/org/matsim/application/options/ShpOptions.java b/contribs/application/src/main/java/org/matsim/application/options/ShpOptions.java index 359eedb0db4..985db84bba7 100644 --- a/contribs/application/src/main/java/org/matsim/application/options/ShpOptions.java +++ b/contribs/application/src/main/java/org/matsim/application/options/ShpOptions.java @@ -3,6 +3,11 @@ import org.apache.commons.lang3.ArrayUtils; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.geotools.api.data.*; +import org.geotools.api.feature.simple.SimpleFeature; +import org.geotools.api.feature.simple.SimpleFeatureType; +import org.geotools.api.referencing.FactoryException; +import org.geotools.api.referencing.crs.CoordinateReferenceSystem; import org.geotools.data.*; import org.geotools.data.shapefile.ShapefileDataStore; import org.geotools.data.shapefile.ShapefileDataStoreFactory; @@ -21,10 +26,6 @@ import org.matsim.core.utils.geometry.transformations.TransformationFactory; import org.matsim.core.utils.gis.GeoFileReader; import org.matsim.core.utils.io.IOUtils; -import org.opengis.feature.simple.SimpleFeature; -import org.opengis.feature.simple.SimpleFeatureType; -import org.opengis.referencing.FactoryException; -import org.opengis.referencing.crs.CoordinateReferenceSystem; import picocli.CommandLine; import javax.annotation.Nullable; diff --git a/contribs/application/src/main/java/org/matsim/application/prepare/CreateLandUseShp.java b/contribs/application/src/main/java/org/matsim/application/prepare/CreateLandUseShp.java index 4f10c61e745..a4cec737419 100644 --- a/contribs/application/src/main/java/org/matsim/application/prepare/CreateLandUseShp.java +++ b/contribs/application/src/main/java/org/matsim/application/prepare/CreateLandUseShp.java @@ -2,12 +2,14 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.geotools.data.DataStore; -import org.geotools.data.FileDataStore; -import org.geotools.data.FileDataStoreFactorySpi; +import org.geotools.api.data.DataStore; +import org.geotools.api.data.FileDataStore; +import org.geotools.api.data.FileDataStoreFactorySpi; +import org.geotools.api.data.SimpleFeatureStore; +import org.geotools.api.feature.simple.SimpleFeature; +import org.geotools.api.feature.simple.SimpleFeatureType; import org.geotools.data.collection.ListFeatureCollection; import org.geotools.data.shapefile.ShapefileDataStoreFactory; -import org.geotools.data.simple.SimpleFeatureStore; import org.geotools.data.store.ReprojectingFeatureCollection; import org.geotools.feature.simple.SimpleFeatureTypeBuilder; import org.geotools.referencing.CRS; @@ -15,8 +17,6 @@ import org.locationtech.jts.index.strtree.STRtree; import org.matsim.application.MATSimAppCommand; import org.matsim.application.options.CrsOptions; -import org.opengis.feature.simple.SimpleFeature; -import org.opengis.feature.simple.SimpleFeatureType; import picocli.CommandLine; import java.nio.file.FileSystem; diff --git a/contribs/application/src/main/java/org/matsim/application/prepare/ShapeFileTextLookup.java b/contribs/application/src/main/java/org/matsim/application/prepare/ShapeFileTextLookup.java index 1be1a71eed1..e6b768e9ae8 100644 --- a/contribs/application/src/main/java/org/matsim/application/prepare/ShapeFileTextLookup.java +++ b/contribs/application/src/main/java/org/matsim/application/prepare/ShapeFileTextLookup.java @@ -6,11 +6,11 @@ import org.apache.commons.text.similarity.*; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.geotools.api.feature.simple.SimpleFeature; +import org.geotools.api.feature.type.AttributeDescriptor; import org.matsim.application.MATSimAppCommand; import org.matsim.application.options.CsvOptions; import org.matsim.application.options.ShpOptions; -import org.opengis.feature.simple.SimpleFeature; -import org.opengis.feature.type.AttributeDescriptor; import picocli.CommandLine; import java.nio.file.Files; diff --git a/contribs/application/src/main/java/org/matsim/application/prepare/counts/NetworkIndex.java b/contribs/application/src/main/java/org/matsim/application/prepare/counts/NetworkIndex.java index da00479b097..f44409de03b 100644 --- a/contribs/application/src/main/java/org/matsim/application/prepare/counts/NetworkIndex.java +++ b/contribs/application/src/main/java/org/matsim/application/prepare/counts/NetworkIndex.java @@ -3,6 +3,8 @@ import org.apache.commons.csv.CSVFormat; import org.apache.commons.csv.CSVParser; import org.apache.commons.csv.CSVRecord; +import org.geotools.api.referencing.operation.MathTransform; +import org.geotools.api.referencing.operation.TransformException; import org.geotools.geometry.jts.JTS; import org.locationtech.jts.algorithm.distance.DiscreteHausdorffDistance; import org.locationtech.jts.geom.*; @@ -13,8 +15,6 @@ import org.matsim.api.core.v01.network.Network; import org.matsim.core.utils.geometry.geotools.MGC; import org.matsim.core.utils.io.IOUtils; -import org.opengis.referencing.operation.MathTransform; -import org.opengis.referencing.operation.TransformException; import javax.annotation.Nullable; import java.io.IOException; diff --git a/contribs/application/src/main/java/org/matsim/application/prepare/freight/dataProcessing/GenerateLookupTable.java b/contribs/application/src/main/java/org/matsim/application/prepare/freight/dataProcessing/GenerateLookupTable.java index b6a8f99d22f..c86a773cc28 100644 --- a/contribs/application/src/main/java/org/matsim/application/prepare/freight/dataProcessing/GenerateLookupTable.java +++ b/contribs/application/src/main/java/org/matsim/application/prepare/freight/dataProcessing/GenerateLookupTable.java @@ -4,12 +4,12 @@ import org.apache.commons.csv.CSVParser; import org.apache.commons.csv.CSVPrinter; import org.apache.commons.csv.CSVRecord; +import org.geotools.api.feature.simple.SimpleFeature; import org.locationtech.jts.geom.Geometry; import org.matsim.api.core.v01.Coord; import org.matsim.application.MATSimAppCommand; import org.matsim.application.options.ShpOptions; import org.matsim.core.utils.geometry.geotools.MGC; -import org.opengis.feature.simple.SimpleFeature; import picocli.CommandLine; import java.io.FileWriter; diff --git a/contribs/application/src/main/java/org/matsim/application/prepare/freight/dataProcessing/GermanNutsTransformation.java b/contribs/application/src/main/java/org/matsim/application/prepare/freight/dataProcessing/GermanNutsTransformation.java index eabeedb1c89..a659692739d 100644 --- a/contribs/application/src/main/java/org/matsim/application/prepare/freight/dataProcessing/GermanNutsTransformation.java +++ b/contribs/application/src/main/java/org/matsim/application/prepare/freight/dataProcessing/GermanNutsTransformation.java @@ -1,5 +1,6 @@ package org.matsim.application.prepare.freight.dataProcessing; +import org.geotools.api.feature.simple.SimpleFeature; import org.locationtech.jts.geom.Geometry; import org.locationtech.jts.geom.Point; import org.matsim.api.core.v01.Coord; @@ -7,7 +8,6 @@ import org.matsim.core.utils.geometry.CoordinateTransformation; import org.matsim.core.utils.geometry.geotools.MGC; import org.matsim.core.utils.geometry.transformations.GeotoolsTransformation; -import org.opengis.feature.simple.SimpleFeature; import java.nio.charset.StandardCharsets; import java.nio.file.Path; diff --git a/contribs/application/src/main/java/org/matsim/application/prepare/freight/optimization/DetermineAverageTruckLoad.java b/contribs/application/src/main/java/org/matsim/application/prepare/freight/optimization/DetermineAverageTruckLoad.java index b89303a23bb..f82c2a885d6 100644 --- a/contribs/application/src/main/java/org/matsim/application/prepare/freight/optimization/DetermineAverageTruckLoad.java +++ b/contribs/application/src/main/java/org/matsim/application/prepare/freight/optimization/DetermineAverageTruckLoad.java @@ -6,6 +6,7 @@ import org.apache.commons.csv.CSVRecord; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.geotools.api.feature.simple.SimpleFeature; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Identifiable; @@ -27,7 +28,6 @@ import org.matsim.core.utils.geometry.CoordinateTransformation; import org.matsim.core.utils.geometry.transformations.TransformationFactory; import org.matsim.core.utils.gis.GeoFileReader; -import org.opengis.feature.simple.SimpleFeature; import picocli.CommandLine; import java.io.FileWriter; diff --git a/contribs/application/src/main/java/org/matsim/application/prepare/network/CreateGeoJsonNetwork.java b/contribs/application/src/main/java/org/matsim/application/prepare/network/CreateGeoJsonNetwork.java index cad4484624b..42eb4408fe9 100644 --- a/contribs/application/src/main/java/org/matsim/application/prepare/network/CreateGeoJsonNetwork.java +++ b/contribs/application/src/main/java/org/matsim/application/prepare/network/CreateGeoJsonNetwork.java @@ -82,7 +82,7 @@ public Integer call() throws Exception { json.put("type", "FeatureCollection"); // Default CRS assumed to be 4326 - if (!networkCrs.equalsIgnoreCase("epsg:4326")) { + if (!crs.getTargetCRS().equalsIgnoreCase("epsg:4326")) { ObjectNode crs = json.putObject("crs"); putCrs(crs, networkCrs); } diff --git a/contribs/application/src/main/java/org/matsim/freightDemandGeneration/CarrierReaderFromCSV.java b/contribs/application/src/main/java/org/matsim/freightDemandGeneration/CarrierReaderFromCSV.java index 7939a9dab9a..19dc604a32c 100644 --- a/contribs/application/src/main/java/org/matsim/freightDemandGeneration/CarrierReaderFromCSV.java +++ b/contribs/application/src/main/java/org/matsim/freightDemandGeneration/CarrierReaderFromCSV.java @@ -24,6 +24,7 @@ import org.apache.commons.csv.CSVRecord; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.geotools.api.feature.simple.SimpleFeature; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.network.Link; @@ -33,7 +34,6 @@ import org.matsim.core.utils.geometry.CoordinateTransformation; import org.matsim.vehicles.Vehicle; import org.matsim.vehicles.VehicleType; -import org.opengis.feature.simple.SimpleFeature; import java.io.IOException; import java.nio.file.Files; diff --git a/contribs/application/src/main/java/org/matsim/freightDemandGeneration/DemandReaderFromCSV.java b/contribs/application/src/main/java/org/matsim/freightDemandGeneration/DemandReaderFromCSV.java index d991eaa9a6f..a301fe8dcf1 100644 --- a/contribs/application/src/main/java/org/matsim/freightDemandGeneration/DemandReaderFromCSV.java +++ b/contribs/application/src/main/java/org/matsim/freightDemandGeneration/DemandReaderFromCSV.java @@ -24,6 +24,7 @@ import org.apache.commons.csv.CSVRecord; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.geotools.api.feature.simple.SimpleFeature; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -36,7 +37,6 @@ import org.matsim.core.router.TripStructureUtils; import org.matsim.core.utils.geometry.CoordinateTransformation; import org.matsim.freight.carriers.*; -import org.opengis.feature.simple.SimpleFeature; import java.io.IOException; import java.nio.file.Files; diff --git a/contribs/application/src/test/java/org/matsim/application/options/CsvOptionsTest.java b/contribs/application/src/test/java/org/matsim/application/options/CsvOptionsTest.java index a406deca398..70452d23138 100644 --- a/contribs/application/src/test/java/org/matsim/application/options/CsvOptionsTest.java +++ b/contribs/application/src/test/java/org/matsim/application/options/CsvOptionsTest.java @@ -37,10 +37,12 @@ void output() throws IOException { printer.printRecord("header", "column"); printer.printRecord("1", "2"); + printer.printRecord("3", "4"); + printer.printRecord("5", "6"); printer.close(); assertThat(tmp) - .hasContent("header" + delimiter + "column\n1" + delimiter + "2"); + .hasContent("header" + delimiter + "column\n1" + delimiter + "2" + "\n3" + delimiter + "4" + "\n5" + delimiter + "6"); assertThat(delimiter).isEqualTo(CsvOptions.detectDelimiter(tmp.toString()).toString()); } diff --git a/contribs/application/src/test/java/org/matsim/application/options/ShpOptionsTest.java b/contribs/application/src/test/java/org/matsim/application/options/ShpOptionsTest.java index bc13baad71f..e28ec92193f 100644 --- a/contribs/application/src/test/java/org/matsim/application/options/ShpOptionsTest.java +++ b/contribs/application/src/test/java/org/matsim/application/options/ShpOptionsTest.java @@ -1,13 +1,13 @@ package org.matsim.application.options; import org.assertj.core.data.Offset; +import org.geotools.api.feature.simple.SimpleFeature; import org.junit.jupiter.api.Assumptions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.locationtech.jts.geom.Geometry; import org.matsim.api.core.v01.Coord; import org.matsim.testcases.MatsimTestUtils; -import org.opengis.feature.simple.SimpleFeature; import java.nio.file.Files; import java.nio.file.Path; diff --git a/contribs/application/src/test/java/org/matsim/freightDemandGeneration/DemandReaderFromCSVTest.java b/contribs/application/src/test/java/org/matsim/freightDemandGeneration/DemandReaderFromCSVTest.java index c9133b6b56b..9d672b4a461 100644 --- a/contribs/application/src/test/java/org/matsim/freightDemandGeneration/DemandReaderFromCSVTest.java +++ b/contribs/application/src/test/java/org/matsim/freightDemandGeneration/DemandReaderFromCSVTest.java @@ -8,6 +8,7 @@ import java.util.Map; import java.util.Set; +import org.geotools.api.feature.simple.SimpleFeature; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; @@ -27,7 +28,6 @@ import org.matsim.freightDemandGeneration.CarrierReaderFromCSV.CarrierInformationElement; import org.matsim.freightDemandGeneration.DemandReaderFromCSV.DemandInformationElement; import org.matsim.testcases.MatsimTestUtils; -import org.opengis.feature.simple.SimpleFeature; import it.unimi.dsi.fastutil.objects.Object2IntMap; import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; diff --git a/contribs/bicycle/src/main/java/org/matsim/contrib/bicycle/BicycleScoreEventsCreator.java b/contribs/bicycle/src/main/java/org/matsim/contrib/bicycle/BicycleScoreEventsCreator.java index e82f524c711..43e44b8bc93 100644 --- a/contribs/bicycle/src/main/java/org/matsim/contrib/bicycle/BicycleScoreEventsCreator.java +++ b/contribs/bicycle/src/main/java/org/matsim/contrib/bicycle/BicycleScoreEventsCreator.java @@ -132,7 +132,6 @@ class BicycleScoreEventsCreator implements } @Override public void handleEvent( VehicleLeavesTrafficEvent event ){ - vehicle2driver.handleEvent( event ); if ( this.bicycleConfig.isMotorizedInteraction() ){ // dec count by one: String mode = this.modeFromVehicle.get( event.getVehicleId() ); @@ -155,6 +154,8 @@ class BicycleScoreEventsCreator implements } else { log.warn( "no driver found for vehicleId=" + event.getVehicleId() + "; not clear why this could happen" ); } + // Needs to be called last, because it will remove driver information + vehicle2driver.handleEvent( event ); // --- } diff --git a/contribs/bicycle/src/main/java/org/matsim/contrib/bicycle/network/ElevationDataParser.java b/contribs/bicycle/src/main/java/org/matsim/contrib/bicycle/network/ElevationDataParser.java index a1a34d8fb76..73643505aa1 100644 --- a/contribs/bicycle/src/main/java/org/matsim/contrib/bicycle/network/ElevationDataParser.java +++ b/contribs/bicycle/src/main/java/org/matsim/contrib/bicycle/network/ElevationDataParser.java @@ -21,18 +21,18 @@ import java.awt.image.Raster; import java.io.IOException; +import org.geotools.api.data.DataSourceException; +import org.geotools.api.referencing.operation.TransformException; import org.geotools.coverage.grid.GridCoordinates2D; import org.geotools.coverage.grid.GridCoverage2D; import org.geotools.coverage.grid.GridGeometry2D; import org.geotools.coverage.grid.InvalidGridGeometryException; -import org.geotools.data.DataSourceException; import org.geotools.gce.geotiff.GeoTiffReader; -import org.geotools.geometry.DirectPosition2D; +import org.geotools.geometry.Position2D; import org.matsim.api.core.v01.Coord; import org.matsim.core.utils.geometry.CoordUtils; import org.matsim.core.utils.geometry.CoordinateTransformation; import org.matsim.core.utils.geometry.transformations.TransformationFactory; -import org.opengis.referencing.operation.TransformException; /** * @author smetzler, dziemke @@ -101,7 +101,7 @@ public double getElevation(Coord coord) { GridCoordinates2D posGrid = null; try { - posGrid = gg.worldToGrid(new DirectPosition2D(transformedCoord.getX(), transformedCoord.getY())); + posGrid = gg.worldToGrid(new Position2D(transformedCoord.getX(), transformedCoord.getY())); } catch (InvalidGridGeometryException e) { e.printStackTrace(); } catch (TransformException e) { diff --git a/contribs/bicycle/src/test/java/org/matsim/contrib/bicycle/run/BicycleTest.java b/contribs/bicycle/src/test/java/org/matsim/contrib/bicycle/run/BicycleTest.java index 222834c746b..6c53356fb13 100644 --- a/contribs/bicycle/src/test/java/org/matsim/contrib/bicycle/run/BicycleTest.java +++ b/contribs/bicycle/src/test/java/org/matsim/contrib/bicycle/run/BicycleTest.java @@ -48,6 +48,7 @@ import org.matsim.core.controler.OutputDirectoryHierarchy.OverwriteFileSetting; import org.matsim.core.population.PopulationUtils; import org.matsim.core.population.io.PopulationReader; +import org.matsim.core.population.routes.PopulationComparison; import org.matsim.core.router.TripStructureUtils; import org.matsim.core.scenario.ScenarioUtils; import org.matsim.core.utils.collections.CollectionUtils; @@ -204,7 +205,8 @@ void testLane() { Scenario scenarioCurrent = ScenarioUtils.createScenario(ConfigUtils.createConfig()); new PopulationReader(scenarioReference).readFile(utils.getInputDirectory() + "output_plans.xml.gz"); new PopulationReader(scenarioCurrent).readFile(utils.getOutputDirectory() + "output_plans.xml.gz"); - assertTrue(PopulationUtils.equalPopulation(scenarioReference.getPopulation(), scenarioCurrent.getPopulation()), "Populations are different"); + + assertEquals(PopulationComparison.Result.equal, PopulationComparison.compare(scenarioReference.getPopulation(), scenarioCurrent.getPopulation()), "Populations are different"); } @Test diff --git a/contribs/bicycle/test/input/org/matsim/contrib/bicycle/run/BicycleTest/testCobblestone/output_events.xml.gz b/contribs/bicycle/test/input/org/matsim/contrib/bicycle/run/BicycleTest/testCobblestone/output_events.xml.gz index 9cb0d3cf237..df938db8693 100644 Binary files a/contribs/bicycle/test/input/org/matsim/contrib/bicycle/run/BicycleTest/testCobblestone/output_events.xml.gz and b/contribs/bicycle/test/input/org/matsim/contrib/bicycle/run/BicycleTest/testCobblestone/output_events.xml.gz differ diff --git a/contribs/bicycle/test/input/org/matsim/contrib/bicycle/run/BicycleTest/testCobblestone/output_plans.xml.gz b/contribs/bicycle/test/input/org/matsim/contrib/bicycle/run/BicycleTest/testCobblestone/output_plans.xml.gz index 17c8452fd78..9cd6def1cce 100644 Binary files a/contribs/bicycle/test/input/org/matsim/contrib/bicycle/run/BicycleTest/testCobblestone/output_plans.xml.gz and b/contribs/bicycle/test/input/org/matsim/contrib/bicycle/run/BicycleTest/testCobblestone/output_plans.xml.gz differ diff --git a/contribs/bicycle/test/input/org/matsim/contrib/bicycle/run/BicycleTest/testGradient/output_events.xml.gz b/contribs/bicycle/test/input/org/matsim/contrib/bicycle/run/BicycleTest/testGradient/output_events.xml.gz index 97f24034206..fd77527354e 100644 Binary files a/contribs/bicycle/test/input/org/matsim/contrib/bicycle/run/BicycleTest/testGradient/output_events.xml.gz and b/contribs/bicycle/test/input/org/matsim/contrib/bicycle/run/BicycleTest/testGradient/output_events.xml.gz differ diff --git a/contribs/bicycle/test/input/org/matsim/contrib/bicycle/run/BicycleTest/testGradient/output_plans.xml.gz b/contribs/bicycle/test/input/org/matsim/contrib/bicycle/run/BicycleTest/testGradient/output_plans.xml.gz index 59e2f55ae6f..99ee5c39f20 100644 Binary files a/contribs/bicycle/test/input/org/matsim/contrib/bicycle/run/BicycleTest/testGradient/output_plans.xml.gz and b/contribs/bicycle/test/input/org/matsim/contrib/bicycle/run/BicycleTest/testGradient/output_plans.xml.gz differ diff --git a/contribs/bicycle/test/input/org/matsim/contrib/bicycle/run/BicycleTest/testGradientLane/output_events.xml.gz b/contribs/bicycle/test/input/org/matsim/contrib/bicycle/run/BicycleTest/testGradientLane/output_events.xml.gz index a49a018f3d0..0fc24545326 100644 Binary files a/contribs/bicycle/test/input/org/matsim/contrib/bicycle/run/BicycleTest/testGradientLane/output_events.xml.gz and b/contribs/bicycle/test/input/org/matsim/contrib/bicycle/run/BicycleTest/testGradientLane/output_events.xml.gz differ diff --git a/contribs/bicycle/test/input/org/matsim/contrib/bicycle/run/BicycleTest/testGradientLane/output_plans.xml.gz b/contribs/bicycle/test/input/org/matsim/contrib/bicycle/run/BicycleTest/testGradientLane/output_plans.xml.gz index 69788484cf9..4af157ab83e 100644 Binary files a/contribs/bicycle/test/input/org/matsim/contrib/bicycle/run/BicycleTest/testGradientLane/output_plans.xml.gz and b/contribs/bicycle/test/input/org/matsim/contrib/bicycle/run/BicycleTest/testGradientLane/output_plans.xml.gz differ diff --git a/contribs/bicycle/test/input/org/matsim/contrib/bicycle/run/BicycleTest/testGradientLane/testGradient/output_events.xml.gz b/contribs/bicycle/test/input/org/matsim/contrib/bicycle/run/BicycleTest/testGradientLane/testGradient/output_events.xml.gz deleted file mode 100644 index 97f24034206..00000000000 Binary files a/contribs/bicycle/test/input/org/matsim/contrib/bicycle/run/BicycleTest/testGradientLane/testGradient/output_events.xml.gz and /dev/null differ diff --git a/contribs/bicycle/test/input/org/matsim/contrib/bicycle/run/BicycleTest/testGradientLane/testGradient/output_plans.xml.gz b/contribs/bicycle/test/input/org/matsim/contrib/bicycle/run/BicycleTest/testGradientLane/testGradient/output_plans.xml.gz deleted file mode 100644 index 59e2f55ae6f..00000000000 Binary files a/contribs/bicycle/test/input/org/matsim/contrib/bicycle/run/BicycleTest/testGradientLane/testGradient/output_plans.xml.gz and /dev/null differ diff --git a/contribs/bicycle/test/input/org/matsim/contrib/bicycle/run/BicycleTest/testLane/output_events.xml.gz b/contribs/bicycle/test/input/org/matsim/contrib/bicycle/run/BicycleTest/testLane/output_events.xml.gz index 955cde9e707..07129f0a0a9 100644 Binary files a/contribs/bicycle/test/input/org/matsim/contrib/bicycle/run/BicycleTest/testLane/output_events.xml.gz and b/contribs/bicycle/test/input/org/matsim/contrib/bicycle/run/BicycleTest/testLane/output_events.xml.gz differ diff --git a/contribs/bicycle/test/input/org/matsim/contrib/bicycle/run/BicycleTest/testLane/output_plans.xml.gz b/contribs/bicycle/test/input/org/matsim/contrib/bicycle/run/BicycleTest/testLane/output_plans.xml.gz index f41e975b460..22ce253ffda 100644 Binary files a/contribs/bicycle/test/input/org/matsim/contrib/bicycle/run/BicycleTest/testLane/output_plans.xml.gz and b/contribs/bicycle/test/input/org/matsim/contrib/bicycle/run/BicycleTest/testLane/output_plans.xml.gz differ diff --git a/contribs/bicycle/test/input/org/matsim/contrib/bicycle/run/BicycleTest/testLinkBasedScoring/output_events.xml.gz b/contribs/bicycle/test/input/org/matsim/contrib/bicycle/run/BicycleTest/testLinkBasedScoring/output_events.xml.gz index 3478209daf4..ff9247df740 100644 Binary files a/contribs/bicycle/test/input/org/matsim/contrib/bicycle/run/BicycleTest/testLinkBasedScoring/output_events.xml.gz and b/contribs/bicycle/test/input/org/matsim/contrib/bicycle/run/BicycleTest/testLinkBasedScoring/output_events.xml.gz differ diff --git a/contribs/bicycle/test/input/org/matsim/contrib/bicycle/run/BicycleTest/testLinkBasedScoring/output_plans.xml.gz b/contribs/bicycle/test/input/org/matsim/contrib/bicycle/run/BicycleTest/testLinkBasedScoring/output_plans.xml.gz index 31eeebd5ab5..52f95856f96 100644 Binary files a/contribs/bicycle/test/input/org/matsim/contrib/bicycle/run/BicycleTest/testLinkBasedScoring/output_plans.xml.gz and b/contribs/bicycle/test/input/org/matsim/contrib/bicycle/run/BicycleTest/testLinkBasedScoring/output_plans.xml.gz differ diff --git a/contribs/bicycle/test/input/org/matsim/contrib/bicycle/run/BicycleTest/testLinkVsLegMotorizedScoring/output_events.xml.gz b/contribs/bicycle/test/input/org/matsim/contrib/bicycle/run/BicycleTest/testLinkVsLegMotorizedScoring/output_events.xml.gz index e6f996e514c..763f7214df7 100644 Binary files a/contribs/bicycle/test/input/org/matsim/contrib/bicycle/run/BicycleTest/testLinkVsLegMotorizedScoring/output_events.xml.gz and b/contribs/bicycle/test/input/org/matsim/contrib/bicycle/run/BicycleTest/testLinkVsLegMotorizedScoring/output_events.xml.gz differ diff --git a/contribs/bicycle/test/input/org/matsim/contrib/bicycle/run/BicycleTest/testLinkVsLegMotorizedScoring/output_plans.xml.gz b/contribs/bicycle/test/input/org/matsim/contrib/bicycle/run/BicycleTest/testLinkVsLegMotorizedScoring/output_plans.xml.gz index 6a99b6e8af4..29a33e2aa48 100644 Binary files a/contribs/bicycle/test/input/org/matsim/contrib/bicycle/run/BicycleTest/testLinkVsLegMotorizedScoring/output_plans.xml.gz and b/contribs/bicycle/test/input/org/matsim/contrib/bicycle/run/BicycleTest/testLinkVsLegMotorizedScoring/output_plans.xml.gz differ diff --git a/contribs/bicycle/test/input/org/matsim/contrib/bicycle/run/BicycleTest/testNormal/output_events.xml.gz b/contribs/bicycle/test/input/org/matsim/contrib/bicycle/run/BicycleTest/testNormal/output_events.xml.gz index c45233d6432..67b34e49d71 100644 Binary files a/contribs/bicycle/test/input/org/matsim/contrib/bicycle/run/BicycleTest/testNormal/output_events.xml.gz and b/contribs/bicycle/test/input/org/matsim/contrib/bicycle/run/BicycleTest/testNormal/output_events.xml.gz differ diff --git a/contribs/bicycle/test/input/org/matsim/contrib/bicycle/run/BicycleTest/testNormal/output_plans.xml.gz b/contribs/bicycle/test/input/org/matsim/contrib/bicycle/run/BicycleTest/testNormal/output_plans.xml.gz index 31eeebd5ab5..52f95856f96 100644 Binary files a/contribs/bicycle/test/input/org/matsim/contrib/bicycle/run/BicycleTest/testNormal/output_plans.xml.gz and b/contribs/bicycle/test/input/org/matsim/contrib/bicycle/run/BicycleTest/testNormal/output_plans.xml.gz differ diff --git a/contribs/bicycle/test/input/org/matsim/contrib/bicycle/run/BicycleTest/testNormal10It/output_events.xml.gz b/contribs/bicycle/test/input/org/matsim/contrib/bicycle/run/BicycleTest/testNormal10It/output_events.xml.gz index f0c50645e9b..dde3baab5cd 100644 Binary files a/contribs/bicycle/test/input/org/matsim/contrib/bicycle/run/BicycleTest/testNormal10It/output_events.xml.gz and b/contribs/bicycle/test/input/org/matsim/contrib/bicycle/run/BicycleTest/testNormal10It/output_events.xml.gz differ diff --git a/contribs/bicycle/test/input/org/matsim/contrib/bicycle/run/BicycleTest/testNormal10It/output_plans.xml.gz b/contribs/bicycle/test/input/org/matsim/contrib/bicycle/run/BicycleTest/testNormal10It/output_plans.xml.gz index 3c5b6caa023..9dedc2b2558 100644 Binary files a/contribs/bicycle/test/input/org/matsim/contrib/bicycle/run/BicycleTest/testNormal10It/output_plans.xml.gz and b/contribs/bicycle/test/input/org/matsim/contrib/bicycle/run/BicycleTest/testNormal10It/output_plans.xml.gz differ diff --git a/contribs/bicycle/test/input/org/matsim/contrib/bicycle/run/BicycleTest/testPedestrian/output_events.xml.gz b/contribs/bicycle/test/input/org/matsim/contrib/bicycle/run/BicycleTest/testPedestrian/output_events.xml.gz index f5b8f36e29d..94e4cbee126 100644 Binary files a/contribs/bicycle/test/input/org/matsim/contrib/bicycle/run/BicycleTest/testPedestrian/output_events.xml.gz and b/contribs/bicycle/test/input/org/matsim/contrib/bicycle/run/BicycleTest/testPedestrian/output_events.xml.gz differ diff --git a/contribs/bicycle/test/input/org/matsim/contrib/bicycle/run/BicycleTest/testPedestrian/output_plans.xml.gz b/contribs/bicycle/test/input/org/matsim/contrib/bicycle/run/BicycleTest/testPedestrian/output_plans.xml.gz index b09a281270f..6e4970d1379 100644 Binary files a/contribs/bicycle/test/input/org/matsim/contrib/bicycle/run/BicycleTest/testPedestrian/output_plans.xml.gz and b/contribs/bicycle/test/input/org/matsim/contrib/bicycle/run/BicycleTest/testPedestrian/output_plans.xml.gz differ diff --git a/contribs/carsharing/src/main/java/org/matsim/contrib/carsharing/config/FreefloatingAreasReader.java b/contribs/carsharing/src/main/java/org/matsim/contrib/carsharing/config/FreefloatingAreasReader.java index 8230aaf2296..3b796eb74d5 100644 --- a/contribs/carsharing/src/main/java/org/matsim/contrib/carsharing/config/FreefloatingAreasReader.java +++ b/contribs/carsharing/src/main/java/org/matsim/contrib/carsharing/config/FreefloatingAreasReader.java @@ -5,13 +5,13 @@ import java.util.Map; import java.util.Stack; +import org.geotools.api.feature.simple.SimpleFeature; import org.geotools.referencing.crs.DefaultGeographicCRS; import org.matsim.api.core.v01.Coord; import org.matsim.contrib.carsharing.qsim.FreefloatingAreas; import org.matsim.core.utils.gis.PolygonFeatureFactory; import org.matsim.core.utils.io.MatsimXmlParser; import org.matsim.core.utils.misc.Counter; -import org.opengis.feature.simple.SimpleFeature; import org.xml.sax.Attributes; public class FreefloatingAreasReader extends MatsimXmlParser { diff --git a/contribs/carsharing/src/main/java/org/matsim/contrib/carsharing/qsim/FreefloatingAreas.java b/contribs/carsharing/src/main/java/org/matsim/contrib/carsharing/qsim/FreefloatingAreas.java index 6de9769e920..cda26560ab0 100644 --- a/contribs/carsharing/src/main/java/org/matsim/contrib/carsharing/qsim/FreefloatingAreas.java +++ b/contribs/carsharing/src/main/java/org/matsim/contrib/carsharing/qsim/FreefloatingAreas.java @@ -2,6 +2,7 @@ import java.util.ArrayList; +import org.geotools.api.feature.simple.SimpleFeature; import org.geotools.referencing.crs.DefaultGeographicCRS; import org.locationtech.jts.geom.Coordinate; import org.locationtech.jts.geom.MultiPolygon; @@ -9,7 +10,6 @@ import org.locationtech.jts.operation.distance.DistanceOp; import org.matsim.api.core.v01.Coord; import org.matsim.core.utils.gis.PointFeatureFactory; -import org.opengis.feature.simple.SimpleFeature; public class FreefloatingAreas { private PointFeatureFactory pointFeatureFactory; diff --git a/contribs/carsharing/src/main/java/org/matsim/contrib/carsharing/relocation/demand/CarsharingVehicleRelocationContainer.java b/contribs/carsharing/src/main/java/org/matsim/contrib/carsharing/relocation/demand/CarsharingVehicleRelocationContainer.java index dae3bd0386d..ea102e0f25c 100644 --- a/contribs/carsharing/src/main/java/org/matsim/contrib/carsharing/relocation/demand/CarsharingVehicleRelocationContainer.java +++ b/contribs/carsharing/src/main/java/org/matsim/contrib/carsharing/relocation/demand/CarsharingVehicleRelocationContainer.java @@ -9,6 +9,7 @@ import java.util.Map.Entry; import java.util.TreeMap; +import org.geotools.api.feature.simple.SimpleFeature; import org.geotools.referencing.crs.DefaultGeographicCRS; import org.locationtech.jts.geom.MultiPolygon; import org.locationtech.jts.geom.Point; @@ -28,7 +29,6 @@ import org.matsim.contrib.carsharing.relocation.utils.RelocationZonesReader; import org.matsim.core.network.NetworkUtils; import org.matsim.core.utils.gis.PointFeatureFactory; -import org.opengis.feature.simple.SimpleFeature; public class CarsharingVehicleRelocationContainer { private Scenario scenario; diff --git a/contribs/carsharing/src/main/java/org/matsim/contrib/carsharing/relocation/infrastructure/RelocationZone.java b/contribs/carsharing/src/main/java/org/matsim/contrib/carsharing/relocation/infrastructure/RelocationZone.java index 97a7f6f3ddd..6e3e2eed9e5 100644 --- a/contribs/carsharing/src/main/java/org/matsim/contrib/carsharing/relocation/infrastructure/RelocationZone.java +++ b/contribs/carsharing/src/main/java/org/matsim/contrib/carsharing/relocation/infrastructure/RelocationZone.java @@ -7,13 +7,13 @@ import java.util.Map; import java.util.TreeMap; +import org.geotools.api.feature.simple.SimpleFeature; import org.locationtech.jts.geom.MultiPolygon; import org.locationtech.jts.geom.Point; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Identifiable; import org.matsim.api.core.v01.network.Link; -import org.opengis.feature.simple.SimpleFeature; public class RelocationZone implements Identifiable { diff --git a/contribs/carsharing/src/main/java/org/matsim/contrib/carsharing/relocation/utils/RelocationZonesReader.java b/contribs/carsharing/src/main/java/org/matsim/contrib/carsharing/relocation/utils/RelocationZonesReader.java index 07df9ed165b..d7649f97d62 100644 --- a/contribs/carsharing/src/main/java/org/matsim/contrib/carsharing/relocation/utils/RelocationZonesReader.java +++ b/contribs/carsharing/src/main/java/org/matsim/contrib/carsharing/relocation/utils/RelocationZonesReader.java @@ -8,6 +8,7 @@ import java.util.Map; import java.util.Stack; +import org.geotools.api.feature.simple.SimpleFeature; import org.geotools.referencing.crs.DefaultGeographicCRS; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -15,7 +16,6 @@ import org.matsim.core.utils.gis.PolygonFeatureFactory; import org.matsim.core.utils.io.MatsimXmlParser; import org.matsim.core.utils.misc.Counter; -import org.opengis.feature.simple.SimpleFeature; import org.xml.sax.Attributes; public class RelocationZonesReader extends MatsimXmlParser { diff --git a/contribs/commercialTrafficApplications/src/main/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/examples/RunJointDemandDRTExample.java b/contribs/commercialTrafficApplications/src/main/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/examples/RunJointDemandDRTExample.java index 72144a8d440..7e8b84afaba 100644 --- a/contribs/commercialTrafficApplications/src/main/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/examples/RunJointDemandDRTExample.java +++ b/contribs/commercialTrafficApplications/src/main/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/examples/RunJointDemandDRTExample.java @@ -30,6 +30,7 @@ import org.matsim.contrib.commercialTrafficApplications.jointDemand.JointDemandConfigGroup; import org.matsim.contrib.commercialTrafficApplications.jointDemand.JointDemandModule; import org.matsim.contrib.common.zones.systems.grid.square.SquareGridZoneSystemParams; +import org.matsim.contrib.drt.optimizer.DrtOptimizationConstraintsSet; import org.matsim.contrib.drt.optimizer.insertion.extensive.ExtensiveInsertionSearchParams; import org.matsim.contrib.drt.run.DrtConfigGroup; import org.matsim.contrib.drt.run.DrtConfigs; @@ -141,9 +142,10 @@ private static void loadConfigGroups(Config config) { MultiModeDrtConfigGroup multiModeDrtConfigGroup = ConfigUtils.addOrGetModule(config, MultiModeDrtConfigGroup.class); DrtConfigGroup drtCfg = new DrtConfigGroup(); - drtCfg.maxWaitTime = 2 * 3600; - drtCfg.maxTravelTimeAlpha = 5; - drtCfg.maxTravelTimeBeta = 15 * 60; + DrtOptimizationConstraintsSet defaultConstraintsSet = drtCfg.addOrGetDrtOptimizationConstraintsParams().addOrGetDefaultDrtOptimizationConstraintsSet(); + defaultConstraintsSet.maxWaitTime = 2 * 3600; + defaultConstraintsSet.maxTravelTimeAlpha = 5; + defaultConstraintsSet.maxTravelTimeBeta = 15 * 60; drtCfg.stopDuration = 60; drtCfg.vehiclesFile = "jointDemand_vehicles.xml"; multiModeDrtConfigGroup.addParameterSet(drtCfg); diff --git a/contribs/common/src/main/java/org/matsim/contrib/common/zones/ZoneSystemUtils.java b/contribs/common/src/main/java/org/matsim/contrib/common/zones/ZoneSystemUtils.java index 725a9bb3a41..7352cd74278 100644 --- a/contribs/common/src/main/java/org/matsim/contrib/common/zones/ZoneSystemUtils.java +++ b/contribs/common/src/main/java/org/matsim/contrib/common/zones/ZoneSystemUtils.java @@ -4,6 +4,8 @@ import one.util.streamex.EntryStream; import one.util.streamex.StreamEx; import org.apache.commons.lang3.tuple.Pair; +import org.geotools.api.feature.Property; +import org.geotools.api.feature.simple.SimpleFeature; import org.locationtech.jts.geom.Point; import org.locationtech.jts.geom.Polygonal; import org.locationtech.jts.geom.prep.PreparedGeometry; @@ -28,8 +30,6 @@ import org.matsim.core.config.ConfigGroup; import org.matsim.core.utils.geometry.geotools.MGC; import org.matsim.core.utils.gis.GeoFileReader; -import org.opengis.feature.Property; -import org.opengis.feature.simple.SimpleFeature; import javax.annotation.Nonnull; import javax.annotation.Nullable; diff --git a/contribs/common/src/main/java/org/matsim/contrib/common/zones/io/ZoneShpReader.java b/contribs/common/src/main/java/org/matsim/contrib/common/zones/io/ZoneShpReader.java index 46e6978a184..1aea45726f1 100644 --- a/contribs/common/src/main/java/org/matsim/contrib/common/zones/io/ZoneShpReader.java +++ b/contribs/common/src/main/java/org/matsim/contrib/common/zones/io/ZoneShpReader.java @@ -19,13 +19,13 @@ package org.matsim.contrib.common.zones.io; +import org.geotools.api.feature.simple.SimpleFeature; import org.locationtech.jts.geom.MultiPolygon; import org.locationtech.jts.geom.prep.PreparedPolygon; import org.matsim.api.core.v01.Id; import org.matsim.contrib.common.zones.Zone; import org.matsim.contrib.common.zones.ZoneImpl; import org.matsim.core.utils.gis.GeoFileReader; -import org.opengis.feature.simple.SimpleFeature; import java.net.URL; import java.util.Collection; diff --git a/contribs/common/src/main/java/org/matsim/contrib/common/zones/io/ZoneShpWriter.java b/contribs/common/src/main/java/org/matsim/contrib/common/zones/io/ZoneShpWriter.java index 68ae03a7b6d..7068c2518ac 100644 --- a/contribs/common/src/main/java/org/matsim/contrib/common/zones/io/ZoneShpWriter.java +++ b/contribs/common/src/main/java/org/matsim/contrib/common/zones/io/ZoneShpWriter.java @@ -19,14 +19,14 @@ package org.matsim.contrib.common.zones.io; +import org.geotools.api.feature.simple.SimpleFeature; +import org.geotools.api.referencing.crs.CoordinateReferenceSystem; import org.locationtech.jts.geom.prep.PreparedGeometry; import org.matsim.api.core.v01.Id; import org.matsim.contrib.common.zones.Zone; import org.matsim.core.utils.geometry.geotools.MGC; import org.matsim.core.utils.gis.GeoFileWriter; import org.matsim.core.utils.gis.PolygonFeatureFactory; -import org.opengis.feature.simple.SimpleFeature; -import org.opengis.referencing.crs.CoordinateReferenceSystem; import java.util.ArrayList; import java.util.List; diff --git a/contribs/common/src/main/java/org/matsim/contrib/common/zones/util/SubzoneUtils.java b/contribs/common/src/main/java/org/matsim/contrib/common/zones/util/SubzoneUtils.java index 01b9a80c6ee..d864f49b6ca 100644 --- a/contribs/common/src/main/java/org/matsim/contrib/common/zones/util/SubzoneUtils.java +++ b/contribs/common/src/main/java/org/matsim/contrib/common/zones/util/SubzoneUtils.java @@ -19,6 +19,7 @@ package org.matsim.contrib.common.zones.util; +import org.geotools.api.feature.simple.SimpleFeature; import org.geotools.geometry.jts.GeometryCollector; import org.locationtech.jts.geom.Geometry; import org.locationtech.jts.geom.Polygon; @@ -27,7 +28,6 @@ import org.locationtech.jts.geom.util.PolygonExtracter; import org.matsim.api.core.v01.Id; import org.matsim.contrib.common.zones.Zone; -import org.opengis.feature.simple.SimpleFeature; import java.util.Collection; import java.util.HashMap; diff --git a/contribs/discrete_mode_choice/src/main/java/org/matsim/contribs/discrete_mode_choice/components/constraints/ShapeFileConstraint.java b/contribs/discrete_mode_choice/src/main/java/org/matsim/contribs/discrete_mode_choice/components/constraints/ShapeFileConstraint.java index fff197c1ec2..742b7d930ce 100644 --- a/contribs/discrete_mode_choice/src/main/java/org/matsim/contribs/discrete_mode_choice/components/constraints/ShapeFileConstraint.java +++ b/contribs/discrete_mode_choice/src/main/java/org/matsim/contribs/discrete_mode_choice/components/constraints/ShapeFileConstraint.java @@ -8,11 +8,12 @@ import java.util.List; import java.util.Set; -import org.geotools.data.DataStore; -import org.geotools.data.DataStoreFinder; +import org.geotools.api.data.DataStore; +import org.geotools.api.data.DataStoreFinder; +import org.geotools.api.data.SimpleFeatureSource; +import org.geotools.api.feature.simple.SimpleFeature; import org.geotools.data.simple.SimpleFeatureCollection; import org.geotools.data.simple.SimpleFeatureIterator; -import org.geotools.data.simple.SimpleFeatureSource; import org.locationtech.jts.geom.Coordinate; import org.locationtech.jts.geom.Geometry; import org.locationtech.jts.geom.GeometryFactory; @@ -26,7 +27,6 @@ import org.matsim.contribs.discrete_mode_choice.model.trip_based.TripConstraint; import org.matsim.contribs.discrete_mode_choice.model.trip_based.TripConstraintFactory; import org.matsim.contribs.discrete_mode_choice.model.trip_based.candidates.TripCandidate; -import org.opengis.feature.simple.SimpleFeature; /** * This constraint decides whether a mode is allowed for a certain trip by diff --git a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/dashboards/DrtAnalysisPostProcessing.java b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/dashboards/DrtAnalysisPostProcessing.java index 34ce02553dc..a8f9e8eabb0 100644 --- a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/dashboards/DrtAnalysisPostProcessing.java +++ b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/dashboards/DrtAnalysisPostProcessing.java @@ -4,14 +4,16 @@ import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; import org.apache.commons.csv.CSVFormat; import org.apache.commons.csv.CSVPrinter; +import org.geotools.api.data.FileDataStoreFactorySpi; +import org.geotools.api.data.SimpleFeatureStore; +import org.geotools.api.data.Transaction; +import org.geotools.api.feature.simple.SimpleFeature; +import org.geotools.api.feature.simple.SimpleFeatureType; import org.geotools.data.DataUtilities; import org.geotools.data.DefaultTransaction; -import org.geotools.data.FileDataStoreFactorySpi; -import org.geotools.data.Transaction; import org.geotools.data.collection.ListFeatureCollection; import org.geotools.data.shapefile.ShapefileDataStore; import org.geotools.data.shapefile.ShapefileDataStoreFactory; -import org.geotools.data.simple.SimpleFeatureStore; import org.geotools.feature.SchemaException; import org.geotools.feature.simple.SimpleFeatureBuilder; import org.geotools.geometry.jts.JTSFactoryFinder; @@ -34,8 +36,6 @@ import org.matsim.core.utils.gis.GeoFileWriter; import org.matsim.pt.transitSchedule.api.TransitScheduleReader; import org.matsim.pt.transitSchedule.api.TransitStopFacility; -import org.opengis.feature.simple.SimpleFeature; -import org.opengis.feature.simple.SimpleFeatureType; import picocli.CommandLine; import tech.tablesaw.api.ColumnType; import tech.tablesaw.api.DoubleColumn; diff --git a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/edrt/run/EDrtModeOptimizerQSimModule.java b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/edrt/run/EDrtModeOptimizerQSimModule.java index b617a93a0d3..546f5b90cc2 100644 --- a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/edrt/run/EDrtModeOptimizerQSimModule.java +++ b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/edrt/run/EDrtModeOptimizerQSimModule.java @@ -28,13 +28,7 @@ import org.matsim.contrib.drt.extension.edrt.schedule.EDrtStayTaskEndTimeCalculator; import org.matsim.contrib.drt.extension.edrt.schedule.EDrtTaskFactoryImpl; import org.matsim.contrib.drt.extension.edrt.scheduler.EmptyVehicleChargingScheduler; -import org.matsim.contrib.drt.optimizer.DefaultDrtOptimizer; -import org.matsim.contrib.drt.optimizer.DrtModeOptimizerQSimModule; -import org.matsim.contrib.drt.optimizer.DrtOptimizer; -import org.matsim.contrib.drt.optimizer.DrtRequestInsertionRetryParams; -import org.matsim.contrib.drt.optimizer.DrtRequestInsertionRetryQueue; -import org.matsim.contrib.drt.optimizer.QSimScopeForkJoinPoolHolder; -import org.matsim.contrib.drt.optimizer.VehicleEntry; +import org.matsim.contrib.drt.optimizer.*; import org.matsim.contrib.drt.optimizer.depot.DepotFinder; import org.matsim.contrib.drt.optimizer.insertion.CostCalculationStrategy; import org.matsim.contrib.drt.optimizer.insertion.DefaultInsertionCostCalculator; @@ -147,7 +141,10 @@ public EmptyVehicleChargingScheduler get() { bindModal(VehicleEntry.EntryFactory.class).toProvider( EDrtVehicleDataEntryFactory.EDrtVehicleDataEntryFactoryProvider.class).asEagerSingleton(); - bindModal(CostCalculationStrategy.class).to(drtCfg.rejectRequestIfMaxWaitOrTravelTimeViolated ? + DrtOptimizationConstraintsSet defaultConstraintsSet = drtCfg.addOrGetDrtOptimizationConstraintsParams().addOrGetDefaultDrtOptimizationConstraintsSet(); + bindModal(CostCalculationStrategy.class) + .to(defaultConstraintsSet.rejectRequestIfMaxWaitOrTravelTimeViolated + ? CostCalculationStrategy.RejectSoftConstraintViolations.class : CostCalculationStrategy.DiscourageSoftConstraintViolations.class).asEagerSingleton(); @@ -179,7 +176,8 @@ public EmptyVehicleRelocator get() { getter.getModal(StopTimeCalculator.class), scheduleWaitBeforeDrive))) .asEagerSingleton(); - bindModal(DefaultOfferAcceptor.class).toProvider(modalProvider(getter -> new DefaultOfferAcceptor(drtCfg.maxAllowedPickupDelay))); + bindModal(DefaultOfferAcceptor.class).toProvider(modalProvider(getter -> new DefaultOfferAcceptor( + defaultConstraintsSet.maxAllowedPickupDelay))); bindModal(DrtOfferAcceptor.class).to(modalKey(DefaultOfferAcceptor.class)); bindModal(ScheduleTimingUpdater.class).toProvider(modalProvider( diff --git a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/fiss/RunFissDrtScenarioIT.java b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/fiss/RunFissDrtScenarioIT.java index d9eda86cc8b..97f515ca57c 100644 --- a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/fiss/RunFissDrtScenarioIT.java +++ b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/fiss/RunFissDrtScenarioIT.java @@ -12,6 +12,7 @@ import org.matsim.contrib.drt.extension.operations.DrtWithOperationsConfigGroup; import org.matsim.contrib.drt.extension.operations.operationFacilities.OperationFacilitiesParams; import org.matsim.contrib.drt.extension.operations.shifts.config.ShiftsParams; +import org.matsim.contrib.drt.optimizer.DrtOptimizationConstraintsSet; import org.matsim.contrib.drt.optimizer.insertion.extensive.ExtensiveInsertionSearchParams; import org.matsim.contrib.drt.optimizer.rebalancing.RebalancingParams; import org.matsim.contrib.drt.optimizer.rebalancing.mincostflow.MinCostFlowRebalancingStrategyParams; @@ -53,16 +54,17 @@ void test() { DrtConfigGroup drtConfigGroup = drtWithShiftsConfigGroup; drtConfigGroup.mode = TransportMode.drt; - drtConfigGroup.maxTravelTimeAlpha = 1.5; - drtConfigGroup.maxTravelTimeBeta = 10. * 60.; drtConfigGroup.stopDuration = 30.; - drtConfigGroup.maxWaitTime = 600.; - drtConfigGroup.rejectRequestIfMaxWaitOrTravelTimeViolated = true; + DrtOptimizationConstraintsSet defaultConstraintsSet = drtConfigGroup.addOrGetDrtOptimizationConstraintsParams().addOrGetDefaultDrtOptimizationConstraintsSet(); + defaultConstraintsSet.maxTravelTimeAlpha = 1.5; + defaultConstraintsSet.maxTravelTimeBeta = 10. * 60.; + defaultConstraintsSet.maxWaitTime = 600.; + defaultConstraintsSet.rejectRequestIfMaxWaitOrTravelTimeViolated = true; + defaultConstraintsSet.maxWalkDistance = 1000.; drtConfigGroup.useModeFilteredSubnetwork = false; drtConfigGroup.vehiclesFile = fleetFile; drtConfigGroup.operationalScheme = DrtConfigGroup.OperationalScheme.door2door; drtConfigGroup.plotDetailedCustomerStats = true; - drtConfigGroup.maxWalkDistance = 1000.; drtConfigGroup.idleVehiclesReturnToDepots = false; drtConfigGroup.addParameterSet(new ExtensiveInsertionSearchParams()); diff --git a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/eshifts/run/RunEShiftDrtScenarioIT.java b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/eshifts/run/RunEShiftDrtScenarioIT.java index 2bd5fdffc27..06fd5ea4eaf 100644 --- a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/eshifts/run/RunEShiftDrtScenarioIT.java +++ b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/eshifts/run/RunEShiftDrtScenarioIT.java @@ -9,6 +9,7 @@ import org.matsim.contrib.drt.extension.operations.EDrtOperationsControlerCreator; import org.matsim.contrib.drt.extension.operations.operationFacilities.OperationFacilitiesParams; import org.matsim.contrib.drt.extension.operations.shifts.config.ShiftsParams; +import org.matsim.contrib.drt.optimizer.DrtOptimizationConstraintsSet; import org.matsim.contrib.drt.optimizer.insertion.extensive.ExtensiveInsertionSearchParams; import org.matsim.contrib.drt.optimizer.rebalancing.RebalancingParams; import org.matsim.contrib.drt.optimizer.rebalancing.mincostflow.MinCostFlowRebalancingStrategyParams; @@ -56,16 +57,17 @@ void test() { DrtConfigGroup drtConfigGroup = drtWithShiftsConfigGroup; drtConfigGroup.mode = TransportMode.drt; - drtConfigGroup.maxTravelTimeAlpha = 1.5; - drtConfigGroup.maxTravelTimeBeta = 10. * 60.; + DrtOptimizationConstraintsSet constraintsSet = drtConfigGroup.addOrGetDrtOptimizationConstraintsParams().addOrGetDefaultDrtOptimizationConstraintsSet(); + constraintsSet.maxTravelTimeAlpha = 1.5; + constraintsSet.maxTravelTimeBeta = 10. * 60.; drtConfigGroup.stopDuration = 30.; - drtConfigGroup.maxWaitTime = 600.; - drtConfigGroup.rejectRequestIfMaxWaitOrTravelTimeViolated = true; + constraintsSet.maxWaitTime = 600.; + constraintsSet.rejectRequestIfMaxWaitOrTravelTimeViolated = true; drtConfigGroup.useModeFilteredSubnetwork = false; drtConfigGroup.vehiclesFile = fleetFile; drtConfigGroup.operationalScheme = DrtConfigGroup.OperationalScheme.door2door; drtConfigGroup.plotDetailedCustomerStats = true; - drtConfigGroup.maxWalkDistance = 1000.; + constraintsSet.maxWalkDistance = 1000.; drtConfigGroup.idleVehiclesReturnToDepots = false; drtConfigGroup.addParameterSet(new ExtensiveInsertionSearchParams()); diff --git a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/shifts/run/RunMultiHubShiftDrtScenarioIT.java b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/shifts/run/RunMultiHubShiftDrtScenarioIT.java index b0b5089b81e..bc9243a24fa 100644 --- a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/shifts/run/RunMultiHubShiftDrtScenarioIT.java +++ b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/shifts/run/RunMultiHubShiftDrtScenarioIT.java @@ -9,6 +9,7 @@ import org.matsim.contrib.drt.extension.operations.DrtOperationsParams; import org.matsim.contrib.drt.extension.operations.operationFacilities.OperationFacilitiesParams; import org.matsim.contrib.drt.extension.operations.shifts.config.ShiftsParams; +import org.matsim.contrib.drt.optimizer.DrtOptimizationConstraintsSet; import org.matsim.contrib.drt.optimizer.insertion.extensive.ExtensiveInsertionSearchParams; import org.matsim.contrib.drt.optimizer.rebalancing.RebalancingParams; import org.matsim.contrib.drt.optimizer.rebalancing.mincostflow.MinCostFlowRebalancingStrategyParams; @@ -45,16 +46,17 @@ void test() { DrtConfigGroup drtConfigGroup = drtWithShiftsConfigGroup; drtConfigGroup.mode = TransportMode.drt; - drtConfigGroup.maxTravelTimeAlpha = 1.5; - drtConfigGroup.maxTravelTimeBeta = 10. * 60.; + DrtOptimizationConstraintsSet defaultConstraintsSet = drtConfigGroup.addOrGetDrtOptimizationConstraintsParams().addOrGetDefaultDrtOptimizationConstraintsSet(); drtConfigGroup.stopDuration = 30.; - drtConfigGroup.maxWaitTime = 600.; - drtConfigGroup.rejectRequestIfMaxWaitOrTravelTimeViolated = true; + defaultConstraintsSet.maxTravelTimeAlpha = 1.5; + defaultConstraintsSet.maxTravelTimeBeta = 10. * 60.; + defaultConstraintsSet.maxWaitTime = 600.; + defaultConstraintsSet.rejectRequestIfMaxWaitOrTravelTimeViolated = true; + defaultConstraintsSet.maxWalkDistance = 1000.; drtConfigGroup.useModeFilteredSubnetwork = false; drtConfigGroup.vehiclesFile = fleetFile; drtConfigGroup.operationalScheme = DrtConfigGroup.OperationalScheme.door2door; drtConfigGroup.plotDetailedCustomerStats = true; - drtConfigGroup.maxWalkDistance = 1000.; drtConfigGroup.idleVehiclesReturnToDepots = false; drtConfigGroup.addParameterSet(new ExtensiveInsertionSearchParams()); diff --git a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/shifts/run/RunShiftDrtScenarioIT.java b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/shifts/run/RunShiftDrtScenarioIT.java index 1d85910ebec..c2b671c90e7 100644 --- a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/shifts/run/RunShiftDrtScenarioIT.java +++ b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/shifts/run/RunShiftDrtScenarioIT.java @@ -9,6 +9,7 @@ import org.matsim.contrib.drt.extension.operations.DrtWithOperationsConfigGroup; import org.matsim.contrib.drt.extension.operations.operationFacilities.OperationFacilitiesParams; import org.matsim.contrib.drt.extension.operations.shifts.config.ShiftsParams; +import org.matsim.contrib.drt.optimizer.DrtOptimizationConstraintsSet; import org.matsim.contrib.drt.optimizer.insertion.extensive.ExtensiveInsertionSearchParams; import org.matsim.contrib.drt.optimizer.rebalancing.RebalancingParams; import org.matsim.contrib.drt.optimizer.rebalancing.mincostflow.MinCostFlowRebalancingStrategyParams; @@ -44,38 +45,38 @@ void test() { DrtWithOperationsConfigGroup drtWithShiftsConfigGroup = (DrtWithOperationsConfigGroup) multiModeDrtConfigGroup.createParameterSet("drt"); - DrtConfigGroup drtConfigGroup = drtWithShiftsConfigGroup; - drtConfigGroup.mode = TransportMode.drt; - drtConfigGroup.maxTravelTimeAlpha = 1.5; - drtConfigGroup.maxTravelTimeBeta = 10. * 60.; - drtConfigGroup.stopDuration = 30.; - drtConfigGroup.maxWaitTime = 600.; - drtConfigGroup.rejectRequestIfMaxWaitOrTravelTimeViolated = true; - drtConfigGroup.useModeFilteredSubnetwork = false; - drtConfigGroup.vehiclesFile = fleetFile; - drtConfigGroup.operationalScheme = DrtConfigGroup.OperationalScheme.door2door; - drtConfigGroup.plotDetailedCustomerStats = true; - drtConfigGroup.maxWalkDistance = 1000.; - drtConfigGroup.idleVehiclesReturnToDepots = false; - - drtConfigGroup.addParameterSet(new ExtensiveInsertionSearchParams()); - - ConfigGroup rebalancing = drtConfigGroup.createParameterSet("rebalancing"); - drtConfigGroup.addParameterSet(rebalancing); + drtWithShiftsConfigGroup.mode = TransportMode.drt; + DrtOptimizationConstraintsSet defaultConstraintsSet = drtWithShiftsConfigGroup.addOrGetDrtOptimizationConstraintsParams().addOrGetDefaultDrtOptimizationConstraintsSet(); + drtWithShiftsConfigGroup.stopDuration = 30.; + defaultConstraintsSet.maxTravelTimeAlpha = 1.5; + defaultConstraintsSet.maxTravelTimeBeta = 10. * 60.; + defaultConstraintsSet.maxWaitTime = 600.; + defaultConstraintsSet.rejectRequestIfMaxWaitOrTravelTimeViolated = true; + defaultConstraintsSet.maxWalkDistance = 1000.; + drtWithShiftsConfigGroup.useModeFilteredSubnetwork = false; + drtWithShiftsConfigGroup.vehiclesFile = fleetFile; + drtWithShiftsConfigGroup.operationalScheme = DrtConfigGroup.OperationalScheme.door2door; + drtWithShiftsConfigGroup.plotDetailedCustomerStats = true; + drtWithShiftsConfigGroup.idleVehiclesReturnToDepots = false; + + drtWithShiftsConfigGroup.addParameterSet(new ExtensiveInsertionSearchParams()); + + ConfigGroup rebalancing = drtWithShiftsConfigGroup.createParameterSet("rebalancing"); + drtWithShiftsConfigGroup.addParameterSet(rebalancing); ((RebalancingParams) rebalancing).interval = 600; MinCostFlowRebalancingStrategyParams strategyParams = new MinCostFlowRebalancingStrategyParams(); strategyParams.targetAlpha = 0.3; strategyParams.targetBeta = 0.3; - drtConfigGroup.getRebalancingParams().get().addParameterSet(strategyParams); + drtWithShiftsConfigGroup.getRebalancingParams().get().addParameterSet(strategyParams); DrtZoneSystemParams drtZoneSystemParams = new DrtZoneSystemParams(); SquareGridZoneSystemParams zoneParams = (SquareGridZoneSystemParams) drtZoneSystemParams.createParameterSet(SquareGridZoneSystemParams.SET_NAME); zoneParams.cellSize = 500.; drtZoneSystemParams.addParameterSet(zoneParams); drtZoneSystemParams.targetLinkSelection = DrtZoneSystemParams.TargetLinkSelection.mostCentral; - drtConfigGroup.addParameterSet(drtZoneSystemParams); + drtWithShiftsConfigGroup.addParameterSet(drtZoneSystemParams); multiModeDrtConfigGroup.addParameterSet(drtWithShiftsConfigGroup); diff --git a/contribs/drt/pom.xml b/contribs/drt/pom.xml index 5ae4b7b984c..eda34a832d3 100644 --- a/contribs/drt/pom.xml +++ b/contribs/drt/pom.xml @@ -51,12 +51,6 @@ ${geotools.version} - - org.geotools - gt-opengis - ${geotools.version} - - org.locationtech.jts jts-core diff --git a/contribs/drt/src/main/java/org/matsim/contrib/drt/analysis/DrtAnalysisControlerListener.java b/contribs/drt/src/main/java/org/matsim/contrib/drt/analysis/DrtAnalysisControlerListener.java index edc20fb87b7..67ee1973686 100644 --- a/contribs/drt/src/main/java/org/matsim/contrib/drt/analysis/DrtAnalysisControlerListener.java +++ b/contribs/drt/src/main/java/org/matsim/contrib/drt/analysis/DrtAnalysisControlerListener.java @@ -44,6 +44,7 @@ import org.matsim.contrib.common.timeprofile.TimeProfileCharts; import org.matsim.contrib.common.util.ChartSaveUtils; import org.matsim.contrib.drt.analysis.DrtEventSequenceCollector.EventSequence; +import org.matsim.contrib.drt.optimizer.DrtOptimizationConstraintsSet; import org.matsim.contrib.drt.passenger.events.DrtRequestSubmittedEvent; import org.matsim.contrib.drt.run.DrtConfigGroup; import org.matsim.contrib.drt.schedule.DrtStayTask; @@ -400,7 +401,7 @@ private void writeAndPlotWaitTimeEstimateComparison(Collection pe if (createChart) { final JFreeChart chart2 = DensityScatterPlots.createPlot("Wait times", "Actual wait time [s]", "Initially planned wait time [s]", - times, Pair.of(0., drtCfg.maxWaitTime)); + times, Pair.of(0., drtCfg.addOrGetDrtOptimizationConstraintsParams().addOrGetDefaultDrtOptimizationConstraintsSet().maxWaitTime)); // xAxis.setLowerBound(0); // yAxis.setLowerBound(0); ChartUtils.writeChartAsPNG(new FileOutputStream(plotFileName), chart2, 1500, 1500); @@ -663,12 +664,15 @@ private static void analyseDetours(Network network, List legs, Map new DefaultOfferAcceptor(drtCfg.maxAllowedPickupDelay))); + bindModal(DefaultOfferAcceptor.class).toProvider(modalProvider(getter -> new DefaultOfferAcceptor( + defaultOptimizationConstraintsSet.maxAllowedPickupDelay))); bindModal(DrtOfferAcceptor.class).to(modalKey(DefaultOfferAcceptor.class)); bindModal(ScheduleTimingUpdater.class).toProvider(modalProvider( diff --git a/contribs/drt/src/main/java/org/matsim/contrib/drt/optimizer/DrtOptimizationConstraintsParams.java b/contribs/drt/src/main/java/org/matsim/contrib/drt/optimizer/DrtOptimizationConstraintsParams.java new file mode 100644 index 00000000000..9f517b8b862 --- /dev/null +++ b/contribs/drt/src/main/java/org/matsim/contrib/drt/optimizer/DrtOptimizationConstraintsParams.java @@ -0,0 +1,80 @@ +package org.matsim.contrib.drt.optimizer; + +import com.google.common.base.Verify; +import org.matsim.core.config.Config; +import org.matsim.core.config.ReflectiveConfigGroup; + +import java.util.List; +import java.util.Optional; + +/** + * @author nkuehnel / MOIA + */ +public class DrtOptimizationConstraintsParams extends ReflectiveConfigGroup { + + public static final String SET_NAME = "drtOptimizationConstraints"; + + public static String defaultConstraintSet = DrtOptimizationConstraintsSet.DEFAULT_PARAMS_NAME; + + + public DrtOptimizationConstraintsParams() { + super(SET_NAME); + } + + @Override + protected void checkConsistency(Config config) { + super.checkConsistency(config); + List drtOptimizationConstraintsSets = getDrtOptimizationConstraintsSets(); + + Verify.verify(!drtOptimizationConstraintsSets.isEmpty(), + "At least one DrtOptimizationConstraintsParams is required."); + Verify.verify(drtOptimizationConstraintsSets.stream() + .anyMatch(params -> params.name.equals(defaultConstraintSet)), + "Default DrtOptimizationConstraintsParams is required."); + Verify.verify(drtOptimizationConstraintsSets.stream() + .map(params -> params.name) + .distinct() + .count() == drtOptimizationConstraintsSets.size(), + "Cannot have DrtOptimizationConstraintsParams with identical names."); + } + + public List getDrtOptimizationConstraintsSets() { + return getParameterSets(DrtOptimizationConstraintsSet.SET_NAME).stream() + .filter(DrtOptimizationConstraintsSet.class::isInstance) + .map(DrtOptimizationConstraintsSet.class::cast) + .toList(); + } + + public DrtOptimizationConstraintsSet addOrGetDefaultDrtOptimizationConstraintsSet() { + Optional drtOptParams = getDrtOptimizationConstraintsSets().stream() + .filter(params -> params.name.equals(defaultConstraintSet)) + .findAny(); + if (drtOptParams.isEmpty()) { + addParameterSet(new DrtOptimizationConstraintsSet()); + } + return getDrtOptimizationConstraintsSets().stream() + .filter(params -> params.name.equals(defaultConstraintSet)) + .findAny().orElseThrow(); + } + + /** + * for backwards compatibility with old drt config groups + */ + public void handleAddUnknownParam(final String paramName, final String value) { + switch (paramName) { + case "maxWaitTime": + case "maxTravelTimeAlpha": + case "maxTravelTimeBeta": + case "maxAbsoluteDetour": + case "maxDetourAlpha": + case "maxDetourBeta": + case "maxAllowedPickupDelay": + case "rejectRequestIfMaxWaitOrTravelTimeViolated": + case "maxWalkDistance": + addOrGetDefaultDrtOptimizationConstraintsSet().addParam(paramName, value); + break; + default: + super.handleAddUnknownParam(paramName, value); + } + } +} \ No newline at end of file diff --git a/contribs/drt/src/main/java/org/matsim/contrib/drt/optimizer/DrtOptimizationConstraintsSet.java b/contribs/drt/src/main/java/org/matsim/contrib/drt/optimizer/DrtOptimizationConstraintsSet.java new file mode 100644 index 00000000000..d80bc047b4e --- /dev/null +++ b/contribs/drt/src/main/java/org/matsim/contrib/drt/optimizer/DrtOptimizationConstraintsSet.java @@ -0,0 +1,99 @@ +package org.matsim.contrib.drt.optimizer; + +import com.google.common.base.Verify; +import jakarta.validation.constraints.DecimalMin; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.PositiveOrZero; +import org.matsim.core.config.Config; +import org.matsim.core.config.ReflectiveConfigGroup; + +public class DrtOptimizationConstraintsSet extends ReflectiveConfigGroup { + + public static final String SET_NAME = "drtOptimizationConstraintsSet"; + public static final String DEFAULT_PARAMS_NAME = "default"; + + public DrtOptimizationConstraintsSet() { + super(SET_NAME); + } + + @Parameter + @Comment("name of optimization params") + @NotBlank + public String name = DEFAULT_PARAMS_NAME; + + @Parameter + @Comment("Max wait time for the bus to come (optimisation constraint).") + @PositiveOrZero + public double maxWaitTime = Double.NaN;// seconds + + @Parameter + @Comment("Defines the slope of the maxTravelTime estimation function (optimisation constraint), i.e. " + + "min(unsharedRideTime + maxAbsoluteDetour, maxTravelTimeAlpha * unsharedRideTime + maxTravelTimeBeta). " + + "Alpha should not be smaller than 1.") + @DecimalMin("1.0") + public double maxTravelTimeAlpha = Double.NaN;// [-] + + @Parameter + @Comment("Defines the shift of the maxTravelTime estimation function (optimisation constraint), i.e. " + + "min(unsharedRideTime + maxAbsoluteDetour, maxTravelTimeAlpha * unsharedRideTime + maxTravelTimeBeta). " + + "Beta should not be smaller than 0.") + @PositiveOrZero + public double maxTravelTimeBeta = Double.NaN;// [s] + + @Parameter + @Comment( + "Defines the maximum allowed absolute detour in seconds. Note that the detour is computed from the latest promised pickup time. " + + "To enable the max detour constraint, maxAllowedPickupDelay has to be specified. maxAbsoluteDetour should not be smaller than 0, " + + "and should be higher than the offset maxDetourBeta. By default, this limit is disabled (i.e. set to Inf)") + @PositiveOrZero + public double maxAbsoluteDetour = Double.POSITIVE_INFINITY;// [s] + + @Parameter + @Comment( + "Defines the maximum allowed absolute detour based on the unsharedRideTime. Note that the detour is computed from the latest promised " + + "pickup time. To enable the max detour constraint, maxAllowedPickupDelay has to be specified. A linear combination similar to travel " + + "time constrain is used. This is the ratio part. By default, this limit is disabled (i.e. set to Inf, together with maxDetourBeta).") + @DecimalMin("1.0") + public double maxDetourAlpha = Double.POSITIVE_INFINITY; + + @Parameter + @Comment( + "Defines the maximum allowed absolute detour based on the unsharedRideTime. Note that the detour is computed from the latest promised " + + "pickup time. To enable the max detour constraint, maxAllowedPickupDelay has to be specified. A linear combination similar to travel " + + "time constrain is used. This is the constant part. By default, this limit is disabled (i.e. set to Inf, together with maxDetourAlpha).") + @PositiveOrZero + public double maxDetourBeta = Double.POSITIVE_INFINITY;// [s] + + @Parameter + @Comment( + "Defines the maximum delay allowed from the initial scheduled pick up time. Once the initial pickup time is offered, the latest promised" + + "pickup time is calculated based on initial scheduled pickup time + maxAllowedPickupDelay. " + + "By default, this limit is disabled. If enabled, a value between 0 and 240 is a good choice.") + @PositiveOrZero + public double maxAllowedPickupDelay = Double.POSITIVE_INFINITY;// [s] + + @Parameter + @Comment("If true, the max travel and wait times of a submitted request" + + " are considered hard constraints (the request gets rejected if one of the constraints is violated)." + + " If false, the max travel and wait times are considered soft constraints (insertion of a request that" + + " violates one of the constraints is allowed, but its cost is increased by additional penalty to make" + + " it relatively less attractive). Penalisation of insertions can be customised by injecting a customised" + + " InsertionCostCalculator.PenaltyCalculator") + public boolean rejectRequestIfMaxWaitOrTravelTimeViolated = true;//TODO consider renaming maxWalkDistance to max access/egress distance (or even have 2 separate params) + + @Parameter + @Comment( + "Maximum beeline distance (in meters) to next stop location in stopbased system for access/egress walk leg to/from drt." + + " If no stop can be found within this maximum distance will return null (in most cases caught by fallback routing module).") + @PositiveOrZero // used only for stopbased DRT scheme + public double maxWalkDistance = Double.MAX_VALUE;// [m]; + + @Override + protected void checkConsistency(Config config) { + super.checkConsistency(config); + if ((maxDetourAlpha != Double.POSITIVE_INFINITY && maxDetourBeta != Double.POSITIVE_INFINITY) || maxAbsoluteDetour != Double.POSITIVE_INFINITY) { + Verify.verify(maxAllowedPickupDelay != Double.POSITIVE_INFINITY, "Detour constraints are activated, " + + "maxAllowedPickupDelay must be specified! A value between 0 and 240 seconds can be a good choice for maxAllowedPickupDelay."); + } + } +} diff --git a/contribs/drt/src/main/java/org/matsim/contrib/drt/prebooking/PrebookingStopActivity.java b/contribs/drt/src/main/java/org/matsim/contrib/drt/prebooking/PrebookingStopActivity.java index 268521d4ada..1e1965d11a6 100644 --- a/contribs/drt/src/main/java/org/matsim/contrib/drt/prebooking/PrebookingStopActivity.java +++ b/contribs/drt/src/main/java/org/matsim/contrib/drt/prebooking/PrebookingStopActivity.java @@ -131,19 +131,19 @@ private boolean updatePickupRequests(double now) { var enterIterator = enterTimes.entrySet().iterator(); while (enterIterator.hasNext()) { - if (onboard >= vehicle.getCapacity()) { - // only let people enter if there is currently free capacity - break; - } - var entry = enterIterator.next(); + int availableCapacity = vehicle.getCapacity() - onboard; if (entry.getValue() <= now) { - // let agent enter now - Verify.verify(passengerHandler.tryPickUpPassengers(this, driver, entry.getKey(), now)); - enteredRequests.add(entry.getKey()); - onboard += pickupRequests.get(entry.getKey()).getPassengerCount(); - enterIterator.remove(); + int requiredCapacity = pickupRequests.get(entry.getKey()).getPassengerCount(); + + if (requiredCapacity <= availableCapacity) { + // let agent enter now + Verify.verify(passengerHandler.tryPickUpPassengers(this, driver, entry.getKey(), now)); + enteredRequests.add(entry.getKey()); + onboard += requiredCapacity; + enterIterator.remove(); + } } } diff --git a/contribs/drt/src/main/java/org/matsim/contrib/drt/routing/DrtRouteCreator.java b/contribs/drt/src/main/java/org/matsim/contrib/drt/routing/DrtRouteCreator.java index 15f9bb77530..9cb031a9ebf 100644 --- a/contribs/drt/src/main/java/org/matsim/contrib/drt/routing/DrtRouteCreator.java +++ b/contribs/drt/src/main/java/org/matsim/contrib/drt/routing/DrtRouteCreator.java @@ -23,6 +23,7 @@ import org.matsim.api.core.v01.network.Network; import org.matsim.api.core.v01.population.Person; import org.matsim.api.core.v01.population.Route; +import org.matsim.contrib.drt.optimizer.DrtOptimizationConstraintsSet; import org.matsim.contrib.drt.run.DrtConfigGroup; import org.matsim.contrib.dvrp.path.VrpPathWithTravelData; import org.matsim.contrib.dvrp.path.VrpPaths; @@ -61,7 +62,9 @@ public DrtRouteCreator(DrtConfigGroup drtCfg, Network modalNetwork, * @return maximum travel time */ static double getMaxTravelTime(DrtConfigGroup drtCfg, double unsharedRideTime) { - return drtCfg.maxTravelTimeAlpha * unsharedRideTime + drtCfg.maxTravelTimeBeta; + DrtOptimizationConstraintsSet defaultConstraintsSet = drtCfg.addOrGetDrtOptimizationConstraintsParams().addOrGetDefaultDrtOptimizationConstraintsSet(); + return defaultConstraintsSet.maxTravelTimeAlpha * unsharedRideTime + + defaultConstraintsSet.maxTravelTimeBeta; } /** @@ -72,7 +75,10 @@ static double getMaxTravelTime(DrtConfigGroup drtCfg, double unsharedRideTime) { * @return maximum ride time */ static double getMaxRideTime(DrtConfigGroup drtCfg, double unsharedRideTime) { - return Math.min(unsharedRideTime + drtCfg.maxAbsoluteDetour, drtCfg.maxDetourAlpha * unsharedRideTime + drtCfg.maxDetourBeta); + DrtOptimizationConstraintsSet defaultConstraintsSet = drtCfg.addOrGetDrtOptimizationConstraintsParams().addOrGetDefaultDrtOptimizationConstraintsSet(); + return Math.min(unsharedRideTime + defaultConstraintsSet.maxAbsoluteDetour, + defaultConstraintsSet.maxDetourAlpha * unsharedRideTime + + defaultConstraintsSet.maxDetourBeta); } public Route createRoute(double departureTime, Link accessActLink, Link egressActLink, Person person, @@ -89,7 +95,7 @@ public Route createRoute(double departureTime, Link accessActLink, Link egressAc route.setTravelTime(maxTravelTime); route.setMaxRideTime(maxRideDuration); route.setDirectRideTime(unsharedRideTime); - route.setMaxWaitTime(drtCfg.maxWaitTime); + route.setMaxWaitTime(drtCfg.addOrGetDrtOptimizationConstraintsParams().addOrGetDefaultDrtOptimizationConstraintsSet().maxWaitTime); if (this.drtCfg.storeUnsharedPath) { route.setUnsharedPath(unsharedPath); diff --git a/contribs/drt/src/main/java/org/matsim/contrib/drt/run/DrtConfigGroup.java b/contribs/drt/src/main/java/org/matsim/contrib/drt/run/DrtConfigGroup.java index 2e1923688c6..b271a8690e8 100644 --- a/contribs/drt/src/main/java/org/matsim/contrib/drt/run/DrtConfigGroup.java +++ b/contribs/drt/src/main/java/org/matsim/contrib/drt/run/DrtConfigGroup.java @@ -19,20 +19,21 @@ package org.matsim.contrib.drt.run; -import static org.matsim.core.config.groups.QSimConfigGroup.EndtimeInterpretation; - import java.util.Collection; +import java.util.List; import java.util.Optional; import javax.annotation.Nullable; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.checkerframework.checker.units.qual.C; import org.matsim.api.core.v01.TransportMode; +import org.matsim.contrib.common.util.ReflectiveConfigGroupWithConfigurableParameterSets; import org.matsim.contrib.drt.analysis.zonal.DrtZoneSystemParams; import org.matsim.contrib.drt.estimator.DrtEstimatorParams; import org.matsim.contrib.drt.fare.DrtFareParams; +import org.matsim.contrib.drt.optimizer.DrtOptimizationConstraintsParams; +import org.matsim.contrib.drt.optimizer.DrtOptimizationConstraintsSet; import org.matsim.contrib.drt.optimizer.DrtRequestInsertionRetryParams; import org.matsim.contrib.drt.optimizer.insertion.DrtInsertionSearchParams; import org.matsim.contrib.drt.optimizer.insertion.extensive.ExtensiveInsertionSearchParams; @@ -44,19 +45,17 @@ import org.matsim.contrib.drt.speedup.DrtSpeedUpParams; import org.matsim.contrib.dvrp.router.DvrpModeRoutingNetworkModule; import org.matsim.contrib.dvrp.run.Modal; -import org.matsim.contrib.common.util.ReflectiveConfigGroupWithConfigurableParameterSets; import org.matsim.core.config.Config; -import org.matsim.core.config.groups.ScoringConfigGroup; +import org.matsim.core.config.groups.QSimConfigGroup.EndtimeInterpretation; import org.matsim.core.config.groups.RoutingConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; import com.google.common.base.Preconditions; import com.google.common.base.Verify; -import jakarta.validation.constraints.DecimalMin; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.Positive; -import jakarta.validation.constraints.PositiveOrZero; public class DrtConfigGroup extends ReflectiveConfigGroupWithConfigurableParameterSets implements Modal { private static final Logger log = LogManager.getLogger(DrtConfigGroup.class); @@ -88,66 +87,6 @@ public static DrtConfigGroup getSingleModeDrtConfig(Config config) { @Positive public double stopDuration = Double.NaN;// seconds - @Parameter - @Comment("Max wait time for the bus to come (optimisation constraint).") - @PositiveOrZero - public double maxWaitTime = Double.NaN;// seconds - - @Parameter - @Comment("Defines the slope of the maxTravelTime estimation function (optimisation constraint), i.e. " - + "min(unsharedRideTime + maxAbsoluteDetour, maxTravelTimeAlpha * unsharedRideTime + maxTravelTimeBeta). " - + "Alpha should not be smaller than 1.") - @DecimalMin("1.0") - public double maxTravelTimeAlpha = Double.NaN;// [-] - - @Parameter - @Comment("Defines the shift of the maxTravelTime estimation function (optimisation constraint), i.e. " - + "min(unsharedRideTime + maxAbsoluteDetour, maxTravelTimeAlpha * unsharedRideTime + maxTravelTimeBeta). " - + "Beta should not be smaller than 0.") - @PositiveOrZero - public double maxTravelTimeBeta = Double.NaN;// [s] - - @Parameter - @Comment( - "Defines the maximum allowed absolute detour in seconds. Note that the detour is computed from the latest promised pickup time. " + - "To enable the max detour constraint, maxAllowedPickupDelay has to be specified. maxAbsoluteDetour should not be smaller than 0, " - + "and should be higher than the offset maxDetourBeta. By default, this limit is disabled (i.e. set to Inf)") - @PositiveOrZero - public double maxAbsoluteDetour = Double.POSITIVE_INFINITY;// [s] - - @Parameter - @Comment( - "Defines the maximum allowed absolute detour based on the unsharedRideTime. Note that the detour is computed from the latest promised " - + "pickup time. To enable the max detour constraint, maxAllowedPickupDelay has to be specified. A linear combination similar to travel " - + "time constrain is used. This is the ratio part. By default, this limit is disabled (i.e. set to Inf, together with maxDetourBeta).") - @DecimalMin("1.0") - public double maxDetourAlpha = Double.POSITIVE_INFINITY; - - @Parameter - @Comment( - "Defines the maximum allowed absolute detour based on the unsharedRideTime. Note that the detour is computed from the latest promised " - + "pickup time. To enable the max detour constraint, maxAllowedPickupDelay has to be specified. A linear combination similar to travel " - + "time constrain is used. This is the constant part. By default, this limit is disabled (i.e. set to Inf, together with maxDetourAlpha).") - @PositiveOrZero - public double maxDetourBeta = Double.POSITIVE_INFINITY;// [s] - - @Parameter - @Comment( - "Defines the maximum delay allowed from the initial scheduled pick up time. Once the initial pickup time is offered, the latest promised" - + "pickup time is calculated based on initial scheduled pickup time + maxAllowedPickupDelay. " - + "By default, this limit is disabled. If enabled, a value between 0 and 240 is a good choice.") - @PositiveOrZero - public double maxAllowedPickupDelay = Double.POSITIVE_INFINITY;// [s] - - @Parameter - @Comment("If true, the max travel and wait times of a submitted request" - + " are considered hard constraints (the request gets rejected if one of the constraints is violated)." - + " If false, the max travel and wait times are considered soft constraints (insertion of a request that" - + " violates one of the constraints is allowed, but its cost is increased by additional penalty to make" - + " it relatively less attractive). Penalisation of insertions can be customised by injecting a customised" - + " InsertionCostCalculator.PenaltyCalculator") - public boolean rejectRequestIfMaxWaitOrTravelTimeViolated = true; - @Parameter @Comment("If true, the startLink is changed to last link in the current schedule, so the taxi starts the next " + "day at the link where it stopped operating the day before. False by default.") @@ -175,14 +114,6 @@ public enum OperationalScheme { @NotNull public OperationalScheme operationalScheme = OperationalScheme.door2door; - //TODO consider renaming maxWalkDistance to max access/egress distance (or even have 2 separate params) - @Parameter - @Comment( - "Maximum beeline distance (in meters) to next stop location in stopbased system for access/egress walk leg to/from drt." - + " If no stop can be found within this maximum distance will return null (in most cases caught by fallback routing module).") - @PositiveOrZero // used only for stopbased DRT scheme - public double maxWalkDistance = Double.MAX_VALUE;// [m]; - @Parameter @Comment("An XML file specifying the vehicle fleet." + " The file format according to dvrp_vehicles_v1.dtd" @@ -230,6 +161,9 @@ public enum SimulationType { @NotNull private DrtInsertionSearchParams drtInsertionSearchParams; + @NotNull + private DrtOptimizationConstraintsParams drtOptimizationConstraintsParams; + @Nullable private DrtZoneSystemParams zonalSystemParams; @@ -257,6 +191,12 @@ public DrtConfigGroup() { } private void initSingletonParameterSets() { + + //optimization constraints (mandatory) + addDefinition(DrtOptimizationConstraintsParams.SET_NAME, DrtOptimizationConstraintsParams::new, + () -> drtOptimizationConstraintsParams, + params -> drtOptimizationConstraintsParams = (DrtOptimizationConstraintsParams) params); + //rebalancing (optional) addDefinition(RebalancingParams.SET_NAME, RebalancingParams::new, () -> rebalancingParams, params -> rebalancingParams = (RebalancingParams)params); @@ -298,7 +238,27 @@ private void initSingletonParameterSets() { addDefinition(DrtEstimatorParams.SET_NAME, DrtEstimatorParams::new, () -> drtEstimatorParams, params -> drtEstimatorParams = (DrtEstimatorParams) params); + } + /** + * for backwards compatibility with old drt config groups + */ + public void handleAddUnknownParam(final String paramName, final String value) { + switch (paramName) { + case "maxWaitTime": + case "maxTravelTimeAlpha": + case "maxTravelTimeBeta": + case "maxAbsoluteDetour": + case "maxDetourAlpha": + case "maxDetourBeta": + case "maxAllowedPickupDelay": + case "rejectRequestIfMaxWaitOrTravelTimeViolated": + case "maxWalkDistance": + addOrGetDrtOptimizationConstraintsParams().addOrGetDefaultDrtOptimizationConstraintsSet().addParam(paramName, value); + break; + default: + super.handleAddUnknownParam(paramName, value); + } } @Override @@ -315,7 +275,11 @@ protected void checkConsistency(Config config) { + "attempting to travel without vehicles being available."); } - Verify.verify(maxWaitTime >= stopDuration, "maxWaitTime must not be smaller than stopDuration"); + List drtOptimizationConstraintsSets = addOrGetDrtOptimizationConstraintsParams().getDrtOptimizationConstraintsSets(); + for (DrtOptimizationConstraintsSet constraintsSet : drtOptimizationConstraintsSets) { + Verify.verify(constraintsSet.maxWaitTime >= stopDuration, + "maxWaitTime must not be smaller than stopDuration"); + } Verify.verify(operationalScheme != OperationalScheme.stopbased || transitStopFile != null, "transitStopFile must not be null when operationalScheme is " + OperationalScheme.stopbased); @@ -344,11 +308,6 @@ protected void checkConsistency(Config config) { DvrpModeRoutingNetworkModule.checkUseModeFilteredSubnetworkAllowed(config, mode); } - if ((maxDetourAlpha != Double.POSITIVE_INFINITY && maxDetourBeta != Double.POSITIVE_INFINITY) || maxAbsoluteDetour != Double.POSITIVE_INFINITY) { - Verify.verify(maxAllowedPickupDelay != Double.POSITIVE_INFINITY, "Detour constraints are activated, " + - "maxAllowedPickupDelay must be specified! A value between 0 and 240 seconds can be a good choice for maxAllowedPickupDelay."); - } - if (simulationType == SimulationType.estimateAndTeleport) { Verify.verify(drtSpeedUpParams == null, "Simulation type is estimateAndTeleport, but drtSpeedUpParams is set. " + "Please remove drtSpeedUpParams from the config, as these two functionalities are not compatible."); @@ -360,10 +319,19 @@ public String getMode() { return mode; } + + public DrtInsertionSearchParams getDrtInsertionSearchParams() { return drtInsertionSearchParams; } + public DrtOptimizationConstraintsParams addOrGetDrtOptimizationConstraintsParams() { + if(drtOptimizationConstraintsParams == null) { + drtOptimizationConstraintsParams = new DrtOptimizationConstraintsParams(); + } + return drtOptimizationConstraintsParams; + } + public Optional getZonalSystemParams() { return Optional.ofNullable(zonalSystemParams); } diff --git a/contribs/drt/src/main/java/org/matsim/contrib/drt/run/DrtModeRoutingModule.java b/contribs/drt/src/main/java/org/matsim/contrib/drt/run/DrtModeRoutingModule.java index 8d037b171dc..95c23eeaf17 100644 --- a/contribs/drt/src/main/java/org/matsim/contrib/drt/run/DrtModeRoutingModule.java +++ b/contribs/drt/src/main/java/org/matsim/contrib/drt/run/DrtModeRoutingModule.java @@ -104,7 +104,8 @@ public void install() { .asEagerSingleton(); case stopbased, serviceAreaBased -> { bindModal( AccessEgressFacilityFinder.class ).toProvider( modalProvider( - getter -> new ClosestAccessEgressFacilityFinder( drtCfg.maxWalkDistance, + getter -> new ClosestAccessEgressFacilityFinder( + drtCfg.addOrGetDrtOptimizationConstraintsParams().addOrGetDefaultDrtOptimizationConstraintsSet().maxWalkDistance, getter.get( Network.class ), QuadTrees.createQuadTree( getter.getModal( DrtStopNetwork.class ).getDrtStops().values() ) ) ) ) .asEagerSingleton(); diff --git a/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/MaxDetourConstraintTest.java b/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/MaxDetourConstraintTest.java index ec0e2a1f030..d15ae3dab03 100644 --- a/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/MaxDetourConstraintTest.java +++ b/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/MaxDetourConstraintTest.java @@ -36,17 +36,18 @@ public void testMaxDetourConstraint() { DrtConfigGroup drtConfigGroup = DrtConfigGroup.getSingleModeDrtConfig(config); // Max wait time - drtConfigGroup.maxWaitTime = 300; + DrtOptimizationConstraintsSet defaultConstraintsSet = drtConfigGroup.addOrGetDrtOptimizationConstraintsParams().addOrGetDefaultDrtOptimizationConstraintsSet(); + defaultConstraintsSet.maxWaitTime = 300; // Turn on the max detour constraint - drtConfigGroup.maxDetourAlpha = 1.5; - drtConfigGroup.maxDetourBeta = 300; - drtConfigGroup.maxAllowedPickupDelay = 180; - drtConfigGroup.maxAbsoluteDetour = 1200; + defaultConstraintsSet.maxDetourAlpha = 1.5; + defaultConstraintsSet.maxDetourBeta = 300; + defaultConstraintsSet.maxAllowedPickupDelay = 180; + defaultConstraintsSet.maxAbsoluteDetour = 1200; // Make the max total travel time constraints very loose (i.e., make it not active) - drtConfigGroup.maxTravelTimeAlpha = 10; - drtConfigGroup.maxTravelTimeBeta = 7200; + defaultConstraintsSet.maxTravelTimeAlpha = 10; + defaultConstraintsSet.maxTravelTimeBeta = 7200; config.controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists); config.controller().setOutputDirectory(utils.getOutputDirectory()); diff --git a/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/DrtPoolingParameterTest.java b/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/DrtPoolingParameterTest.java index 8451f93b1e2..96836e36303 100644 --- a/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/DrtPoolingParameterTest.java +++ b/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/DrtPoolingParameterTest.java @@ -10,6 +10,7 @@ import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.population.*; import org.matsim.contrib.common.zones.systems.grid.square.SquareGridZoneSystemParams; +import org.matsim.contrib.drt.optimizer.DrtOptimizationConstraintsSet; import org.matsim.contrib.drt.run.DrtControlerCreator; import org.matsim.contrib.drt.run.MultiModeDrtConfigGroup; import org.matsim.contrib.dvrp.fleet.DvrpVehicle; @@ -225,9 +226,10 @@ private PersonEnterDrtVehicleEventHandler setupAndRunScenario(double maxWaitTime MultiModeDrtConfigGroup mm = ConfigUtils.addOrGetModule(config, MultiModeDrtConfigGroup.class); mm.getModalElements().forEach(x -> { - x.maxWaitTime = maxWaitTime; - x.maxTravelTimeAlpha = maxTravelTimeAlpha; - x.maxTravelTimeBeta = maxTravelTimeBeta; + DrtOptimizationConstraintsSet defaultConstraintsSet = x.addOrGetDrtOptimizationConstraintsParams().addOrGetDefaultDrtOptimizationConstraintsSet(); + defaultConstraintsSet.maxWaitTime = maxWaitTime; + defaultConstraintsSet.maxTravelTimeAlpha = maxTravelTimeAlpha; + defaultConstraintsSet.maxTravelTimeBeta = maxTravelTimeBeta; x.stopDuration = 1.; }); diff --git a/contribs/drt/src/test/java/org/matsim/contrib/drt/prebooking/ComplexUnschedulerTest.java b/contribs/drt/src/test/java/org/matsim/contrib/drt/prebooking/ComplexUnschedulerTest.java index 93a59a769bd..b0d3e37c42f 100644 --- a/contribs/drt/src/test/java/org/matsim/contrib/drt/prebooking/ComplexUnschedulerTest.java +++ b/contribs/drt/src/test/java/org/matsim/contrib/drt/prebooking/ComplexUnschedulerTest.java @@ -626,7 +626,7 @@ private class Fixture { DrtConfigGroup drtConfig = new DrtConfigGroup(); drtConfig.stopDuration = 30.0; - drtConfig.maxWaitTime = 600.0; + drtConfig.addOrGetDrtOptimizationConstraintsParams().addOrGetDefaultDrtOptimizationConstraintsSet().maxWaitTime = 600.0; this.entryFactory = new VehicleDataEntryFactoryImpl(); diff --git a/contribs/drt/src/test/java/org/matsim/contrib/drt/prebooking/PrebookingTestEnvironment.java b/contribs/drt/src/test/java/org/matsim/contrib/drt/prebooking/PrebookingTestEnvironment.java index c97f2c34a81..f161c3ad9a1 100644 --- a/contribs/drt/src/test/java/org/matsim/contrib/drt/prebooking/PrebookingTestEnvironment.java +++ b/contribs/drt/src/test/java/org/matsim/contrib/drt/prebooking/PrebookingTestEnvironment.java @@ -10,6 +10,7 @@ import org.matsim.api.core.v01.network.Node; import org.matsim.api.core.v01.population.*; import org.matsim.contrib.common.zones.systems.grid.square.SquareGridZoneSystemParams; +import org.matsim.contrib.drt.optimizer.DrtOptimizationConstraintsSet; import org.matsim.contrib.drt.optimizer.insertion.DrtInsertionSearchParams; import org.matsim.contrib.drt.optimizer.insertion.selective.SelectiveInsertionSearchParams; import org.matsim.contrib.drt.passenger.events.DrtRequestSubmittedEvent; @@ -226,9 +227,10 @@ private void buildConfig(Config config) { DrtConfigGroup modeConfig = new DrtConfigGroup(); drtConfig.addParameterSet(modeConfig); modeConfig.mode = "drt"; - modeConfig.maxWaitTime = maximumWaitTime; - modeConfig.maxTravelTimeAlpha = detourRelative; - modeConfig.maxTravelTimeBeta = detourAbsolute; + DrtOptimizationConstraintsSet defaultConstraintsSet = modeConfig.addOrGetDrtOptimizationConstraintsParams().addOrGetDefaultDrtOptimizationConstraintsSet(); + defaultConstraintsSet.maxWaitTime = maximumWaitTime; + defaultConstraintsSet.maxTravelTimeAlpha = detourRelative; + defaultConstraintsSet.maxTravelTimeBeta = detourAbsolute; modeConfig.stopDuration = stopDuration; modeConfig.idleVehiclesReturnToDepots = false; modeConfig.vehiclesFile = null; diff --git a/contribs/drt/src/test/java/org/matsim/contrib/drt/routing/DrtRoutingModuleTest.java b/contribs/drt/src/test/java/org/matsim/contrib/drt/routing/DrtRoutingModuleTest.java index e4d242dabcf..459c3bf8965 100644 --- a/contribs/drt/src/test/java/org/matsim/contrib/drt/routing/DrtRoutingModuleTest.java +++ b/contribs/drt/src/test/java/org/matsim/contrib/drt/routing/DrtRoutingModuleTest.java @@ -36,6 +36,7 @@ import org.matsim.api.core.v01.population.Plan; import org.matsim.api.core.v01.population.PlanElement; import org.matsim.api.core.v01.population.PopulationFactory; +import org.matsim.contrib.drt.optimizer.DrtOptimizationConstraintsSet; import org.matsim.contrib.drt.run.DrtConfigGroup; import org.matsim.contrib.drt.run.DrtControlerCreator; import org.matsim.contrib.drt.run.MultiModeDrtConfigGroup; @@ -80,9 +81,10 @@ void testCottbusClosestAccessEgressStopFinder() { DrtConfigGroup drtCfg = DrtConfigGroup.getSingleModeDrtConfig(scenario.getConfig()); String drtMode = "DrtX"; drtCfg.mode = drtMode; - drtCfg.maxTravelTimeAlpha = 1.5; - drtCfg.maxTravelTimeBeta = 5 * 60; - drtCfg.maxWaitTime = 5 * 60; + DrtOptimizationConstraintsSet defaultConstraintsSet = drtCfg.addOrGetDrtOptimizationConstraintsParams().addOrGetDefaultDrtOptimizationConstraintsSet(); + defaultConstraintsSet.maxTravelTimeAlpha = 1.5; + defaultConstraintsSet.maxTravelTimeBeta = 5 * 60; + defaultConstraintsSet.maxWaitTime = 5 * 60; ImmutableMap, DrtStopFacility> drtStops = scenario.getTransitSchedule() .getFacilities() @@ -91,7 +93,8 @@ void testCottbusClosestAccessEgressStopFinder() { .map(DrtStopFacilityImpl::createFromFacility) .collect(ImmutableMap.toImmutableMap(DrtStopFacility::getId, f -> f)); - AccessEgressFacilityFinder stopFinder = new ClosestAccessEgressFacilityFinder(drtCfg.maxWalkDistance, + AccessEgressFacilityFinder stopFinder = new ClosestAccessEgressFacilityFinder( + defaultConstraintsSet.maxWalkDistance, scenario.getNetwork(), QuadTrees.createQuadTree(drtStops.values())); DrtRouteCreator drtRouteCreator = new DrtRouteCreator(drtCfg, scenario.getNetwork(), new SpeedyDijkstraFactory(), new FreeSpeedTravelTime(), TimeAsTravelDisutility::new); @@ -259,7 +262,7 @@ void testRouteDescriptionHandling() { private Scenario createTestScenario() { Config config = ConfigUtils.createConfig(); DrtConfigGroup drtConfigGroup = new DrtConfigGroup(); - drtConfigGroup.maxWalkDistance = 200; + drtConfigGroup.addOrGetDrtOptimizationConstraintsParams().addOrGetDefaultDrtOptimizationConstraintsSet().maxWalkDistance = 200; drtConfigGroup.transitStopFile = utils.getClassInputDirectory() + "testCottbus/drtstops.xml.gz"; MultiModeDrtConfigGroup multiModeDrtConfigGroup = new MultiModeDrtConfigGroup(); multiModeDrtConfigGroup.addParameterSet(drtConfigGroup); diff --git a/contribs/drt/src/test/java/org/matsim/contrib/drt/run/DrtConfigGroupTest.java b/contribs/drt/src/test/java/org/matsim/contrib/drt/run/DrtConfigGroupTest.java new file mode 100644 index 00000000000..ae9cd5c3f21 --- /dev/null +++ b/contribs/drt/src/test/java/org/matsim/contrib/drt/run/DrtConfigGroupTest.java @@ -0,0 +1,73 @@ +package org.matsim.contrib.drt.run; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.matsim.contrib.drt.optimizer.DrtOptimizationConstraintsParams; +import org.matsim.contrib.drt.optimizer.DrtOptimizationConstraintsSet; +import org.matsim.core.config.Config; +import org.matsim.core.config.ConfigUtils; + +import com.google.common.base.VerifyException; + +class DrtConfigGroupTest { + + @Test + void testHasDefaultDrtOptimizationConstraintsParam() { + Config config = ConfigUtils.createConfig(); + DrtConfigGroup drtConfig = new DrtConfigGroup(); + config.addModule(drtConfig); + + // get DrtOptimizationConstraintsParams + DrtOptimizationConstraintsSet params = drtConfig.addOrGetDrtOptimizationConstraintsParams().addOrGetDefaultDrtOptimizationConstraintsSet(); + + Assertions.assertEquals(DrtOptimizationConstraintsParams.defaultConstraintSet, params.name); + Assertions.assertThrows(VerifyException.class, () -> drtConfig.checkConsistency(config)); + drtConfig.stopDuration = 0; + params.maxWaitTime = drtConfig.stopDuration; + Assertions.assertDoesNotThrow(() -> drtConfig.checkConsistency(config)); + } + + @Test + void testMultipleDrtOptimizationConstraintsParams() { + Config config = ConfigUtils.createConfig(); + DrtConfigGroup drtConfig = new DrtConfigGroup(); + config.addModule(drtConfig); + + // add second DrtOptimizationConstraintsParams + DrtOptimizationConstraintsSet params = new DrtOptimizationConstraintsSet(); + params.name = "test"; + + DrtOptimizationConstraintsParams optimizationConstraintsParams = drtConfig.addOrGetDrtOptimizationConstraintsParams(); + optimizationConstraintsParams.addParameterSet(params); + + //default not yet present + Assertions.assertEquals(1, optimizationConstraintsParams.getDrtOptimizationConstraintsSets().size()); + + DrtOptimizationConstraintsSet defaultConstraints = optimizationConstraintsParams.addOrGetDefaultDrtOptimizationConstraintsSet(); + Assertions.assertEquals(2, optimizationConstraintsParams.getDrtOptimizationConstraintsSets().size()); + + drtConfig.stopDuration = 0; + params.maxWaitTime = drtConfig.stopDuration; + defaultConstraints.maxWaitTime = drtConfig.stopDuration; + + Assertions.assertDoesNotThrow(() -> drtConfig.checkConsistency(config)); + } + + @Test + void testNoDuplicateDrtDrtOptimizationConstraintsParams() { + Config config = ConfigUtils.createConfig(); + DrtConfigGroup drtConfig = new DrtConfigGroup(); + config.addModule(drtConfig); + + // add second DrtOptimizationConstraintsParams with same name + DrtOptimizationConstraintsSet params = new DrtOptimizationConstraintsSet(); + params.name = DrtOptimizationConstraintsSet.DEFAULT_PARAMS_NAME; + + DrtOptimizationConstraintsParams optimizationConstraintsParams = drtConfig.addOrGetDrtOptimizationConstraintsParams(); + optimizationConstraintsParams.addOrGetDefaultDrtOptimizationConstraintsSet(); + optimizationConstraintsParams.addParameterSet(params); + + Assertions.assertEquals(2, optimizationConstraintsParams.getDrtOptimizationConstraintsSets().size()); + Assertions.assertThrows(VerifyException.class, () -> drtConfig.checkConsistency(config)); + } +} diff --git a/contribs/drt/src/test/java/org/matsim/contrib/drt/run/examples/RunDrtExampleIT.java b/contribs/drt/src/test/java/org/matsim/contrib/drt/run/examples/RunDrtExampleIT.java index e1c1492fbed..0b2adb16db2 100644 --- a/contribs/drt/src/test/java/org/matsim/contrib/drt/run/examples/RunDrtExampleIT.java +++ b/contribs/drt/src/test/java/org/matsim/contrib/drt/run/examples/RunDrtExampleIT.java @@ -90,7 +90,9 @@ void testRunDrtExampleWithNoRejections_ExtensiveSearch() { for (var drtCfg : MultiModeDrtConfigGroup.get(config).getModalElements()) { //disable rejections - drtCfg.rejectRequestIfMaxWaitOrTravelTimeViolated = false; + drtCfg.addOrGetDrtOptimizationConstraintsParams() + .addOrGetDefaultDrtOptimizationConstraintsSet() + .rejectRequestIfMaxWaitOrTravelTimeViolated = false; } config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); @@ -129,7 +131,9 @@ void testRunDrtExampleWithNoRejections_SelectiveSearch() { drtCfg.addParameterSet(selectiveInsertionSearchParams); //disable rejections - drtCfg.rejectRequestIfMaxWaitOrTravelTimeViolated = false; + drtCfg.addOrGetDrtOptimizationConstraintsParams() + .addOrGetDefaultDrtOptimizationConstraintsSet() + .rejectRequestIfMaxWaitOrTravelTimeViolated = false; } config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); @@ -168,7 +172,9 @@ void testRunDrtExampleWithNoRejections_RepeatedSelectiveSearch() { drtCfg.addParameterSet(repeatedSelectiveInsertionSearchParams); //disable rejections - drtCfg.rejectRequestIfMaxWaitOrTravelTimeViolated = false; + drtCfg.addOrGetDrtOptimizationConstraintsParams() + .addOrGetDefaultDrtOptimizationConstraintsSet() + .rejectRequestIfMaxWaitOrTravelTimeViolated = false; } config.controller().setLastIteration(3); @@ -393,7 +399,7 @@ void testRunDrtWithPrebooking() { * rejectionRate, rejections, waitAverage, inVehicleTravelTimeMean, & totalTravelTimeMean */ - private void verifyDrtCustomerStatsCloseToExpectedStats(String outputDirectory, Stats expectedStats) { + static void verifyDrtCustomerStatsCloseToExpectedStats(String outputDirectory, Stats expectedStats) { String filename = outputDirectory + "/drt_customer_stats_drt.csv"; @@ -424,7 +430,7 @@ private void verifyDrtCustomerStatsCloseToExpectedStats(String outputDirectory, assertThat(actualStats).usingRecursiveComparison().isEqualTo(expectedStats); } - private static class Stats { + static class Stats { private final double rejectionRate; private final double rejections; private final double waitAverage; diff --git a/contribs/drt/src/test/java/org/matsim/contrib/drt/run/examples/RunOldDrtConfigCompatibilityIT.java b/contribs/drt/src/test/java/org/matsim/contrib/drt/run/examples/RunOldDrtConfigCompatibilityIT.java new file mode 100644 index 00000000000..60dc9c1bf7e --- /dev/null +++ b/contribs/drt/src/test/java/org/matsim/contrib/drt/run/examples/RunOldDrtConfigCompatibilityIT.java @@ -0,0 +1,63 @@ +package org.matsim.contrib.drt.run.examples; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.matsim.api.core.v01.Id; +import org.matsim.contrib.common.zones.systems.grid.square.SquareGridZoneSystemParams; +import org.matsim.contrib.drt.run.MultiModeDrtConfigGroup; +import org.matsim.contrib.dvrp.run.DvrpConfigGroup; +import org.matsim.contrib.zone.skims.DvrpTravelTimeMatrixParams; +import org.matsim.core.config.Config; +import org.matsim.core.config.ConfigUtils; +import org.matsim.core.controler.OutputDirectoryHierarchy; +import org.matsim.core.utils.io.IOUtils; +import org.matsim.examples.ExamplesUtils; +import org.matsim.testcases.MatsimTestUtils; +import org.matsim.vis.otfvis.OTFVisConfigGroup; + +import java.net.URL; + +/** + * + * Tests the older drt config version where optimization constraints where not stored as separate parameters + * @author nkuehnel / MOIA + */ +public class RunOldDrtConfigCompatibilityIT { + + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); + + @Test + void testRunDrtExampleWithNoRejections_ExtensiveSearch() { + Id.resetCaches(); + + DvrpConfigGroup dvrpConfigGroup = new DvrpConfigGroup(); + DvrpTravelTimeMatrixParams matrixParams = dvrpConfigGroup.getTravelTimeMatrixParams(); + matrixParams.addParameterSet(matrixParams.createParameterSet(SquareGridZoneSystemParams.SET_NAME)); + + URL configUrl = IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("mielec"), "mielec_drt_config_v1.xml"); + Config config = ConfigUtils.loadConfig(configUrl, new MultiModeDrtConfigGroup(), dvrpConfigGroup, + new OTFVisConfigGroup()); + + for (var drtCfg : MultiModeDrtConfigGroup.get(config).getModalElements()) { + //disable rejections + drtCfg.addOrGetDrtOptimizationConstraintsParams() + .addOrGetDefaultDrtOptimizationConstraintsSet() + .rejectRequestIfMaxWaitOrTravelTimeViolated = false; + } + + config.controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists); + config.controller().setOutputDirectory(utils.getOutputDirectory()); + RunDrtExample.run(config, false); + + var expectedStats = RunDrtExampleIT.Stats.newBuilder() + .rejectionRate(0.0) + .rejections(0) + .waitAverage(297.19) + .inVehicleTravelTimeMean(386.78) + .totalTravelTimeMean(683.97) + .build(); + + RunDrtExampleIT.verifyDrtCustomerStatsCloseToExpectedStats(utils.getOutputDirectory(), expectedStats); + } +} diff --git a/contribs/drt/src/test/java/org/matsim/contrib/drt/teleportation/DrtTeleportationTest.java b/contribs/drt/src/test/java/org/matsim/contrib/drt/teleportation/DrtTeleportationTest.java index 4cd79608057..47ede4e4e89 100644 --- a/contribs/drt/src/test/java/org/matsim/contrib/drt/teleportation/DrtTeleportationTest.java +++ b/contribs/drt/src/test/java/org/matsim/contrib/drt/teleportation/DrtTeleportationTest.java @@ -10,6 +10,7 @@ import org.matsim.contrib.drt.estimator.DrtEstimatorModule; import org.matsim.contrib.drt.estimator.impl.PessimisticDrtEstimator; import org.matsim.contrib.drt.fare.DrtFareParams; +import org.matsim.contrib.drt.optimizer.DrtOptimizationConstraintsSet; import org.matsim.contrib.drt.run.DrtConfigGroup; import org.matsim.contrib.drt.run.DrtControlerCreator; import org.matsim.contrib.drt.run.MultiModeDrtConfigGroup; @@ -45,9 +46,10 @@ void testTeleportationEngine() throws IOException { Controler controler = DrtControlerCreator.createControler(config, false); DrtConfigGroup drtConfigGroup = DrtConfigGroup.getSingleModeDrtConfig(config); - drtConfigGroup.maxTravelTimeAlpha = 1.2; - drtConfigGroup.maxTravelTimeBeta = 600; - drtConfigGroup.maxWaitTime = 300; + DrtOptimizationConstraintsSet defaultConstraintsSet = drtConfigGroup.addOrGetDrtOptimizationConstraintsParams().addOrGetDefaultDrtOptimizationConstraintsSet(); + defaultConstraintsSet.maxTravelTimeAlpha = 1.2; + defaultConstraintsSet.maxTravelTimeBeta = 600; + defaultConstraintsSet.maxWaitTime = 300; DrtFareParams fareParams = new DrtFareParams(); fareParams.baseFare = 1.0; fareParams.distanceFare_m = 0.001; @@ -75,12 +77,12 @@ public void install() { double waitAvg = Double.parseDouble(row.get("wait_average")); - assertThat(waitAvg).isEqualTo(drtConfigGroup.maxWaitTime); + assertThat(waitAvg).isEqualTo(defaultConstraintsSet.maxWaitTime); double distMean = Double.parseDouble(row.get("distance_m_mean")); double directDistMean = Double.parseDouble(row.get("directDistance_m_mean")); - assertThat(distMean / directDistMean).isCloseTo(drtConfigGroup.maxTravelTimeAlpha, Offset.offset(0.0001)); + assertThat(distMean / directDistMean).isCloseTo(defaultConstraintsSet.maxTravelTimeAlpha, Offset.offset(0.0001)); } diff --git a/contribs/emissions/src/main/java/org/matsim/contrib/emissions/utils/EmissionsConfigGroup.java b/contribs/emissions/src/main/java/org/matsim/contrib/emissions/utils/EmissionsConfigGroup.java index e5092b57568..f7107ece5f0 100644 --- a/contribs/emissions/src/main/java/org/matsim/contrib/emissions/utils/EmissionsConfigGroup.java +++ b/contribs/emissions/src/main/java/org/matsim/contrib/emissions/utils/EmissionsConfigGroup.java @@ -172,7 +172,7 @@ public URL getAverageColdEmissionFactorsFileURL(URL context) { // =============== // =============== /** - * @param detailedVsAverageLookupBehavior -- {@value #DETAILED_VS_AVERAGE_LOOKUP_BEHAVIOR_CMT} + * @param detailedVsAverageLookupBehavior -- {@value #DETAILED_VS_AVERAGE_LOOKUP_BEHAVIOR_CMT} * @noinspection JavadocReference */ @StringSetter(DETAILED_VS_AVERAGE_LOOKUP_BEHAVIOR) diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestWarmEmissionAnalysisModule.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestWarmEmissionAnalysisModule.java index cd88c087a65..30b456f1455 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestWarmEmissionAnalysisModule.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestWarmEmissionAnalysisModule.java @@ -20,7 +20,6 @@ package org.matsim.contrib.emissions; -import org.geotools.metadata.iso.quality.TemporalAccuracyImpl; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.params.ParameterizedTest; diff --git a/contribs/ev/src/main/java/org/matsim/contrib/ev/discharging/LTHDriveEnergyConsumption.java b/contribs/ev/src/main/java/org/matsim/contrib/ev/discharging/LTHDriveEnergyConsumption.java index ea20f84a484..f055b3f49e2 100644 --- a/contribs/ev/src/main/java/org/matsim/contrib/ev/discharging/LTHDriveEnergyConsumption.java +++ b/contribs/ev/src/main/java/org/matsim/contrib/ev/discharging/LTHDriveEnergyConsumption.java @@ -24,7 +24,6 @@ import org.apache.commons.math3.analysis.interpolation.PiecewiseBicubicSplineInterpolatingFunction; import org.apache.commons.math3.analysis.interpolation.PiecewiseBicubicSplineInterpolator; import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.network.Link; import org.matsim.contrib.ev.EvUnits; import org.matsim.contrib.ev.fleet.ElectricVehicle; diff --git a/contribs/hybridsim/pom.xml b/contribs/hybridsim/pom.xml index f8b3785885c..fa6c86d2f52 100644 --- a/contribs/hybridsim/pom.xml +++ b/contribs/hybridsim/pom.xml @@ -10,8 +10,8 @@ hybridsim - 4.26.1 - 1.63.0 + 4.27.0 + 1.64.0 diff --git a/contribs/minibus/src/main/java/org/matsim/contrib/minibus/schedule/CreatePStops.java b/contribs/minibus/src/main/java/org/matsim/contrib/minibus/schedule/CreatePStops.java index 52c5a6fe36d..a26e8d6e1be 100644 --- a/contribs/minibus/src/main/java/org/matsim/contrib/minibus/schedule/CreatePStops.java +++ b/contribs/minibus/src/main/java/org/matsim/contrib/minibus/schedule/CreatePStops.java @@ -31,6 +31,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.geotools.api.feature.simple.SimpleFeature; import org.locationtech.jts.geom.Coordinate; import org.locationtech.jts.geom.Geometry; import org.locationtech.jts.geom.GeometryFactory; @@ -49,7 +50,6 @@ import org.matsim.pt.transitSchedule.TransitScheduleFactoryImpl; import org.matsim.pt.transitSchedule.api.TransitSchedule; import org.matsim.pt.transitSchedule.api.TransitStopFacility; -import org.opengis.feature.simple.SimpleFeature; /** * Create one TransitStopFacility for each car mode link of the network diff --git a/contribs/minibus/src/main/java/org/matsim/contrib/minibus/schedule/CreatePStopsOnJunctionApproachesAndBetweenJunctions.java b/contribs/minibus/src/main/java/org/matsim/contrib/minibus/schedule/CreatePStopsOnJunctionApproachesAndBetweenJunctions.java index f2303896615..73d31f3c30f 100644 --- a/contribs/minibus/src/main/java/org/matsim/contrib/minibus/schedule/CreatePStopsOnJunctionApproachesAndBetweenJunctions.java +++ b/contribs/minibus/src/main/java/org/matsim/contrib/minibus/schedule/CreatePStopsOnJunctionApproachesAndBetweenJunctions.java @@ -32,6 +32,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.geotools.api.feature.simple.SimpleFeature; import org.locationtech.jts.geom.Coordinate; import org.locationtech.jts.geom.Geometry; import org.locationtech.jts.geom.GeometryFactory; @@ -60,7 +61,6 @@ import org.matsim.pt.transitSchedule.TransitScheduleFactoryImpl; import org.matsim.pt.transitSchedule.api.TransitSchedule; import org.matsim.pt.transitSchedule.api.TransitStopFacility; -import org.opengis.feature.simple.SimpleFeature; /** * Create one TransitStopFacility for each car mode link of the network diff --git a/contribs/noise/src/main/java/org/matsim/contrib/noise/DEMContext.java b/contribs/noise/src/main/java/org/matsim/contrib/noise/DEMContext.java index e55dd2dd43a..c82ee7010a1 100644 --- a/contribs/noise/src/main/java/org/matsim/contrib/noise/DEMContext.java +++ b/contribs/noise/src/main/java/org/matsim/contrib/noise/DEMContext.java @@ -1,12 +1,13 @@ package org.matsim.contrib.noise; -import org.opengis.geometry.DirectPosition; + +import org.geotools.api.geometry.Position; public interface DEMContext { /** * Returns the elevation at the given position. */ - float getElevation(DirectPosition position); + float getElevation(Position position); } diff --git a/contribs/noise/src/main/java/org/matsim/contrib/noise/DEMContextImpl.java b/contribs/noise/src/main/java/org/matsim/contrib/noise/DEMContextImpl.java index 1737c23dc58..9df8c41de65 100644 --- a/contribs/noise/src/main/java/org/matsim/contrib/noise/DEMContextImpl.java +++ b/contribs/noise/src/main/java/org/matsim/contrib/noise/DEMContextImpl.java @@ -1,11 +1,12 @@ package org.matsim.contrib.noise; +import org.geotools.api.geometry.Position; import org.geotools.coverage.grid.GridCoverage2D; import org.geotools.gce.geotiff.GeoTiffReader; import org.geotools.util.factory.Hints; +import org.locationtech.jts.geom.Point; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.opengis.geometry.DirectPosition; import jakarta.inject.Inject; import java.io.File; @@ -33,8 +34,8 @@ public class DEMContextImpl implements DEMContext { } @Override - public float getElevation(DirectPosition position) { - float[] sample = (float[])coverage.evaluate(position); + public float getElevation(Position point) { + float[] sample = (float[])coverage.evaluate(point); return sample[0]; } } diff --git a/contribs/noise/src/main/java/org/matsim/contrib/noise/FeatureNoiseBarriersReader.java b/contribs/noise/src/main/java/org/matsim/contrib/noise/FeatureNoiseBarriersReader.java index 419af93a267..30f56b6f90b 100644 --- a/contribs/noise/src/main/java/org/matsim/contrib/noise/FeatureNoiseBarriersReader.java +++ b/contribs/noise/src/main/java/org/matsim/contrib/noise/FeatureNoiseBarriersReader.java @@ -7,6 +7,11 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.geotools.api.feature.simple.SimpleFeature; +import org.geotools.api.referencing.FactoryException; +import org.geotools.api.referencing.crs.CoordinateReferenceSystem; +import org.geotools.api.referencing.operation.MathTransform; +import org.geotools.api.referencing.operation.TransformException; import org.geotools.feature.FeatureCollection; import org.geotools.feature.FeatureIterator; import org.geotools.geojson.GeoJSONUtil; @@ -16,11 +21,6 @@ import org.locationtech.jts.geom.*; import org.matsim.api.core.v01.Id; import org.matsim.core.utils.misc.Counter; -import org.opengis.feature.simple.SimpleFeature; -import org.opengis.referencing.FactoryException; -import org.opengis.referencing.crs.CoordinateReferenceSystem; -import org.opengis.referencing.operation.MathTransform; -import org.opengis.referencing.operation.TransformException; /** * @author nkuehnel diff --git a/contribs/noise/src/main/java/org/matsim/contrib/noise/RLS19NoiseEmission.java b/contribs/noise/src/main/java/org/matsim/contrib/noise/RLS19NoiseEmission.java index 296f05273b2..c6074e50226 100644 --- a/contribs/noise/src/main/java/org/matsim/contrib/noise/RLS19NoiseEmission.java +++ b/contribs/noise/src/main/java/org/matsim/contrib/noise/RLS19NoiseEmission.java @@ -2,7 +2,10 @@ import com.google.common.collect.Range; import com.google.inject.Inject; -import org.geotools.geometry.DirectPosition2D; +import org.geotools.api.geometry.Position; +import org.geotools.api.referencing.FactoryException; +import org.geotools.api.referencing.crs.CoordinateReferenceSystem; +import org.geotools.geometry.Position2D; import org.geotools.referencing.CRS; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Scenario; @@ -10,9 +13,6 @@ import org.matsim.api.core.v01.network.Network; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.opengis.geometry.DirectPosition; -import org.opengis.referencing.FactoryException; -import org.opengis.referencing.crs.CoordinateReferenceSystem; import static org.matsim.contrib.noise.RLS19VehicleType.*; @@ -164,8 +164,8 @@ public double calculateSingleVehicleLevel(NoiseVehicleType type, NoiseLink noise Coord to = matsimLink.getToNode().getCoord(); //MATSim coord's x/y are inversed to geotools/jts - DirectPosition positionFrom = new DirectPosition2D(crs, from.getY(), from.getX()); - DirectPosition positionTo = new DirectPosition2D(crs, to.getY(), to.getX()); + Position positionFrom = new Position2D(crs, from.getY(), from.getX()); + Position positionTo = new Position2D(crs, to.getY(), to.getX()); float elevationFrom = demContext.getElevation(positionFrom); float elevationTo = demContext.getElevation(positionTo); diff --git a/contribs/otfvis/src/main/java/org/matsim/contrib/otfvis/OTFVisLiveModule.java b/contribs/otfvis/src/main/java/org/matsim/contrib/otfvis/OTFVisLiveModule.java index 001f4a227b3..7d9cfa12823 100644 --- a/contribs/otfvis/src/main/java/org/matsim/contrib/otfvis/OTFVisLiveModule.java +++ b/contribs/otfvis/src/main/java/org/matsim/contrib/otfvis/OTFVisLiveModule.java @@ -37,6 +37,17 @@ import com.google.inject.Inject; public class OTFVisLiveModule extends AbstractModule { + + /** + * For win, one needs to add + * + * --add-exports java.base/java.lang=ALL-UNNAMED --add-exports java.desktop/sun.awt=ALL-UNNAMED --add-exports java.desktop/sun.java2d=ALL-UNNAMED + * + * as arguments to the JVM to get around module protection. + */ + public OTFVisLiveModule() { + // so I can attach javadoc to this. kai, may'24 + } @Override public void install() { diff --git a/contribs/otfvis/src/main/java/org/matsim/vis/otfvis/opengl/drawer/SimpleBackgroundFeatureDrawer.java b/contribs/otfvis/src/main/java/org/matsim/vis/otfvis/opengl/drawer/SimpleBackgroundFeatureDrawer.java index 0fc455c6c04..2423b74db12 100644 --- a/contribs/otfvis/src/main/java/org/matsim/vis/otfvis/opengl/drawer/SimpleBackgroundFeatureDrawer.java +++ b/contribs/otfvis/src/main/java/org/matsim/vis/otfvis/opengl/drawer/SimpleBackgroundFeatureDrawer.java @@ -24,8 +24,9 @@ import java.util.ArrayList; import java.util.List; +import org.geotools.api.data.SimpleFeatureSource; +import org.geotools.api.feature.simple.SimpleFeature; import org.geotools.data.simple.SimpleFeatureIterator; -import org.geotools.data.simple.SimpleFeatureSource; import org.locationtech.jts.geom.Coordinate; import org.locationtech.jts.geom.Geometry; import org.locationtech.jts.geom.GeometryFactory; @@ -34,7 +35,6 @@ import org.locationtech.jts.geom.MultiPolygon; import org.locationtech.jts.geom.Point; import org.locationtech.jts.geom.Polygon; -import org.opengis.feature.simple.SimpleFeature; import com.jogamp.opengl.GL; import com.jogamp.opengl.GL2; diff --git a/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingproxy/analysis/RegionModeshareAnalyzer.java b/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingproxy/analysis/RegionModeshareAnalyzer.java index e63ad0929ff..aaa3da60ad5 100644 --- a/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingproxy/analysis/RegionModeshareAnalyzer.java +++ b/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingproxy/analysis/RegionModeshareAnalyzer.java @@ -28,6 +28,7 @@ import java.util.List; import java.util.Map; +import org.geotools.api.feature.simple.SimpleFeature; import org.locationtech.jts.geom.Geometry; import org.matsim.api.core.v01.population.Activity; import org.matsim.api.core.v01.population.Leg; @@ -35,7 +36,6 @@ import org.matsim.api.core.v01.population.PlanElement; import org.matsim.core.population.algorithms.AbstractPersonAlgorithm; import org.matsim.core.utils.geometry.geotools.MGC; -import org.opengis.feature.simple.SimpleFeature; import gnu.trove.map.TObjectIntMap; import gnu.trove.map.hash.TObjectIntHashMap; diff --git a/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingproxy/run/RunAreaAnalysis.java b/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingproxy/run/RunAreaAnalysis.java index 7643b4ea3b4..ed759e9b356 100644 --- a/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingproxy/run/RunAreaAnalysis.java +++ b/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingproxy/run/RunAreaAnalysis.java @@ -23,13 +23,13 @@ import java.nio.file.Paths; import java.util.Collection; +import org.geotools.api.feature.simple.SimpleFeature; import org.matsim.contrib.parking.parkingproxy.analysis.RegionModeshareAnalyzer; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; import org.matsim.core.population.io.StreamingPopulationReader; import org.matsim.core.scenario.ScenarioUtils; import org.matsim.core.utils.gis.GeoFileReader; -import org.opengis.feature.simple.SimpleFeature; public class RunAreaAnalysis { diff --git a/contribs/protobuf/pom.xml b/contribs/protobuf/pom.xml index 8b2b9121993..a824085d737 100644 --- a/contribs/protobuf/pom.xml +++ b/contribs/protobuf/pom.xml @@ -11,7 +11,7 @@ protobuf - 4.26.1 + 4.27.0 diff --git a/contribs/sbb-extensions/src/main/java/ch/sbb/matsim/analysis/skims/CalculateSkimMatrices.java b/contribs/sbb-extensions/src/main/java/ch/sbb/matsim/analysis/skims/CalculateSkimMatrices.java index 2684832db0a..f65f15224ac 100644 --- a/contribs/sbb-extensions/src/main/java/ch/sbb/matsim/analysis/skims/CalculateSkimMatrices.java +++ b/contribs/sbb-extensions/src/main/java/ch/sbb/matsim/analysis/skims/CalculateSkimMatrices.java @@ -41,6 +41,7 @@ import java.util.function.ToDoubleFunction; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.geotools.api.feature.simple.SimpleFeature; import org.locationtech.jts.geom.Coordinate; import org.locationtech.jts.geom.Envelope; import org.locationtech.jts.geom.Geometry; @@ -80,7 +81,6 @@ import org.matsim.pt.transitSchedule.api.TransitLine; import org.matsim.pt.transitSchedule.api.TransitRoute; import org.matsim.pt.transitSchedule.api.TransitScheduleReader; -import org.opengis.feature.simple.SimpleFeature; /** * Main class to calculate skim matrices. Provides a main-method to be directly started from the command line, but the main-method also acts as a template for custom code using the skims calculation. diff --git a/contribs/sbb-extensions/src/main/java/ch/sbb/matsim/analysis/skims/MatricesToXY.java b/contribs/sbb-extensions/src/main/java/ch/sbb/matsim/analysis/skims/MatricesToXY.java index 405cdb0be00..e617db66b0b 100644 --- a/contribs/sbb-extensions/src/main/java/ch/sbb/matsim/analysis/skims/MatricesToXY.java +++ b/contribs/sbb-extensions/src/main/java/ch/sbb/matsim/analysis/skims/MatricesToXY.java @@ -27,11 +27,11 @@ import java.util.Map; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.geotools.api.feature.simple.SimpleFeature; import org.locationtech.jts.geom.Geometry; import org.locationtech.jts.geom.Point; import org.matsim.core.utils.gis.GeoFileReader; import org.matsim.core.utils.io.IOUtils; -import org.opengis.feature.simple.SimpleFeature; /** * Creates a huge csv file with the data of all the matrices combined. Zones are identified by their identifier as well as one random coordinate per zone. Given the from-/to-coordinates for each diff --git a/contribs/shared_mobility/src/main/java/org/matsim/contrib/shared_mobility/utils/WriteStationShapefile.java b/contribs/shared_mobility/src/main/java/org/matsim/contrib/shared_mobility/utils/WriteStationShapefile.java index 5edcf65eb29..3f78b4251d4 100644 --- a/contribs/shared_mobility/src/main/java/org/matsim/contrib/shared_mobility/utils/WriteStationShapefile.java +++ b/contribs/shared_mobility/src/main/java/org/matsim/contrib/shared_mobility/utils/WriteStationShapefile.java @@ -3,6 +3,8 @@ import java.util.ArrayList; import java.util.Collection; +import org.geotools.api.feature.simple.SimpleFeature; +import org.geotools.api.referencing.crs.CoordinateReferenceSystem; import org.locationtech.jts.geom.Coordinate; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; @@ -17,8 +19,6 @@ import org.matsim.core.utils.geometry.geotools.MGC; import org.matsim.core.utils.gis.PointFeatureFactory; import org.matsim.core.utils.gis.GeoFileWriter; -import org.opengis.feature.simple.SimpleFeature; -import org.opengis.referencing.crs.CoordinateReferenceSystem; public class WriteStationShapefile { static public void main(String[] args) throws ConfigurationException { diff --git a/contribs/simwrapper/src/main/java/org/matsim/simwrapper/SimWrapper.java b/contribs/simwrapper/src/main/java/org/matsim/simwrapper/SimWrapper.java index 028d6d6949f..19a8717ba7e 100644 --- a/contribs/simwrapper/src/main/java/org/matsim/simwrapper/SimWrapper.java +++ b/contribs/simwrapper/src/main/java/org/matsim/simwrapper/SimWrapper.java @@ -120,6 +120,15 @@ boolean hasDashboard(Class d, String context) { * Generate the dashboards specification and writes .yaml files to {@code dir}. */ public void generate(Path dir) throws IOException { + generate(dir, false); + } + + /** + * Generate the dashboards specification and writes .yaml files to {@code dir}. + * @param dir target directory + * @param append if true, existing dashboards will not be overwritten + */ + public void generate(Path dir, boolean append) throws IOException { ObjectMapper mapper = new ObjectMapper(new YAMLFactory() .disable(YAMLGenerator.Feature.WRITE_DOC_START_MARKER) @@ -157,6 +166,11 @@ public void generate(Path dir) throws IOException { yaml.subtabs = layout.getTabs(); Path out = dir.resolve("dashboard-" + i + ".yaml"); + + while (append && Files.exists(out)) { + out = dir.resolve("dashboard-" + ++i + ".yaml"); + } + writer.writeValue(out.toFile(), yaml); i++; diff --git a/contribs/small-scale-traffic-generation/src/main/java/org/matsim/smallScaleCommercialTrafficGeneration/GenerateSmallScaleCommercialTrafficDemand.java b/contribs/small-scale-traffic-generation/src/main/java/org/matsim/smallScaleCommercialTrafficGeneration/GenerateSmallScaleCommercialTrafficDemand.java index 4077f18d080..026c853a5be 100644 --- a/contribs/small-scale-traffic-generation/src/main/java/org/matsim/smallScaleCommercialTrafficGeneration/GenerateSmallScaleCommercialTrafficDemand.java +++ b/contribs/small-scale-traffic-generation/src/main/java/org/matsim/smallScaleCommercialTrafficGeneration/GenerateSmallScaleCommercialTrafficDemand.java @@ -22,10 +22,15 @@ import com.google.inject.Inject; import com.google.inject.Provider; import it.unimi.dsi.fastutil.objects.Object2DoubleMap; +import org.apache.commons.math3.distribution.EnumeratedDistribution; +import org.apache.commons.math3.random.MersenneTwister; +import org.apache.commons.math3.random.RandomGenerator; +import org.apache.commons.math3.util.Pair; import org.apache.logging.log4j.Level; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.core.config.Configurator; +import org.geotools.api.feature.simple.SimpleFeature; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -71,7 +76,6 @@ import org.matsim.vehicles.Vehicle; import org.matsim.vehicles.VehicleType; import org.matsim.vehicles.VehicleUtils; -import org.opengis.feature.simple.SimpleFeature; import picocli.CommandLine; import java.io.File; @@ -90,6 +94,7 @@ * * @author Ricardo Ewert */ +//TODO: use EnumeratedDistribution for distributions with probabilities @CommandLine.Command(name = "generate-small-scale-commercial-traffic", description = "Generates plans for a small scale commercial traffic model", showDefaultValues = true) public class GenerateSmallScaleCommercialTrafficDemand implements MATSimAppCommand { // freight traffic from extern: @@ -164,6 +169,7 @@ public enum SmallScaleCommercialTrafficType { private Path output; private Random rnd; + private RandomGenerator rng; private final Map>> facilitiesPerZone = new HashMap<>(); private Index indexZones; @@ -500,7 +506,10 @@ private Config readAndCheckConfig(Path configPath, String modelName, String samp config.controller().getOverwriteFileSetting(), ControllerConfigGroup.CompressionType.gzip); new File(Path.of(config.controller().getOutputDirectory()).resolve("calculatedData").toString()).mkdir(); MatsimRandom.getRandom().setSeed(config.global().getRandomSeed()); + rnd = MatsimRandom.getRandom(); + rng = new MersenneTwister(config.global().getRandomSeed()); + if (config.network().getInputFile() == null) throw new Exception("No network file in config"); if (config.global().getCoordinateSystem() == null) @@ -543,8 +552,9 @@ private void createCarriers(Scenario scenario, TripDistributionMatrix odMatrix, * odMatrix.getListOfModesOrVehTypes().size(); int createdCarrier = 0; int fixedNumberOfVehiclePerTypeAndLocation = 1; //TODO possible improvement, perhaps check KiD - ValueSelectorUnderGivenProbability tourStartTimeSelector = createTourStartTimeDistribution(smallScaleCommercialTrafficType); - ValueSelectorUnderGivenProbability tourDurationTimeSelector = createTourDurationTimeDistribution(smallScaleCommercialTrafficType); + + EnumeratedDistribution tourDistribution = createTourDistribution(smallScaleCommercialTrafficType); + Map stopDurationTimeSelector = createStopDurationTimeDistributionPerCategory( smallScaleCommercialTrafficType); @@ -674,7 +684,7 @@ private void createCarriers(Scenario scenario, TripDistributionMatrix odMatrix, createNewCarrierAndAddVehicleTypes(scenario, purpose, startZone, selectedStartCategory, carrierName, vehicleTypes, numberOfDepots, fleetSize, fixedNumberOfVehiclePerTypeAndLocation, vehicleDepots, linksPerZone, smallScaleCommercialTrafficType, - tourStartTimeSelector, tourDurationTimeSelector); + tourDistribution); log.info("Create services for carrier: {}", carrierName); for (String stopZone : odMatrix.getListOfZones()) { int trafficVolumeForOD = Math.round((float)odMatrix.getTripDistributionValue(startZone, @@ -702,11 +712,12 @@ private void createCarriers(Scenario scenario, TripDistributionMatrix odMatrix, } } } - System.out.println("Final results for the start time distribution"); - tourStartTimeSelector.writeResults(); - System.out.println("Final results for the tour duration distribution"); - tourDurationTimeSelector.writeResults(); +// System.out.println("Final results for the start time distribution"); +// tourStartTimeSelector.writeResults(); + +// System.out.println("Final results for the tour duration distribution"); +// tourDurationTimeSelector.writeResults(); for (StopDurationGoodTrafficKey sector : stopDurationTimeSelector.keySet()) { System.out.println("Final results for the stop duration distribution in sector " + sector); @@ -750,8 +761,7 @@ private void createNewCarrierAndAddVehicleTypes(Scenario scenario, Integer purpo int fixedNumberOfVehiclePerTypeAndLocation, List vehicleDepots, Map, Link>> linksPerZone, String smallScaleCommercialTrafficType, - ValueSelectorUnderGivenProbability tourStartTimeSelector, - ValueSelectorUnderGivenProbability tourDurationTimeSelector) { + EnumeratedDistribution tourStartTimeSelector) { Carriers carriers = CarriersUtils.addOrGetCarriers(scenario); CarrierVehicleTypes carrierVehicleTypes = CarriersUtils.getCarrierVehicleTypes(scenario); @@ -777,8 +787,10 @@ private void createNewCarrierAndAddVehicleTypes(Scenario scenario, Integer purpo } for (String singleDepot : vehicleDepots) { - int vehicleStartTime = getVehicleStartTime(tourStartTimeSelector); - int tourDuration = getVehicleTourDuration(tourDurationTimeSelector); + TourStartAndDuration t = tourStartTimeSelector.sample(); + + int vehicleStartTime = getVehicleStartTime(t); + int tourDuration = getVehicleTourDuration(t); int vehicleEndTime = vehicleStartTime + tourDuration; for (String thisVehicleType : vehicleTypes) { //TODO Flottenzusammensetzung anpassen. Momentan pro Depot alle Fahrzeugtypen 1x erzeugen VehicleType thisType = carrierVehicleTypes.getVehicleTypes() @@ -807,28 +819,16 @@ private void createNewCarrierAndAddVehicleTypes(Scenario scenario, Integer purpo /** * Gives a duration for the created tour under the given probability. * - * @param tourDurationTimeSelector - * @return */ - private int getVehicleTourDuration(ValueSelectorUnderGivenProbability tourDurationTimeSelector) { - ValueSelectorUnderGivenProbability.ProbabilityForValue selectedValue = tourDurationTimeSelector.getNextValueUnderGivenProbability(); - int tourDurationLowerBound = Integer.parseInt(selectedValue.getValue()); - int tourDurationUpperBound = Integer.parseInt(selectedValue.getUpperBound()); - return rnd.nextInt(tourDurationLowerBound * 3600, tourDurationUpperBound * 3600); + private int getVehicleTourDuration(TourStartAndDuration t) { + return (int) rnd.nextDouble(t.minDuration * 60, t.maxDuration * 60); } /** * Gives a tour start time for the created tour under the given probability. - * - * @param tourStartTimeSelector - * @return */ - private int getVehicleStartTime(ValueSelectorUnderGivenProbability tourStartTimeSelector) { - ValueSelectorUnderGivenProbability.ProbabilityForValue selectedValue = tourStartTimeSelector.getNextValueUnderGivenProbability(); - int tourStartTimeLowerBound = Integer.parseInt(selectedValue.getValue()); - int tourStartTimeUpperBound = Integer.parseInt(selectedValue.getUpperBound()); - return rnd.nextInt(tourStartTimeLowerBound * 3600, tourStartTimeUpperBound * 3600); - + private int getVehicleStartTime(TourStartAndDuration t) { + return rnd.nextInt(t.hourLower * 3600, t.hourUpper * 3600); } @@ -1306,6 +1306,487 @@ private ValueSelectorUnderGivenProbability createTourDurationTimeDistribution(St return new ValueSelectorUnderGivenProbability(tourDurationProbabilityDistribution, rnd); } + private EnumeratedDistribution createTourDistribution(String smallScaleCommercialTrafficType) { + List> tourDurationProbabilityDistribution = new ArrayList<>(); + + if (smallScaleCommercialTrafficType.equals(SmallScaleCommercialTrafficType.commercialPersonTraffic.toString())) { + + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(0, 4, 0.0, 30.0), 0.0005917893035900173)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(0, 4, 30.0, 60.0), 0.00021859484237437887)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(0, 4, 90.0, 120.0), 0.00037490287407786324)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(0, 4, 120.0, 180.0), 0.0004337321926125666)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(0, 4, 180.0, 240.0), 0.0005834182239827621)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(0, 4, 240.0, 300.0), 0.0005116938323661723)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(0, 4, 300.0, 360.0), 0.0005027065159573272)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(0, 4, 360.0, 420.0), 0.0006719740164147071)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(0, 4, 420.0, 480.0), 0.00022375027665644004)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(0, 4, 480.0, 540.0), 0.00022103749529549306)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(0, 4, 540.0, 600.0), 0.00022119440831885122)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(0, 4, 600.0, 660.0), 0.0002732185104003396)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(0, 4, 660.0, 720.0), 7.287567629774946e-05)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(0, 4, 720.0, 780.0), 0.0005090670761685264)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(0, 4, 780.0, 840.0), 0.0002169454122557984)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(0, 4, 840.0, 1080.0), 0.0016947794402011696)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(4, 5, 0.0, 30.0), 0.00033050926084770643)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(4, 5, 30.0, 60.0), 0.0004963985976117265)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(4, 5, 60.0, 90.0), 0.0009458837608304906)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(4, 5, 90.0, 120.0), 0.0006507941771038976)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(4, 5, 120.0, 180.0), 0.0002949035696660126)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(4, 5, 180.0, 240.0), 0.0005812406149568905)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(4, 5, 240.0, 300.0), 0.00072666224822023)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(4, 5, 300.0, 360.0), 0.0006017750128936798)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(4, 5, 360.0, 420.0), 0.0007696491628020603)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(4, 5, 420.0, 480.0), 0.0006951014583380694)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(4, 5, 480.0, 540.0), 0.0006675367479652174)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(4, 5, 540.0, 600.0), 0.0009951412624367468)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(4, 5, 600.0, 660.0), 0.0006193958232902363)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(4, 5, 660.0, 720.0), 0.0005496335422364244)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(4, 5, 720.0, 780.0), 0.000963763774344583)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(4, 5, 780.0, 840.0), 0.001585152586657775)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(4, 5, 840.0, 1080.0), 0.0022779973751500433)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(5, 6, 0.0, 30.0), 0.003678291745870938)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(5, 6, 30.0, 60.0), 0.0037749680865755936)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(5, 6, 60.0, 90.0), 0.0021464058981758467)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(5, 6, 90.0, 120.0), 0.0010105726369455444)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(5, 6, 120.0, 180.0), 0.0017166729332290624)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(5, 6, 180.0, 240.0), 0.001218657902054598)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(5, 6, 240.0, 300.0), 0.0019212859349972463)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(5, 6, 300.0, 360.0), 0.0018498349748915703)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(5, 6, 360.0, 420.0), 0.0020820722844894844)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(5, 6, 420.0, 480.0), 0.0033255032578691536)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(5, 6, 480.0, 540.0), 0.004499580798913233)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(5, 6, 540.0, 600.0), 0.004508722079694882)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(5, 6, 600.0, 660.0), 0.009460453046374911)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(5, 6, 660.0, 720.0), 0.008632039128635343)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(5, 6, 720.0, 780.0), 0.005173130409039029)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(5, 6, 780.0, 840.0), 0.0021287189901771954)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(5, 6, 840.0, 1080.0), 0.002735246591728173)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(6, 7, 0.0, 30.0), 0.015534599731489868)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(6, 7, 30.0, 60.0), 0.009424737666749776)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(6, 7, 60.0, 90.0), 0.003979757502241877)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(6, 7, 90.0, 120.0), 0.0026219034509082214)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(6, 7, 120.0, 180.0), 0.004373894821911171)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(6, 7, 180.0, 240.0), 0.005349695968407728)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(6, 7, 240.0, 300.0), 0.008398668008895199)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(6, 7, 300.0, 360.0), 0.013017576110359298)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(6, 7, 360.0, 420.0), 0.013178466937493282)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(6, 7, 420.0, 480.0), 0.015799261066253244)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(6, 7, 480.0, 540.0), 0.031932993774084484)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(6, 7, 540.0, 600.0), 0.056976770375347194)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(6, 7, 600.0, 660.0), 0.03411514635058722)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(6, 7, 660.0, 720.0), 0.010952547256934878)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(6, 7, 720.0, 780.0), 0.005071677294689363)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(6, 7, 780.0, 840.0), 0.002758017802376135)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(6, 7, 840.0, 1080.0), 0.003182481371327368)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(7, 8, 0.0, 30.0), 0.018010507239762663)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(7, 8, 30.0, 60.0), 0.009246211080247332)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(7, 8, 60.0, 90.0), 0.006297103845359016)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(7, 8, 90.0, 120.0), 0.003415561088528113)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(7, 8, 120.0, 180.0), 0.010918022744746231)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(7, 8, 180.0, 240.0), 0.011371721163141522)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(7, 8, 240.0, 300.0), 0.01861910064916215)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(7, 8, 300.0, 360.0), 0.015443374909900384)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(7, 8, 360.0, 420.0), 0.020470726990450452)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(7, 8, 420.0, 480.0), 0.030727618880727087)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(7, 8, 480.0, 540.0), 0.07364088624635841)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(7, 8, 540.0, 600.0), 0.04082061588575034)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(7, 8, 600.0, 660.0), 0.012935881167590665)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(7, 8, 660.0, 720.0), 0.005469250367916343)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(7, 8, 720.0, 780.0), 0.0030030673084490513)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(7, 8, 780.0, 840.0), 0.0011042643367551329)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(7, 8, 840.0, 1080.0), 0.0011327583672022575)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(8, 9, 0.0, 30.0), 0.015589932735904798)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(8, 9, 30.0, 60.0), 0.007157798082590814)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(8, 9, 60.0, 90.0), 0.006563655710107534)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(8, 9, 90.0, 120.0), 0.004888423230467872)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(8, 9, 120.0, 180.0), 0.01261126944262904)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(8, 9, 180.0, 240.0), 0.013275311108363174)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(8, 9, 240.0, 300.0), 0.011059737216827653)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(8, 9, 300.0, 360.0), 0.00980644443311104)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(8, 9, 360.0, 420.0), 0.013476523854959467)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(8, 9, 420.0, 480.0), 0.01766932338862498)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(8, 9, 480.0, 540.0), 0.013855266610087914)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(8, 9, 540.0, 600.0), 0.006090238569895901)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(8, 9, 600.0, 660.0), 0.00326688741194661)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(8, 9, 660.0, 720.0), 0.0009742217966822537)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(8, 9, 720.0, 780.0), 0.0008462163162537791)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(8, 9, 780.0, 840.0), 0.0009357453082055104)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(8, 9, 840.0, 1080.0), 0.0006867783494497427)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(9, 10, 0.0, 30.0), 0.011836581569331607)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(9, 10, 30.0, 60.0), 0.0060475163532472224)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(9, 10, 60.0, 90.0), 0.006091033719221284)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(9, 10, 90.0, 120.0), 0.004870323217391879)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(9, 10, 120.0, 180.0), 0.009852214102720915)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(9, 10, 180.0, 240.0), 0.006649077724867284)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(9, 10, 240.0, 300.0), 0.006549809619698136)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(9, 10, 300.0, 360.0), 0.00743649188225418)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(9, 10, 360.0, 420.0), 0.008370330719772223)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(9, 10, 420.0, 480.0), 0.006055410372169952)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(9, 10, 480.0, 540.0), 0.003221026290023441)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(9, 10, 540.0, 600.0), 0.00270804359225063)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(9, 10, 600.0, 660.0), 0.0011328763880567346)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(9, 10, 660.0, 720.0), 0.0005295062815147344)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(9, 10, 720.0, 780.0), 0.0005244739409173669)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(9, 10, 780.0, 840.0), 0.00022261373811852168)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(9, 10, 840.0, 1080.0), 0.0002976820307410009)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(10, 11, 0.0, 30.0), 0.0072347359578799255)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(10, 11, 30.0, 60.0), 0.005528762818372258)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(10, 11, 60.0, 90.0), 0.004301874597910846)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(10, 11, 90.0, 120.0), 0.002706271535768685)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(10, 11, 120.0, 180.0), 0.004461225555303183)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(10, 11, 180.0, 240.0), 0.003289266637558867)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(10, 11, 240.0, 300.0), 0.004773112389257731)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(10, 11, 300.0, 360.0), 0.004153307715767419)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(10, 11, 360.0, 420.0), 0.0023002274828502435)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(10, 11, 420.0, 480.0), 0.002295722460734858)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(10, 11, 480.0, 540.0), 0.0008008191218782178)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(10, 11, 540.0, 600.0), 0.0005302938593833011)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(10, 11, 600.0, 660.0), 0.00012017333498779025)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(10, 11, 660.0, 720.0), 0.00029497120761336085)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(10, 11, 720.0, 780.0), 7.442207741095891e-05)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(10, 11, 780.0, 840.0), 7.491510042413546e-05)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(11, 12, 0.0, 30.0), 0.005979044848708125)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(11, 12, 30.0, 60.0), 0.0030727725862362003)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(11, 12, 60.0, 90.0), 0.0018328582061095421)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(11, 12, 90.0, 120.0), 0.0015730248216810105)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(11, 12, 120.0, 180.0), 0.0025909176745678485)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(11, 12, 180.0, 240.0), 0.0023584284876344117)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(11, 12, 240.0, 300.0), 0.002888683132930499)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(11, 12, 300.0, 360.0), 0.0026723295114103734)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(11, 12, 360.0, 420.0), 0.001368034507711622)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(11, 12, 420.0, 480.0), 0.001322142609646873)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(11, 12, 480.0, 540.0), 0.00014896322977011863)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(11, 12, 540.0, 600.0), 0.00036793050573151096)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(11, 12, 600.0, 660.0), 0.0003024749417379503)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(11, 12, 660.0, 720.0), 7.263766179594998e-05)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(11, 12, 720.0, 780.0), 7.737798495114381e-05)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(11, 12, 840.0, 1080.0), 7.360037219024495e-05)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(12, 13, 0.0, 30.0), 0.005442934607459622)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(12, 13, 30.0, 60.0), 0.0023099603288455053)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(12, 13, 60.0, 90.0), 0.0015476125810207045)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(12, 13, 90.0, 120.0), 0.0015690710859882222)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(12, 13, 120.0, 180.0), 0.003155552178314994)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(12, 13, 180.0, 240.0), 0.0024715148201473933)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(12, 13, 240.0, 300.0), 0.00214638868043489)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(12, 13, 300.0, 360.0), 0.0017134793037846727)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(12, 13, 360.0, 420.0), 0.0009684921868733149)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(12, 13, 420.0, 480.0), 0.0005519992558366529)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(12, 13, 480.0, 540.0), 0.0004441672064981391)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(12, 13, 540.0, 600.0), 0.00022332686365997108)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(12, 13, 600.0, 660.0), 0.00023780343565208111)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(12, 13, 660.0, 720.0), 0.00014898555439278127)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(13, 14, 0.0, 30.0), 0.0065652971880044205)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(13, 14, 30.0, 60.0), 0.0033645458423904226)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(13, 14, 60.0, 90.0), 0.002247264924524252)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(13, 14, 90.0, 120.0), 0.0021755851670695867)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(13, 14, 120.0, 180.0), 0.00292250684836152)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(13, 14, 180.0, 240.0), 0.0029939610328467135)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(13, 14, 240.0, 300.0), 0.0013771262994841458)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(13, 14, 300.0, 360.0), 0.0005929387919824101)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(13, 14, 360.0, 420.0), 0.0007299574379337656)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(13, 14, 420.0, 480.0), 0.00015161310680499916)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(13, 14, 480.0, 540.0), 0.00022326623210165028)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(13, 14, 540.0, 600.0), 0.00021908720500178134)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(14, 15, 0.0, 30.0), 0.004700575755513116)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(14, 15, 30.0, 60.0), 0.002876930233578738)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(14, 15, 60.0, 90.0), 0.0012326059557891803)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(14, 15, 90.0, 120.0), 0.001688513011030605)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(14, 15, 120.0, 180.0), 0.0024148215923521744)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(14, 15, 180.0, 240.0), 0.0009664823712470381)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(14, 15, 240.0, 300.0), 0.0008158516384741175)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(14, 15, 300.0, 360.0), 0.0005326476409500361)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(14, 15, 360.0, 420.0), 0.00037447250704764534)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(14, 15, 420.0, 480.0), 7.278074100962308e-05)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(14, 15, 480.0, 540.0), 0.00015460621875651884)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(14, 15, 540.0, 600.0), 0.00022625636961834557)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(14, 15, 840.0, 1080.0), 7.369704340227916e-05)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(15, 16, 0.0, 30.0), 0.005421542133242069)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(15, 16, 30.0, 60.0), 0.0028543297205245563)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(15, 16, 60.0, 90.0), 0.001320449445343739)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(15, 16, 90.0, 120.0), 0.0011372744623221703)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(15, 16, 120.0, 180.0), 0.0011175546229352943)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(15, 16, 180.0, 240.0), 0.0005212091408906178)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(15, 16, 240.0, 300.0), 0.00025063117439263165)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(15, 16, 300.0, 360.0), 0.0002906557976189996)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(15, 16, 360.0, 420.0), 6.934683987097806e-05)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(15, 16, 420.0, 480.0), 7.198332684426051e-05)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(16, 17, 0.0, 30.0), 0.005997678933359281)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(16, 17, 30.0, 60.0), 0.0014450238860978966)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(16, 17, 60.0, 90.0), 0.0008909835110546583)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(16, 17, 90.0, 120.0), 0.0008692603958852261)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(16, 17, 120.0, 180.0), 0.0004645626068627116)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(16, 17, 180.0, 240.0), 0.0005161866418057845)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(16, 17, 240.0, 300.0), 0.00047492492382272117)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(16, 17, 300.0, 360.0), 7.348989097075777e-05)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(16, 17, 360.0, 420.0), 0.0003000342936128893)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(17, 18, 0.0, 30.0), 0.004621906661329853)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(17, 18, 30.0, 60.0), 0.0015152391398060199)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(17, 18, 60.0, 90.0), 0.0006769045119123614)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(17, 18, 90.0, 120.0), 0.00044820275277284946)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(17, 18, 120.0, 180.0), 0.0007140653752077821)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(17, 18, 180.0, 240.0), 0.0001502672132808765)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(17, 18, 240.0, 300.0), 0.0003842231300012746)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(17, 18, 300.0, 360.0), 0.00021634404805889257)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(18, 19, 0.0, 30.0), 0.0034023082743939916)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(18, 19, 30.0, 60.0), 0.0006251774232962365)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(18, 19, 60.0, 90.0), 0.00022163965781205308)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(18, 19, 90.0, 120.0), 7.360037219024495e-05)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(18, 19, 120.0, 180.0), 0.00045934601255169126)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(18, 19, 180.0, 240.0), 7.511874968194916e-05)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(18, 19, 240.0, 300.0), 0.0001486019187134722)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(18, 19, 300.0, 360.0), 7.505084488366769e-05)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(18, 19, 420.0, 480.0), 7.594714627228585e-05)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(19, 24, 0.0, 30.0), 0.005137034953520923)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(19, 24, 30.0, 60.0), 0.0010774703023578233)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(19, 24, 60.0, 90.0), 0.00048539418673270443)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(19, 24, 90.0, 120.0), 0.0002988049182984063)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(19, 24, 120.0, 180.0), 0.00032644209078127245)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(19, 24, 180.0, 240.0), 0.0005357497395368892)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(19, 24, 240.0, 300.0), 0.0002944914928100358)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(19, 24, 300.0, 360.0), 0.00022851651374757815)); + } + else if (smallScaleCommercialTrafficType.equals(SmallScaleCommercialTrafficType.goodsTraffic.toString())) { + + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(0, 4, 0.0, 30.0), 0.0002666800577200411)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(0, 4, 30.0, 60.0), 0.0006395055678719748)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(0, 4, 60.0, 90.0), 0.0007110769046958423)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(0, 4, 90.0, 120.0), 0.0006665961628449491)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(0, 4, 120.0, 180.0), 0.0023195866923785575)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(0, 4, 180.0, 240.0), 0.00261751319938476)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(0, 4, 240.0, 300.0), 0.0021430032453503087)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(0, 4, 300.0, 360.0), 0.0029303876579925905)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(0, 4, 360.0, 420.0), 0.00283576618143643)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(0, 4, 420.0, 480.0), 0.0027188265347502893)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(0, 4, 480.0, 540.0), 0.002597768116531099)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(0, 4, 540.0, 600.0), 0.002659151494701916)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(0, 4, 600.0, 660.0), 0.0021738406044924437)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(0, 4, 660.0, 720.0), 0.0021949848461843176)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(0, 4, 720.0, 780.0), 0.0021801193011023083)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(0, 4, 780.0, 840.0), 0.001746033717539671)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(0, 4, 840.0, 1080.0), 0.00350888397405923)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(4, 5, 0.0, 30.0), 0.0006845643884312735)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(4, 5, 30.0, 60.0), 0.0004003126952082357)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(4, 5, 60.0, 90.0), 0.0008155012585632697)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(4, 5, 90.0, 120.0), 0.0010930534970200114)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(4, 5, 120.0, 180.0), 0.0011760353713952051)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(4, 5, 180.0, 240.0), 0.0019364061980548415)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(4, 5, 240.0, 300.0), 0.002953452881036028)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(4, 5, 300.0, 360.0), 0.002589370165068672)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(4, 5, 360.0, 420.0), 0.0025604405819583055)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(4, 5, 420.0, 480.0), 0.0034319041631081476)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(4, 5, 480.0, 540.0), 0.0033480025727905907)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(4, 5, 540.0, 600.0), 0.002175717502193024)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(4, 5, 600.0, 660.0), 0.0028036478238686957)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(4, 5, 660.0, 720.0), 0.0028759635193342887)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(4, 5, 720.0, 780.0), 0.0017584406503249872)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(4, 5, 780.0, 840.0), 0.0016742001219093045)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(4, 5, 840.0, 1080.0), 0.0020658205220468245)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(5, 6, 0.0, 30.0), 0.0017247403950228777)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(5, 6, 30.0, 60.0), 0.003090998236080484)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(5, 6, 60.0, 90.0), 0.0015209554995803177)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(5, 6, 90.0, 120.0), 0.0016533392810110293)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(5, 6, 120.0, 180.0), 0.003732306124403562)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(5, 6, 180.0, 240.0), 0.004106247357091271)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(5, 6, 240.0, 300.0), 0.003188442431357427)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(5, 6, 300.0, 360.0), 0.005929370570550301)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(5, 6, 360.0, 420.0), 0.005992695595693005)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(5, 6, 420.0, 480.0), 0.006390572360276255)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(5, 6, 480.0, 540.0), 0.00993732232424166)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(5, 6, 540.0, 600.0), 0.007917613781985494)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(5, 6, 600.0, 660.0), 0.00753055040114282)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(5, 6, 660.0, 720.0), 0.004839531706746983)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(5, 6, 720.0, 780.0), 0.003571294178536547)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(5, 6, 780.0, 840.0), 0.0022261075091276465)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(5, 6, 840.0, 1080.0), 0.0020123396391017526)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(6, 7, 0.0, 30.0), 0.00553085745500388)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(6, 7, 30.0, 60.0), 0.005164301035284355)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(6, 7, 60.0, 90.0), 0.0034287284279468384)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(6, 7, 90.0, 120.0), 0.003359657704287739)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(6, 7, 120.0, 180.0), 0.005963896679549981)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(6, 7, 180.0, 240.0), 0.006376396116305889)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(6, 7, 240.0, 300.0), 0.011553162434249647)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(6, 7, 300.0, 360.0), 0.01216390369869719)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(6, 7, 360.0, 420.0), 0.015303642980241483)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(6, 7, 420.0, 480.0), 0.01894502604909179)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(6, 7, 480.0, 540.0), 0.026995818384739457)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(6, 7, 540.0, 600.0), 0.03735238580259259)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(6, 7, 600.0, 660.0), 0.02007351137947408)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(6, 7, 660.0, 720.0), 0.007579189226621267)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(6, 7, 720.0, 780.0), 0.003806896198418994)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(6, 7, 780.0, 840.0), 0.0020371212990837376)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(6, 7, 840.0, 1080.0), 0.00246729057836831)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(7, 8, 0.0, 30.0), 0.007834929725170775)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(7, 8, 30.0, 60.0), 0.007875284751511802)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(7, 8, 60.0, 90.0), 0.0056369706407995695)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(7, 8, 90.0, 120.0), 0.007252792818630801)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(7, 8, 120.0, 180.0), 0.011595289158181222)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(7, 8, 180.0, 240.0), 0.01584695155572567)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(7, 8, 240.0, 300.0), 0.019385993489144607)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(7, 8, 300.0, 360.0), 0.01804569113072999)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(7, 8, 360.0, 420.0), 0.020338168968415053)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(7, 8, 420.0, 480.0), 0.03244941203821404)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(7, 8, 480.0, 540.0), 0.046986423884473)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(7, 8, 540.0, 600.0), 0.026127574804977814)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(7, 8, 600.0, 660.0), 0.006859707180170414)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(7, 8, 660.0, 720.0), 0.004053368732850601)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(7, 8, 720.0, 780.0), 0.0017728320836715625)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(7, 8, 780.0, 840.0), 0.0008117046283836942)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(7, 8, 840.0, 1080.0), 0.0014889766393137468)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(8, 9, 0.0, 30.0), 0.008702611915372131)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(8, 9, 30.0, 60.0), 0.009703391735884857)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(8, 9, 60.0, 90.0), 0.00833249802530372)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(8, 9, 90.0, 120.0), 0.008160824294542027)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(8, 9, 120.0, 180.0), 0.014522058792957903)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(8, 9, 180.0, 240.0), 0.019189639247661674)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(8, 9, 240.0, 300.0), 0.022628081955363144)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(8, 9, 300.0, 360.0), 0.018168175275565253)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(8, 9, 360.0, 420.0), 0.01830766579908246)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(8, 9, 420.0, 480.0), 0.022414786327228577)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(8, 9, 480.0, 540.0), 0.015454698179801149)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(8, 9, 540.0, 600.0), 0.00743339793333549)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(8, 9, 600.0, 660.0), 0.0028959167218627997)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(8, 9, 660.0, 720.0), 0.0011608823477359163)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(8, 9, 720.0, 780.0), 0.0006126324367099846)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(8, 9, 780.0, 840.0), 0.0007090395380022889)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(8, 9, 840.0, 1080.0), 0.0009650931773638335)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(9, 10, 0.0, 30.0), 0.010532384705529854)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(9, 10, 30.0, 60.0), 0.010106787618396446)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(9, 10, 60.0, 90.0), 0.007305519187631069)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(9, 10, 90.0, 120.0), 0.0065298278976416635)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(9, 10, 120.0, 180.0), 0.012991661099288086)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(9, 10, 180.0, 240.0), 0.011082392048301831)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(9, 10, 240.0, 300.0), 0.013735041027849332)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(9, 10, 300.0, 360.0), 0.012921165569106639)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(9, 10, 360.0, 420.0), 0.010187951930469277)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(9, 10, 420.0, 480.0), 0.0070071162811467125)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(9, 10, 480.0, 540.0), 0.003478434072337058)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(9, 10, 540.0, 600.0), 0.002487434148850001)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(9, 10, 600.0, 660.0), 0.0007617139935295275)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(9, 10, 660.0, 720.0), 0.0004794259473854554)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(9, 10, 720.0, 780.0), 0.00011828408353297643)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(9, 10, 780.0, 840.0), 0.0009221448817170415)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(10, 11, 0.0, 30.0), 0.0053803765038808364)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(10, 11, 30.0, 60.0), 0.00748440387556175)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(10, 11, 60.0, 90.0), 0.003817044622559703)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(10, 11, 90.0, 120.0), 0.0042559767658946045)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(10, 11, 120.0, 180.0), 0.004633517730561146)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(10, 11, 180.0, 240.0), 0.0040156278424527785)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(10, 11, 240.0, 300.0), 0.004097425621422603)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(10, 11, 300.0, 360.0), 0.00534407493573042)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(10, 11, 360.0, 420.0), 0.002849425985304954)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(10, 11, 420.0, 480.0), 0.0024443772372422234)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(10, 11, 480.0, 540.0), 0.0011258612568464076)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(10, 11, 540.0, 600.0), 0.0005966047093584399)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(10, 11, 600.0, 660.0), 0.0005779388889435179)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(10, 11, 660.0, 720.0), 0.0004527621290439082)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(10, 11, 720.0, 780.0), 0.00011727646428602624)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(10, 11, 780.0, 840.0), 0.00011130198744577025)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(11, 12, 0.0, 30.0), 0.0025301846046864363)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(11, 12, 30.0, 60.0), 0.002932856090944951)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(11, 12, 60.0, 90.0), 0.0015297442159744696)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(11, 12, 90.0, 120.0), 0.0016816440829740813)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(11, 12, 120.0, 180.0), 0.0023140070407952395)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(11, 12, 180.0, 240.0), 0.0013768767086426792)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(11, 12, 240.0, 300.0), 0.0019019317686819275)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(11, 12, 300.0, 360.0), 0.0015577691125463963)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(11, 12, 360.0, 420.0), 0.001499121306916632)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(11, 12, 420.0, 480.0), 0.0007361366421130972)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(11, 12, 480.0, 540.0), 0.0007423049940853575)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(11, 12, 540.0, 600.0), 0.00011130198744577025)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(11, 12, 660.0, 720.0), 0.00024243947114654707)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(11, 12, 720.0, 780.0), 0.000261579996858755)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(12, 13, 0.0, 30.0), 0.0021669594044717543)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(12, 13, 30.0, 60.0), 0.0033993161916113994)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(12, 13, 60.0, 90.0), 0.001870484877697732)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(12, 13, 90.0, 120.0), 0.0008448185262884799)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(12, 13, 120.0, 180.0), 0.002024573233571085)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(12, 13, 180.0, 240.0), 0.0021888099857994042)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(12, 13, 240.0, 300.0), 0.0021657834323017752)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(12, 13, 300.0, 360.0), 0.0010623089332746248)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(12, 13, 360.0, 420.0), 0.0006268095760401356)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(12, 13, 420.0, 480.0), 0.0005094532977538987)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(12, 13, 480.0, 540.0), 0.0004744090926784203)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(12, 13, 540.0, 600.0), 0.00016487328572417658)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(12, 13, 660.0, 720.0), 0.0001162996982120756)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(13, 14, 0.0, 30.0), 0.0033401411497772818)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(13, 14, 30.0, 60.0), 0.002492685695459365)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(13, 14, 60.0, 90.0), 0.0027064477589805068)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(13, 14, 90.0, 120.0), 0.0018052297053924354)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(13, 14, 120.0, 180.0), 0.0027984509294891498)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(13, 14, 180.0, 240.0), 0.0022758505657711914)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(13, 14, 240.0, 300.0), 0.0003535503655144059)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(13, 14, 300.0, 360.0), 0.0005890430396050117)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(13, 14, 360.0, 420.0), 0.0002319134363595028)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(13, 14, 420.0, 480.0), 0.00011617748025141993)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(13, 14, 480.0, 540.0), 0.0003690064941818713)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(13, 14, 540.0, 600.0), 0.0001650495071007077)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(13, 14, 600.0, 660.0), 0.00023113252306835525)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(13, 14, 840.0, 1080.0), 0.00017239206443126303)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(14, 15, 0.0, 30.0), 0.003543871129770451)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(14, 15, 30.0, 60.0), 0.0018407982276338393)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(14, 15, 60.0, 90.0), 0.0010649270862293423)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(14, 15, 90.0, 120.0), 0.0009538696044712171)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(14, 15, 120.0, 180.0), 0.0021318639289119572)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(14, 15, 180.0, 240.0), 0.0019740243143620277)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(14, 15, 240.0, 300.0), 0.0006157677659961421)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(14, 15, 300.0, 360.0), 0.0004035374922773149)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(14, 15, 360.0, 420.0), 0.00011607019237524387)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(14, 15, 420.0, 480.0), 0.0003938282727195195)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(14, 15, 480.0, 540.0), 0.00011130198744577025)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(14, 15, 600.0, 660.0), 0.00011942109323430472)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(15, 16, 0.0, 30.0), 0.00254340964132742)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(15, 16, 30.0, 60.0), 0.0017847751078888892)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(15, 16, 60.0, 90.0), 0.000841891386995212)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(15, 16, 90.0, 120.0), 0.0003543852337006742)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(15, 16, 120.0, 180.0), 0.0013974221085794884)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(15, 16, 180.0, 240.0), 0.0006229273683665316)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(15, 16, 240.0, 300.0), 0.00020579571489011056)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(15, 16, 300.0, 360.0), 0.0004809214516599411)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(15, 16, 360.0, 420.0), 0.00022514291890117063)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(15, 16, 420.0, 480.0), 0.00014748146383900364)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(15, 16, 720.0, 780.0), 0.00011605559293173729)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(16, 17, 0.0, 30.0), 0.0019634787835054656)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(16, 17, 30.0, 60.0), 0.000860670737476427)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(16, 17, 60.0, 90.0), 0.0003550148096943092)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(16, 17, 90.0, 120.0), 0.000855728546868917)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(16, 17, 120.0, 180.0), 0.0009283998993093458)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(16, 17, 180.0, 240.0), 0.00022795178106384156)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(16, 17, 240.0, 300.0), 0.00024119874825349313)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(16, 17, 420.0, 480.0), 0.00023429279224671318)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(16, 17, 480.0, 540.0), 0.00011727269965059726)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(16, 17, 660.0, 720.0), 0.00011130198744577025)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(17, 18, 0.0, 30.0), 0.0017099830161073832)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(17, 18, 30.0, 60.0), 0.0006015092064895483)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(17, 18, 60.0, 90.0), 0.00011819436012345105)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(17, 18, 90.0, 120.0), 0.0002279569151752547)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(17, 18, 120.0, 180.0), 0.0006440525787748041)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(17, 18, 180.0, 240.0), 0.0003142746964600832)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(17, 18, 300.0, 360.0), 0.00022788575876606104)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(17, 18, 360.0, 420.0), 0.0004761806298753505)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(17, 18, 480.0, 540.0), 0.00011727269965059726)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(18, 19, 0.0, 30.0), 0.0020011795184968267)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(18, 19, 30.0, 60.0), 0.00023620950461199452)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(18, 19, 60.0, 90.0), 0.00011935825257957617)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(18, 19, 90.0, 120.0), 0.00011130198744577025)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(18, 19, 120.0, 180.0), 0.00012222981614916706)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(18, 19, 180.0, 240.0), 0.0002377005397786721)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(18, 19, 240.0, 300.0), 0.00026373526728965034)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(18, 19, 300.0, 360.0), 0.000256086036315955)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(18, 19, 360.0, 420.0), 0.00011394287938236544)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(19, 24, 0.0, 30.0), 0.0021116872169622083)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(19, 24, 30.0, 60.0), 0.0003681765715703113)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(19, 24, 60.0, 90.0), 0.0004137833254678062)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(19, 24, 90.0, 120.0), 0.00025108497234833097)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(19, 24, 120.0, 180.0), 0.0007576827338029722)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(19, 24, 180.0, 240.0), 0.0005180490039062906)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(19, 24, 240.0, 300.0), 0.0004944106124208977)); + tourDurationProbabilityDistribution.add(Pair.create(new TourStartAndDuration(19, 24, 300.0, 360.0), 0.0002278857587658224)); + } else + throw new IllegalArgumentException("Unknown small scale commercial traffic type: " + smallScaleCommercialTrafficType); + + return new EnumeratedDistribution<>(rng, tourDurationProbabilityDistribution); + } + /** * Creates the probability distribution for the duration of the services. * The values are given in [min] and have an upperBound. @@ -2096,4 +2577,7 @@ public boolean equals(Object obj) { private StopDurationGoodTrafficKey makeStopDurationGoodTrafficKey(String employeeCategory, String vehicleType) { return new StopDurationGoodTrafficKey(employeeCategory, vehicleType); } + + private record TourStartAndDuration(int hourLower, int hourUpper, double minDuration, double maxDuration) {} + } diff --git a/contribs/small-scale-traffic-generation/src/main/java/org/matsim/smallScaleCommercialTrafficGeneration/TripDistributionMatrix.java b/contribs/small-scale-traffic-generation/src/main/java/org/matsim/smallScaleCommercialTrafficGeneration/TripDistributionMatrix.java index 82be8708c6d..0b10c6a3d95 100644 --- a/contribs/small-scale-traffic-generation/src/main/java/org/matsim/smallScaleCommercialTrafficGeneration/TripDistributionMatrix.java +++ b/contribs/small-scale-traffic-generation/src/main/java/org/matsim/smallScaleCommercialTrafficGeneration/TripDistributionMatrix.java @@ -27,6 +27,7 @@ import it.unimi.dsi.fastutil.objects.Object2DoubleOpenHashMap; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.geotools.api.feature.simple.SimpleFeature; import org.locationtech.jts.geom.Geometry; import org.locationtech.jts.geom.Point; import org.matsim.api.core.v01.Id; @@ -39,7 +40,6 @@ import org.matsim.smallScaleCommercialTrafficGeneration.TrafficVolumeGeneration.TrafficVolumeKey; import org.matsim.vehicles.VehicleType; import org.matsim.vehicles.VehicleUtils; -import org.opengis.feature.simple.SimpleFeature; import java.io.BufferedWriter; import java.io.IOException; diff --git a/contribs/small-scale-traffic-generation/src/main/java/org/matsim/smallScaleCommercialTrafficGeneration/prepare/CreateDataDistributionOfStructureData.java b/contribs/small-scale-traffic-generation/src/main/java/org/matsim/smallScaleCommercialTrafficGeneration/prepare/CreateDataDistributionOfStructureData.java index c9ce08fe9b3..477231505c1 100644 --- a/contribs/small-scale-traffic-generation/src/main/java/org/matsim/smallScaleCommercialTrafficGeneration/prepare/CreateDataDistributionOfStructureData.java +++ b/contribs/small-scale-traffic-generation/src/main/java/org/matsim/smallScaleCommercialTrafficGeneration/prepare/CreateDataDistributionOfStructureData.java @@ -3,6 +3,7 @@ import it.unimi.dsi.fastutil.objects.Object2DoubleMap; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.geotools.api.feature.simple.SimpleFeature; import org.locationtech.jts.geom.Geometry; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -11,7 +12,6 @@ import org.matsim.core.utils.geometry.geotools.MGC; import org.matsim.facilities.*; import org.matsim.smallScaleCommercialTrafficGeneration.SmallScaleCommercialTrafficUtils; -import org.opengis.feature.simple.SimpleFeature; import picocli.CommandLine; import java.io.File; @@ -35,8 +35,11 @@ private enum LanduseConfiguration { useOnlyOSMLanduse, useOSMBuildingsAndLanduse } - @CommandLine.Option(names = "--pathOutput", description = "Path for the output", defaultValue = "output/TestDistributionClass") - private Path output; + @CommandLine.Option(names = "--outputFacilityFile", description = "Path for the outputFacilityFile", defaultValue = "output/TestDistributionClass/commercialFacilities.xml.gz") + private Path outputFacilityFile; + + @CommandLine.Option(names = "--outputDataDistributionFile", description = "Path for the outputDataDistributionFile", defaultValue = "output/TestDistributionClass/dataDistributionPerZone.csv") + private Path outputDataDistributionFile; @CommandLine.Option(names = "--landuseConfiguration", description = "Set option of used OSM data. Options: useOnlyOSMLanduse, useOSMBuildingsAndLanduse, useExistingDataDistribution", defaultValue = "useOSMBuildingsAndLanduse") private LanduseConfiguration usedLanduseConfiguration; @@ -112,13 +115,13 @@ public Integer call() throws Exception { ShpOptions.Index indexInvestigationAreaRegions = SmallScaleCommercialTrafficUtils.getIndexRegions(shapeFileRegionsPath, shapeCRS, regionsShapeRegionColumn); - if(Files.notExists(output)) - new File(output.toString()).mkdir(); + if(Files.notExists(outputFacilityFile.getParent())) + new File(outputFacilityFile.toString()).mkdir(); landuseCategoriesAndDataConnection = landuseDataConnectionCreator.createLanduseDataConnection(); Map> resultingDataPerZone = LanduseBuildingAnalysis - .createInputDataDistribution(output, landuseCategoriesAndDataConnection, + .createInputDataDistribution(outputDataDistributionFile, landuseCategoriesAndDataConnection, usedLanduseConfiguration.toString(), indexLanduse, indexZones, indexBuildings, indexInvestigationAreaRegions, shapeFileZoneNameColumn, buildingsPerZone, pathToInvestigationAreaData, shapeFileBuildingTypeColumn); @@ -127,11 +130,10 @@ public Integer call() throws Exception { ActivityFacilitiesFactory facilitiesFactory = facilities.getFactory(); calculateAreaSharesOfTheFacilities(facilities, facilitiesFactory); - Path facilityOutput = output.resolve("commercialFacilities.xml.gz"); - log.info("Created {} facilities, writing to {}", facilities.getFacilities().size(), facilityOutput); + log.info("Created {} facilities, writing to {}", facilities.getFacilities().size(), outputFacilityFile); FacilitiesWriter writer = new FacilitiesWriter(facilities); - writer.write(facilityOutput.toString()); + writer.write(outputFacilityFile.toString()); return 0; } diff --git a/contribs/small-scale-traffic-generation/src/main/java/org/matsim/smallScaleCommercialTrafficGeneration/prepare/LanduseBuildingAnalysis.java b/contribs/small-scale-traffic-generation/src/main/java/org/matsim/smallScaleCommercialTrafficGeneration/prepare/LanduseBuildingAnalysis.java index d26f95bde07..9b917eb006d 100644 --- a/contribs/small-scale-traffic-generation/src/main/java/org/matsim/smallScaleCommercialTrafficGeneration/prepare/LanduseBuildingAnalysis.java +++ b/contribs/small-scale-traffic-generation/src/main/java/org/matsim/smallScaleCommercialTrafficGeneration/prepare/LanduseBuildingAnalysis.java @@ -27,13 +27,13 @@ import org.apache.commons.csv.CSVRecord; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.geotools.api.feature.simple.SimpleFeature; import org.locationtech.jts.geom.Geometry; import org.locationtech.jts.geom.Point; import org.matsim.api.core.v01.Coord; import org.matsim.application.options.ShpOptions.Index; import org.matsim.core.utils.geometry.geotools.MGC; import org.matsim.core.utils.io.IOUtils; -import org.opengis.feature.simple.SimpleFeature; import java.io.BufferedWriter; import java.io.IOException; @@ -57,19 +57,19 @@ public class LanduseBuildingAnalysis { * Creates a distribution of the given input data for each zone based on the * used OSM data. */ - public static Map> createInputDataDistribution(Path output, + public static Map> createInputDataDistribution(Path outputDataDistributionFile, Map> landuseCategoriesAndDataConnection, String usedLanduseConfiguration, Index indexLanduse, Index indexZones, Index indexBuildings, Index indexInvestigationAreaRegions, String shapeFileZoneNameColumn, Map>> buildingsPerZone, - Path pathToInvestigationAreaData, String shapeFileBuildingTypeColumn) + Path pathToInvestigationAreaData, + String shapeFileBuildingTypeColumn) throws IOException { Map> resultingDataPerZone = new HashMap<>(); Map zoneIdRegionConnection = new HashMap<>(); - Path outputFileInOutputFolder = output.resolve("dataDistributionPerZone.csv"); log.info("New analyze for data distribution is started. The used method is: {}", usedLanduseConfiguration); Map> landuseCategoriesPerZone = new HashMap<>(); @@ -83,7 +83,7 @@ public static Map> createInputDataDistribution( createResultingDataForLanduseInZones(landuseCategoriesPerZone, investigationAreaData, resultingDataPerZone, landuseCategoriesAndDataConnection, zoneIdRegionConnection); - writeResultOfDataDistribution(resultingDataPerZone, outputFileInOutputFolder, + writeResultOfDataDistribution(resultingDataPerZone, outputDataDistributionFile, zoneIdRegionConnection); diff --git a/contribs/small-scale-traffic-generation/src/main/python/analyze_kid.py b/contribs/small-scale-traffic-generation/src/main/python/analyze_kid.py new file mode 100644 index 00000000000..61e8bd32be1 --- /dev/null +++ b/contribs/small-scale-traffic-generation/src/main/python/analyze_kid.py @@ -0,0 +1,190 @@ +# -*- coding: utf-8 -*- + +from datetime import timedelta + +import matplotlib.pyplot as plt +import matplotlib.ticker as ticker +import numpy as np +import pandas as pd +import seaborn as sns + +# %% + +sns.set_style("ticks") +sns.set_context("paper", font_scale=1.2, rc={"grid.linewidth": 1, "lines.linewidth": 2}) +# sns.set_palette("Set2") + +plt.rcParams['figure.dpi'] = 350 +plt.rcParams['pdf.fonttype'] = 42 +plt.rcParams['ps.fonttype'] = 42 +plt.rcParams['font.family'] = 'Arial' + +palette = sns.color_palette("Set2") + +# %% + +d = "/Users/rakow/Development/shared-svn/studies/countries/de/KiD_2002/Daten/" + +Fahrten = pd.read_csv(d + "KiD_2002_(Einzel)Fahrten-Datei.txt", delimiter="\t", encoding="ISO-8859-1") +Ketten = pd.read_csv(d + "KiD_2002_Fahrtenketten-Datei.txt", delimiter="\t", encoding="ISO-8859-1") +Fahrzeug = pd.read_csv(d + "KiD_2002_Fahrzeug-Datei.txt", delimiter="\t", encoding="ISO-8859-1") + +# %% + +Fahrten["start"] = pd.to_datetime(Fahrten["F04"], errors="coerce") +Fahrten["end"] = pd.to_datetime(Fahrten["F10a"], errors="coerce") + +# %% + +# Filter commercial trips +df = Fahrten[Fahrten["F07b"] == 1] + +df = df.merge(Fahrzeug, on="K00") +df = df.rename(columns={"K91": "w", "F14": "dist"}) + +df["type"] = df["F07a"].map( + {1: "goodsTraffic", 2: "commercialPersonTraffic", 3: "commercialPersonTraffic", 4: "commercialPersonTraffic", + 5: "returnDepot"}) +df = df[["K00", "F00", "start", "end", "w", "dist", "type"]] + +df["start"] = df["start"].dt.hour * 60 + df["start"].dt.minute +df["end"] = df["end"].dt.hour * 60 + df["end"].dt.minute + +# Filter valid ranges +df = df[df.start <= df.end] + +df["duration"] = df.end - df.start + +df = df.dropna() + +purpose = df.groupby("K00").apply( + lambda x: "goodsTraffic" if "goodsTraffic" in set(x["type"]) else "commercialPersonTraffic") + +# %% + +durations = [0, 10, 20, 30, 40, 50, 60, 75, 90, 105, 120, 150, 180, 240, 300, 420, 540, 660, np.inf] + +df["dur_group"] = pd.cut(df.duration, durations) + +starts = [0, 4 * 60, 5 * 60, 6 * 60, 7 * 60, 8 * 60, 9 * 60, 10 * 60, 11 * 60, 12 * 60, 13 * 60, 14 * 60, 15 * 60, + 16 * 60, 17 * 60, 18 * 60, 19 * 60, np.inf] +start_labels = ["0-4", "4-5", "5-6", "6-7", "7-8", "8-9", "9-10", "10-11", "11-12", "12-13", "13-14", "14-15", "15-16", + "16-17", "17-18", "18-19", "19-24"] + +df["start_group"] = pd.cut(df.start, starts) + +# %% + +x = np.arange(start=0, stop=24 * 60, step=15, dtype=np.float64) + +# %% + +y = np.zeros_like(x) + +for t in df.itertuples(): + idx = np.searchsorted(x, [t.start, t.end]) + idx[1] += 1 + + y[slice(*idx)] += t.w + +y /= np.max(y / 1000) + +# %% + +fig, ax = plt.subplots(figsize=(8, 4)) + +sns.lineplot(x=x, y=y, ax=ax) + +sns.despine() + +ax.xaxis.set_major_locator(ticker.FixedLocator(np.arange(start=0, stop=24 * 60, step=120, dtype=np.float64))) +ax.xaxis.set_major_formatter(lambda x, y: str(timedelta(minutes=x))[:-3]) + +# %% + + +sns.histplot(data=df, x="duration", bins=durations) + +# %% + +# Only commercial tours + +Ketten["start"] = pd.to_datetime(Ketten["T04"], errors="coerce") + +tf = Ketten[Ketten.T07 == 1] + +tf = tf.merge(Fahrzeug, on="K00").set_index("K00") +tf["type"] = purpose + +tf["start"] = tf["start"].dt.hour * 60 + tf["start"].dt.minute + +tf = tf.rename(columns={"K91": "w", "T01": "duration", "T05": "dist", "K03": "vWeight"}) + +tf = tf[tf.duration > 0] + +tf = tf[["start", "w", "duration", "dist", "vWeight", "type"]] + +tf = tf.dropna() + +# %% + +vehicles = [0, 2800, 3500, 7500, 12000, 100000] + +tf["vClass"] = pd.cut(tf.vWeight, vehicles, labels=["vehType1", "vehType2", "vehType3", "vehType4", "vehType5"]) + +t_durations = np.hstack(([0, 30, 60, 90], np.arange(120, 15 * 60, step=60, dtype=np.float64), [18 * 60])) + +tf["dur_group"] = pd.cut(tf.duration, t_durations) +tf["start_group"] = pd.cut(tf.start, starts, labels=start_labels) + +tf = tf.dropna() + +# %% + +aggr = tf.groupby(["type", "start_group", "dur_group"]).agg(p=("w", "sum")) + +for group in ("goodsTraffic", "commercialPersonTraffic"): + sub = aggr.loc[group, :] + sub.p /= sub.p.sum() + +aggr = aggr.reset_index() + +target = "goodsTraffic" +for a in aggr.itertuples(): + + if a.type != target or a.p <= 0: + continue + + f, t = a.start_group.split("-") + lower, upper = a.dur_group.left, a.dur_group.right + + print(f"Pair.create(new TourStartAndDuration({f}, {t}, {lower}, {upper}), {a.p}),") + +# %% + +fig, ax = plt.subplots(figsize=(8, 4)) + +sns.histplot(data=tf, x="start", bins=starts, ax=ax) + +sns.despine() + +ax.xaxis.set_major_locator(ticker.FixedLocator(np.arange(start=0, stop=24 * 60, step=120, dtype=np.float64))) +ax.xaxis.set_major_formatter(lambda x, y: str(timedelta(minutes=x))[:-3]) + +# %% + +fig, ax = plt.subplots(figsize=(8, 4)) + +sns.histplot(data=tf, x="duration", bins=t_durations, ax=ax) +sns.despine() + +ax.xaxis.set_major_formatter(lambda x, y: int(x // 60)) +ax.xaxis.set_major_locator(ticker.FixedLocator(np.arange(start=0, stop=24 * 60, step=60, dtype=np.float64))) + +# %% + +grid = sns.FacetGrid(tf, col="start_group", col_wrap=6, palette="tab20c") + +grid.map_dataframe(sns.histplot, x="duration", bins=t_durations, stat="percent") + +# %% diff --git a/contribs/small-scale-traffic-generation/src/test/java/org/matsim/smallScaleCommercialTrafficGeneration/TrafficVolumeGenerationTest.java b/contribs/small-scale-traffic-generation/src/test/java/org/matsim/smallScaleCommercialTrafficGeneration/TrafficVolumeGenerationTest.java index fc0bbe878cf..ce0aeda6610 100644 --- a/contribs/small-scale-traffic-generation/src/test/java/org/matsim/smallScaleCommercialTrafficGeneration/TrafficVolumeGenerationTest.java +++ b/contribs/small-scale-traffic-generation/src/test/java/org/matsim/smallScaleCommercialTrafficGeneration/TrafficVolumeGenerationTest.java @@ -20,6 +20,7 @@ package org.matsim.smallScaleCommercialTrafficGeneration; import it.unimi.dsi.fastutil.objects.Object2DoubleMap; +import org.geotools.api.feature.simple.SimpleFeature; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; @@ -38,7 +39,6 @@ import org.matsim.smallScaleCommercialTrafficGeneration.prepare.LanduseDataConnectionCreator; import org.matsim.smallScaleCommercialTrafficGeneration.prepare.LanduseDataConnectionCreatorForOSM_Data; import org.matsim.testcases.MatsimTestUtils; -import org.opengis.feature.simple.SimpleFeature; import java.io.File; import java.io.IOException; @@ -59,8 +59,8 @@ void testTrafficVolumeGenerationCommercialPersonTraffic() throws IOException { Map>> buildingsPerZone = new HashMap<>(); - Path output = Path.of(utils.getOutputDirectory()); - assert(new File(output.resolve("calculatedData").toString()).mkdir()); + Path outputDataDistributionFile = Path.of(utils.getOutputDirectory()).resolve("dataDistributionPerZone.csv"); + assert(new File(outputDataDistributionFile.getParent().resolve("calculatedData").toString()).mkdir()); Path inputDataDirectory = Path.of(utils.getPackageInputDirectory()); String usedLanduseConfiguration = "useOSMBuildingsAndLanduse"; String shapeFileZoneNameColumn = "name"; @@ -70,7 +70,7 @@ void testTrafficVolumeGenerationCommercialPersonTraffic() throws IOException { Map> landuseCategoriesAndDataConnection = landuseDataConnectionCreator.createLanduseDataConnection(); Map> resultingDataPerZone = LanduseBuildingAnalysis - .createInputDataDistribution(output, landuseCategoriesAndDataConnection, + .createInputDataDistribution(outputDataDistributionFile, landuseCategoriesAndDataConnection, usedLanduseConfiguration, SCTUtils.getIndexLanduse(inputDataDirectory), SCTUtils.getZoneIndex(inputDataDirectory), SCTUtils.getIndexBuildings(inputDataDirectory), SCTUtils.getIndexRegions(inputDataDirectory), shapeFileZoneNameColumn, buildingsPerZone, pathToInvestigationAreaData, shapeFileBuildingTypeColumn); @@ -83,9 +83,9 @@ void testTrafficVolumeGenerationCommercialPersonTraffic() throws IOException { TrafficVolumeGeneration.setInputParameters(usedTrafficType); Map> trafficVolumePerTypeAndZone_start = TrafficVolumeGeneration - .createTrafficVolume_start(resultingDataPerZone, output, sample, modesORvehTypes, usedTrafficType); + .createTrafficVolume_start(resultingDataPerZone, outputDataDistributionFile.getParent(), sample, modesORvehTypes, usedTrafficType); Map> trafficVolumePerTypeAndZone_stop = TrafficVolumeGeneration - .createTrafficVolume_stop(resultingDataPerZone, output, sample, modesORvehTypes, usedTrafficType); + .createTrafficVolume_stop(resultingDataPerZone, outputDataDistributionFile.getParent(), sample, modesORvehTypes, usedTrafficType); Assertions.assertEquals(3, trafficVolumePerTypeAndZone_start.size()); Assertions.assertEquals(3, trafficVolumePerTypeAndZone_stop.size()); @@ -138,9 +138,9 @@ void testTrafficVolumeGenerationCommercialPersonTraffic() throws IOException { //test with different sample sample = 0.25; trafficVolumePerTypeAndZone_start = TrafficVolumeGeneration - .createTrafficVolume_start(resultingDataPerZone, output, sample, modesORvehTypes, usedTrafficType); + .createTrafficVolume_start(resultingDataPerZone, outputDataDistributionFile.getParent(), sample, modesORvehTypes, usedTrafficType); trafficVolumePerTypeAndZone_stop = TrafficVolumeGeneration - .createTrafficVolume_stop(resultingDataPerZone, output, sample, modesORvehTypes, usedTrafficType); + .createTrafficVolume_stop(resultingDataPerZone, outputDataDistributionFile.getParent(), sample, modesORvehTypes, usedTrafficType); Assertions.assertEquals(3, trafficVolumePerTypeAndZone_start.size()); Assertions.assertEquals(3, trafficVolumePerTypeAndZone_stop.size()); @@ -190,8 +190,8 @@ void testTrafficVolumeGenerationGoodsTraffic() throws IOException { Map>> buildingsPerZone = new HashMap<>(); - Path output = Path.of(utils.getOutputDirectory()); - assert(new File(output.resolve("calculatedData").toString()).mkdir()); + Path outputDataDistributionFile = Path.of(utils.getOutputDirectory()).resolve("dataDistributionPerZone.csv"); + assert(new File(outputDataDistributionFile.getParent().resolve("calculatedData").toString()).mkdir()); Path inputDataDirectory = Path.of(utils.getPackageInputDirectory()); String usedLanduseConfiguration = "useOSMBuildingsAndLanduse"; String shapeFileZoneNameColumn = "name"; @@ -201,7 +201,7 @@ void testTrafficVolumeGenerationGoodsTraffic() throws IOException { Map> landuseCategoriesAndDataConnection = landuseDataConnectionCreator.createLanduseDataConnection(); Map> resultingDataPerZone = LanduseBuildingAnalysis - .createInputDataDistribution(output, landuseCategoriesAndDataConnection, + .createInputDataDistribution(outputDataDistributionFile, landuseCategoriesAndDataConnection, usedLanduseConfiguration, SCTUtils.getIndexLanduse(inputDataDirectory), SCTUtils.getZoneIndex(inputDataDirectory), SCTUtils.getIndexBuildings(inputDataDirectory), SCTUtils.getIndexRegions(inputDataDirectory), shapeFileZoneNameColumn, buildingsPerZone, pathToInvestigationAreaData, shapeFileBuildingTypeColumn); @@ -213,9 +213,9 @@ void testTrafficVolumeGenerationGoodsTraffic() throws IOException { TrafficVolumeGeneration.setInputParameters(usedTrafficType); Map> trafficVolumePerTypeAndZone_start = TrafficVolumeGeneration - .createTrafficVolume_start(resultingDataPerZone, output, sample, modesORvehTypes, usedTrafficType); + .createTrafficVolume_start(resultingDataPerZone, outputDataDistributionFile.getParent(), sample, modesORvehTypes, usedTrafficType); Map> trafficVolumePerTypeAndZone_stop = TrafficVolumeGeneration - .createTrafficVolume_stop(resultingDataPerZone, output, sample, modesORvehTypes, usedTrafficType); + .createTrafficVolume_stop(resultingDataPerZone, outputDataDistributionFile.getParent(), sample, modesORvehTypes, usedTrafficType); Assertions.assertEquals(15, trafficVolumePerTypeAndZone_start.size()); Assertions.assertEquals(15, trafficVolumePerTypeAndZone_stop.size()); @@ -514,8 +514,8 @@ void testAddingExistingScenariosWithSample() throws Exception { void testReducingDemandAfterAddingExistingScenarios_goods() throws Exception { Map>> buildingsPerZone = new HashMap<>(); - Path output = Path.of(utils.getOutputDirectory()); - assert(new File(output.resolve("calculatedData").toString()).mkdir()); + Path outputDataDistributionFile = Path.of(utils.getOutputDirectory()).resolve("dataDistributionPerZone.csv"); + assert(new File(outputDataDistributionFile.getParent().resolve("calculatedData").toString()).mkdir()); Path inputDataDirectory = Path.of(utils.getPackageInputDirectory()); String usedLanduseConfiguration = "useOSMBuildingsAndLanduse"; String networkPath = "https://raw.githubusercontent.com/matsim-org/matsim-libs/master/examples/scenarios/freight-chessboard-9x9/grid9x9.xml"; @@ -542,15 +542,15 @@ void testReducingDemandAfterAddingExistingScenarios_goods() throws Exception { Map>> facilitiesPerZone = new HashMap<>(); Map> resultingDataPerZone = LanduseBuildingAnalysis - .createInputDataDistribution(output, landuseCategoriesAndDataConnection, + .createInputDataDistribution(outputDataDistributionFile, landuseCategoriesAndDataConnection, usedLanduseConfiguration, SCTUtils.getIndexLanduse(inputDataDirectory), SCTUtils.getZoneIndex(inputDataDirectory), SCTUtils.getIndexBuildings(inputDataDirectory), SCTUtils.getIndexRegions(inputDataDirectory), shapeFileZoneNameColumn, buildingsPerZone, pathToInvestigationAreaData, shapeFileBuildingTypeColumn); Map> trafficVolumePerTypeAndZone_start = TrafficVolumeGeneration - .createTrafficVolume_start(resultingDataPerZone, output, sample, modesORvehTypes, usedTrafficType); + .createTrafficVolume_start(resultingDataPerZone, outputDataDistributionFile.getParent(), sample, modesORvehTypes, usedTrafficType); Map> trafficVolumePerTypeAndZone_stop = TrafficVolumeGeneration - .createTrafficVolume_stop(resultingDataPerZone, output, sample, modesORvehTypes, usedTrafficType); + .createTrafficVolume_stop(resultingDataPerZone, outputDataDistributionFile.getParent(), sample, modesORvehTypes, usedTrafficType); Map, Link>> linksPerZone = GenerateSmallScaleCommercialTrafficDemand .filterLinksForZones(scenario, SCTUtils.getZoneIndex(inputDataDirectory), facilitiesPerZone, shapeFileZoneNameColumn); @@ -680,8 +680,8 @@ void testReducingDemandAfterAddingExistingScenarios_commercialPersonTraffic() th Map>> buildingsPerZone = new HashMap<>(); Map>> facilitiesPerZone = new HashMap<>(); - Path output = Path.of(utils.getOutputDirectory()); - assert(new File(output.resolve("calculatedData").toString()).mkdir()); + Path outputDataDistributionFile = Path.of(utils.getOutputDirectory()).resolve("dataDistributionPerZone.csv"); + assert(new File(outputDataDistributionFile.getParent().resolve("calculatedData").toString()).mkdir()); Path inputDataDirectory = Path.of(utils.getPackageInputDirectory()); String usedLanduseConfiguration = "useOSMBuildingsAndLanduse"; String networkPath = "https://raw.githubusercontent.com/matsim-org/matsim-libs/master/examples/scenarios/freight-chessboard-9x9/grid9x9.xml"; @@ -708,15 +708,15 @@ void testReducingDemandAfterAddingExistingScenarios_commercialPersonTraffic() th Map> resultingDataPerZone = LanduseBuildingAnalysis - .createInputDataDistribution(output, landuseCategoriesAndDataConnection, + .createInputDataDistribution(outputDataDistributionFile, landuseCategoriesAndDataConnection, usedLanduseConfiguration, SCTUtils.getIndexLanduse(inputDataDirectory), SCTUtils.getZoneIndex(inputDataDirectory), SCTUtils.getIndexBuildings(inputDataDirectory), SCTUtils.getIndexRegions(inputDataDirectory), shapeFileZoneNameColumn, buildingsPerZone, pathToInvestigationAreaData, shapeFileBuildingTypeColumn); Map> trafficVolumePerTypeAndZone_start = TrafficVolumeGeneration - .createTrafficVolume_start(resultingDataPerZone, output, sample, modesORvehTypes, usedTrafficType); + .createTrafficVolume_start(resultingDataPerZone, outputDataDistributionFile.getParent(), sample, modesORvehTypes, usedTrafficType); Map> trafficVolumePerTypeAndZone_stop = TrafficVolumeGeneration - .createTrafficVolume_stop(resultingDataPerZone, output, sample, modesORvehTypes, usedTrafficType); + .createTrafficVolume_stop(resultingDataPerZone, outputDataDistributionFile.getParent(), sample, modesORvehTypes, usedTrafficType); Map, Link>> regionLinksMap = GenerateSmallScaleCommercialTrafficDemand .filterLinksForZones(scenario, SCTUtils.getZoneIndex(inputDataDirectory), facilitiesPerZone, shapeFileZoneNameColumn); diff --git a/contribs/small-scale-traffic-generation/src/test/java/org/matsim/smallScaleCommercialTrafficGeneration/TripDistributionMatrixTest.java b/contribs/small-scale-traffic-generation/src/test/java/org/matsim/smallScaleCommercialTrafficGeneration/TripDistributionMatrixTest.java index 90870d2ceff..7109fbbede2 100644 --- a/contribs/small-scale-traffic-generation/src/test/java/org/matsim/smallScaleCommercialTrafficGeneration/TripDistributionMatrixTest.java +++ b/contribs/small-scale-traffic-generation/src/test/java/org/matsim/smallScaleCommercialTrafficGeneration/TripDistributionMatrixTest.java @@ -20,6 +20,7 @@ package org.matsim.smallScaleCommercialTrafficGeneration; import it.unimi.dsi.fastutil.objects.Object2DoubleMap; +import org.geotools.api.feature.simple.SimpleFeature; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; @@ -30,7 +31,6 @@ import org.matsim.smallScaleCommercialTrafficGeneration.TrafficVolumeGeneration.TrafficVolumeKey; import org.matsim.smallScaleCommercialTrafficGeneration.prepare.LanduseBuildingAnalysis; import org.matsim.testcases.MatsimTestUtils; -import org.opengis.feature.simple.SimpleFeature; import java.io.File; import java.io.IOException; @@ -54,8 +54,8 @@ void testTripDistributionCommercialPersonTrafficTraffic() throws IOException { Map> landuseCategoriesAndDataConnection = new HashMap<>(); Map>> buildingsPerZone = new HashMap<>(); - Path output = Path.of(utils.getOutputDirectory()); - assert(new File(output.resolve("calculatedData").toString()).mkdir()); + Path outputDataDistributionFile = Path.of(utils.getOutputDirectory()).resolve("dataDistributionPerZone.csv"); + assert(new File(outputDataDistributionFile.getParent().resolve("calculatedData").toString()).mkdir()); Path inputDataDirectory = Path.of(utils.getPackageInputDirectory()); String usedLanduseConfiguration = "useOSMBuildingsAndLanduse"; String networkLocation = "https://raw.githubusercontent.com/matsim-org/matsim-libs/master/examples/scenarios/freight-chessboard-9x9/grid9x9.xml"; @@ -65,7 +65,7 @@ void testTripDistributionCommercialPersonTrafficTraffic() throws IOException { Path pathToInvestigationAreaData = Path.of(utils.getPackageInputDirectory()).resolve("investigationAreaData.csv"); Map> resultingDataPerZone = LanduseBuildingAnalysis - .createInputDataDistribution(output, landuseCategoriesAndDataConnection, + .createInputDataDistribution(outputDataDistributionFile, landuseCategoriesAndDataConnection, usedLanduseConfiguration, getIndexLanduse(inputDataDirectory), getZoneIndex(inputDataDirectory), getIndexBuildings(inputDataDirectory), SCTUtils.getIndexRegions(inputDataDirectory), shapeFileZoneNameColumn, buildingsPerZone, pathToInvestigationAreaData, shapeFileBuildingTypeColumn); @@ -78,9 +78,9 @@ void testTripDistributionCommercialPersonTrafficTraffic() throws IOException { TrafficVolumeGeneration.setInputParameters(usedTrafficType); Map> trafficVolumePerTypeAndZone_start = TrafficVolumeGeneration - .createTrafficVolume_start(resultingDataPerZone, output, sample, modesORvehTypes, usedTrafficType); + .createTrafficVolume_start(resultingDataPerZone, outputDataDistributionFile.getParent(), sample, modesORvehTypes, usedTrafficType); Map> trafficVolumePerTypeAndZone_stop = TrafficVolumeGeneration - .createTrafficVolume_stop(resultingDataPerZone, output, sample, modesORvehTypes, usedTrafficType); + .createTrafficVolume_stop(resultingDataPerZone, outputDataDistributionFile.getParent(), sample, modesORvehTypes, usedTrafficType); ArrayList listOfZones = new ArrayList<>( List.of("area1", "area2", "area3")); final TripDistributionMatrix odMatrix = TripDistributionMatrix.Builder .newInstance(getZoneIndex(inputDataDirectory), trafficVolumePerTypeAndZone_start, trafficVolumePerTypeAndZone_stop, usedTrafficType, @@ -146,8 +146,8 @@ void testTripDistributionGoodsTraffic() throws IOException { Map> landuseCategoriesAndDataConnection = new HashMap<>(); Map>> buildingsPerZone = new HashMap<>(); - Path output = Path.of(utils.getOutputDirectory()); - assert(new File(output.resolve("calculatedData").toString()).mkdir()); + Path outputDataDistributionFile = Path.of(utils.getOutputDirectory()).resolve("dataDistributionPerZone.csv"); + assert(new File(outputDataDistributionFile.getParent().resolve("calculatedData").toString()).mkdir()); Path inputDataDirectory = Path.of(utils.getPackageInputDirectory()); String usedLanduseConfiguration = "useOSMBuildingsAndLanduse"; String networkLocation = "https://raw.githubusercontent.com/matsim-org/matsim-libs/master/examples/scenarios/freight-chessboard-9x9/grid9x9.xml"; @@ -157,7 +157,7 @@ void testTripDistributionGoodsTraffic() throws IOException { Path pathToInvestigationAreaData = Path.of(utils.getPackageInputDirectory()).resolve("investigationAreaData.csv"); Map> resultingDataPerZone = LanduseBuildingAnalysis - .createInputDataDistribution(output, landuseCategoriesAndDataConnection, + .createInputDataDistribution(outputDataDistributionFile, landuseCategoriesAndDataConnection, usedLanduseConfiguration, getIndexLanduse(inputDataDirectory), getZoneIndex(inputDataDirectory), getIndexBuildings(inputDataDirectory), SCTUtils.getIndexRegions(inputDataDirectory), shapeFileZoneNameColumn, buildingsPerZone, pathToInvestigationAreaData, shapeFileBuildingTypeColumn); @@ -173,9 +173,9 @@ void testTripDistributionGoodsTraffic() throws IOException { TrafficVolumeGeneration.setInputParameters(usedTrafficType); Map> trafficVolumePerTypeAndZone_start = TrafficVolumeGeneration - .createTrafficVolume_start(resultingDataPerZone, output, sample, modesORvehTypes, usedTrafficType); + .createTrafficVolume_start(resultingDataPerZone, outputDataDistributionFile.getParent(), sample, modesORvehTypes, usedTrafficType); Map> trafficVolumePerTypeAndZone_stop = TrafficVolumeGeneration - .createTrafficVolume_stop(resultingDataPerZone, output, sample, modesORvehTypes, usedTrafficType); + .createTrafficVolume_stop(resultingDataPerZone, outputDataDistributionFile.getParent(), sample, modesORvehTypes, usedTrafficType); final TripDistributionMatrix odMatrix = TripDistributionMatrix.Builder .newInstance(getZoneIndex(inputDataDirectory), trafficVolumePerTypeAndZone_start, trafficVolumePerTypeAndZone_stop, usedTrafficType, listOfZones).build(); diff --git a/contribs/small-scale-traffic-generation/src/test/java/org/matsim/smallScaleCommercialTrafficGeneration/prepare/LanduseBuildingAnalysisTest.java b/contribs/small-scale-traffic-generation/src/test/java/org/matsim/smallScaleCommercialTrafficGeneration/prepare/LanduseBuildingAnalysisTest.java index d380e832ddb..a44b17581e2 100644 --- a/contribs/small-scale-traffic-generation/src/test/java/org/matsim/smallScaleCommercialTrafficGeneration/prepare/LanduseBuildingAnalysisTest.java +++ b/contribs/small-scale-traffic-generation/src/test/java/org/matsim/smallScaleCommercialTrafficGeneration/prepare/LanduseBuildingAnalysisTest.java @@ -20,12 +20,12 @@ package org.matsim.smallScaleCommercialTrafficGeneration.prepare; import it.unimi.dsi.fastutil.objects.Object2DoubleMap; +import org.geotools.api.feature.simple.SimpleFeature; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.smallScaleCommercialTrafficGeneration.SCTUtils; import org.matsim.testcases.MatsimTestUtils; -import org.opengis.feature.simple.SimpleFeature; import java.io.File; import java.io.IOException; @@ -47,8 +47,8 @@ public class LanduseBuildingAnalysisTest { void testReadOfDataDistributionPerZoneAndBuildingAnalysis() throws IOException { Map>> buildingsPerZone = new HashMap<>(); - Path output = Path.of(utils.getOutputDirectory()); - assert(new File(output.resolve("calculatedData").toString()).mkdir()); + Path outputDataDistributionFile = Path.of(utils.getOutputDirectory()).resolve("dataDistributionPerZone.csv"); + assert(new File(outputDataDistributionFile.getParent().resolve("calculatedData").toString()).mkdir()); Path inputDataDirectory = Path.of(utils.getPackageInputDirectory()).getParent(); String usedLanduseConfiguration = "useOSMBuildingsAndLanduse"; String shapeFileZoneNameColumn = "name"; @@ -59,7 +59,7 @@ void testReadOfDataDistributionPerZoneAndBuildingAnalysis() throws IOException { // Test if the reading of the existing data distribution works correctly Map> resultingDataPerZone = LanduseBuildingAnalysis - .createInputDataDistribution(output, landuseCategoriesAndDataConnection, + .createInputDataDistribution(outputDataDistributionFile, landuseCategoriesAndDataConnection, usedLanduseConfiguration, SCTUtils.getIndexLanduse(inputDataDirectory), SCTUtils.getZoneIndex(inputDataDirectory), SCTUtils.getIndexBuildings(inputDataDirectory), SCTUtils.getIndexRegions(inputDataDirectory), shapeFileZoneNameColumn, buildingsPerZone, pathToInvestigationAreaData, shapeFileBuildingTypeColumn); @@ -241,8 +241,8 @@ void testReadOfDataDistributionPerZoneAndBuildingAnalysis() throws IOException { void testLanduseDistribution() throws IOException { Map>> buildingsPerZone = new HashMap<>(); - Path output = Path.of(utils.getOutputDirectory()); - assert(new File(output.resolve("calculatedData").toString()).mkdir()); + Path outputDataDistributionFile = Path.of(utils.getOutputDirectory()).resolve("dataDistributionPerZone.csv"); + assert(new File(outputDataDistributionFile.getParent().resolve("calculatedData").toString()).mkdir()); Path inputDataDirectory = Path.of(utils.getPackageInputDirectory()).getParent(); String usedLanduseConfiguration = "useOSMBuildingsAndLanduse"; String shapeFileZoneNameColumn = "name"; @@ -253,7 +253,7 @@ void testLanduseDistribution() throws IOException { // Analyze resultingData per zone Map> resultingDataPerZone = LanduseBuildingAnalysis - .createInputDataDistribution(output, landuseCategoriesAndDataConnection, + .createInputDataDistribution(outputDataDistributionFile, landuseCategoriesAndDataConnection, usedLanduseConfiguration, SCTUtils.getIndexLanduse(inputDataDirectory), SCTUtils.getZoneIndex(inputDataDirectory), SCTUtils.getIndexBuildings(inputDataDirectory), SCTUtils.getIndexRegions(inputDataDirectory), shapeFileZoneNameColumn, buildingsPerZone, pathToInvestigationAreaData, shapeFileBuildingTypeColumn); diff --git a/contribs/small-scale-traffic-generation/src/test/java/org/matsim/smallScaleCommercialTrafficGeneration/prepare/RunCreateDataDistributionOfStructureDataTest.java b/contribs/small-scale-traffic-generation/src/test/java/org/matsim/smallScaleCommercialTrafficGeneration/prepare/RunCreateDataDistributionOfStructureDataTest.java index 1953bec4914..d24ee4b31bb 100644 --- a/contribs/small-scale-traffic-generation/src/test/java/org/matsim/smallScaleCommercialTrafficGeneration/prepare/RunCreateDataDistributionOfStructureDataTest.java +++ b/contribs/small-scale-traffic-generation/src/test/java/org/matsim/smallScaleCommercialTrafficGeneration/prepare/RunCreateDataDistributionOfStructureDataTest.java @@ -37,7 +37,8 @@ void testDataDistributionOfStructureData() throws MalformedURLException { String investigationAreaData = Path.of(utils.getPackageInputDirectory()).getParent().resolve("investigationAreaData.csv").toString(); new CreateDataDistributionOfStructureData().execute( - "--pathOutput", utils.getOutputDirectory(), + "--outputFacilityFile", utils.getOutputDirectory() + "/commercialFacilities.xml.gz", + "--outputDataDistributionFile", utils.getOutputDirectory() + "/dataDistributionPerZone.csv", "--landuseConfiguration", useOSMBuildingsAndLanduse, "--regionsShapeFileName", regionsShapeFileName, "--regionsShapeRegionColumn", regionsShapeRegionColumn, diff --git a/contribs/small-scale-traffic-generation/test/input/org/matsim/smallScaleCommercialTrafficGeneration/test.output_events.xml.gz b/contribs/small-scale-traffic-generation/test/input/org/matsim/smallScaleCommercialTrafficGeneration/test.output_events.xml.gz index 5f61199dc0b..b402920a875 100644 Binary files a/contribs/small-scale-traffic-generation/test/input/org/matsim/smallScaleCommercialTrafficGeneration/test.output_events.xml.gz and b/contribs/small-scale-traffic-generation/test/input/org/matsim/smallScaleCommercialTrafficGeneration/test.output_events.xml.gz differ diff --git a/contribs/sumo/pom.xml b/contribs/sumo/pom.xml index d55aa642bf5..da11bdf4865 100644 --- a/contribs/sumo/pom.xml +++ b/contribs/sumo/pom.xml @@ -23,7 +23,7 @@ info.picocli picocli - 4.7.5 + 4.7.6 diff --git a/contribs/taxi/src/main/java/org/matsim/contrib/taxi/run/MultiModeTaxiModule.java b/contribs/taxi/src/main/java/org/matsim/contrib/taxi/run/MultiModeTaxiModule.java index 31bf3440150..4c577fed4a8 100644 --- a/contribs/taxi/src/main/java/org/matsim/contrib/taxi/run/MultiModeTaxiModule.java +++ b/contribs/taxi/src/main/java/org/matsim/contrib/taxi/run/MultiModeTaxiModule.java @@ -21,6 +21,7 @@ package org.matsim.contrib.taxi.run; import org.matsim.contrib.drt.fare.DrtFareParams; +import org.matsim.contrib.drt.optimizer.DrtOptimizationConstraintsSet; import org.matsim.contrib.drt.run.DrtConfigGroup; import org.matsim.contrib.drt.run.DrtModeModule; import org.matsim.contrib.drt.run.DrtModeQSimModule; @@ -66,16 +67,17 @@ public static DrtConfigGroup convertTaxiToDrtCfg(TaxiConfigGroup taxiCfg) { // Taxi optimisers do not reject, so time constraints are only used for routing plans (DrtRouteCreator). // Using some (relatively high) values as we do not know what values should be there. They can be adjusted // manually after the TaxiAsDrtConfigGroup config is created. - drtCfg.maxWaitTime = 3600; - drtCfg.maxTravelTimeAlpha = 2; - drtCfg.maxTravelTimeBeta = 3600; - drtCfg.maxAbsoluteDetour = Double.MAX_VALUE; + DrtOptimizationConstraintsSet defaultConstraintsSet = drtCfg.addOrGetDrtOptimizationConstraintsParams().addOrGetDefaultDrtOptimizationConstraintsSet(); + defaultConstraintsSet.maxWaitTime = 3600; + defaultConstraintsSet.maxTravelTimeAlpha = 2; + defaultConstraintsSet.maxTravelTimeBeta = 3600; + defaultConstraintsSet.maxAbsoluteDetour = Double.MAX_VALUE; - drtCfg.rejectRequestIfMaxWaitOrTravelTimeViolated = false; + defaultConstraintsSet.rejectRequestIfMaxWaitOrTravelTimeViolated = false; drtCfg.changeStartLinkToLastLinkInSchedule = taxiCfg.changeStartLinkToLastLinkInSchedule; drtCfg.idleVehiclesReturnToDepots = false; drtCfg.operationalScheme = DrtConfigGroup.OperationalScheme.door2door; - drtCfg.maxWalkDistance = Double.MAX_VALUE; + defaultConstraintsSet.maxWalkDistance = Double.MAX_VALUE; drtCfg.vehiclesFile = taxiCfg.taxisFile; drtCfg.transitStopFile = null; drtCfg.drtServiceAreaShapeFile = null; diff --git a/contribs/vsp/src/main/java/playground/vsp/analysis/DefaultAnalysis.java b/contribs/vsp/src/main/java/playground/vsp/analysis/DefaultAnalysis.java index 1f4c3b97a44..dd7a01db2db 100644 --- a/contribs/vsp/src/main/java/playground/vsp/analysis/DefaultAnalysis.java +++ b/contribs/vsp/src/main/java/playground/vsp/analysis/DefaultAnalysis.java @@ -26,13 +26,13 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.geotools.api.feature.simple.SimpleFeature; import org.matsim.api.core.v01.Scenario; import org.matsim.core.api.experimental.events.EventsManager; import org.matsim.core.events.EventsReaderXMLv1; import org.matsim.core.events.EventsUtils; import org.matsim.core.events.handler.EventHandler; import org.matsim.core.gbl.Gbl; -import org.opengis.feature.simple.SimpleFeature; import playground.vsp.analysis.modules.AbstractAnalysisModule; import playground.vsp.analysis.modules.legModeDistanceDistribution.LegModeDistanceDistribution; diff --git a/contribs/vsp/src/main/java/playground/vsp/analysis/modules/act2mode/ActivityToModeAnalysis.java b/contribs/vsp/src/main/java/playground/vsp/analysis/modules/act2mode/ActivityToModeAnalysis.java index 12055885daa..43c250265e7 100644 --- a/contribs/vsp/src/main/java/playground/vsp/analysis/modules/act2mode/ActivityToModeAnalysis.java +++ b/contribs/vsp/src/main/java/playground/vsp/analysis/modules/act2mode/ActivityToModeAnalysis.java @@ -27,6 +27,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.geotools.api.feature.simple.SimpleFeature; import org.locationtech.jts.geom.Coordinate; import org.locationtech.jts.geom.GeometryFactory; import org.matsim.api.core.v01.Id; @@ -36,7 +37,6 @@ import org.matsim.core.utils.geometry.geotools.MGC; import org.matsim.core.utils.gis.PointFeatureFactory; import org.matsim.core.utils.gis.GeoFileWriter; -import org.opengis.feature.simple.SimpleFeature; import playground.vsp.analysis.modules.AbstractAnalysisModule; diff --git a/contribs/vsp/src/main/java/playground/vsp/analysis/modules/networkAnalysis/NetworkAnalyzer.java b/contribs/vsp/src/main/java/playground/vsp/analysis/modules/networkAnalysis/NetworkAnalyzer.java index 4e41f3ae95f..ebb01d0b4a2 100644 --- a/contribs/vsp/src/main/java/playground/vsp/analysis/modules/networkAnalysis/NetworkAnalyzer.java +++ b/contribs/vsp/src/main/java/playground/vsp/analysis/modules/networkAnalysis/NetworkAnalyzer.java @@ -16,6 +16,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.geotools.api.feature.simple.SimpleFeature; import org.geotools.feature.simple.SimpleFeatureBuilder; import org.geotools.feature.simple.SimpleFeatureTypeBuilder; import org.locationtech.jts.geom.Coordinate; @@ -44,7 +45,6 @@ import org.matsim.core.scenario.ScenarioUtils; import org.matsim.core.utils.geometry.geotools.MGC; import org.matsim.core.utils.gis.GeoFileWriter; -import org.opengis.feature.simple.SimpleFeature; import playground.vsp.analysis.modules.AbstractAnalysisModule; import playground.vsp.analysis.modules.networkAnalysis.utils.AccessibilityCalc; diff --git a/contribs/vsp/src/main/java/playground/vsp/analysis/modules/ptAccessibility/utils/PtAccesShapeWriter.java b/contribs/vsp/src/main/java/playground/vsp/analysis/modules/ptAccessibility/utils/PtAccesShapeWriter.java index f21e092ba84..170eab02e6d 100644 --- a/contribs/vsp/src/main/java/playground/vsp/analysis/modules/ptAccessibility/utils/PtAccesShapeWriter.java +++ b/contribs/vsp/src/main/java/playground/vsp/analysis/modules/ptAccessibility/utils/PtAccesShapeWriter.java @@ -28,6 +28,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.geotools.api.feature.simple.SimpleFeature; import org.locationtech.jts.geom.Coordinate; import org.locationtech.jts.geom.MultiPolygon; import org.matsim.api.core.v01.Coord; @@ -35,7 +36,6 @@ import org.matsim.core.utils.gis.PointFeatureFactory; import org.matsim.core.utils.gis.PolygonFeatureFactory; import org.matsim.core.utils.gis.GeoFileWriter; -import org.opengis.feature.simple.SimpleFeature; import playground.vsp.analysis.modules.ptAccessibility.activity.ActivityLocation; import playground.vsp.analysis.modules.ptAccessibility.activity.LocationMap; @@ -59,7 +59,7 @@ public static void writeMultiPolygons(Map mps, String file setName(name). addAttribute("name", String.class). create(); - Collection features = new ArrayList(); + Collection features = new ArrayList<>(); Object[] featureAttribs; for(Entry e: mps.entrySet()){ diff --git a/contribs/vsp/src/main/java/playground/vsp/analysis/modules/ptAccessibility/utils/PtAccessMapShapeWriter.java b/contribs/vsp/src/main/java/playground/vsp/analysis/modules/ptAccessibility/utils/PtAccessMapShapeWriter.java index 615512e0fe6..49f9b6d7449 100644 --- a/contribs/vsp/src/main/java/playground/vsp/analysis/modules/ptAccessibility/utils/PtAccessMapShapeWriter.java +++ b/contribs/vsp/src/main/java/playground/vsp/analysis/modules/ptAccessibility/utils/PtAccessMapShapeWriter.java @@ -26,13 +26,13 @@ import java.util.Map.Entry; import java.util.ServiceConfigurationError; +import org.geotools.api.feature.simple.SimpleFeature; import org.geotools.feature.simple.SimpleFeatureBuilder; import org.geotools.feature.simple.SimpleFeatureTypeBuilder; import org.locationtech.jts.geom.Geometry; import org.locationtech.jts.geom.MultiPolygon; import org.matsim.core.utils.geometry.geotools.MGC; import org.matsim.core.utils.gis.GeoFileWriter; -import org.opengis.feature.simple.SimpleFeature; import playground.vsp.analysis.modules.ptAccessibility.stops.PtStopMap; @@ -135,7 +135,7 @@ private static void writeGeometries(String outputFolderAndFileName, HashMap> distance2mode2bufferEntry : distance2mode2buffer.entrySet()) { - bufferFeatures = new ArrayList(); + bufferFeatures = new ArrayList<>(); HashMap mode2buffer = distance2mode2bufferEntry.getValue(); for (Entry mode2BufferEntry : mode2buffer.entrySet()) { bufferFeatureAttribs = new Object[2]; diff --git a/contribs/vsp/src/main/java/playground/vsp/analysis/modules/ptPaxVolumes/PtPaxVolumesAnalyzer.java b/contribs/vsp/src/main/java/playground/vsp/analysis/modules/ptPaxVolumes/PtPaxVolumesAnalyzer.java index b921fa27a53..c15ca89613d 100644 --- a/contribs/vsp/src/main/java/playground/vsp/analysis/modules/ptPaxVolumes/PtPaxVolumesAnalyzer.java +++ b/contribs/vsp/src/main/java/playground/vsp/analysis/modules/ptPaxVolumes/PtPaxVolumesAnalyzer.java @@ -27,6 +27,7 @@ import java.util.Map.Entry; import java.util.ServiceConfigurationError; +import org.geotools.api.feature.simple.SimpleFeature; import org.geotools.feature.simple.SimpleFeatureBuilder; import org.geotools.feature.simple.SimpleFeatureTypeBuilder; import org.locationtech.jts.geom.Coordinate; @@ -39,7 +40,6 @@ import org.matsim.core.utils.geometry.geotools.MGC; import org.matsim.core.utils.gis.GeoFileWriter; import org.matsim.pt.transitSchedule.api.TransitLine; -import org.opengis.feature.simple.SimpleFeature; import playground.vsp.analysis.modules.AbstractAnalysisModule; diff --git a/contribs/vsp/src/main/java/playground/vsp/analysis/modules/transitSchedule2Shp/TransitSchedule2Shp.java b/contribs/vsp/src/main/java/playground/vsp/analysis/modules/transitSchedule2Shp/TransitSchedule2Shp.java index 8423b07bc67..f0b2a77841d 100644 --- a/contribs/vsp/src/main/java/playground/vsp/analysis/modules/transitSchedule2Shp/TransitSchedule2Shp.java +++ b/contribs/vsp/src/main/java/playground/vsp/analysis/modules/transitSchedule2Shp/TransitSchedule2Shp.java @@ -25,6 +25,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.geotools.api.feature.simple.SimpleFeature; import org.geotools.feature.simple.SimpleFeatureBuilder; import org.geotools.feature.simple.SimpleFeatureTypeBuilder; import org.locationtech.jts.geom.Coordinate; @@ -43,7 +44,6 @@ import org.matsim.pt.transitSchedule.api.TransitLine; import org.matsim.pt.transitSchedule.api.TransitRoute; import org.matsim.pt.transitSchedule.api.TransitSchedule; -import org.opengis.feature.simple.SimpleFeature; import playground.vsp.analysis.modules.AbstractAnalysisModule; @@ -82,7 +82,7 @@ public void postProcessData() { @Override public void writeResults(String outputFolder) { - Collection features = new ArrayList(); + Collection features = new ArrayList<>(); // write a shape per line for(TransitLine transitLine: this.schedule.getTransitLines().values()){ if(transitLine.getRoutes().isEmpty()){ diff --git a/contribs/vsp/src/main/java/playground/vsp/analysis/modules/transitVehicleVolume/TransitVehicleVolumeAnalyzer.java b/contribs/vsp/src/main/java/playground/vsp/analysis/modules/transitVehicleVolume/TransitVehicleVolumeAnalyzer.java index 22093aa08e6..d279b86c492 100644 --- a/contribs/vsp/src/main/java/playground/vsp/analysis/modules/transitVehicleVolume/TransitVehicleVolumeAnalyzer.java +++ b/contribs/vsp/src/main/java/playground/vsp/analysis/modules/transitVehicleVolume/TransitVehicleVolumeAnalyzer.java @@ -29,6 +29,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.geotools.api.feature.simple.SimpleFeature; import org.geotools.feature.simple.SimpleFeatureBuilder; import org.geotools.feature.simple.SimpleFeatureTypeBuilder; import org.locationtech.jts.geom.Coordinate; @@ -44,7 +45,6 @@ import org.matsim.counts.Count; import org.matsim.counts.Counts; import org.matsim.counts.Volume; -import org.opengis.feature.simple.SimpleFeature; import playground.vsp.analysis.modules.AbstractAnalysisModule; @@ -127,7 +127,7 @@ private void writeModeShape(String name, Counts counts, Map mo } SimpleFeatureBuilder builder = new SimpleFeatureBuilder(b.buildFeatureType()); - Collection features = new ArrayList(); + Collection features = new ArrayList<>(); Object[] featureAttribs; for(Count c: counts.getCounts().values()){ diff --git a/contribs/vsp/src/main/java/playground/vsp/analysis/utils/heatMap/HeatMap.java b/contribs/vsp/src/main/java/playground/vsp/analysis/utils/heatMap/HeatMap.java index f8441de40be..c35342f7403 100644 --- a/contribs/vsp/src/main/java/playground/vsp/analysis/utils/heatMap/HeatMap.java +++ b/contribs/vsp/src/main/java/playground/vsp/analysis/utils/heatMap/HeatMap.java @@ -25,6 +25,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.geotools.api.feature.simple.SimpleFeature; import org.geotools.feature.simple.SimpleFeatureBuilder; import org.geotools.feature.simple.SimpleFeatureTypeBuilder; import org.locationtech.jts.geom.Coordinate; @@ -36,7 +37,6 @@ import org.matsim.core.utils.collections.Tuple; import org.matsim.core.utils.geometry.geotools.MGC; import org.matsim.core.utils.gis.GeoFileWriter; -import org.opengis.feature.simple.SimpleFeature; /** * @author droeder @@ -185,7 +185,7 @@ public static void writeHeatMapShape(String name, HeatMap heatmap, String file, b.add("count", Double.class); SimpleFeatureBuilder builder = new SimpleFeatureBuilder(b.buildFeatureType()); - Collection features = new ArrayList(); + Collection features = new ArrayList<>(); Object[] featureAttribs; int i = 0; diff --git a/contribs/vsp/src/main/java/playground/vsp/andreas/utils/ana/RouteAllModesAsCar.java b/contribs/vsp/src/main/java/playground/vsp/andreas/utils/ana/RouteAllModesAsCar.java index 28ddbf7ab00..11baea3d7d3 100644 --- a/contribs/vsp/src/main/java/playground/vsp/andreas/utils/ana/RouteAllModesAsCar.java +++ b/contribs/vsp/src/main/java/playground/vsp/andreas/utils/ana/RouteAllModesAsCar.java @@ -28,6 +28,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.geotools.api.feature.simple.SimpleFeature; import org.geotools.feature.simple.SimpleFeatureBuilder; import org.geotools.feature.simple.SimpleFeatureTypeBuilder; import org.locationtech.jts.geom.Coordinate; @@ -56,7 +57,6 @@ import org.matsim.core.utils.geometry.geotools.MGC; import org.matsim.core.utils.gis.GeoFileWriter; import org.matsim.pt.PtConstants; -import org.opengis.feature.simple.SimpleFeature; /** * Routes all modes of transport (except for transit_walk) as car modes and counts the number of trips per link. @@ -118,7 +118,7 @@ private void writeAsShape(String outputDir, String targetCoordinateSystem) { SimpleFeatureBuilder builder = new SimpleFeatureBuilder(typeBuilder.buildFeatureType()); - Collection features = new ArrayList(); + Collection features = new ArrayList<>(); Object[] featureAttribs; diff --git a/contribs/vsp/src/main/java/playground/vsp/andreas/utils/ana/compareLinkStats/LinksstatsPolygonBasedFeatureGenerator.java b/contribs/vsp/src/main/java/playground/vsp/andreas/utils/ana/compareLinkStats/LinksstatsPolygonBasedFeatureGenerator.java index 8cc5021b57c..82bda0a2832 100644 --- a/contribs/vsp/src/main/java/playground/vsp/andreas/utils/ana/compareLinkStats/LinksstatsPolygonBasedFeatureGenerator.java +++ b/contribs/vsp/src/main/java/playground/vsp/andreas/utils/ana/compareLinkStats/LinksstatsPolygonBasedFeatureGenerator.java @@ -23,14 +23,14 @@ import java.util.HashMap; import java.util.Map; +import org.geotools.api.feature.simple.SimpleFeature; +import org.geotools.api.referencing.crs.CoordinateReferenceSystem; import org.locationtech.jts.geom.Coordinate; import org.matsim.api.core.v01.network.Link; import org.matsim.core.utils.geometry.geotools.MGC; import org.matsim.core.utils.gis.PolygonFeatureFactory; import org.matsim.utils.gis.matsim2esri.network.FeatureGenerator; import org.matsim.utils.gis.matsim2esri.network.WidthCalculator; -import org.opengis.feature.simple.SimpleFeature; -import org.opengis.referencing.crs.CoordinateReferenceSystem; public class LinksstatsPolygonBasedFeatureGenerator implements FeatureGenerator{ diff --git a/contribs/vsp/src/main/java/playground/vsp/andreas/utils/ana/compareLinkStats/LinkstatsStringBasedFeatureGenerator.java b/contribs/vsp/src/main/java/playground/vsp/andreas/utils/ana/compareLinkStats/LinkstatsStringBasedFeatureGenerator.java index f88e52dd9e2..7853077dfa1 100644 --- a/contribs/vsp/src/main/java/playground/vsp/andreas/utils/ana/compareLinkStats/LinkstatsStringBasedFeatureGenerator.java +++ b/contribs/vsp/src/main/java/playground/vsp/andreas/utils/ana/compareLinkStats/LinkstatsStringBasedFeatureGenerator.java @@ -24,6 +24,8 @@ import java.util.LinkedHashMap; import java.util.Map; +import org.geotools.api.feature.simple.SimpleFeature; +import org.geotools.api.referencing.crs.CoordinateReferenceSystem; import org.locationtech.jts.geom.Coordinate; import org.matsim.api.core.v01.network.Link; import org.matsim.core.network.NetworkUtils; @@ -31,8 +33,6 @@ import org.matsim.core.utils.gis.PolylineFeatureFactory; import org.matsim.utils.gis.matsim2esri.network.FeatureGenerator; import org.matsim.utils.gis.matsim2esri.network.WidthCalculator; -import org.opengis.feature.simple.SimpleFeature; -import org.opengis.referencing.crs.CoordinateReferenceSystem; public class LinkstatsStringBasedFeatureGenerator implements FeatureGenerator{ diff --git a/contribs/vsp/src/main/java/playground/vsp/andreas/utils/ana/compareLinkStats/NetworkAndMore2ESRI.java b/contribs/vsp/src/main/java/playground/vsp/andreas/utils/ana/compareLinkStats/NetworkAndMore2ESRI.java index 06049bc5b48..abb8c3c3c11 100644 --- a/contribs/vsp/src/main/java/playground/vsp/andreas/utils/ana/compareLinkStats/NetworkAndMore2ESRI.java +++ b/contribs/vsp/src/main/java/playground/vsp/andreas/utils/ana/compareLinkStats/NetworkAndMore2ESRI.java @@ -21,6 +21,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.geotools.api.referencing.crs.CoordinateReferenceSystem; import org.matsim.core.network.io.MatsimNetworkReader; import org.matsim.core.scenario.MutableScenario; import org.matsim.core.scenario.ScenarioUtils; @@ -31,7 +32,6 @@ import org.matsim.utils.gis.matsim2esri.network.FeatureGeneratorBuilderImpl; import org.matsim.utils.gis.matsim2esri.network.LanesBasedWidthCalculator; import org.matsim.utils.gis.matsim2esri.network.Links2ESRIShape; -import org.opengis.referencing.crs.CoordinateReferenceSystem; public class NetworkAndMore2ESRI extends Links2ESRIShape{ diff --git a/contribs/vsp/src/main/java/playground/vsp/andreas/utils/ana/countVehOnLinks/CountVehOnLinksPolygonBasedFeatureGenerator.java b/contribs/vsp/src/main/java/playground/vsp/andreas/utils/ana/countVehOnLinks/CountVehOnLinksPolygonBasedFeatureGenerator.java index 102634cd53d..5f22adde1f8 100644 --- a/contribs/vsp/src/main/java/playground/vsp/andreas/utils/ana/countVehOnLinks/CountVehOnLinksPolygonBasedFeatureGenerator.java +++ b/contribs/vsp/src/main/java/playground/vsp/andreas/utils/ana/countVehOnLinks/CountVehOnLinksPolygonBasedFeatureGenerator.java @@ -22,14 +22,14 @@ import java.util.HashMap; import java.util.Map; +import org.geotools.api.feature.simple.SimpleFeature; +import org.geotools.api.referencing.crs.CoordinateReferenceSystem; import org.locationtech.jts.geom.Coordinate; import org.matsim.api.core.v01.network.Link; import org.matsim.core.utils.geometry.geotools.MGC; import org.matsim.core.utils.gis.PolygonFeatureFactory; import org.matsim.utils.gis.matsim2esri.network.FeatureGenerator; import org.matsim.utils.gis.matsim2esri.network.WidthCalculator; -import org.opengis.feature.simple.SimpleFeature; -import org.opengis.referencing.crs.CoordinateReferenceSystem; public class CountVehOnLinksPolygonBasedFeatureGenerator implements FeatureGenerator{ diff --git a/contribs/vsp/src/main/java/playground/vsp/andreas/utils/ana/countVehOnLinks/CountVehOnLinksStringBasedFeatureGenerator.java b/contribs/vsp/src/main/java/playground/vsp/andreas/utils/ana/countVehOnLinks/CountVehOnLinksStringBasedFeatureGenerator.java index 3bd65d714a4..c94c9e5db74 100644 --- a/contribs/vsp/src/main/java/playground/vsp/andreas/utils/ana/countVehOnLinks/CountVehOnLinksStringBasedFeatureGenerator.java +++ b/contribs/vsp/src/main/java/playground/vsp/andreas/utils/ana/countVehOnLinks/CountVehOnLinksStringBasedFeatureGenerator.java @@ -23,6 +23,8 @@ import java.util.LinkedHashMap; import java.util.Map; +import org.geotools.api.feature.simple.SimpleFeature; +import org.geotools.api.referencing.crs.CoordinateReferenceSystem; import org.locationtech.jts.geom.Coordinate; import org.matsim.api.core.v01.network.Link; import org.matsim.core.network.NetworkUtils; @@ -30,8 +32,6 @@ import org.matsim.core.utils.gis.PolylineFeatureFactory; import org.matsim.utils.gis.matsim2esri.network.FeatureGenerator; import org.matsim.utils.gis.matsim2esri.network.WidthCalculator; -import org.opengis.feature.simple.SimpleFeature; -import org.opengis.referencing.crs.CoordinateReferenceSystem; public class CountVehOnLinksStringBasedFeatureGenerator implements FeatureGenerator{ diff --git a/contribs/vsp/src/main/java/playground/vsp/andreas/utils/ana/countVehOnLinks/PackageMain.java b/contribs/vsp/src/main/java/playground/vsp/andreas/utils/ana/countVehOnLinks/PackageMain.java index ecda8472e30..d49960a9084 100644 --- a/contribs/vsp/src/main/java/playground/vsp/andreas/utils/ana/countVehOnLinks/PackageMain.java +++ b/contribs/vsp/src/main/java/playground/vsp/andreas/utils/ana/countVehOnLinks/PackageMain.java @@ -21,6 +21,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.geotools.api.referencing.crs.CoordinateReferenceSystem; import org.matsim.api.core.v01.network.Network; import org.matsim.core.config.ConfigUtils; import org.matsim.core.network.io.MatsimNetworkReader; @@ -31,7 +32,6 @@ import org.matsim.utils.gis.matsim2esri.network.FeatureGeneratorBuilderImpl; import org.matsim.utils.gis.matsim2esri.network.LanesBasedWidthCalculator; import org.matsim.utils.gis.matsim2esri.network.Links2ESRIShape; -import org.opengis.referencing.crs.CoordinateReferenceSystem; public class PackageMain extends Links2ESRIShape{ diff --git a/contribs/vsp/src/main/java/playground/vsp/andreas/utils/ana/filterActsPerShape/WorkHomeShapeCounter.java b/contribs/vsp/src/main/java/playground/vsp/andreas/utils/ana/filterActsPerShape/WorkHomeShapeCounter.java index c7489566966..fde71b63868 100644 --- a/contribs/vsp/src/main/java/playground/vsp/andreas/utils/ana/filterActsPerShape/WorkHomeShapeCounter.java +++ b/contribs/vsp/src/main/java/playground/vsp/andreas/utils/ana/filterActsPerShape/WorkHomeShapeCounter.java @@ -27,8 +27,9 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.geotools.api.data.SimpleFeatureSource; +import org.geotools.api.feature.simple.SimpleFeature; import org.geotools.data.simple.SimpleFeatureIterator; -import org.geotools.data.simple.SimpleFeatureSource; import org.locationtech.jts.geom.Geometry; import org.locationtech.jts.geom.Polygon; import org.matsim.api.core.v01.Coord; @@ -40,7 +41,6 @@ import org.matsim.core.population.algorithms.AbstractPersonAlgorithm; import org.matsim.core.utils.geometry.geotools.MGC; import org.matsim.core.utils.gis.GeoFileReader; -import org.opengis.feature.simple.SimpleFeature; public class WorkHomeShapeCounter extends AbstractPersonAlgorithm{ diff --git a/contribs/vsp/src/main/java/playground/vsp/andreas/utils/pop/FilterPopulationByShape.java b/contribs/vsp/src/main/java/playground/vsp/andreas/utils/pop/FilterPopulationByShape.java index 63fede8cee6..d346fae1a03 100644 --- a/contribs/vsp/src/main/java/playground/vsp/andreas/utils/pop/FilterPopulationByShape.java +++ b/contribs/vsp/src/main/java/playground/vsp/andreas/utils/pop/FilterPopulationByShape.java @@ -26,6 +26,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.geotools.api.feature.simple.SimpleFeature; import org.locationtech.jts.geom.Geometry; import org.locationtech.jts.geom.GeometryFactory; import org.locationtech.jts.geom.MultiPolygon; @@ -53,7 +54,6 @@ import org.matsim.core.scenario.ScenarioUtils; import org.matsim.core.utils.geometry.geotools.MGC; import org.matsim.core.utils.gis.GeoFileReader; -import org.opengis.feature.simple.SimpleFeature; /** * Filters a given Population by a given shape - includes all routed modes diff --git a/contribs/vsp/src/main/java/playground/vsp/andreas/utils/pt/transitSchedule2shape/DaShapeWriter.java b/contribs/vsp/src/main/java/playground/vsp/andreas/utils/pt/transitSchedule2shape/DaShapeWriter.java index 600ff620232..7408cde20fb 100644 --- a/contribs/vsp/src/main/java/playground/vsp/andreas/utils/pt/transitSchedule2shape/DaShapeWriter.java +++ b/contribs/vsp/src/main/java/playground/vsp/andreas/utils/pt/transitSchedule2shape/DaShapeWriter.java @@ -30,6 +30,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.geotools.api.feature.simple.SimpleFeature; import org.geotools.feature.simple.SimpleFeatureBuilder; import org.geotools.feature.simple.SimpleFeatureTypeBuilder; import org.locationtech.jts.geom.Coordinate; @@ -49,7 +50,6 @@ import org.matsim.pt.transitSchedule.api.TransitRouteStop; import org.matsim.pt.transitSchedule.api.TransitSchedule; import org.matsim.pt.transitSchedule.api.TransitStopFacility; -import org.opengis.feature.simple.SimpleFeature; /** * diff --git a/contribs/vsp/src/main/java/playground/vsp/corineLandcover/CORINELandCoverCoordsModifier.java b/contribs/vsp/src/main/java/playground/vsp/corineLandcover/CORINELandCoverCoordsModifier.java index d16d17d4ada..99fe02269c7 100644 --- a/contribs/vsp/src/main/java/playground/vsp/corineLandcover/CORINELandCoverCoordsModifier.java +++ b/contribs/vsp/src/main/java/playground/vsp/corineLandcover/CORINELandCoverCoordsModifier.java @@ -26,6 +26,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.geotools.api.feature.simple.SimpleFeature; import org.locationtech.jts.geom.Geometry; import org.locationtech.jts.geom.Point; import org.matsim.api.core.v01.Coord; @@ -40,7 +41,6 @@ import org.matsim.core.scenario.ScenarioUtils; import org.matsim.core.utils.geometry.geotools.MGC; import org.matsim.core.utils.gis.GeoFileReader; -import org.opengis.feature.simple.SimpleFeature; import playground.vsp.openberlinscenario.cemdap.output.Cemdap2MatsimUtils; import playground.vsp.openberlinscenario.cemdap.output.CemdapOutput2MatsimPlansConverter; diff --git a/contribs/vsp/src/main/java/playground/vsp/corineLandcover/CorineLandCoverData.java b/contribs/vsp/src/main/java/playground/vsp/corineLandcover/CorineLandCoverData.java index d8b0584a210..267ef739180 100644 --- a/contribs/vsp/src/main/java/playground/vsp/corineLandcover/CorineLandCoverData.java +++ b/contribs/vsp/src/main/java/playground/vsp/corineLandcover/CorineLandCoverData.java @@ -27,12 +27,12 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.geotools.api.feature.simple.SimpleFeature; import org.locationtech.jts.geom.Geometry; import org.locationtech.jts.geom.Point; import org.matsim.api.core.v01.Coord; import org.matsim.core.gbl.Gbl; import org.matsim.core.utils.gis.GeoFileReader; -import org.opengis.feature.simple.SimpleFeature; /** * Created by amit on 31.07.17. diff --git a/contribs/vsp/src/main/java/playground/vsp/demandde/commuterDemandCottbus/CommuterDemandWriter.java b/contribs/vsp/src/main/java/playground/vsp/demandde/commuterDemandCottbus/CommuterDemandWriter.java index 10f4c106725..0c931ed13c1 100644 --- a/contribs/vsp/src/main/java/playground/vsp/demandde/commuterDemandCottbus/CommuterDemandWriter.java +++ b/contribs/vsp/src/main/java/playground/vsp/demandde/commuterDemandCottbus/CommuterDemandWriter.java @@ -29,6 +29,9 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.geotools.api.feature.simple.SimpleFeature; +import org.geotools.api.referencing.crs.CoordinateReferenceSystem; +import org.geotools.api.referencing.operation.MathTransform; import org.geotools.geometry.jts.JTS; import org.geotools.referencing.CRS; import org.locationtech.jts.geom.Coordinate; @@ -52,9 +55,6 @@ import org.matsim.core.utils.geometry.geotools.MGC; import org.matsim.core.utils.misc.Time; import org.matsim.core.utils.timing.TimeInterpretation; -import org.opengis.feature.simple.SimpleFeature; -import org.opengis.referencing.crs.CoordinateReferenceSystem; -import org.opengis.referencing.operation.MathTransform; /** * @author jbischoff diff --git a/contribs/vsp/src/main/java/playground/vsp/demandde/commuterDemandCottbus/CommuterGenerator.java b/contribs/vsp/src/main/java/playground/vsp/demandde/commuterDemandCottbus/CommuterGenerator.java index 41c2466c84d..17f4de617b0 100644 --- a/contribs/vsp/src/main/java/playground/vsp/demandde/commuterDemandCottbus/CommuterGenerator.java +++ b/contribs/vsp/src/main/java/playground/vsp/demandde/commuterDemandCottbus/CommuterGenerator.java @@ -24,6 +24,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.geotools.api.feature.simple.SimpleFeature; +import org.geotools.api.referencing.crs.CoordinateReferenceSystem; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.population.PopulationWriter; import org.matsim.core.config.Config; @@ -34,8 +36,6 @@ import org.matsim.core.utils.geometry.geotools.MGC; import org.matsim.core.utils.geometry.transformations.TransformationFactory; import org.matsim.core.utils.gis.GeoFileReader; -import org.opengis.feature.simple.SimpleFeature; -import org.opengis.referencing.crs.CoordinateReferenceSystem; /** * @author jbischoff @@ -85,7 +85,7 @@ public static void main(String[] args) throws Exception { //landuse if (useLanduse){ DgLanduseReader landuseReader = new DgLanduseReader(); - Tuple,CoordinateReferenceSystem> homeLanduse = landuseReader.readLanduseDataHome(); + Tuple, CoordinateReferenceSystem> homeLanduse = landuseReader.readLanduseDataHome(); Tuple,CoordinateReferenceSystem> workLanduse = landuseReader.readLanduseDataWork(); cdw.addLanduse("home", homeLanduse); cdw.addLanduse("work", workLanduse); diff --git a/contribs/vsp/src/main/java/playground/vsp/demandde/commuterDemandCottbus/DgLanduseReader.java b/contribs/vsp/src/main/java/playground/vsp/demandde/commuterDemandCottbus/DgLanduseReader.java index 6a7b47969d3..8ee88afb6d4 100644 --- a/contribs/vsp/src/main/java/playground/vsp/demandde/commuterDemandCottbus/DgLanduseReader.java +++ b/contribs/vsp/src/main/java/playground/vsp/demandde/commuterDemandCottbus/DgLanduseReader.java @@ -22,10 +22,10 @@ import java.util.Collection; import java.util.HashSet; +import org.geotools.api.feature.simple.SimpleFeature; +import org.geotools.api.referencing.crs.CoordinateReferenceSystem; import org.matsim.core.utils.collections.Tuple; import org.matsim.core.utils.gis.GeoFileReader; -import org.opengis.feature.simple.SimpleFeature; -import org.opengis.referencing.crs.CoordinateReferenceSystem; /** @@ -60,7 +60,7 @@ public class DgLanduseReader { // private static final String[] landuse_files_work = {INDUSTRIE_GEWERBEGEBIETE}; - public Tuple,CoordinateReferenceSystem> readLanduseDataHome(){ + public Tuple, CoordinateReferenceSystem> readLanduseDataHome(){ return this.readLanduseData(landuse_files_home); } diff --git a/contribs/vsp/src/main/java/playground/vsp/demandde/commuterDemandCottbus/DgPopulation2ShapeWriter.java b/contribs/vsp/src/main/java/playground/vsp/demandde/commuterDemandCottbus/DgPopulation2ShapeWriter.java index 943f51c177f..4a3c67112c3 100644 --- a/contribs/vsp/src/main/java/playground/vsp/demandde/commuterDemandCottbus/DgPopulation2ShapeWriter.java +++ b/contribs/vsp/src/main/java/playground/vsp/demandde/commuterDemandCottbus/DgPopulation2ShapeWriter.java @@ -22,6 +22,9 @@ import java.util.ArrayList; import java.util.List; +import org.geotools.api.feature.simple.SimpleFeature; +import org.geotools.api.referencing.crs.CoordinateReferenceSystem; +import org.geotools.api.referencing.operation.MathTransform; import org.geotools.geometry.jts.JTS; import org.geotools.referencing.CRS; import org.locationtech.jts.geom.Coordinate; @@ -33,9 +36,6 @@ import org.matsim.core.utils.geometry.geotools.MGC; import org.matsim.core.utils.gis.PointFeatureFactory; import org.matsim.core.utils.gis.GeoFileWriter; -import org.opengis.feature.simple.SimpleFeature; -import org.opengis.referencing.crs.CoordinateReferenceSystem; -import org.opengis.referencing.operation.MathTransform; /** @@ -67,7 +67,7 @@ public void write(String activityType, String filename, CoordinateReferenceSyste addAttribute("end_time", Double.class). create(); - List features = new ArrayList(); + List features = new ArrayList<>(); SimpleFeature f = null; for (Person p : this.pop.getPersons().values()){ Plan plan = p.getSelectedPlan(); diff --git a/contribs/vsp/src/main/java/playground/vsp/demandde/counts/TSBASt2Count.java b/contribs/vsp/src/main/java/playground/vsp/demandde/counts/TSBASt2Count.java index 6796e013723..8c652ff8248 100644 --- a/contribs/vsp/src/main/java/playground/vsp/demandde/counts/TSBASt2Count.java +++ b/contribs/vsp/src/main/java/playground/vsp/demandde/counts/TSBASt2Count.java @@ -11,12 +11,12 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.geotools.api.referencing.FactoryException; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; import org.matsim.counts.Count; import org.matsim.counts.Counts; import org.matsim.counts.CountsWriter; -import org.opengis.referencing.FactoryException; import playground.vsp.demandde.counts.BastHourlyCountData.Day; diff --git a/contribs/vsp/src/main/java/playground/vsp/demandde/pendlermatrix/GVPlanReader.java b/contribs/vsp/src/main/java/playground/vsp/demandde/pendlermatrix/GVPlanReader.java index 113c347994a..82d2c4e4026 100644 --- a/contribs/vsp/src/main/java/playground/vsp/demandde/pendlermatrix/GVPlanReader.java +++ b/contribs/vsp/src/main/java/playground/vsp/demandde/pendlermatrix/GVPlanReader.java @@ -21,6 +21,7 @@ import java.util.Collection; +import org.geotools.api.feature.simple.SimpleFeature; import org.locationtech.jts.geom.Coordinate; import org.locationtech.jts.geom.Geometry; import org.locationtech.jts.geom.GeometryFactory; @@ -33,7 +34,6 @@ import org.matsim.core.scenario.ScenarioUtils; import org.matsim.core.utils.geometry.transformations.TransformationFactory; import org.matsim.core.utils.gis.GeoFileReader; -import org.opengis.feature.simple.SimpleFeature; import playground.vsp.pipeline.PopulationReaderTask; import playground.vsp.pipeline.PopulationWriterTask; diff --git a/contribs/vsp/src/main/java/playground/vsp/demandde/pendlermatrix/PendlerMatrixReader.java b/contribs/vsp/src/main/java/playground/vsp/demandde/pendlermatrix/PendlerMatrixReader.java index 1d53d1a7aa4..c084f138bc1 100644 --- a/contribs/vsp/src/main/java/playground/vsp/demandde/pendlermatrix/PendlerMatrixReader.java +++ b/contribs/vsp/src/main/java/playground/vsp/demandde/pendlermatrix/PendlerMatrixReader.java @@ -26,6 +26,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.geotools.api.feature.simple.SimpleFeature; import org.locationtech.jts.geom.Coordinate; import org.locationtech.jts.geom.Geometry; import org.locationtech.jts.geom.Point; @@ -45,7 +46,6 @@ import org.matsim.facilities.ActivityFacility; import org.matsim.facilities.ActivityOption; import org.matsim.facilities.Facility; -import org.opengis.feature.simple.SimpleFeature; public class PendlerMatrixReader { @@ -81,7 +81,7 @@ public void run() { private void readShape() { Collection landkreise = GeoFileReader.getAllFeatures(this.shapeFile); - ActivityFacilitiesFactory factory = ((MutableScenario)this.sc).getActivityFacilities().getFactory(); + ActivityFacilitiesFactory factory = this.sc.getActivityFacilities().getFactory(); for (SimpleFeature landkreis : landkreise) { Integer gemeindeschluessel = Integer.parseInt((String) landkreis.getAttribute("gemeindesc")); Geometry geo = (Geometry) landkreis.getDefaultGeometry(); diff --git a/contribs/vsp/src/main/java/playground/vsp/demandde/pendlermatrix/Verschmierer.java b/contribs/vsp/src/main/java/playground/vsp/demandde/pendlermatrix/Verschmierer.java index 4ccba3644f7..d01ca26ce36 100644 --- a/contribs/vsp/src/main/java/playground/vsp/demandde/pendlermatrix/Verschmierer.java +++ b/contribs/vsp/src/main/java/playground/vsp/demandde/pendlermatrix/Verschmierer.java @@ -23,6 +23,7 @@ import java.util.Map; import java.util.Random; +import org.geotools.api.feature.simple.SimpleFeature; import org.locationtech.jts.geom.Coordinate; import org.locationtech.jts.geom.Geometry; import org.locationtech.jts.geom.GeometryFactory; @@ -30,7 +31,6 @@ import org.matsim.api.core.v01.Coord; import org.matsim.core.utils.geometry.geotools.MGC; import org.matsim.core.utils.gis.GeoFileReader; -import org.opengis.feature.simple.SimpleFeature; public class Verschmierer { diff --git a/contribs/vsp/src/main/java/playground/vsp/demandde/prognose2025/DemandMatrixReader.java b/contribs/vsp/src/main/java/playground/vsp/demandde/prognose2025/DemandMatrixReader.java index ba6cd54148d..967e7628e1d 100644 --- a/contribs/vsp/src/main/java/playground/vsp/demandde/prognose2025/DemandMatrixReader.java +++ b/contribs/vsp/src/main/java/playground/vsp/demandde/prognose2025/DemandMatrixReader.java @@ -26,6 +26,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.geotools.api.feature.simple.SimpleFeature; import org.locationtech.jts.geom.Coordinate; import org.locationtech.jts.geom.Geometry; import org.locationtech.jts.geom.Point; @@ -49,7 +50,6 @@ import org.matsim.facilities.ActivityFacility; import org.matsim.facilities.ActivityOption; import org.matsim.facilities.Facility; -import org.opengis.feature.simple.SimpleFeature; import playground.vsp.demandde.pendlermatrix.TripFlowSink; @@ -158,7 +158,7 @@ public void startRow(String[] row) { private void readShape() { Collection landkreise = GeoFileReader.getAllFeatures(this.shapeFile); - final ActivityFacilitiesFactory factory = ((MutableScenario)this.sc).getActivityFacilities().getFactory(); + final ActivityFacilitiesFactory factory = this.sc.getActivityFacilities().getFactory(); for (SimpleFeature landkreis : landkreise) { Integer gemeindeschluessel = Integer.parseInt((String) landkreis.getAttribute("gemeindesc")); Geometry geo = (Geometry) landkreis.getDefaultGeometry(); diff --git a/contribs/vsp/src/main/java/playground/vsp/openberlinscenario/cemdap/input/SynPopCreator.java b/contribs/vsp/src/main/java/playground/vsp/openberlinscenario/cemdap/input/SynPopCreator.java index 3ec676d187d..d457bb7dec9 100644 --- a/contribs/vsp/src/main/java/playground/vsp/openberlinscenario/cemdap/input/SynPopCreator.java +++ b/contribs/vsp/src/main/java/playground/vsp/openberlinscenario/cemdap/input/SynPopCreator.java @@ -30,6 +30,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.geotools.api.feature.simple.SimpleFeature; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Person; import org.matsim.api.core.v01.population.Plan; @@ -45,7 +46,6 @@ import org.matsim.households.HouseholdImpl; import org.matsim.utils.objectattributes.ObjectAttributes; import org.matsim.utils.objectattributes.attributable.Attributes; -import org.opengis.feature.simple.SimpleFeature; import playground.vsp.openberlinscenario.Gender; import playground.vsp.openberlinscenario.cemdap.LogToOutputSaver; diff --git a/contribs/vsp/src/main/java/playground/vsp/openberlinscenario/cemdap/input/SynPopCreatorChildren.java b/contribs/vsp/src/main/java/playground/vsp/openberlinscenario/cemdap/input/SynPopCreatorChildren.java index 71cec77ea8a..5369dd74f6c 100644 --- a/contribs/vsp/src/main/java/playground/vsp/openberlinscenario/cemdap/input/SynPopCreatorChildren.java +++ b/contribs/vsp/src/main/java/playground/vsp/openberlinscenario/cemdap/input/SynPopCreatorChildren.java @@ -20,6 +20,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.geotools.api.feature.simple.SimpleFeature; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Person; import org.matsim.api.core.v01.population.Plan; @@ -31,7 +32,6 @@ import org.matsim.core.scenario.ScenarioUtils; import org.matsim.core.utils.gis.GeoFileReader; import org.matsim.utils.objectattributes.ObjectAttributes; -import org.opengis.feature.simple.SimpleFeature; import playground.vsp.openberlinscenario.Gender; import playground.vsp.openberlinscenario.cemdap.LogToOutputSaver; diff --git a/contribs/vsp/src/main/java/playground/vsp/openberlinscenario/cemdap/input/ZoneAndLOSGeneratorV2.java b/contribs/vsp/src/main/java/playground/vsp/openberlinscenario/cemdap/input/ZoneAndLOSGeneratorV2.java index c97a9b2cbf6..dde91a38d73 100644 --- a/contribs/vsp/src/main/java/playground/vsp/openberlinscenario/cemdap/input/ZoneAndLOSGeneratorV2.java +++ b/contribs/vsp/src/main/java/playground/vsp/openberlinscenario/cemdap/input/ZoneAndLOSGeneratorV2.java @@ -33,12 +33,11 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.geotools.api.feature.simple.SimpleFeature; import org.locationtech.jts.geom.Geometry; import org.matsim.api.core.v01.Coord; import org.matsim.core.utils.gis.GeoFileReader; import org.matsim.core.utils.io.IOUtils; -import org.opengis.feature.simple.SimpleFeature; - import playground.vsp.openberlinscenario.cemdap.LogToOutputSaver; /** diff --git a/contribs/vsp/src/main/java/playground/vsp/openberlinscenario/cemdap/output/Cemdap2MatsimUtils.java b/contribs/vsp/src/main/java/playground/vsp/openberlinscenario/cemdap/output/Cemdap2MatsimUtils.java index 6298091c81a..97d160c368d 100644 --- a/contribs/vsp/src/main/java/playground/vsp/openberlinscenario/cemdap/output/Cemdap2MatsimUtils.java +++ b/contribs/vsp/src/main/java/playground/vsp/openberlinscenario/cemdap/output/Cemdap2MatsimUtils.java @@ -21,6 +21,7 @@ import java.util.Random; +import org.geotools.api.feature.simple.SimpleFeature; import org.locationtech.jts.geom.Coordinate; import org.locationtech.jts.geom.Envelope; import org.locationtech.jts.geom.Geometry; @@ -28,7 +29,6 @@ import org.locationtech.jts.geom.Point; import org.matsim.api.core.v01.Coord; import org.matsim.core.gbl.MatsimRandom; -import org.opengis.feature.simple.SimpleFeature; /** * @author dziemke diff --git a/contribs/vsp/src/main/java/playground/vsp/openberlinscenario/cemdap/output/CemdapOutput2MatsimPlansConverter.java b/contribs/vsp/src/main/java/playground/vsp/openberlinscenario/cemdap/output/CemdapOutput2MatsimPlansConverter.java index b8be4c3a3a8..5049ac72cb1 100644 --- a/contribs/vsp/src/main/java/playground/vsp/openberlinscenario/cemdap/output/CemdapOutput2MatsimPlansConverter.java +++ b/contribs/vsp/src/main/java/playground/vsp/openberlinscenario/cemdap/output/CemdapOutput2MatsimPlansConverter.java @@ -28,6 +28,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.geotools.api.feature.simple.SimpleFeature; import org.locationtech.jts.geom.Geometry; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -42,7 +43,6 @@ import org.matsim.core.scenario.ScenarioUtils; import org.matsim.core.utils.gis.GeoFileReader; import org.matsim.utils.objectattributes.ObjectAttributes; -import org.opengis.feature.simple.SimpleFeature; import playground.vsp.corineLandcover.CorineLandCoverData; import playground.vsp.corineLandcover.GeometryUtils; diff --git a/contribs/vsp/src/main/java/playground/vsp/pt/fare/PtFareConfigGroup.java b/contribs/vsp/src/main/java/playground/vsp/pt/fare/PtFareConfigGroup.java index b463d323fc6..20c9291dc1b 100644 --- a/contribs/vsp/src/main/java/playground/vsp/pt/fare/PtFareConfigGroup.java +++ b/contribs/vsp/src/main/java/playground/vsp/pt/fare/PtFareConfigGroup.java @@ -15,6 +15,12 @@ public class PtFareConfigGroup extends ReflectiveConfigGroup { public enum PtFareCalculationModels {distanceBased} // More to come (e.g. zone based, hybrid...) + private static final String PT_FARE_CALCULATION_CMT = "PT fare calculation scheme. Current implementation: distanceBased (more to come...)"; + public static final String UPPER_BOUND_FACTOR_CMT = "When upper bound is applied, upperBound = upperBoundFactor * max Fare of the day. " + + "This value is decided by the ratio between average daily cost of a ticket subscription and the single " + + "trip ticket of the same trip. Usually this value should be somewhere between 1.0 and 2.0"; + public static final String APPLY_UPPER_BOUND_CMT = "Enable the upper bound for daily PT fare to count for ticket subscription. Input value: true or false"; + private PtFareCalculationModels ptFareCalculation = PtFareCalculationModels.distanceBased; // Use distance based calculation by default private boolean applyUpperBound = true; @PositiveOrZero @@ -27,11 +33,9 @@ public PtFareConfigGroup() { @Override public Map getComments() { Map map = super.getComments(); - map.put(PT_FARE_CALCULATION, "PT fare calculation scheme. Current implementation: distanceBased (more to come...)"); - map.put(APPLY_UPPER_BOUND, "Enable the upper bound for daily PT fare to count for ticket subscription. Input value: true or false"); - map.put(UPPER_BOUND_FACTOR, "When upper bound is applied, upperBound = upperBoundFactor * max Fare of the day. " + - "This value is decided by the ratio between average daily cost of a ticket subscription and the single " + - "trip ticket of the same trip. Usually this value should be somewhere between 1.0 and 2.0"); + map.put(PT_FARE_CALCULATION, PT_FARE_CALCULATION_CMT ); + map.put(APPLY_UPPER_BOUND, APPLY_UPPER_BOUND_CMT ); + map.put(UPPER_BOUND_FACTOR, UPPER_BOUND_FACTOR_CMT ); return map; } @@ -61,6 +65,9 @@ public double getUpperBoundFactor() { return upperBoundFactor; } + /** + * @param upperBoundFactor -- {@value #UPPER_BOUND_FACTOR_CMT} + */ @StringSetter(UPPER_BOUND_FACTOR) public void setUpperBoundFactor(double upperBoundFactor) { this.upperBoundFactor = upperBoundFactor; diff --git a/contribs/vsp/src/main/java/playground/vsp/pt/transitRouteTrimmer/TransitRouteTrimmerUtils.java b/contribs/vsp/src/main/java/playground/vsp/pt/transitRouteTrimmer/TransitRouteTrimmerUtils.java index f8aadd7ee15..99239b29fd1 100644 --- a/contribs/vsp/src/main/java/playground/vsp/pt/transitRouteTrimmer/TransitRouteTrimmerUtils.java +++ b/contribs/vsp/src/main/java/playground/vsp/pt/transitRouteTrimmer/TransitRouteTrimmerUtils.java @@ -22,15 +22,17 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.geotools.api.data.SimpleFeatureSource; +import org.geotools.api.data.SimpleFeatureStore; +import org.geotools.api.data.Transaction; +import org.geotools.api.feature.simple.SimpleFeature; +import org.geotools.api.feature.simple.SimpleFeatureType; import org.geotools.data.DataUtilities; import org.geotools.data.DefaultTransaction; -import org.geotools.data.Transaction; import org.geotools.data.collection.ListFeatureCollection; import org.geotools.data.shapefile.ShapefileDataStore; import org.geotools.data.shapefile.ShapefileDataStoreFactory; import org.geotools.data.simple.SimpleFeatureCollection; -import org.geotools.data.simple.SimpleFeatureSource; -import org.geotools.data.simple.SimpleFeatureStore; import org.geotools.feature.SchemaException; import org.geotools.feature.simple.SimpleFeatureBuilder; import org.geotools.geometry.jts.JTSFactoryFinder; @@ -43,8 +45,6 @@ import org.matsim.core.utils.geometry.CoordinateTransformation; import org.matsim.pt.transitSchedule.api.*; import org.matsim.utils.gis.shp2matsim.ShpGeometryUtils; -import org.opengis.feature.simple.SimpleFeature; -import org.opengis.feature.simple.SimpleFeatureType; import java.io.File; import java.io.IOException; diff --git a/contribs/vsp/src/test/java/org/matsim/integration/drtAndPt/PtAlongALine2Test.java b/contribs/vsp/src/test/java/org/matsim/integration/drtAndPt/PtAlongALine2Test.java index 3e00dd03d50..0c2e2fbd58e 100644 --- a/contribs/vsp/src/test/java/org/matsim/integration/drtAndPt/PtAlongALine2Test.java +++ b/contribs/vsp/src/test/java/org/matsim/integration/drtAndPt/PtAlongALine2Test.java @@ -24,6 +24,7 @@ import org.matsim.api.core.v01.population.Population; import org.matsim.api.core.v01.population.PopulationFactory; import org.matsim.contrib.common.zones.systems.grid.square.SquareGridZoneSystemParams; +import org.matsim.contrib.drt.optimizer.DrtOptimizationConstraintsSet; import org.matsim.contrib.drt.optimizer.insertion.extensive.ExtensiveInsertionSearchParams; import org.matsim.contrib.drt.routing.DrtRoute; import org.matsim.contrib.drt.routing.DrtRouteFactory; @@ -229,11 +230,12 @@ void testPtAlongALineWithRaptorAndDrtServiceArea() { { DrtConfigGroup drtConfigGroup = new DrtConfigGroup(); drtConfigGroup.mode = TransportMode.drt; - drtConfigGroup.maxTravelTimeAlpha = 2.0; - drtConfigGroup.maxTravelTimeBeta = 5. * 60.; + DrtOptimizationConstraintsSet defaultConstraintsSet = drtConfigGroup.addOrGetDrtOptimizationConstraintsParams().addOrGetDefaultDrtOptimizationConstraintsSet(); + defaultConstraintsSet.maxTravelTimeAlpha = 2.0; + defaultConstraintsSet.maxTravelTimeBeta = 5. * 60.; drtConfigGroup.stopDuration = 60.; - drtConfigGroup.maxWaitTime = Double.MAX_VALUE; - drtConfigGroup.rejectRequestIfMaxWaitOrTravelTimeViolated = false; + defaultConstraintsSet.maxWaitTime = Double.MAX_VALUE; + defaultConstraintsSet.rejectRequestIfMaxWaitOrTravelTimeViolated = false; drtConfigGroup.useModeFilteredSubnetwork = true; drtConfigGroup.addParameterSet(new ExtensiveInsertionSearchParams()); @@ -243,11 +245,12 @@ void testPtAlongALineWithRaptorAndDrtServiceArea() { if (drt2) { DrtConfigGroup drtConfigGroup = new DrtConfigGroup(); drtConfigGroup.mode = "drt2"; - drtConfigGroup.maxTravelTimeAlpha = 1.3; - drtConfigGroup.maxTravelTimeBeta = 5. * 60.; + DrtOptimizationConstraintsSet defaultConstraintsSet = drtConfigGroup.addOrGetDrtOptimizationConstraintsParams().addOrGetDefaultDrtOptimizationConstraintsSet(); + defaultConstraintsSet.maxTravelTimeAlpha = 1.3; + defaultConstraintsSet.maxTravelTimeBeta = 5. * 60.; drtConfigGroup.stopDuration = 60.; - drtConfigGroup.maxWaitTime = Double.MAX_VALUE; - drtConfigGroup.rejectRequestIfMaxWaitOrTravelTimeViolated = false; + defaultConstraintsSet.maxWaitTime = Double.MAX_VALUE; + defaultConstraintsSet.rejectRequestIfMaxWaitOrTravelTimeViolated = false; drtConfigGroup.useModeFilteredSubnetwork = true; drtConfigGroup.addParameterSet(new ExtensiveInsertionSearchParams()); @@ -256,11 +259,12 @@ void testPtAlongALineWithRaptorAndDrtServiceArea() { if (drt3) { DrtConfigGroup drtConfigGroup = new DrtConfigGroup(); drtConfigGroup.mode = "drt3"; - drtConfigGroup.maxTravelTimeAlpha = 1.3; - drtConfigGroup.maxTravelTimeBeta = 5. * 60.; + DrtOptimizationConstraintsSet defaultConstraintsSet = drtConfigGroup.addOrGetDrtOptimizationConstraintsParams().addOrGetDefaultDrtOptimizationConstraintsSet(); + defaultConstraintsSet.maxTravelTimeAlpha = 1.3; + defaultConstraintsSet.maxTravelTimeBeta = 5. * 60.; drtConfigGroup.stopDuration = 60.; - drtConfigGroup.maxWaitTime = Double.MAX_VALUE; - drtConfigGroup.rejectRequestIfMaxWaitOrTravelTimeViolated = false; + defaultConstraintsSet.maxWaitTime = Double.MAX_VALUE; + defaultConstraintsSet.rejectRequestIfMaxWaitOrTravelTimeViolated = false; drtConfigGroup.useModeFilteredSubnetwork = true; drtConfigGroup.addParameterSet(new ExtensiveInsertionSearchParams()); diff --git a/contribs/vsp/src/test/java/org/matsim/integration/drtAndPt/PtAlongALineTest.java b/contribs/vsp/src/test/java/org/matsim/integration/drtAndPt/PtAlongALineTest.java index 00c908721c0..e771f174dd7 100644 --- a/contribs/vsp/src/test/java/org/matsim/integration/drtAndPt/PtAlongALineTest.java +++ b/contribs/vsp/src/test/java/org/matsim/integration/drtAndPt/PtAlongALineTest.java @@ -11,6 +11,7 @@ import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; +import org.matsim.contrib.drt.optimizer.DrtOptimizationConstraintsSet; import org.matsim.contrib.drt.routing.DrtRoute; import org.matsim.contrib.drt.routing.DrtRouteFactory; import org.matsim.contrib.drt.run.DrtConfigGroup; @@ -110,10 +111,12 @@ void testDrtAlongALine() { DrtConfigGroup drtConfig = new DrtConfigGroup(); drtConfig.mode = "drt_A"; drtConfig.stopDuration = 60.; - drtConfig.maxWaitTime = 900.; - drtConfig.maxTravelTimeAlpha = 1.3; - drtConfig.maxTravelTimeBeta = 10. * 60.; - drtConfig.rejectRequestIfMaxWaitOrTravelTimeViolated = false; + DrtOptimizationConstraintsSet defaultConstraintsSet = + drtConfig.addOrGetDrtOptimizationConstraintsParams().addOrGetDefaultDrtOptimizationConstraintsSet(); + defaultConstraintsSet.maxWaitTime = 900.; + defaultConstraintsSet.maxTravelTimeAlpha = 1.3; + defaultConstraintsSet.maxTravelTimeBeta = 10. * 60.; + defaultConstraintsSet.rejectRequestIfMaxWaitOrTravelTimeViolated = false; drtConfig.changeStartLinkToLastLinkInSchedule = true; multiModeDrtCfg.addParameterSet(drtConfig); } @@ -247,11 +250,12 @@ void testPtAlongALineWithRaptorAndDrtStopFilterAttribute() { MultiModeDrtConfigGroup mm = ConfigUtils.addOrGetModule(config, MultiModeDrtConfigGroup.class); { DrtConfigGroup drtConfig = new DrtConfigGroup(); - drtConfig.maxTravelTimeAlpha = 1.3; - drtConfig.maxTravelTimeBeta = 5. * 60.; drtConfig.stopDuration = 60.; - drtConfig.maxWaitTime = Double.MAX_VALUE; - drtConfig.rejectRequestIfMaxWaitOrTravelTimeViolated = false; + DrtOptimizationConstraintsSet defaultConstraintsSet = drtConfig.addOrGetDrtOptimizationConstraintsParams().addOrGetDefaultDrtOptimizationConstraintsSet(); + defaultConstraintsSet.maxTravelTimeAlpha = 1.3; + defaultConstraintsSet.maxTravelTimeBeta = 5. * 60.; + defaultConstraintsSet.maxWaitTime = Double.MAX_VALUE; + defaultConstraintsSet.rejectRequestIfMaxWaitOrTravelTimeViolated = false; drtConfig.mode = TransportMode.drt; mm.addParameterSet(drtConfig); } diff --git a/examples/scenarios/dvrp-grid/eight_shared_taxi_config.xml b/examples/scenarios/dvrp-grid/eight_shared_taxi_config.xml index fa26707492f..4dd451ddac4 100644 --- a/examples/scenarios/dvrp-grid/eight_shared_taxi_config.xml +++ b/examples/scenarios/dvrp-grid/eight_shared_taxi_config.xml @@ -5,10 +5,12 @@ - - - - + + + + + + diff --git a/examples/scenarios/dvrp-grid/multi_mode_one_shared_taxi_config.xml b/examples/scenarios/dvrp-grid/multi_mode_one_shared_taxi_config.xml index bb0c4beed1f..1d306865741 100644 --- a/examples/scenarios/dvrp-grid/multi_mode_one_shared_taxi_config.xml +++ b/examples/scenarios/dvrp-grid/multi_mode_one_shared_taxi_config.xml @@ -14,10 +14,12 @@ - - - - + + + + + + @@ -30,10 +32,12 @@ - - - - + + + + + + diff --git a/examples/scenarios/dvrp-grid/one_shared_taxi_config.xml b/examples/scenarios/dvrp-grid/one_shared_taxi_config.xml index 6f727d250e8..2d3b062aea6 100644 --- a/examples/scenarios/dvrp-grid/one_shared_taxi_config.xml +++ b/examples/scenarios/dvrp-grid/one_shared_taxi_config.xml @@ -13,10 +13,12 @@ - - - - + + + + + + diff --git a/examples/scenarios/dvrp-grid/one_taxi_and_one_shared_taxi_config.xml b/examples/scenarios/dvrp-grid/one_taxi_and_one_shared_taxi_config.xml index 4d953cfcf33..1f1f0a1b3fa 100644 --- a/examples/scenarios/dvrp-grid/one_taxi_and_one_shared_taxi_config.xml +++ b/examples/scenarios/dvrp-grid/one_taxi_and_one_shared_taxi_config.xml @@ -8,9 +8,12 @@ - - - + + + + + + diff --git a/examples/scenarios/kelheim/config-with-drt.xml b/examples/scenarios/kelheim/config-with-drt.xml index 7657d679502..65d678e96d3 100644 --- a/examples/scenarios/kelheim/config-with-drt.xml +++ b/examples/scenarios/kelheim/config-with-drt.xml @@ -243,15 +243,17 @@ - - - - - - - - - + + + + + + + + + + + @@ -286,15 +288,17 @@ - - - - - - - - - + + + + + + + + + + + diff --git a/examples/scenarios/mielec/mielec_drt_config.xml b/examples/scenarios/mielec/mielec_drt_config.xml index 403207359f5..6557f58136a 100644 --- a/examples/scenarios/mielec/mielec_drt_config.xml +++ b/examples/scenarios/mielec/mielec_drt_config.xml @@ -8,9 +8,11 @@ - - - + + + + + diff --git a/examples/scenarios/mielec/mielec_drt_config_v1.xml b/examples/scenarios/mielec/mielec_drt_config_v1.xml new file mode 100644 index 00000000000..403207359f5 --- /dev/null +++ b/examples/scenarios/mielec/mielec_drt_config_v1.xml @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/scenarios/mielec/mielec_edrt_config.xml b/examples/scenarios/mielec/mielec_edrt_config.xml index 5ab35db759d..fa045f53415 100644 --- a/examples/scenarios/mielec/mielec_edrt_config.xml +++ b/examples/scenarios/mielec/mielec_edrt_config.xml @@ -13,9 +13,11 @@ - - - + + + + + diff --git a/examples/scenarios/mielec/mielec_multiModeEdrt_config.xml b/examples/scenarios/mielec/mielec_multiModeEdrt_config.xml index 2d20b7b5756..9f0ac950685 100644 --- a/examples/scenarios/mielec/mielec_multiModeEdrt_config.xml +++ b/examples/scenarios/mielec/mielec_multiModeEdrt_config.xml @@ -14,9 +14,11 @@ - - - + + + + + @@ -40,9 +42,11 @@ - - - + + + + + diff --git a/examples/scenarios/mielec/mielec_serviceArea_based_drt_config.xml b/examples/scenarios/mielec/mielec_serviceArea_based_drt_config.xml index ceb0ca0a3cb..98754db5f24 100644 --- a/examples/scenarios/mielec/mielec_serviceArea_based_drt_config.xml +++ b/examples/scenarios/mielec/mielec_serviceArea_based_drt_config.xml @@ -13,10 +13,11 @@ - - - - + + + + + diff --git a/examples/scenarios/mielec/mielec_stop_based_drt_config.xml b/examples/scenarios/mielec/mielec_stop_based_drt_config.xml index 5b9da8ef8d0..7d07ee1fd64 100644 --- a/examples/scenarios/mielec/mielec_stop_based_drt_config.xml +++ b/examples/scenarios/mielec/mielec_stop_based_drt_config.xml @@ -13,12 +13,14 @@ - - - + + + + + + + - - diff --git a/matsim/pom.xml b/matsim/pom.xml index 0024dd46383..0a47a21d321 100644 --- a/matsim/pom.xml +++ b/matsim/pom.xml @@ -227,7 +227,7 @@ jakarta.validation jakarta.validation-api - 3.0.2 + 3.1.0 org.hibernate.validator diff --git a/matsim/src/main/java/org/matsim/analysis/ModeChoiceCoverageControlerListener.java b/matsim/src/main/java/org/matsim/analysis/ModeChoiceCoverageControlerListener.java index ce1bd875272..068e11e8cd8 100644 --- a/matsim/src/main/java/org/matsim/analysis/ModeChoiceCoverageControlerListener.java +++ b/matsim/src/main/java/org/matsim/analysis/ModeChoiceCoverageControlerListener.java @@ -98,95 +98,102 @@ public void notifyIterationEnds(final IterationEndsEvent event) { updateModesUsedPerPerson(); - - /* - * Looks through modesUsedPerPersonTrip at each person-trip. How many of those person trips have used each mode more than the - * predefined limits. - */ - int totalPersonTripCount = 0; - Map> modeCountCurrentIteration = new TreeMap<>(); - //Map> - - for (Map> mapForPerson : modesUsedPerPersonTrip.values()) { - //Map> - for (Map mapForPersonTrip : mapForPerson.values()) { - //Map - totalPersonTripCount++; - for (String mode : mapForPersonTrip.keySet()) { - Integer realCount = mapForPersonTrip.get(mode); - for (Integer limit : limits) { - Map modeCountMap = modeCountCurrentIteration.computeIfAbsent(limit, k -> new TreeMap<>()); - Double modeCount = modeCountMap.computeIfAbsent(mode, k -> 0.); - if (realCount >= limit) { - modeCount++; - } - modeCountMap.put(mode, modeCount); - modeCountCurrentIteration.put(limit, modeCountMap); - } - } - } - } - // Calculates mcc share for each mode in current iteration, and updates modeCCHistory accordingly - for (Integer limit : limits) { - Map modeCnt = modeCountCurrentIteration.get(limit); - this.modes.addAll(modeCnt.keySet()); // potentially adds new modes to setthat just showed up in current iter - Map> modeIterationShareMap = modeCCHistory.computeIfAbsent(limit, k -> new HashMap<>()); - for (String mode : modes) { - Double cnt = modeCnt.get(mode); - double share = 0.; - if (cnt != null) { - share = cnt / totalPersonTripCount; - } - - log.info("-- mode choice coverage (" + limit + "x) of mode " + mode + " = " + share); - - Map iterationShareMap = modeIterationShareMap.get(mode); - - // If this is the first iteration where the mode shows up, add zeros to all previous iterations in history - if (iterationShareMap == null) { - iterationShareMap = new TreeMap<>(); - for (int iter = firstIteration; iter < event.getIteration(); iter++) { - iterationShareMap.put(iter, 0.0); - } - modeIterationShareMap.put(mode, iterationShareMap); - } - - iterationShareMap.put(event.getIteration(), share); - } - } - - - // Print MCC Stats to output file - for (Integer limit : limits) { - Map> modeIterationShareMap = modeCCHistory.get(limit); - - BufferedWriter modeOut = IOUtils.getBufferedWriter(this.modeFileName + limit + "x.txt"); - try { - modeOut.write("Iteration"); - for (String mode : modes) { - modeOut.write("\t" + mode); - } - modeOut.write("\n"); - for (int iter = firstIteration; iter <= event.getIteration(); iter++) { - modeOut.write(String.valueOf(iter)); - for (String mode : modes) { - modeOut.write("\t" + modeIterationShareMap.get(mode).get(iter)); - } - modeOut.write("\n"); - } - - modeOut.flush(); - modeOut.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - - // Produce Graphs - if (this.createPNG && event.getIteration() > this.minIteration) { - produceGraphs(); - } - + /* + * Looks through modesUsedPerPersonTrip at each person-trip. How many of those person trips have used each mode more than the + * predefined limits. + */ + int totalPersonTripCount = 0; + Map> modeCountCurrentIteration = new TreeMap<>(); + //Map> + + for (Map> mapForPerson : modesUsedPerPersonTrip.values()) { + //Map> + for (Map mapForPersonTrip : mapForPerson.values()) { + //Map + totalPersonTripCount++; + for (String mode : mapForPersonTrip.keySet()) { + Integer realCount = mapForPersonTrip.get(mode); + for (Integer limit : limits) { + Map modeCountMap = modeCountCurrentIteration.computeIfAbsent(limit, k -> new TreeMap<>()); + Double modeCount = modeCountMap.computeIfAbsent(mode, k -> 0.); + if (realCount >= limit) { + modeCount++; + } + modeCountMap.put(mode, modeCount); + modeCountCurrentIteration.put(limit, modeCountMap); + } + } + } + } + + + // for testing purposes: if there are any trips, do analysis. If not, it is probably a test or a faulty / empty population. -sme0524 + if (!modeCountCurrentIteration.isEmpty()) { + // Calculates mcc share for each mode in current iteration, and updates modeCCHistory accordingly + for (Integer limit : limits) { + Map modeCnt = modeCountCurrentIteration.get(limit); + this.modes.addAll(modeCnt.keySet()); // potentially adds new modes to setthat just showed up in current iter + Map> modeIterationShareMap = modeCCHistory.computeIfAbsent(limit, k -> new HashMap<>()); + for (String mode : modes) { + Double cnt = modeCnt.get(mode); + double share = 0.; + if (cnt != null) { + share = cnt / totalPersonTripCount; + } + + log.info("-- mode choice coverage (" + limit + "x) of mode " + mode + " = " + share); + + Map iterationShareMap = modeIterationShareMap.get(mode); + + // If this is the first iteration where the mode shows up, add zeros to all previous iterations in history + if (iterationShareMap == null) { + iterationShareMap = new TreeMap<>(); + for (int iter = firstIteration; iter < event.getIteration(); iter++) { + iterationShareMap.put(iter, 0.0); + } + modeIterationShareMap.put(mode, iterationShareMap); + } + + iterationShareMap.put(event.getIteration(), share); + } + } + + + // Print MCC Stats to output file + for (Integer limit : limits) { + Map> modeIterationShareMap = modeCCHistory.get(limit); + + BufferedWriter modeOut = IOUtils.getBufferedWriter(this.modeFileName + limit + "x.txt"); + try { + modeOut.write("Iteration"); + for (String mode : modes) { + modeOut.write("\t" + mode); + } + modeOut.write("\n"); + for (int iter = firstIteration; iter <= event.getIteration(); iter++) { + modeOut.write(String.valueOf(iter)); + for (String mode : modes) { + modeOut.write("\t" + modeIterationShareMap.get(mode).get(iter)); + } + modeOut.write("\n"); + } + + modeOut.flush(); + modeOut.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + // Produce Graphs + if (this.createPNG && event.getIteration() > this.minIteration) { + produceGraphs(); + } + + } else { + log.warn("There are no trips conducted by the analyzed population. This should only be the case for tests. If you are running a simulation run, " + + " this should not happen. Check your population."); + } } private void updateModesUsedPerPerson() { diff --git a/matsim/src/main/java/org/matsim/analysis/ModeStatsModule.java b/matsim/src/main/java/org/matsim/analysis/ModeStatsModule.java index ded90a3ec76..96ff6bc4b7a 100644 --- a/matsim/src/main/java/org/matsim/analysis/ModeStatsModule.java +++ b/matsim/src/main/java/org/matsim/analysis/ModeStatsModule.java @@ -30,5 +30,7 @@ public class ModeStatsModule extends AbstractModule { public void install() { bind(ModeStatsControlerListener.class).in(Singleton.class); addControlerListenerBinding().to(ModeStatsControlerListener.class); +// KN: if this is a somewhat standard analysis it should be added by default rather than adding it in every scenario run class + addControlerListenerBinding().to(ModeChoiceCoverageControlerListener.class); } } diff --git a/matsim/src/main/java/org/matsim/analysis/pt/stop2stop/PtStop2StopAnalysis2Shp.java b/matsim/src/main/java/org/matsim/analysis/pt/stop2stop/PtStop2StopAnalysis2Shp.java index 99eeb4c0b20..1599a5ba979 100644 --- a/matsim/src/main/java/org/matsim/analysis/pt/stop2stop/PtStop2StopAnalysis2Shp.java +++ b/matsim/src/main/java/org/matsim/analysis/pt/stop2stop/PtStop2StopAnalysis2Shp.java @@ -23,6 +23,7 @@ import org.apache.commons.csv.CSVPrinter; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.geotools.api.feature.simple.SimpleFeature; import org.geotools.feature.simple.SimpleFeatureBuilder; import org.geotools.feature.simple.SimpleFeatureTypeBuilder; import org.locationtech.jts.geom.Coordinate; @@ -35,7 +36,6 @@ import org.matsim.core.utils.gis.GeoFileWriter; import org.matsim.core.utils.io.IOUtils; import org.matsim.pt.transitSchedule.api.TransitLine; -import org.opengis.feature.simple.SimpleFeature; import java.io.IOException; import java.util.*; diff --git a/matsim/src/main/java/org/matsim/core/config/groups/ReplanningConfigGroup.java b/matsim/src/main/java/org/matsim/core/config/groups/ReplanningConfigGroup.java index 4a9b0de4f20..1daf2c459c9 100644 --- a/matsim/src/main/java/org/matsim/core/config/groups/ReplanningConfigGroup.java +++ b/matsim/src/main/java/org/matsim/core/config/groups/ReplanningConfigGroup.java @@ -275,7 +275,7 @@ private StrategySettings getStrategySettings(final Id index, f @Override public final Map getComments() { Map map = super.getComments(); - map.put(ReflectiveDelegate.ITERATION_FRACTION_TO_DISABLE_INNOVATION, "fraction of iterations where innovative strategies are switched off. Something like 0.8 should be good. E.g. if you run from iteration 400 to iteration 500, innovation is switched off at iteration 480" ) ; + map.put(ReflectiveDelegate.ITERATION_FRACTION_TO_DISABLE_INNOVATION, "fraction of iterations where innovative strategies are switched off. Something like 0.8 should be good. E.g. if you run from iteration 400 to iteration 500, innovation is switched off at iteration 480. If the ReplanningAnnealer is used, it will also be switched off." ) ; map.put(ReflectiveDelegate.MAX_AGENT_PLAN_MEMORY_SIZE, "maximum number of plans per agent. ``0'' means ``infinity''. Currently (2010), ``5'' is a good number"); StringBuilder strb = new StringBuilder() ; diff --git a/matsim/src/main/java/org/matsim/core/config/groups/SubtourModeChoiceConfigGroup.java b/matsim/src/main/java/org/matsim/core/config/groups/SubtourModeChoiceConfigGroup.java index 1a701ecff8e..b0adab12124 100644 --- a/matsim/src/main/java/org/matsim/core/config/groups/SubtourModeChoiceConfigGroup.java +++ b/matsim/src/main/java/org/matsim/core/config/groups/SubtourModeChoiceConfigGroup.java @@ -32,7 +32,7 @@ public final class SubtourModeChoiceConfigGroup extends ReflectiveConfigGroup { public static final String GROUP_NAME = "subtourModeChoice"; - + public final static String MODES = "modes"; public final static String CHAINBASEDMODES = "chainBasedModes"; public final static String CARAVAIL = "considerCarAvailability"; @@ -40,17 +40,17 @@ public final class SubtourModeChoiceConfigGroup extends ReflectiveConfigGroup { public final static String COORD_DISTANCE = "coordDistance"; private static final String BEHAVIOR = "behavior"; - + private String[] chainBasedModes = new String[] { TransportMode.car, TransportMode.bike }; private String[] allModes = new String[] { TransportMode.car, TransportMode.pt, TransportMode.bike, TransportMode.walk }; // default is false for backward compatibility private boolean considerCarAvailability = false; private SubtourModeChoice.Behavior behavior = SubtourModeChoice.Behavior.fromSpecifiedModesToSpecifiedModes ; - + private double probaForRandomSingleTripMode = 0. ; // yyyyyy backwards compatibility setting; should be change. kai, may'18 private double coordDistance = 0; - + public SubtourModeChoiceConfigGroup() { super(GROUP_NAME); } @@ -67,7 +67,7 @@ private String getChainBaseModesString() { private static String toString( final String[] modes ) { // (not same as toString() because of argument!) - + StringBuilder b = new StringBuilder(); if (modes.length > 0) b.append( modes[ 0 ] ); @@ -106,7 +106,8 @@ public Map getComments() { comments.put(CHAINBASEDMODES, "Defines the chain-based modes, seperated by commas" ); comments.put(CARAVAIL, "Defines whether car availability must be considered or not. A agent has no car only if it has no license, or never access to a car" ); comments.put(SINGLE_PROBA, "Defines the probability of changing a single trip for a unchained mode instead of subtour."); - comments.put(COORD_DISTANCE, "If greater than 0, subtours will also consider coordinates to be at the same location when smaller than set distance."); + comments.put(COORD_DISTANCE, "If greater than 0, activities that are closer than coordDistance, to each other, will be considered part of the same subtour." + + "i.e. if two activities are close to each other, the agent is allowed to use the same 'chain-based' vehicle for both subtours."); { StringBuilder msg = new StringBuilder("Only for backwards compatibility. Defines if only trips from modes list should change mode, or all trips. Options: "); diff --git a/matsim/src/main/java/org/matsim/core/controler/AbstractModule.java b/matsim/src/main/java/org/matsim/core/controler/AbstractModule.java index d6d3eb94efa..fcf5feeefa8 100644 --- a/matsim/src/main/java/org/matsim/core/controler/AbstractModule.java +++ b/matsim/src/main/java/org/matsim/core/controler/AbstractModule.java @@ -76,25 +76,10 @@ public abstract class AbstractModule implements Module { private Binder binder; - private Multibinder eventHandlerMultibinder; - private Multibinder controlerListenerMultibinder; - - /** - * Contents retrieved (I think) by injected method QSim#addQueueSimulationListeners(...). Is not public, and therefore cannot be referenced from here. - *
- * I think that that method will be called every time the mobsim will be constructed. If the injected classes are singletons, they will - * presumably be re-used, otherwise they will be newly constructed. - */ - private Multibinder mobsimListenerMultibinder; - - private Multibinder snapshotWriterMultibinder; - private MapBinder, AttributeConverter> attributeConverterMapBinder; - private Multibinder qsimModulesMultibinder; @Inject com.google.inject.Injector bootstrapInjector; private Config config; - private Multibinder qsimOverridingModulesMultibinder; public AbstractModule() { // config will be injected later @@ -121,17 +106,13 @@ public final void configure(Binder binder) { private void initializeMultibinders() { // We do need to make these calls here in order to register the multi binders. Otherwise, guice doesn't know, that they exist. In particular, // if none of the corresponding addXXXBinding methods was called, the set binder would not be registered, and guice would complain. - this.mobsimListenerMultibinder = Multibinder.newSetBinder(this.binder, MobsimListener.class); - this.snapshotWriterMultibinder = Multibinder.newSetBinder(this.binder, SnapshotWriter.class); - this.eventHandlerMultibinder = Multibinder.newSetBinder(this.binder, EventHandler.class); - this.controlerListenerMultibinder = Multibinder.newSetBinder(this.binder, ControlerListener.class); - this.attributeConverterMapBinder = - MapBinder.newMapBinder( - this.binder, - new TypeLiteral>(){}, - new TypeLiteral>() {} ); - this.qsimModulesMultibinder = Multibinder.newSetBinder(this.binder, AbstractQSimModule.class); - this.qsimOverridingModulesMultibinder = Multibinder.newSetBinder( this.binder, AbstractQSimModule.class, Names.named( "overridesFromAbstractModule" ) ); + Multibinder.newSetBinder(this.binder, MobsimListener.class); + Multibinder.newSetBinder(this.binder, SnapshotWriter.class); + Multibinder.newSetBinder(this.binder, EventHandler.class); + Multibinder.newSetBinder(this.binder, ControlerListener.class); + MapBinder.newMapBinder(this.binder, new TypeLiteral>(){}, new TypeLiteral>() {} ); + Multibinder.newSetBinder(this.binder, AbstractQSimModule.class); + Multibinder.newSetBinder( this.binder, AbstractQSimModule.class, Names.named( "overridesFromAbstractModule" ) ); } public abstract void install(); @@ -146,21 +127,21 @@ protected final void install(Module module) { } protected final LinkedBindingBuilder addEventHandlerBinding() { - return eventHandlerMultibinder.addBinding(); + return Multibinder.newSetBinder(this.binder, EventHandler.class).addBinding(); } protected final void installQSimModule(AbstractQSimModule qsimModule) { - qsimModulesMultibinder.addBinding().toInstance(qsimModule); + Multibinder.newSetBinder(this.binder, AbstractQSimModule.class).addBinding().toInstance(qsimModule); } protected final void installOverridingQSimModule(AbstractQSimModule qsimModule) { - qsimOverridingModulesMultibinder.addBinding().toInstance(qsimModule); + Multibinder.newSetBinder( this.binder, AbstractQSimModule.class, Names.named( "overridesFromAbstractModule" ) ).addBinding().toInstance(qsimModule); } /** * @see ControlerListener */ protected final LinkedBindingBuilder addControlerListenerBinding() { - return controlerListenerMultibinder.addBinding(); + return Multibinder.newSetBinder(this.binder, ControlerListener.class).addBinding(); } /** @@ -182,16 +163,22 @@ protected final com.google.inject.binder.LinkedBindingBuilder + * I think that that method will be called every time the mobsim will be constructed. If the injected classes are singletons, they will + * presumably be re-used, otherwise they will be newly constructed. + */ protected final com.google.inject.binder.LinkedBindingBuilder addMobsimListenerBinding() { - return mobsimListenerMultibinder.addBinding(); + return Multibinder.newSetBinder(this.binder, MobsimListener.class).addBinding(); } protected final com.google.inject.binder.LinkedBindingBuilder addSnapshotWriterBinding() { - return snapshotWriterMultibinder.addBinding(); + return Multibinder.newSetBinder(this.binder, SnapshotWriter.class).addBinding(); } protected final LinkedBindingBuilder> addAttributeConverterBinding(final Class clazz ) { - return attributeConverterMapBinder.addBinding( clazz ); + return MapBinder.newMapBinder(this.binder, new TypeLiteral>(){}, new TypeLiteral>() {} ).addBinding( clazz ); } /** * @deprecated better use {@link #addTravelDisutilityFactoryBinding(String)}. diff --git a/matsim/src/main/java/org/matsim/core/network/algorithms/NetworkTeleatlasAddManeuverRestrictions.java b/matsim/src/main/java/org/matsim/core/network/algorithms/NetworkTeleatlasAddManeuverRestrictions.java index b88e16c0a2b..f9a20978221 100644 --- a/matsim/src/main/java/org/matsim/core/network/algorithms/NetworkTeleatlasAddManeuverRestrictions.java +++ b/matsim/src/main/java/org/matsim/core/network/algorithms/NetworkTeleatlasAddManeuverRestrictions.java @@ -28,9 +28,10 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.geotools.api.data.SimpleFeatureSource; +import org.geotools.api.feature.simple.SimpleFeature; import org.geotools.data.shapefile.dbf.DbaseFileReader; import org.geotools.data.simple.SimpleFeatureIterator; -import org.geotools.data.simple.SimpleFeatureSource; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; @@ -41,7 +42,6 @@ import org.matsim.core.utils.collections.Tuple; import org.matsim.core.utils.gis.GeoFileReader; import org.matsim.core.utils.io.IOUtils; -import org.opengis.feature.simple.SimpleFeature; /** * Adds maneuver restrictions to a MATSim {@link Network network} created diff --git a/matsim/src/main/java/org/matsim/core/network/io/NetworkReaderTeleatlas.java b/matsim/src/main/java/org/matsim/core/network/io/NetworkReaderTeleatlas.java index c4416bb5531..4c947ad52fa 100644 --- a/matsim/src/main/java/org/matsim/core/network/io/NetworkReaderTeleatlas.java +++ b/matsim/src/main/java/org/matsim/core/network/io/NetworkReaderTeleatlas.java @@ -24,8 +24,10 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.geotools.api.data.SimpleFeatureSource; +import org.geotools.api.feature.simple.SimpleFeature; +import org.geotools.api.geometry.BoundingBox; import org.geotools.data.simple.SimpleFeatureIterator; -import org.geotools.data.simple.SimpleFeatureSource; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; @@ -34,8 +36,6 @@ import org.matsim.core.api.internal.MatsimSomeReader; import org.matsim.core.network.NetworkUtils; import org.matsim.core.utils.gis.GeoFileReader; -import org.opengis.feature.simple.SimpleFeature; -import org.opengis.geometry.BoundingBox; /** * A reader for TeleAtlas network description files. The reader is based on diff --git a/matsim/src/main/java/org/matsim/core/replanning/annealing/ReplanningAnnealerConfigGroup.java b/matsim/src/main/java/org/matsim/core/replanning/annealing/ReplanningAnnealerConfigGroup.java index 3c13879d7ca..41dd22aa4d5 100644 --- a/matsim/src/main/java/org/matsim/core/replanning/annealing/ReplanningAnnealerConfigGroup.java +++ b/matsim/src/main/java/org/matsim/core/replanning/annealing/ReplanningAnnealerConfigGroup.java @@ -227,9 +227,9 @@ public void setShapeFactor(double shapeFactor) { public Map getComments() { Map map = super.getComments(); map.put(HALFLIFE, - "this parameter enters the exponential and sigmoid formulas. May be an iteration or a share, i.e. 0.5 for halfLife at 50% of iterations. Exponential: startValue / exp(it/halfLife)"); - map.put(SHAPE_FACTOR, "sigmoid: 1/(1+e^(shapeFactor*(it - halfLife))); geometric: startValue * shapeFactor^it; msa: startValue / it^shapeFactor"); - map.put(ANNEAL_TYPE, "options: linear, exponential, geometric, msa, sigmoid and disabled (no annealing)."); + "this parameter enters the exponential and sigmoid formulas. May be an iteration or a share, i.e. 0.5 for halfLife at 50% of iterations."); + map.put(SHAPE_FACTOR, "see comment of parameter annealType."); + map.put(ANNEAL_TYPE, "options: linear, exponential, geometric, msa, sigmoid and disabled (no annealing). sigmoid: 1/(1+e^(shapeFactor*(it - halfLife))); geometric: startValue * shapeFactor^it; msa: startValue / it^shapeFactor. Exponential: startValue / exp(it/halfLife)"); map.put(ANNEAL_PARAM, "list of config parameters that shall be annealed. Currently supported: globalInnovationRate, BrainExpBeta, PathSizeLogitBeta, learningRate. Default is globalInnovationRate"); map.put(SUBPOPULATION, "subpopulation to have the global innovation rate adjusted. Not applicable when annealing with other parameters."); diff --git a/matsim/src/main/java/org/matsim/core/replanning/modules/SubtourModeChoice.java b/matsim/src/main/java/org/matsim/core/replanning/modules/SubtourModeChoice.java index 75d7625669b..fff07e0bd4d 100644 --- a/matsim/src/main/java/org/matsim/core/replanning/modules/SubtourModeChoice.java +++ b/matsim/src/main/java/org/matsim/core/replanning/modules/SubtourModeChoice.java @@ -33,16 +33,16 @@ * different mode given a list of possible modes. * * A subtour is a consecutive subset of a plan which starts and ends at the same link. - * + * * Certain modes are considered only if the choice would not require some resource to appear * out of thin air. For example, you can only drive your car back from work if you have previously parked it * there. These are called chain-based modes. - * + * * The assumption is that each chain-based mode requires one resource (car, bike, ...) and that this * resource is initially positioned at home. Home is the location of the first activity in the plan. - * - * If the plan initially violates this constraint, this module may (!) repair it. - * + * + * If the plan initially violates this constraint, this module may (!) repair it. + * * @author michaz * */ @@ -51,7 +51,27 @@ public class SubtourModeChoice extends AbstractMultithreadedModule { private final double probaForChangeSingleTripMode; private final double coordDist; - public enum Behavior {fromAllModesToSpecifiedModes, fromSpecifiedModesToSpecifiedModes, betweenAllAndFewerConstraints} + public enum Behavior { + /** + * Allow agents to switch to specified modes from all other modes. + * This implies that agents might switch to a specified mode, but won't be able to switch back + * to their original mode. This option should not be used. + */ + @Deprecated + fromAllModesToSpecifiedModes, + + /** + * Allow agents switching from one of a specified mode to another specified mode. + * Note, that agents that have an unclosed subtour, are not able to switch mode. + * If you have unclosed/open subtours in your data, consider using {@link #betweenAllAndFewerConstraints}. + */ + fromSpecifiedModesToSpecifiedModes, + + /** + * Same as "fromSpecifiedModesToSpecifiedModes", but also allow agents with open subtours to switch modes. + */ + betweenAllAndFewerConstraints + } private Behavior behavior = Behavior.fromSpecifiedModesToSpecifiedModes; @@ -85,19 +105,19 @@ public SubtourModeChoice(GlobalConfigGroup globalConfigGroup, this.probaForChangeSingleTripMode = probaForChangeSingleTripMode; this.coordDist = coordDist; } - + @Deprecated // only use when backwards compatibility is needed. kai, may'18 public final void setBehavior ( Behavior behavior ) { this.behavior = behavior ; } - + protected String[] getModes() { return modes.clone(); } @Override public PlanAlgorithm getPlanAlgoInstance() { - + final ChooseRandomLegModeForSubtour chooseRandomLegMode = new ChooseRandomLegModeForSubtour( TripStructureUtils.getRoutingModeIdentifier(), diff --git a/matsim/src/main/java/org/matsim/core/utils/geometry/GeometryUtils.java b/matsim/src/main/java/org/matsim/core/utils/geometry/GeometryUtils.java index b407c794b2b..1c8fc0ac6e7 100644 --- a/matsim/src/main/java/org/matsim/core/utils/geometry/GeometryUtils.java +++ b/matsim/src/main/java/org/matsim/core/utils/geometry/GeometryUtils.java @@ -28,6 +28,7 @@ import java.util.Map.Entry; import java.util.Random; +import org.geotools.api.feature.simple.SimpleFeature; import org.geotools.geometry.jts.GeometryBuilder; import org.locationtech.jts.geom.Coordinate; import org.locationtech.jts.geom.Geometry; @@ -40,7 +41,6 @@ import org.matsim.api.core.v01.network.Network; import org.matsim.core.gbl.Gbl; import org.matsim.core.utils.geometry.geotools.MGC; -import org.opengis.feature.simple.SimpleFeature; /** * @author kainagel diff --git a/matsim/src/main/java/org/matsim/core/utils/geometry/geotools/MGC.java b/matsim/src/main/java/org/matsim/core/utils/geometry/geotools/MGC.java index cf50c6938c0..3667bf7aa80 100644 --- a/matsim/src/main/java/org/matsim/core/utils/geometry/geotools/MGC.java +++ b/matsim/src/main/java/org/matsim/core/utils/geometry/geotools/MGC.java @@ -25,14 +25,14 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.geotools.api.referencing.FactoryException; +import org.geotools.api.referencing.crs.CoordinateReferenceSystem; import org.geotools.referencing.CRS; import org.locationtech.jts.geom.Coordinate; import org.locationtech.jts.geom.GeometryFactory; import org.locationtech.jts.geom.Point; import org.matsim.api.core.v01.Coord; import org.matsim.core.utils.geometry.transformations.TransformationFactory; -import org.opengis.referencing.FactoryException; -import org.opengis.referencing.crs.CoordinateReferenceSystem; /** * Converter factory for various conversion from Geotools to MATSim and vice versa. diff --git a/matsim/src/main/java/org/matsim/core/utils/geometry/transformations/GeotoolsTransformation.java b/matsim/src/main/java/org/matsim/core/utils/geometry/transformations/GeotoolsTransformation.java index 531383ac9e9..5d6b414394d 100644 --- a/matsim/src/main/java/org/matsim/core/utils/geometry/transformations/GeotoolsTransformation.java +++ b/matsim/src/main/java/org/matsim/core/utils/geometry/transformations/GeotoolsTransformation.java @@ -20,6 +20,10 @@ package org.matsim.core.utils.geometry.transformations; +import org.geotools.api.referencing.FactoryException; +import org.geotools.api.referencing.crs.CoordinateReferenceSystem; +import org.geotools.api.referencing.operation.MathTransform; +import org.geotools.api.referencing.operation.TransformException; import org.geotools.geometry.jts.JTS; import org.geotools.referencing.CRS; import org.locationtech.jts.geom.Point; @@ -27,10 +31,6 @@ import org.matsim.core.utils.geometry.CoordUtils; import org.matsim.core.utils.geometry.CoordinateTransformation; import org.matsim.core.utils.geometry.geotools.MGC; -import org.opengis.referencing.FactoryException; -import org.opengis.referencing.crs.CoordinateReferenceSystem; -import org.opengis.referencing.operation.MathTransform; -import org.opengis.referencing.operation.TransformException; /** * A transformation factory for various coordinate systems using the GeoTools. diff --git a/matsim/src/main/java/org/matsim/core/utils/geometry/transformations/TransformationFactory.java b/matsim/src/main/java/org/matsim/core/utils/geometry/transformations/TransformationFactory.java index 861a1c1f3cc..5398a117794 100644 --- a/matsim/src/main/java/org/matsim/core/utils/geometry/transformations/TransformationFactory.java +++ b/matsim/src/main/java/org/matsim/core/utils/geometry/transformations/TransformationFactory.java @@ -31,6 +31,7 @@ public abstract class TransformationFactory { public final static String WGS84 = "WGS84"; + public final static String EPSG4326 = "EPSG:4326"; public final static String ATLANTIS = "Atlantis"; public final static String CH1903_LV03 = "CH1903_LV03"; // switzerland public final static String CH1903_LV03_Plus = "CH1903_LV03_Plus"; // switzerland new @@ -40,7 +41,7 @@ public abstract class TransformationFactory { public final static String WGS84_UTM35S = "WGS84_UTM35S"; // South Africa (Gauteng) public final static String WGS84_UTM36S = "WGS84_UTM36S"; // South Africa (eThekwini, Kwazulu-Natal) public final static String WGS84_Albers = "WGS84_Albers"; // South Africa (Africa Albers Equal Conic) - public final static String WGS84_SA_Albers = "WGS84_SA_Albers"; // South Africa (Adapted version of Africa Albers Equal) + public final static String WGS84_SA_Albers = "WGS84_SA_Albers"; // South Africa (Adapted version of Africa Albers Equal) public final static String HARTEBEESTHOEK94_LO19 = "SA_Lo19"; // South Africa adaption of Transverse Mercator. Cape Town public final static String HARTEBEESTHOEK94_LO25 = "SA_Lo25"; // South Africa adaption of Transverse Mercator. Nelson Mandela Bay Metropolitan public final static String HARTEBEESTHOEK94_LO29 = "SA_Lo29"; // South Africa adaption of Transverse Mercator. General for SA as a whole, and Gauteng @@ -57,7 +58,7 @@ public abstract class TransformationFactory { public static final String WGS84_TM = "WGS84_TM"; //Singapore3 public static final String PCS_ITRF2000_TM_UOS = "PCS_ITRF2000_TM_UOS"; // South Korea - but used by University of Seoul - probably a wrong one... public static final String DHDN_SoldnerBerlin = "DHDN_SoldnerBerlin"; // Berlin - + /** * Returns a coordinate transformation to transform coordinates from one * coordinate system to another one. @@ -68,12 +69,12 @@ public abstract class TransformationFactory { */ public static CoordinateTransformation getCoordinateTransformation(final String fromSystem, final String toSystem) { if (fromSystem.equals(toSystem)) return new IdentityTransformation(); - if (WGS84.equals(fromSystem)) { + if (WGS84.equals(fromSystem) || EPSG4326.equalsIgnoreCase(fromSystem)) { if (CH1903_LV03.equals(toSystem)) return new WGS84toCH1903LV03(); if (CH1903_LV03_Plus.equals(toSystem)) return new WGS84toCH1903LV03Plus(); if (ATLANTIS.equals(toSystem)) return new WGS84toAtlantis(); } - if (WGS84.equals(toSystem)) { + if (WGS84.equals(toSystem) || EPSG4326.equalsIgnoreCase(toSystem)) { if (CH1903_LV03.equals(fromSystem)) return new CH1903LV03toWGS84(); if (CH1903_LV03_Plus.equals(fromSystem)) return new CH1903LV03PlustoWGS84(); if (GK4.equals(fromSystem)) return new GK4toWGS84(); diff --git a/matsim/src/main/java/org/matsim/core/utils/gis/GeoFileReader.java b/matsim/src/main/java/org/matsim/core/utils/gis/GeoFileReader.java index 80fe6650150..c08aa5f79b2 100644 --- a/matsim/src/main/java/org/matsim/core/utils/gis/GeoFileReader.java +++ b/matsim/src/main/java/org/matsim/core/utils/gis/GeoFileReader.java @@ -22,24 +22,19 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.geotools.data.DataStore; -import org.geotools.data.DataStoreFinder; -import org.geotools.data.FileDataStore; -import org.geotools.data.FileDataStoreFinder; +import org.geotools.api.data.*; +import org.geotools.api.feature.simple.SimpleFeature; +import org.geotools.api.feature.simple.SimpleFeatureType; +import org.geotools.api.feature.type.Name; +import org.geotools.api.referencing.crs.CoordinateReferenceSystem; import org.geotools.data.simple.SimpleFeatureCollection; import org.geotools.data.simple.SimpleFeatureIterator; -import org.geotools.data.simple.SimpleFeatureSource; import org.geotools.geometry.jts.ReferencedEnvelope; import org.geotools.geopkg.GeoPkgDataStoreFactory; import org.geotools.jdbc.JDBCDataStore; import org.matsim.core.api.internal.MatsimSomeReader; import org.matsim.core.gbl.Gbl; import org.matsim.core.utils.misc.Counter; -import org.opengis.feature.Feature; -import org.opengis.feature.simple.SimpleFeature; -import org.opengis.feature.simple.SimpleFeatureType; -import org.opengis.feature.type.Name; -import org.opengis.referencing.crs.CoordinateReferenceSystem; import java.io.File; import java.io.IOException; diff --git a/matsim/src/main/java/org/matsim/core/utils/gis/GeoFileWriter.java b/matsim/src/main/java/org/matsim/core/utils/gis/GeoFileWriter.java index 26296281c56..c0bd720f77a 100644 --- a/matsim/src/main/java/org/matsim/core/utils/gis/GeoFileWriter.java +++ b/matsim/src/main/java/org/matsim/core/utils/gis/GeoFileWriter.java @@ -22,19 +22,19 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.geotools.data.DataStore; -import org.geotools.data.DataStoreFinder; -import org.geotools.data.FileDataStore; +import org.geotools.api.data.DataStore; +import org.geotools.api.data.DataStoreFinder; +import org.geotools.api.data.FileDataStore; +import org.geotools.api.data.SimpleFeatureStore; +import org.geotools.api.feature.simple.SimpleFeature; +import org.geotools.api.feature.simple.SimpleFeatureType; +import org.geotools.api.feature.type.Name; import org.geotools.data.shapefile.ShapefileDataStore; -import org.geotools.data.simple.SimpleFeatureStore; import org.geotools.feature.DefaultFeatureCollection; import org.geotools.feature.NameImpl; import org.geotools.geopkg.GeoPkgDataStoreFactory; import org.geotools.jdbc.JDBCDataStoreFactory; import org.matsim.core.api.internal.MatsimSomeWriter; -import org.opengis.feature.simple.SimpleFeature; -import org.opengis.feature.simple.SimpleFeatureType; -import org.opengis.feature.type.Name; import java.io.File; import java.io.IOException; diff --git a/matsim/src/main/java/org/matsim/core/utils/gis/PointFeatureFactory.java b/matsim/src/main/java/org/matsim/core/utils/gis/PointFeatureFactory.java index e8b3cd008ef..30844e5e672 100644 --- a/matsim/src/main/java/org/matsim/core/utils/gis/PointFeatureFactory.java +++ b/matsim/src/main/java/org/matsim/core/utils/gis/PointFeatureFactory.java @@ -23,15 +23,15 @@ import java.util.LinkedHashMap; import java.util.Map; +import org.geotools.api.feature.simple.SimpleFeature; +import org.geotools.api.feature.simple.SimpleFeatureType; +import org.geotools.api.referencing.crs.CoordinateReferenceSystem; import org.geotools.feature.simple.SimpleFeatureBuilder; import org.geotools.feature.simple.SimpleFeatureTypeBuilder; import org.locationtech.jts.geom.Coordinate; import org.locationtech.jts.geom.GeometryFactory; import org.locationtech.jts.geom.Point; import org.matsim.api.core.v01.Coord; -import org.opengis.feature.simple.SimpleFeature; -import org.opengis.feature.simple.SimpleFeatureType; -import org.opengis.referencing.crs.CoordinateReferenceSystem; /** * @author mrieser / senozon diff --git a/matsim/src/main/java/org/matsim/core/utils/gis/PolygonFeatureFactory.java b/matsim/src/main/java/org/matsim/core/utils/gis/PolygonFeatureFactory.java index 90138d648da..a6389d0af0f 100644 --- a/matsim/src/main/java/org/matsim/core/utils/gis/PolygonFeatureFactory.java +++ b/matsim/src/main/java/org/matsim/core/utils/gis/PolygonFeatureFactory.java @@ -23,6 +23,9 @@ import java.util.LinkedHashMap; import java.util.Map; +import org.geotools.api.feature.simple.SimpleFeature; +import org.geotools.api.feature.simple.SimpleFeatureType; +import org.geotools.api.referencing.crs.CoordinateReferenceSystem; import org.geotools.feature.simple.SimpleFeatureBuilder; import org.geotools.feature.simple.SimpleFeatureTypeBuilder; import org.locationtech.jts.geom.Coordinate; @@ -31,9 +34,6 @@ import org.locationtech.jts.geom.MultiPolygon; import org.locationtech.jts.geom.Polygon; import org.matsim.api.core.v01.Coord; -import org.opengis.feature.simple.SimpleFeature; -import org.opengis.feature.simple.SimpleFeatureType; -import org.opengis.referencing.crs.CoordinateReferenceSystem; /** * @author mrieser / senozon diff --git a/matsim/src/main/java/org/matsim/core/utils/gis/PolylineFeatureFactory.java b/matsim/src/main/java/org/matsim/core/utils/gis/PolylineFeatureFactory.java index 745b7d4aee0..dac6691065f 100644 --- a/matsim/src/main/java/org/matsim/core/utils/gis/PolylineFeatureFactory.java +++ b/matsim/src/main/java/org/matsim/core/utils/gis/PolylineFeatureFactory.java @@ -23,15 +23,15 @@ import java.util.LinkedHashMap; import java.util.Map; +import org.geotools.api.feature.simple.SimpleFeature; +import org.geotools.api.feature.simple.SimpleFeatureType; +import org.geotools.api.referencing.crs.CoordinateReferenceSystem; import org.geotools.feature.simple.SimpleFeatureBuilder; import org.geotools.feature.simple.SimpleFeatureTypeBuilder; import org.locationtech.jts.geom.Coordinate; import org.locationtech.jts.geom.GeometryFactory; import org.locationtech.jts.geom.LineString; import org.locationtech.jts.geom.MultiLineString; -import org.opengis.feature.simple.SimpleFeature; -import org.opengis.feature.simple.SimpleFeatureType; -import org.opengis.referencing.crs.CoordinateReferenceSystem; /** * @author mrieser / senozon diff --git a/matsim/src/main/java/org/matsim/core/utils/gis/ShapeFileReader.java b/matsim/src/main/java/org/matsim/core/utils/gis/ShapeFileReader.java index d3ddd7a6c8c..26defd23bbe 100644 --- a/matsim/src/main/java/org/matsim/core/utils/gis/ShapeFileReader.java +++ b/matsim/src/main/java/org/matsim/core/utils/gis/ShapeFileReader.java @@ -20,16 +20,15 @@ package org.matsim.core.utils.gis; -import org.geotools.data.DataStore; -import org.geotools.data.FileDataStore; +import org.geotools.api.data.DataStore; +import org.geotools.api.data.FileDataStore; +import org.geotools.api.data.SimpleFeatureSource; +import org.geotools.api.feature.simple.SimpleFeature; +import org.geotools.api.feature.simple.SimpleFeatureType; +import org.geotools.api.referencing.crs.CoordinateReferenceSystem; import org.geotools.data.simple.SimpleFeatureCollection; -import org.geotools.data.simple.SimpleFeatureSource; import org.geotools.geometry.jts.ReferencedEnvelope; import org.matsim.core.api.internal.MatsimSomeReader; -import org.opengis.feature.Feature; -import org.opengis.feature.simple.SimpleFeature; -import org.opengis.feature.simple.SimpleFeatureType; -import org.opengis.referencing.crs.CoordinateReferenceSystem; import java.io.IOException; import java.io.UncheckedIOException; diff --git a/matsim/src/main/java/org/matsim/core/utils/gis/ShapeFileWriter.java b/matsim/src/main/java/org/matsim/core/utils/gis/ShapeFileWriter.java index c0ea83390e9..b789ee0bb10 100644 --- a/matsim/src/main/java/org/matsim/core/utils/gis/ShapeFileWriter.java +++ b/matsim/src/main/java/org/matsim/core/utils/gis/ShapeFileWriter.java @@ -20,10 +20,11 @@ package org.matsim.core.utils.gis; +import org.geotools.api.feature.simple.SimpleFeature; import org.matsim.core.api.internal.MatsimSomeWriter; -import org.opengis.feature.simple.SimpleFeature; import java.util.Collection; + /** * This is a simple utility class that provides methods to write Feature instances * of the geotools framework to an ESRI shape file. diff --git a/matsim/src/main/java/org/matsim/utils/gis/matsim2esri/network/FeatureGenerator.java b/matsim/src/main/java/org/matsim/utils/gis/matsim2esri/network/FeatureGenerator.java index 0b2a180eb58..5f06d853f38 100755 --- a/matsim/src/main/java/org/matsim/utils/gis/matsim2esri/network/FeatureGenerator.java +++ b/matsim/src/main/java/org/matsim/utils/gis/matsim2esri/network/FeatureGenerator.java @@ -20,8 +20,8 @@ package org.matsim.utils.gis.matsim2esri.network; +import org.geotools.api.feature.simple.SimpleFeature; import org.matsim.api.core.v01.network.Link; -import org.opengis.feature.simple.SimpleFeature; public interface FeatureGenerator { diff --git a/matsim/src/main/java/org/matsim/utils/gis/matsim2esri/network/FeatureGeneratorBuilderImpl.java b/matsim/src/main/java/org/matsim/utils/gis/matsim2esri/network/FeatureGeneratorBuilderImpl.java index 89351a8efb9..dc1f174ee04 100755 --- a/matsim/src/main/java/org/matsim/utils/gis/matsim2esri/network/FeatureGeneratorBuilderImpl.java +++ b/matsim/src/main/java/org/matsim/utils/gis/matsim2esri/network/FeatureGeneratorBuilderImpl.java @@ -23,9 +23,9 @@ import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; +import org.geotools.api.referencing.crs.CoordinateReferenceSystem; import org.matsim.api.core.v01.network.Network; import org.matsim.core.utils.geometry.geotools.MGC; -import org.opengis.referencing.crs.CoordinateReferenceSystem; /** * Design thoughts:
    diff --git a/matsim/src/main/java/org/matsim/utils/gis/matsim2esri/network/LineStringBasedFeatureGenerator.java b/matsim/src/main/java/org/matsim/utils/gis/matsim2esri/network/LineStringBasedFeatureGenerator.java index e1a58a113a9..155ff94ff71 100755 --- a/matsim/src/main/java/org/matsim/utils/gis/matsim2esri/network/LineStringBasedFeatureGenerator.java +++ b/matsim/src/main/java/org/matsim/utils/gis/matsim2esri/network/LineStringBasedFeatureGenerator.java @@ -20,6 +20,8 @@ package org.matsim.utils.gis.matsim2esri.network; +import org.geotools.api.feature.simple.SimpleFeature; +import org.geotools.api.referencing.crs.CoordinateReferenceSystem; import org.geotools.feature.simple.SimpleFeatureBuilder; import org.geotools.feature.simple.SimpleFeatureTypeBuilder; import org.locationtech.jts.geom.Coordinate; @@ -28,8 +30,6 @@ import org.matsim.api.core.v01.network.Link; import org.matsim.core.network.NetworkUtils; import org.matsim.core.utils.geometry.geotools.MGC; -import org.opengis.feature.simple.SimpleFeature; -import org.opengis.referencing.crs.CoordinateReferenceSystem; public class LineStringBasedFeatureGenerator implements FeatureGenerator{ diff --git a/matsim/src/main/java/org/matsim/utils/gis/matsim2esri/network/Links2ESRIShape.java b/matsim/src/main/java/org/matsim/utils/gis/matsim2esri/network/Links2ESRIShape.java index d8c8d452eb4..26fc4d30886 100755 --- a/matsim/src/main/java/org/matsim/utils/gis/matsim2esri/network/Links2ESRIShape.java +++ b/matsim/src/main/java/org/matsim/utils/gis/matsim2esri/network/Links2ESRIShape.java @@ -25,6 +25,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.geotools.api.feature.simple.SimpleFeature; +import org.geotools.api.referencing.crs.CoordinateReferenceSystem; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; @@ -34,8 +36,6 @@ import org.matsim.core.scenario.ScenarioUtils; import org.matsim.core.utils.geometry.geotools.MGC; import org.matsim.core.utils.gis.GeoFileWriter; -import org.opengis.feature.simple.SimpleFeature; -import org.opengis.referencing.crs.CoordinateReferenceSystem; /** * Simple class to convert the links of MATSim network files to ESRI shape files. The network can be written either diff --git a/matsim/src/main/java/org/matsim/utils/gis/matsim2esri/network/Nodes2ESRIShape.java b/matsim/src/main/java/org/matsim/utils/gis/matsim2esri/network/Nodes2ESRIShape.java index 003c08d7a34..ce7b66a6ce2 100644 --- a/matsim/src/main/java/org/matsim/utils/gis/matsim2esri/network/Nodes2ESRIShape.java +++ b/matsim/src/main/java/org/matsim/utils/gis/matsim2esri/network/Nodes2ESRIShape.java @@ -24,6 +24,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.geotools.api.feature.simple.SimpleFeature; +import org.geotools.api.referencing.crs.CoordinateReferenceSystem; import org.geotools.feature.simple.SimpleFeatureBuilder; import org.geotools.feature.simple.SimpleFeatureTypeBuilder; import org.locationtech.jts.geom.Point; @@ -36,8 +38,6 @@ import org.matsim.core.scenario.ScenarioUtils; import org.matsim.core.utils.geometry.geotools.MGC; import org.matsim.core.utils.gis.GeoFileWriter; -import org.opengis.feature.simple.SimpleFeature; -import org.opengis.referencing.crs.CoordinateReferenceSystem; /** * Simple class to convert the nodess of MATSim network files to ESRI shape files. The nodes could be written points diff --git a/matsim/src/main/java/org/matsim/utils/gis/matsim2esri/network/PolygonFeatureGenerator.java b/matsim/src/main/java/org/matsim/utils/gis/matsim2esri/network/PolygonFeatureGenerator.java index b4894e5b594..9a6563d8722 100755 --- a/matsim/src/main/java/org/matsim/utils/gis/matsim2esri/network/PolygonFeatureGenerator.java +++ b/matsim/src/main/java/org/matsim/utils/gis/matsim2esri/network/PolygonFeatureGenerator.java @@ -20,6 +20,8 @@ package org.matsim.utils.gis.matsim2esri.network; +import org.geotools.api.feature.simple.SimpleFeature; +import org.geotools.api.referencing.crs.CoordinateReferenceSystem; import org.geotools.feature.simple.SimpleFeatureBuilder; import org.geotools.feature.simple.SimpleFeatureTypeBuilder; import org.locationtech.jts.geom.Coordinate; @@ -27,8 +29,6 @@ import org.locationtech.jts.geom.Polygon; import org.matsim.api.core.v01.network.Link; import org.matsim.core.utils.geometry.geotools.MGC; -import org.opengis.feature.simple.SimpleFeature; -import org.opengis.referencing.crs.CoordinateReferenceSystem; public class PolygonFeatureGenerator implements FeatureGenerator{ diff --git a/matsim/src/main/java/org/matsim/utils/gis/matsim2esri/plans/SelectedPlans2ESRIShape.java b/matsim/src/main/java/org/matsim/utils/gis/matsim2esri/plans/SelectedPlans2ESRIShape.java index f40dc653e51..1420943145e 100755 --- a/matsim/src/main/java/org/matsim/utils/gis/matsim2esri/plans/SelectedPlans2ESRIShape.java +++ b/matsim/src/main/java/org/matsim/utils/gis/matsim2esri/plans/SelectedPlans2ESRIShape.java @@ -25,6 +25,8 @@ import java.util.ArrayList; import java.util.List; +import org.geotools.api.feature.simple.SimpleFeature; +import org.geotools.api.referencing.crs.CoordinateReferenceSystem; import org.geotools.feature.simple.SimpleFeatureBuilder; import org.geotools.feature.simple.SimpleFeatureTypeBuilder; import org.locationtech.jts.geom.Coordinate; @@ -52,8 +54,6 @@ import org.matsim.core.scenario.ScenarioUtils; import org.matsim.core.utils.geometry.geotools.MGC; import org.matsim.core.utils.gis.GeoFileWriter; -import org.opengis.feature.simple.SimpleFeature; -import org.opengis.referencing.crs.CoordinateReferenceSystem; /** * Simple class to convert MATSim plans to ESRI shape files. Activities will be converted into points and diff --git a/matsim/src/test/java/org/matsim/core/router/AbstractLeastCostPathCalculatorTest.java b/matsim/src/test/java/org/matsim/core/router/AbstractLeastCostPathCalculatorTest.java index 0bb049ca193..2c59cad79d6 100644 --- a/matsim/src/test/java/org/matsim/core/router/AbstractLeastCostPathCalculatorTest.java +++ b/matsim/src/test/java/org/matsim/core/router/AbstractLeastCostPathCalculatorTest.java @@ -24,11 +24,13 @@ import javax.xml.parsers.ParserConfigurationException; +import org.apache.logging.log4j.LogManager; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; +import org.matsim.api.core.v01.Identifiable; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; @@ -92,4 +94,31 @@ void testCalcLeastCostPath_SameFromTo() throws SAXException, ParserConfiguration assertEquals(network.getNodes().get(Id.create("12", Node.class)), path.nodes.get(0)); } + @Test + void testCalcLeastCostPath_withOptions() throws SAXException, ParserConfigurationException, IOException { + Config config = utils.loadConfig((String)null); + Scenario scenario = ScenarioUtils.createScenario(config); + Network network = scenario.getNetwork(); + new MatsimNetworkReader(scenario.getNetwork()).readFile("test/scenarios/equil/network.xml"); + + //path from 1 to 13 has several options with the same travel time + Node node1 = network.getNodes().get(Id.create("1", Node.class)); + Node node13 = network.getNodes().get(Id.create("13", Node.class)); + + LeastCostPathCalculator routerAlgo = getLeastCostPathCalculator(network); + Path path = routerAlgo.calcLeastCostPath(node1, node13, 8.0*3600, null, null); + + assertEquals(5, path.nodes.size(), "number of nodes wrong."); + assertEquals(4, path.links.size(), "number of links wrong."); + assertEquals(network.getNodes().get(Id.create("1", Node.class)), path.nodes.get(0)); + assertEquals(network.getNodes().get(Id.create("2", Node.class)), path.nodes.get(1)); + assertEquals(network.getNodes().get(Id.create("3", Node.class)), path.nodes.get(2)); + assertEquals(network.getNodes().get(Id.create("12", Node.class)), path.nodes.get(3)); + assertEquals(network.getNodes().get(Id.create("13", Node.class)), path.nodes.get(4)); + assertEquals(network.getLinks().get(Id.create("1", Link.class)), path.links.get(0)); + assertEquals(network.getLinks().get(Id.create("2", Link.class)), path.links.get(1)); + assertEquals(network.getLinks().get(Id.create("11", Link.class)), path.links.get(2)); + assertEquals(network.getLinks().get(Id.create("20", Link.class)), path.links.get(3)); + } + } diff --git a/matsim/src/test/java/org/matsim/core/utils/gis/GeoFileReaderTest.java b/matsim/src/test/java/org/matsim/core/utils/gis/GeoFileReaderTest.java index d74ae57c395..b2c368ff6a3 100644 --- a/matsim/src/test/java/org/matsim/core/utils/gis/GeoFileReaderTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/gis/GeoFileReaderTest.java @@ -23,7 +23,7 @@ import java.io.IOException; -import org.geotools.data.FeatureSource; +import org.geotools.api.data.FeatureSource; import org.geotools.feature.NameImpl; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; diff --git a/matsim/src/test/java/org/matsim/core/utils/gis/GeoFileWriterTest.java b/matsim/src/test/java/org/matsim/core/utils/gis/GeoFileWriterTest.java index 3c4d1de3994..30d0f116dd1 100644 --- a/matsim/src/test/java/org/matsim/core/utils/gis/GeoFileWriterTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/gis/GeoFileWriterTest.java @@ -26,9 +26,11 @@ import java.util.Collection; import java.util.List; +import org.geotools.api.data.SimpleFeatureSource; +import org.geotools.api.feature.simple.SimpleFeature; +import org.geotools.api.feature.simple.SimpleFeatureType; import org.geotools.data.simple.SimpleFeatureCollection; import org.geotools.data.simple.SimpleFeatureIterator; -import org.geotools.data.simple.SimpleFeatureSource; import org.geotools.feature.NameImpl; import org.geotools.feature.simple.SimpleFeatureBuilder; import org.geotools.feature.simple.SimpleFeatureTypeBuilder; @@ -43,8 +45,6 @@ import org.locationtech.jts.geom.MultiPolygon; import org.locationtech.jts.geom.Polygon; import org.matsim.testcases.MatsimTestUtils; -import org.opengis.feature.simple.SimpleFeature; -import org.opengis.feature.simple.SimpleFeatureType; public class GeoFileWriterTest { diff --git a/matsim/src/test/java/org/matsim/utils/gis/matsim2esri/network/Network2ESRIShapeTest.java b/matsim/src/test/java/org/matsim/utils/gis/matsim2esri/network/Network2ESRIShapeTest.java index ad21f1e38cd..c1e4fe470bb 100755 --- a/matsim/src/test/java/org/matsim/utils/gis/matsim2esri/network/Network2ESRIShapeTest.java +++ b/matsim/src/test/java/org/matsim/utils/gis/matsim2esri/network/Network2ESRIShapeTest.java @@ -22,6 +22,8 @@ import java.util.Collection; +import org.geotools.api.feature.simple.SimpleFeature; +import org.geotools.api.referencing.crs.CoordinateReferenceSystem; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; @@ -33,8 +35,6 @@ import org.matsim.core.utils.geometry.geotools.MGC; import org.matsim.core.utils.gis.GeoFileReader; import org.matsim.testcases.MatsimTestUtils; -import org.opengis.feature.simple.SimpleFeature; -import org.opengis.referencing.crs.CoordinateReferenceSystem; public class Network2ESRIShapeTest { diff --git a/matsim/src/test/java/org/matsim/utils/gis/matsim2esri/plans/SelectedPlans2ESRIShapeTest.java b/matsim/src/test/java/org/matsim/utils/gis/matsim2esri/plans/SelectedPlans2ESRIShapeTest.java index c619704622b..25046023c6d 100755 --- a/matsim/src/test/java/org/matsim/utils/gis/matsim2esri/plans/SelectedPlans2ESRIShapeTest.java +++ b/matsim/src/test/java/org/matsim/utils/gis/matsim2esri/plans/SelectedPlans2ESRIShapeTest.java @@ -24,6 +24,8 @@ import java.util.Collection; import java.util.zip.GZIPInputStream; +import org.geotools.api.feature.simple.SimpleFeature; +import org.geotools.api.referencing.crs.CoordinateReferenceSystem; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; @@ -36,8 +38,6 @@ import org.matsim.core.utils.geometry.geotools.MGC; import org.matsim.core.utils.gis.GeoFileReader; import org.matsim.testcases.MatsimTestUtils; -import org.opengis.feature.simple.SimpleFeature; -import org.opengis.referencing.crs.CoordinateReferenceSystem; public class SelectedPlans2ESRIShapeTest { diff --git a/pom.xml b/pom.xml index e2a0c1c1c6f..f81cb43ab6d 100644 --- a/pom.xml +++ b/pom.xml @@ -31,7 +31,7 @@ 2.23.1 - 29.5 + 31.0 0.49.2 1.19.0 7.0.0 @@ -118,7 +118,7 @@ org.apache.commons commons-compress - 1.26.1 + 1.26.2 commons-logging @@ -316,13 +316,13 @@ org.mockito mockito-core - 5.11.0 + 5.12.0 test org.mockito mockito-junit-jupiter - 5.11.0 + 5.12.0 test @@ -353,7 +353,7 @@ net.bytebuddy byte-buddy - 1.14.14 + 1.14.16 test