Skip to content

Commit

Permalink
Merge pull request #1118 from matsim-org/updateLatestMatsim
Browse files Browse the repository at this point in the history
Update latest matsim
  • Loading branch information
nkuehnel authored May 17, 2024
2 parents 78e95b8 + ef25586 commit 5d3f52f
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 41 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
Therefore we need to use a fixed value here and then refer to the matsim version with ${project.parent.version} -->
<!-- Options: stable build based on weekly (e.g. 15.0-PR2344), PR-based (e.g. 15.0-2023w01) or official (e.g. 14.0) releases -->
<!-- <version>16.0-2024w02</version>-->
<version>2025.0-PR3235</version>
<version>2025.0-PR3272</version>
<!--<version>15.0-SNAPSHOT</version>-->
<!-- <version>16.0-SNAPSHOT</version>-->
<relativePath/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,16 @@
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;
import org.matsim.contrib.drt.prebooking.PrebookingParams;
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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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{
Expand Down Expand Up @@ -71,17 +63,18 @@ 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);
{
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() );
Expand All @@ -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() );
Expand All @@ -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() );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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().
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@
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;
import org.matsim.api.core.v01.TransportMode;
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;
Expand Down Expand Up @@ -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<Pair<Geometry, Double>> 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()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -161,7 +162,7 @@ public Map<String,Geometry> readShapeFile(String filename, String attrString){

Map<String,Geometry> shapeMap = new HashMap<String, Geometry>();

for (SimpleFeature ft : ShapeFileReader.getAllFeatures(filename)) {
for (SimpleFeature ft : GeoFileReader.getAllFeatures(filename)) {

GeometryFactory geometryFactory= new GeometryFactory();
WKTReader wktReader = new WKTReader(geometryFactory);
Expand Down

0 comments on commit 5d3f52f

Please sign in to comment.