diff --git a/pom.xml b/pom.xml index ff434596..bf77d693 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ Therefore we need to use a fixed value here and then refer to the matsim version with ${project.parent.version} --> - 2025.0-PR3235 + 2025.0-PR3272 diff --git a/src/main/java/org/matsim/codeexamples/extensions/drt/RunMelunPrebooking.java b/src/main/java/org/matsim/codeexamples/extensions/drt/RunMelunPrebooking.java index 2cdeb01c..7be7dbe6 100644 --- a/src/main/java/org/matsim/codeexamples/extensions/drt/RunMelunPrebooking.java +++ b/src/main/java/org/matsim/codeexamples/extensions/drt/RunMelunPrebooking.java @@ -14,6 +14,7 @@ import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.population.Person; +import org.matsim.contrib.common.zones.systems.grid.square.SquareGridZoneSystemParams; import org.matsim.contrib.drt.extension.insertion.DrtInsertionModule; import org.matsim.contrib.drt.optimizer.insertion.DrtInsertionSearchParams; import org.matsim.contrib.drt.optimizer.insertion.extensive.ExtensiveInsertionSearchParams; @@ -21,11 +22,8 @@ import org.matsim.contrib.drt.prebooking.logic.ProbabilityBasedPrebookingLogic; import org.matsim.contrib.drt.routing.DrtRoute; import org.matsim.contrib.drt.routing.DrtRouteFactory; -import org.matsim.contrib.drt.run.DrtConfigGroup; +import org.matsim.contrib.drt.run.*; import org.matsim.contrib.drt.run.DrtConfigGroup.OperationalScheme; -import org.matsim.contrib.drt.run.DrtConfigs; -import org.matsim.contrib.drt.run.MultiModeDrtConfigGroup; -import org.matsim.contrib.drt.run.MultiModeDrtModule; import org.matsim.contrib.dvrp.fleet.DvrpVehicle; import org.matsim.contrib.dvrp.fleet.FleetSpecification; import org.matsim.contrib.dvrp.fleet.FleetSpecificationImpl; @@ -81,7 +79,9 @@ public static class RunSettings { public static void runSingle(File populationPath, File networkPath, File outputPath, RunSettings settings) { // configuration - Config config = ConfigUtils.createConfig(new MultiModeDrtConfigGroup(), new DvrpConfigGroup()); + DvrpConfigGroup dvrpConfigGroup = new DvrpConfigGroup(); + dvrpConfigGroup.getTravelTimeMatrixParams().addParameterSet(new SquareGridZoneSystemParams()); + Config config = ConfigUtils.createConfig(new MultiModeDrtConfigGroup(), dvrpConfigGroup); config.qsim().setSimStarttimeInterpretation(StarttimeInterpretation.onlyUseStarttime); config.qsim().setStartTime(0.0); @@ -117,9 +117,10 @@ public static void runSingle(File populationPath, File networkPath, File outputP drtConfig.mode = "drt"; drtConfig.operationalScheme = OperationalScheme.door2door; drtConfig.stopDuration = 60.0; - drtConfig.maxWaitTime = settings.maxWaitTime; - drtConfig.maxTravelTimeAlpha = settings.maxTravelTimeAlpha; - drtConfig.maxTravelTimeBeta = settings.maxWaitTime; + DrtOptimizationConstraintsParams constraintsParam = drtConfig.getDrtOptimizationConstraintsParam(); + constraintsParam.maxWaitTime = settings.maxWaitTime; + constraintsParam.maxTravelTimeAlpha = settings.maxTravelTimeAlpha; + constraintsParam.maxTravelTimeBeta = settings.maxWaitTime; DrtInsertionSearchParams insertionSearchParams = new ExtensiveInsertionSearchParams(); drtConfig.addDrtInsertionSearchParams(insertionSearchParams); diff --git a/src/main/java/org/matsim/codeexamples/extensions/dvrp/RunDrtExample.java b/src/main/java/org/matsim/codeexamples/extensions/dvrp/RunDrtExample.java index 37607a7e..87c4272b 100644 --- a/src/main/java/org/matsim/codeexamples/extensions/dvrp/RunDrtExample.java +++ b/src/main/java/org/matsim/codeexamples/extensions/dvrp/RunDrtExample.java @@ -1,37 +1,29 @@ package org.matsim.codeexamples.extensions.dvrp; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.TransportMode; -import org.matsim.api.core.v01.events.Event; +import org.matsim.contrib.common.zones.systems.grid.square.SquareGridZoneSystemParams; import org.matsim.contrib.drt.optimizer.insertion.extensive.ExtensiveInsertionSearchParams; import org.matsim.contrib.drt.routing.DrtRoute; import org.matsim.contrib.drt.routing.DrtRouteFactory; -import org.matsim.contrib.drt.run.DrtConfigGroup; -import org.matsim.contrib.drt.run.DrtConfigs; -import org.matsim.contrib.drt.run.MultiModeDrtConfigGroup; -import org.matsim.contrib.drt.run.MultiModeDrtModule; +import org.matsim.contrib.drt.run.*; import org.matsim.contrib.dvrp.run.DvrpConfigGroup; import org.matsim.contrib.dvrp.run.DvrpModule; import org.matsim.contrib.dvrp.run.DvrpQSimComponents; import org.matsim.contrib.otfvis.OTFVisLiveModule; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.ScoringConfigGroup.ModeParams; import org.matsim.core.config.groups.QSimConfigGroup; import org.matsim.core.config.groups.QSimConfigGroup.SnapshotStyle; import org.matsim.core.config.groups.ReplanningConfigGroup.StrategySettings; -import org.matsim.core.controler.AbstractModule; +import org.matsim.core.config.groups.ScoringConfigGroup.ModeParams; import org.matsim.core.controler.Controler; import org.matsim.core.controler.OutputDirectoryHierarchy.OverwriteFileSetting; -import org.matsim.core.events.handler.BasicEventHandler; -import org.matsim.core.events.handler.EventHandler; import org.matsim.core.replanning.strategies.DefaultPlanStrategiesModule.DefaultSelector; import org.matsim.core.replanning.strategies.DefaultPlanStrategiesModule.DefaultStrategy; import org.matsim.core.scenario.ScenarioUtils; -import org.matsim.core.utils.io.IOUtils; -import org.matsim.examples.ExamplesUtils; import org.matsim.vis.otfvis.OTFVisConfigGroup; class RunDrtExample{ @@ -71,6 +63,7 @@ public static void run(boolean otfvis, String... args ){ @SuppressWarnings("unused") DvrpConfigGroup dvrpConfig = ConfigUtils.addOrGetModule( config, DvrpConfigGroup.class ); + dvrpConfig.getTravelTimeMatrixParams().addParameterSet(new SquareGridZoneSystemParams()); // (config group needs to be "materialized") MultiModeDrtConfigGroup multiModeDrtCfg = ConfigUtils.addOrGetModule(config, MultiModeDrtConfigGroup.class); @@ -78,10 +71,10 @@ public static void run(boolean otfvis, String... args ){ 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 ; + drtConfig.getDrtOptimizationConstraintsParam().maxWaitTime=900; + drtConfig.getDrtOptimizationConstraintsParam().maxTravelTimeAlpha = 1.3; + drtConfig.getDrtOptimizationConstraintsParam().maxTravelTimeBeta=10. * 60.; + drtConfig.getDrtOptimizationConstraintsParam().rejectRequestIfMaxWaitOrTravelTimeViolated= false ; drtConfig.vehiclesFile="one_shared_taxi_vehicles_A.xml"; drtConfig.changeStartLinkToLastLinkInSchedule=true; drtConfig.addParameterSet( new ExtensiveInsertionSearchParams() ); @@ -91,10 +84,10 @@ public static void run(boolean otfvis, String... args ){ DrtConfigGroup drtConfig = new DrtConfigGroup(); drtConfig.mode = DRT_B; drtConfig.stopDuration = 60.; - drtConfig.maxWaitTime=900; - drtConfig.maxTravelTimeAlpha = 1.3; - drtConfig.maxTravelTimeBeta=10. * 60.; - drtConfig.rejectRequestIfMaxWaitOrTravelTimeViolated= false ; + drtConfig.getDrtOptimizationConstraintsParam().maxWaitTime=900; + drtConfig.getDrtOptimizationConstraintsParam().maxTravelTimeAlpha = 1.3; + drtConfig.getDrtOptimizationConstraintsParam().maxTravelTimeBeta=10. * 60.; + drtConfig.getDrtOptimizationConstraintsParam().rejectRequestIfMaxWaitOrTravelTimeViolated= false ; drtConfig.vehiclesFile="one_shared_taxi_vehicles_B.xml"; drtConfig.changeStartLinkToLastLinkInSchedule=true; drtConfig.addParameterSet( new ExtensiveInsertionSearchParams() ); @@ -104,10 +97,11 @@ public static void run(boolean otfvis, String... args ){ DrtConfigGroup drtConfig = new DrtConfigGroup(); drtConfig.mode = DRT_C; drtConfig.stopDuration = 60.; - drtConfig.maxWaitTime=900; - drtConfig.maxTravelTimeAlpha = 1.3; - drtConfig.maxTravelTimeBeta=10. * 60.; - drtConfig.rejectRequestIfMaxWaitOrTravelTimeViolated= false ; + DrtOptimizationConstraintsParams constraintsParam = drtConfig.getDrtOptimizationConstraintsParam(); + constraintsParam.maxWaitTime=900; + constraintsParam.maxTravelTimeAlpha = 1.3; + constraintsParam.maxTravelTimeBeta=10. * 60.; + constraintsParam.rejectRequestIfMaxWaitOrTravelTimeViolated= false ; drtConfig.vehiclesFile="one_shared_taxi_vehicles_C.xml"; drtConfig.changeStartLinkToLastLinkInSchedule=true; drtConfig.addParameterSet( new ExtensiveInsertionSearchParams() ); diff --git a/src/main/java/org/matsim/codeexamples/network/RunCreateNetworkSHP.java b/src/main/java/org/matsim/codeexamples/network/RunCreateNetworkSHP.java index 2d1ae2df..67524fae 100644 --- a/src/main/java/org/matsim/codeexamples/network/RunCreateNetworkSHP.java +++ b/src/main/java/org/matsim/codeexamples/network/RunCreateNetworkSHP.java @@ -19,6 +19,8 @@ package org.matsim.codeexamples.network; +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.Scenario; import org.matsim.api.core.v01.network.Link; @@ -29,11 +31,10 @@ import org.matsim.core.network.NetworkUtils; import org.matsim.core.scenario.ScenarioUtils; import org.matsim.core.utils.geometry.geotools.MGC; +import org.matsim.core.utils.gis.GeoFileWriter; import org.matsim.core.utils.gis.PointFeatureFactory; import org.matsim.core.utils.gis.PolylineFeatureFactory; import org.matsim.core.utils.gis.ShapeFileWriter; -import org.opengis.feature.simple.SimpleFeature; -import org.opengis.referencing.crs.CoordinateReferenceSystem; import java.util.ArrayList; import java.util.Collection; @@ -70,7 +71,7 @@ public static void main(String[] args) { new Object[]{link.getId().toString(), link.getFromNode().getId().toString(), link.getToNode().getId().toString(), link.getLength(), NetworkUtils.getType(link), link.getCapacity(), link.getFreespeed()}, null); features.add(ft); } - ShapeFileWriter.writeGeometries(features, "output/network_links.shp"); + GeoFileWriter.writeGeometries(features, "output/network_links.shp"); features = new ArrayList<>(); PointFeatureFactory nodeFactory = new PointFeatureFactory.Builder(). diff --git a/src/main/java/org/matsim/codeexamples/population/demandGenerationFromShapefile/CreateDemand.java b/src/main/java/org/matsim/codeexamples/population/demandGenerationFromShapefile/CreateDemand.java index e4e42702..270b6dcc 100644 --- a/src/main/java/org/matsim/codeexamples/population/demandGenerationFromShapefile/CreateDemand.java +++ b/src/main/java/org/matsim/codeexamples/population/demandGenerationFromShapefile/CreateDemand.java @@ -7,6 +7,7 @@ import org.apache.commons.math3.util.Pair; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.geotools.api.feature.simple.SimpleFeature; import org.locationtech.jts.geom.*; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -14,8 +15,8 @@ import org.matsim.api.core.v01.population.*; import org.matsim.core.config.ConfigUtils; import org.matsim.core.population.PopulationUtils; +import org.matsim.core.utils.gis.GeoFileReader; import org.matsim.core.utils.gis.ShapeFileReader; -import org.opengis.feature.simple.SimpleFeature; import java.io.IOException; import java.nio.charset.StandardCharsets; @@ -80,14 +81,14 @@ class CreateDemand { // read in the shape file and store the geometries according to their region identifier stored as 'RS' in the // shape file - regions = ShapeFileReader.getAllFeatures(sampleFolder.resolve("thueringen-kreise.shp").toString()).stream() + regions = GeoFileReader.getAllFeatures(sampleFolder.resolve("thueringen-kreise.shp").toString()).stream() .collect(Collectors.toMap(feature -> (String) feature.getAttribute("RS"), feature -> (Geometry) feature.getDefaultGeometry())); // Read in landcover data to make people stay in populated areas // we are using a weighted distribution by area-size, so that small areas receive less inhabitants than more // populated ones. List> weightedGeometries = new ArrayList<>(); - for (SimpleFeature feature : ShapeFileReader.getAllFeatures(sampleFolder.resolve("landcover.shp").toString())) { + for (SimpleFeature feature : GeoFileReader.getAllFeatures(sampleFolder.resolve("landcover.shp").toString())) { Geometry geometry = (Geometry) feature.getDefaultGeometry(); weightedGeometries.add(new Pair<>(geometry, geometry.getArea())); } diff --git a/src/main/java/org/matsim/codeexamples/programming/example21tutorialTUBclass/demand/CreateDemand.java b/src/main/java/org/matsim/codeexamples/programming/example21tutorialTUBclass/demand/CreateDemand.java index 103419f4..3d62ab85 100644 --- a/src/main/java/org/matsim/codeexamples/programming/example21tutorialTUBclass/demand/CreateDemand.java +++ b/src/main/java/org/matsim/codeexamples/programming/example21tutorialTUBclass/demand/CreateDemand.java @@ -22,6 +22,7 @@ import java.util.Map; import java.util.Random; +import org.geotools.api.feature.simple.SimpleFeature; import org.locationtech.jts.geom.Geometry; import org.locationtech.jts.geom.GeometryFactory; import org.locationtech.jts.geom.Point; @@ -43,11 +44,11 @@ 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.matsim.core.utils.gis.GeoFileReader; import org.matsim.core.utils.gis.ShapeFileReader; import org.matsim.core.utils.io.tabularFileParser.TabularFileHandler; import org.matsim.core.utils.io.tabularFileParser.TabularFileParser; import org.matsim.core.utils.io.tabularFileParser.TabularFileParserConfig; -import org.opengis.feature.simple.SimpleFeature; /** * @author jbischoff @@ -161,7 +162,7 @@ public Map readShapeFile(String filename, String attrString){ Map shapeMap = new HashMap(); - for (SimpleFeature ft : ShapeFileReader.getAllFeatures(filename)) { + for (SimpleFeature ft : GeoFileReader.getAllFeatures(filename)) { GeometryFactory geometryFactory= new GeometryFactory(); WKTReader wktReader = new WKTReader(geometryFactory);