Skip to content

Commit

Permalink
update MATSim, add drt config
Browse files Browse the repository at this point in the history
  • Loading branch information
rakow committed May 23, 2024
1 parent 008472f commit d496bf7
Show file tree
Hide file tree
Showing 18 changed files with 166 additions and 36 deletions.
127 changes: 127 additions & 0 deletions input/v6.2/berlin-v6.2.drt-config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE config SYSTEM "http://www.matsim.org/files/dtd/config_v2.dtd">
<config>

<module name="berlinExperimental" >
<param name="tagDrtLinksBufferAroundServiceAreaShp" value="5000.0" />
</module>

<module name="multiModeDrt">
<parameterset type="drt">
<parameterset type="ExtensiveInsertionSearch"/>
<!-- 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. -->
<param name="changeStartLinkToLastLinkInSchedule" value="true" />
<!-- allows to configure a service area per drt mode.Used with serviceArea Operational Scheme -->
<param name="drtServiceAreaShapeFile" value="https://svn.vsp.tu-berlin.de/repos/public-svn/matsim/scenarios/countries/de/berlin/berlin-v6.2/input/shp/Berlin_25832.shp" />
<!-- Idle vehicles return to the nearest of all start links. See: DvrpVehicle.getStartLink() -->
<param name="idleVehiclesReturnToDepots" value="false" />
<!-- Defines the slope of the maxTravelTime estimation function (optimisation constraint), i.e. maxTravelTimeAlpha * estimated_drt_travel_time + maxTravelTimeBeta. Alpha should not be smaller than 1. -->
<param name="maxTravelTimeAlpha" value="1.7" />
<!-- Defines the shift of the maxTravelTime estimation function (optimisation constraint), i.e. maxTravelTimeAlpha * estimated_drt_travel_time + maxTravelTimeBeta. Beta should not be smaller than 0. -->
<param name="maxTravelTimeBeta" value="120.0" />
<!-- Max wait time for the bus to come (optimisation constraint). -->
<param name="maxWaitTime" value="300.0" />
<!-- 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 a direct walk of type drtMode_walk. -->
<param name="maxWalkDistance" value="2000.0" />
<!-- Mode which will be handled by PassengerEngine and VrpOptimizer (passengers'/customers' perspective) -->
<param name="mode" value="drt" />
<!-- Number of threads used for parallel evaluation of request insertion into existing schedules. Scales well up to 4, due to path data provision, the most computationally intensive part, using up to 4 threads. Default value is 'min(4, no. of cores available to JVM)' -->
<param name="numberOfThreads" value="8" />
<!-- Operational Scheme, either of door2door, stopbased or serviceAreaBased. door2door by default -->
<param name="operationalScheme" value="serviceAreaBased" />
<!-- 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 -->
<param name="rejectRequestIfMaxWaitOrTravelTimeViolated" value="false" />
<!-- Bus stop duration. Must be positive. -->
<param name="stopDuration" value="60.0"/>
<!-- Stop locations file (transit schedule format, but without lines) for DRT stops. Used only for the stopbased mode -->
<param name="transitStopFile" value="null"/>
<!-- Limit the operation of vehicles to links (of the 'dvrp_routing' network) with 'allowedModes' containing this 'mode'. For backward compatibility, the value is set to false by default - this means that the vehicles are allowed to operate on all links of the 'dvrp_routing' network. The 'dvrp_routing' is defined by DvrpConfigGroup.networkModes) -->
<param name="useModeFilteredSubnetwork" value="true"/>
<!-- An XML file specifying the vehicle fleet. The file format according to dvrp_vehicles_v1.dtd -->
<param name="vehiclesFile"
value="https://svn.vsp.tu-berlin.de/repos/public-svn/matsim/scenarios/countries/de/berlin/berlin-v6.1/input/berlin-v6.1.drt-by-rndLocations-10000vehicles-4seats.xml.gz"/>
<!-- Writes out detailed DRT customer stats in each iteration. True by default. -->
<param name="writeDetailedCustomerStats" value="true"/>
<parameterset type="drtfare">
<!-- Basefare per Trip (fare = positive value) -->
<param name="basefare" value="0.0"/>
<!-- Minimum fare per trip (paid instead of the sum of base, time and distance fare if that sum would be lower than the minimum fare, fee = positive value). -->
<param name="minFarePerTrip" value="0.0"/>
<!-- Daily subscription fee (fee = positive value) -->
<param name="dailySubscriptionFee" value="0.0"/>
<!-- drt fare per meter (fee = positive value) -->
<param name="distanceFare_m" value="0.0"/>
<!-- drt fare per hour (fee = positive value) -->
<param name="timeFare_h" value="0.0"/>
</parameterset>
</parameterset>
</module>

<module name="dvrp">
<!-- Mode of which the network will be used for throwing events and hence calculating travel times. Default is car. -->
<param name="mobsimMode" value="car"/>
<!-- Set of modes of which the network will be used for DVRP travel time estimation and routing DVRP vehicles. Each specific DVRP mode may use a subnetwork of this network for routing vehicles (e.g. DRT buses travelling only along a specified links or serving a limited area). Default is "car" (i.e. single-element set of modes), i.e. the car network is used. Empty value "" (i.e. empty set of modes) means no network filtering, i.e. the original scenario.network is used -->
<param name="networkModes" value="drt"/>
<!-- Used for OFFLINE estimation of travel times for VrpOptimizer by means of the exponential moving average. The weighting decrease, alpha, must be in (0,1]. We suggest small values of alpha, e.g. 0.05. The averaging starts from the initial travel time estimates. If not provided, the free-speed TTs is used as the initial estimates -->
<param name="travelTimeEstimationAlpha" value="0.05"/>
<!-- Used for ONLINE estimation of travel times for VrpOptimizer by combining WithinDayTravelTime and DvrpOfflineTravelTimeEstimator. The beta coefficient is provided in seconds and should be either 0 (no online estimation) or positive (mixed online-offline estimation). For 'beta = 0', only the offline estimate is used: 'onlineTT(t) = offlineTT(t)', where 'offlineTT(t)' in the offline estimate for TT at time 't', For 'beta > 0', estimating future TTs at time 't', uses the currently observed TT to correct the offline estimates is made: where 'currentTT' is the currently observed TT, and 'correction = min(1, max(0, 1 - (time - currentTime) / beta))' The rule is that correction decreases linearly from 1 (when 'time = currentTime') to 0 (when 'time = currentTime + beta' For 'time > currentTime + beta' correction is 0, whereas if 'time < currentTime' it is 1. If beta is sufficiently large, 'beta >> 0', only the currently observed TT is used. -->
<param name="travelTimeEstimationBeta" value="0.0"/>
</module>

<module name="swissRailRaptor" >
<!-- KN comments: in principle, walk as alternative to drt will not work, since drt is always faster. Need to give the ASC to the router! However, with the reduced drt network we should be able to see differentiation.) -->

<!-- Possible values: CalcLeastCostModePerStop, RandomSelectOneModePerRoutingRequestAndDirection -->
<param name="intermodalAccessEgressModeSelection" value="CalcLeastCostModePerStop" />
<param name="useIntermodalAccessEgress" value="true" />
<parameterset type="intermodalAccessEgress" >
<!-- Radius from the origin / destination coord in which transit stops are searched. Only if less than 2 transit stops are found the search radius is increased step-wise until the maximum search radius set in param radius is reached. -->
<param name="initialSearchRadius" value="1500.0" />
<!-- If the mode is routed on the network, specify which linkId acts as access link to this stop in the transport modes sub-network. -->
<param name="linkIdAttribute" value="null" />
<!-- Radius from the origin / destination coord in which transit stops are accessible by this mode. -->
<param name="maxRadius" value="100000.0" />
<param name="mode" value="walk" />
<!-- If less than 2 stops were found in initialSearchRadius take the distance of the closest transit stop and add this extension radius to search again.The search radius will not exceed the maximum search radius set in param radius. -->
<param name="searchExtensionRadius" value="1000.0" />
<!-- Name of the transit stop attribute used to filter stops that should be included in the set of potential stops for access and egress. The attribute should be of type String. 'null' disables the filter and all stops within the specified radius will be used. -->
<param name="stopFilterAttribute" value="null" />
<!-- Only stops where the filter attribute has the value specified here will be considered as access or egress stops. -->
<param name="stopFilterValue" value="null" />
</parameterset>
<parameterset type="intermodalAccessEgress" >
<!-- If more than 1 transit stop is found in the initial search radius, the raptor stop finder will stop to search
* more distant transit stops.
* Setting setInitialSearchRadius(12000) will allow for crossing the whole Berlkoenig area with drt as
* access/egress mode to pt. This way we are on the safe side and do not exclude any theoretically possible
* drt ride.
* Unfortunately that means that for a route from Alexanderplatz to Friedrichstrasse the pt router basically has
* to route from all transit stops in the city center of Berlin to all transit stops in the city center of Berlin,
* because it has to consider all transit stops in that 12 km radius from Alexanderplatz and Friedrichstrasse,
* respectively. This slows down pt routing enormously.
* To speed up there are two options:
* - restrict the set of transit stops accessible by drt using a stop filter attribute, e.g. only RE+S+U-Bahn
* - reduce the initial search radius (and thereby effectively prohibit drt rides longer than that initial
* search radius for access/egress to pt, because there is always more than 1 transit stop in that radius).
*
* For 2528 agents and no stop filter attribute PlanRouter in iteration 1 took
* - ca. 1 min at InitialSearchRadius 3 km
* - but 53 min at InitialSearchRadius 12km
*
* So we have to make use of the speed up options (and exclude theoretically possible but unlikely drt trips).
* - gleich aug'19 -->
<param name="initialSearchRadius" value="3000.0" />
<param name="linkIdAttribute" value="null" />
<!-- Berlkoenig service area has a maximum diameter of ca. 11km, access trips over 12km don't make sense.
Prohibit them to save computation time.
(RandomAccessEgressModeRaptorStopFinder will try again with walk, the other available access/egress mode)
maybe we should restrict even further, see comment below for InitialSearchRadius. -->
<param name="maxRadius" value="12000.0" />
<param name="mode" value="drt" />
<param name="searchExtensionRadius" value="1000.0" />
<!-- take care that this still corresponds to the attribute used for tagging these TransitStops in RunDrtOpenBerlinScenario -->
<param name="stopFilterAttribute" value="drtStopFilter" />
<param name="stopFilterValue" value="station_S/U/RE/RB_drtServiceArea" />
</parameterset>
</module>
</config>
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
<artifactId>matsim-all</artifactId>

<!-- PR-labelled release -->
<version>2025.0-PR3257</version>
<!-- <version>2025.0-PR3268</version>-->

<!-- snapshot == not recommended: rather use PR-labelled release!-->
<!-- <version>2025.0-SNAPSHOT</version>-->
<version>2025.0-SNAPSHOT</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down Expand Up @@ -128,7 +128,7 @@
<dependency>
<groupId>com.github.matsim-org</groupId>
<artifactId>gtfs2matsim</artifactId>
<version>master-33809c4f0f-1</version>
<version>fc8b13954d</version>
<exclusions>
<exclusion>
<groupId>org.matsim</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.geotools.api.data.SimpleFeatureSource;
import org.geotools.data.simple.SimpleFeatureIterator;
import org.geotools.data.simple.SimpleFeatureSource;
import org.locationtech.jts.geom.Geometry;
import org.locationtech.jts.geom.Point;
import org.matsim.api.core.v01.Id;
Expand All @@ -46,7 +46,7 @@
import org.matsim.core.scenario.ScenarioUtils;
import org.matsim.core.utils.geometry.geotools.MGC;
import org.matsim.core.utils.gis.ShapeFileReader;
import org.opengis.feature.simple.SimpleFeature;
import org.geotools.api.feature.simple.SimpleFeature;

/**
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
import org.matsim.core.scenario.ScenarioUtils;
import org.matsim.core.utils.geometry.geotools.MGC;
import org.matsim.core.utils.gis.ShapeFileReader;
import org.opengis.feature.simple.SimpleFeature;
import org.geotools.api.feature.simple.SimpleFeature;

/**
* @author ikaddoura
Expand Down
12 changes: 7 additions & 5 deletions src/main/java/org/matsim/legacy/run/drt/BerlinShpUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,23 @@
import java.util.Map;
import java.util.Random;

import org.geotools.data.FileDataStore;
import org.geotools.data.FileDataStoreFinder;

import org.geotools.api.data.FileDataStore;
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.Geometry;
import org.locationtech.jts.geom.Point;
import org.matsim.api.core.v01.Coord;
import org.matsim.core.utils.geometry.geotools.MGC;
import org.matsim.core.utils.gis.ShapeFileReader;
import org.opengis.feature.simple.SimpleFeature;

/**
* @author ikaddoura
* @deprecated Since class has not been tested since geotools API changes.
*/

@Deprecated
public final class BerlinShpUtils {

private Map<Integer, Geometry> serviceAreaGeometries;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
import org.matsim.freight.carriers.jsprit.NetworkBasedTransportCosts;
import org.matsim.freight.carriers.jsprit.NetworkRouter;
import org.matsim.vehicles.VehicleType;
import org.opengis.feature.simple.SimpleFeature;
import org.geotools.api.feature.simple.SimpleFeature;

import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import org.matsim.core.scenario.ScenarioUtils;
import org.matsim.core.utils.gis.ShapeFileReader;
import org.matsim.freight.carriers.*;
import org.opengis.feature.simple.SimpleFeature;
import org.geotools.api.feature.simple.SimpleFeature;

/**
* @author Ricardo Ewert MA: Modellierung und Simulation der staedtischen
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/matsim/prepare/choices/PlanBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import org.matsim.vehicles.Vehicle;
import org.matsim.vehicles.VehicleType;
import org.matsim.vehicles.VehicleUtils;
import org.opengis.feature.simple.SimpleFeature;
import org.geotools.api.feature.simple.SimpleFeature;
import tech.tablesaw.api.Row;
import tech.tablesaw.api.Table;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
import org.apache.commons.csv.CSVPrinter;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.geotools.api.referencing.FactoryException;
import org.geotools.api.referencing.operation.MathTransform;
import org.geotools.api.referencing.operation.TransformException;
import org.geotools.geometry.jts.JTS;
import org.geotools.geometry.jts.JTSFactoryFinder;
import org.geotools.referencing.CRS;
Expand All @@ -26,10 +29,7 @@
import org.matsim.core.network.filter.NetworkFilterManager;
import org.matsim.core.utils.geometry.geotools.MGC;
import org.matsim.run.OpenBerlinScenario;
import org.opengis.feature.simple.SimpleFeature;
import org.opengis.referencing.FactoryException;
import org.opengis.referencing.operation.MathTransform;
import org.opengis.referencing.operation.TransformException;
import org.geotools.api.feature.simple.SimpleFeature;
import picocli.CommandLine;

import java.io.IOException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.geotools.api.referencing.operation.TransformException;
import org.geotools.referencing.operation.transform.IdentityTransform;
import org.locationtech.jts.geom.Coordinate;
import org.locationtech.jts.geom.Geometry;
Expand All @@ -27,7 +28,6 @@
import org.matsim.counts.Count;
import org.matsim.counts.Counts;
import org.matsim.counts.CountsWriter;
import org.opengis.referencing.operation.TransformException;
import picocli.CommandLine;
import tech.tablesaw.api.DateColumn;
import tech.tablesaw.api.DoubleColumn;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.geotools.api.referencing.operation.TransformException;
import org.geotools.referencing.operation.transform.IdentityTransform;
import org.matsim.api.core.v01.Coord;
import org.matsim.api.core.v01.Id;
Expand All @@ -26,7 +27,6 @@
import org.matsim.counts.CountsWriter;
import org.matsim.counts.Measurable;
import org.matsim.counts.MeasurementLocation;
import org.opengis.referencing.operation.TransformException;
import picocli.CommandLine;

import java.io.IOException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import org.matsim.core.utils.geometry.geotools.MGC;
import org.matsim.facilities.*;
import org.matsim.prepare.population.Attributes;
import org.opengis.feature.simple.SimpleFeature;
import org.geotools.api.feature.simple.SimpleFeature;
import picocli.CommandLine;

import java.nio.file.Path;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,16 @@
import org.apache.commons.csv.CSVPrinter;
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.api.data.DataStore;
import org.geotools.api.data.DataStoreFinder;
import org.geotools.api.data.SimpleFeatureStore;
import org.geotools.api.data.Transaction;
import org.geotools.api.feature.simple.SimpleFeature;
import org.geotools.api.referencing.crs.CRSAuthorityFactory;
import org.geotools.api.referencing.operation.MathTransform;
import org.geotools.api.referencing.operation.TransformException;
import org.geotools.data.DefaultTransaction;
import org.geotools.data.Transaction;
import org.geotools.data.collection.ListFeatureCollection;
import org.geotools.data.simple.SimpleFeatureStore;
import org.geotools.geometry.jts.JTS;
import org.geotools.geopkg.GeoPkgDataStoreFactory;
import org.geotools.jdbc.JDBCDataStoreFactory;
Expand All @@ -36,10 +40,7 @@
import org.matsim.application.options.CrsOptions;
import org.matsim.core.utils.io.IOUtils;
import org.matsim.run.OpenBerlinScenario;
import org.opengis.feature.simple.SimpleFeature;
import org.opengis.referencing.crs.CRSAuthorityFactory;
import org.opengis.referencing.operation.MathTransform;
import org.opengis.referencing.operation.TransformException;
import org.matsim.utils.gis.shp2matsim.ShpGeometryUtils;
import picocli.CommandLine;

import java.io.IOException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
import it.unimi.dsi.fastutil.objects.Object2IntMap;
import org.geotools.api.feature.simple.SimpleFeature;
import org.geotools.api.feature.simple.SimpleFeatureType;
import org.geotools.api.referencing.FactoryException;
import org.geotools.feature.simple.SimpleFeatureBuilder;
import org.geotools.feature.simple.SimpleFeatureTypeBuilder;
import org.geotools.referencing.CRS;
import org.locationtech.jts.geom.Geometry;
import org.locationtech.jts.geom.MultiPolygon;
import org.locationtech.jts.geom.TopologyException;
import org.locationtech.jts.index.strtree.STRtree;
import org.opengis.feature.simple.SimpleFeature;
import org.opengis.feature.simple.SimpleFeatureType;
import org.opengis.referencing.FactoryException;

import java.math.BigDecimal;
import java.math.RoundingMode;
Expand Down
Loading

0 comments on commit d496bf7

Please sign in to comment.