Skip to content

Commit

Permalink
Merge branch 'master' into kmt_configWarning
Browse files Browse the repository at this point in the history
  • Loading branch information
kt86 authored Dec 16, 2024
2 parents 8f6477f + d63bd25 commit 98081de
Show file tree
Hide file tree
Showing 422 changed files with 4,779 additions and 4,472 deletions.
6 changes: 3 additions & 3 deletions contribs/accessibility/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@
<dependency>
<groupId>org.matsim.contrib</groupId>
<artifactId>matrixbasedptrouter</artifactId>
<version>2025.0-SNAPSHOT</version>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>org.matsim.contrib</groupId>
<artifactId>roadpricing</artifactId>
<version>2025.0-SNAPSHOT</version>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>net.sf.trove4j</groupId>
Expand Down Expand Up @@ -70,7 +70,7 @@
<dependency>
<groupId>org.matsim.contrib</groupId>
<artifactId>analysis</artifactId>
<version>2025.0-SNAPSHOT</version>
<version>${project.parent.version}</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.matsim.contrib</groupId>-->
Expand Down
2 changes: 1 addition & 1 deletion contribs/analysis/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<dependency>
<groupId>org.matsim.contrib</groupId>
<artifactId>roadpricing</artifactId>
<version>2025.0-SNAPSHOT</version>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>org.osgeo</groupId>
Expand Down
18 changes: 9 additions & 9 deletions contribs/application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,37 +40,37 @@
<dependency>
<groupId>org.matsim.contrib</groupId>
<artifactId>otfvis</artifactId>
<version>2025.0-SNAPSHOT</version>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>org.matsim.contrib</groupId>
<artifactId>osm</artifactId>
<version>2025.0-SNAPSHOT</version>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>org.matsim.contrib</groupId>
<artifactId>sumo</artifactId>
<version>2025.0-SNAPSHOT</version>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>org.matsim.contrib</groupId>
<artifactId>analysis</artifactId>
<version>2025.0-SNAPSHOT</version>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>org.matsim.contrib</groupId>
<artifactId>emissions</artifactId>
<version>2025.0-SNAPSHOT</version>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>org.matsim.contrib</groupId>
<artifactId>noise</artifactId>
<version>2025.0-SNAPSHOT</version>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>org.matsim.contrib</groupId>
<artifactId>freight</artifactId>
<version>2025.0-SNAPSHOT</version>
<version>${project.parent.version}</version>
<exclusions>
<!-- Logging levels are all messed up without this exclusion -->
<exclusion>
Expand All @@ -87,7 +87,7 @@
<dependency>
<groupId>com.github.matsim-org</groupId>
<artifactId>gtfs2matsim</artifactId>
<version>47b0802a29</version>
<version>19f1676fc6</version>
<exclusions>
<!-- Exclude unneeded dependencies and these with known CVE -->
<exclusion>
Expand Down Expand Up @@ -151,7 +151,7 @@
<dependency>
<groupId>org.matsim.contrib</groupId>
<artifactId>dvrp</artifactId>
<version>2025.0-SNAPSHOT</version>
<version>${project.parent.version}</version>
<scope>compile</scope>
</dependency>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.matsim.core.utils.io.IOUtils;
import org.matsim.pt.transitSchedule.api.*;
import org.matsim.pt.utils.CreatePseudoNetwork;
import org.matsim.pt.utils.CreatePseudoNetworkWithLoopLinks;
import org.matsim.pt.utils.TransitScheduleValidator;
import org.matsim.vehicles.*;
import picocli.CommandLine;
Expand Down Expand Up @@ -85,8 +86,8 @@ public class CreateTransitScheduleFromGtfs implements MATSimAppCommand {
@CommandLine.Option(names = "--transform-schedule", description = "Fully qualified class name to a Consumer<TransitSchedule> to be executed after the schedule was created", arity = "0..*", split = ",")
private List<Class<?>> transformSchedule;

@CommandLine.Option(names = "--merge-stops", description = "Whether stops should be merged by coordinate")
private boolean mergeStops;
@CommandLine.Option(names = "--merge-stops", description = "Whether stops should be merged by coordinate", defaultValue = "doNotMerge")
private GtfsConverter.MergeGtfsStops mergeStops;

@CommandLine.Option(names = "--prefix", description = "Prefixes to add to the gtfs ids. Required if multiple inputs are used and ids are not unique.", split = ",")
private List<String> prefixes = new ArrayList<>();
Expand All @@ -100,10 +101,29 @@ public class CreateTransitScheduleFromGtfs implements MATSimAppCommand {
@CommandLine.Option(names = "--shp-crs", description = "Overwrite coordinate system of the shape file")
private String shpCrs;

@CommandLine.Option(names = "--pseudo-network", description = "Define how the pseudo network should be created", defaultValue = "singleLinkBetweenStops")
private PseudoNetwork pseudoNetwork;


public static void main(String[] args) {
System.exit(new CommandLine(new CreateTransitScheduleFromGtfs()).execute(args));
}

private static void addHbefaMapping(VehicleType vehicleType, HbefaVehicleCategory category) {
EngineInformation carEngineInformation = vehicleType.getEngineInformation();
VehicleUtils.setHbefaVehicleCategory(carEngineInformation, String.valueOf(category));
VehicleUtils.setHbefaTechnology(carEngineInformation, "average");
VehicleUtils.setHbefaSizeClass(carEngineInformation, "average");
VehicleUtils.setHbefaEmissionsConcept(carEngineInformation, "average");
vehicleType.setNetworkMode(TransportMode.pt);
}

private static void increaseLinkFreespeedIfLower(Link link, double newFreespeed) {
if (link.getFreespeed() < newFreespeed) {
link.setFreespeed(newFreespeed);
}
}

@Override
public Integer call() throws Exception {

Expand Down Expand Up @@ -183,6 +203,13 @@ public Integer call() throws Exception {

Scenario ptScenario = getScenarioWithPseudoPtNetworkAndTransitVehicles(network, scenario.getTransitSchedule(), "pt_");

for (TransitLine line : new ArrayList<>(scenario.getTransitSchedule().getTransitLines().values())) {
if (line.getRoutes().isEmpty()) {
log.warn("Line {} with no routes removed.", line.getId());
scenario.getTransitSchedule().removeTransitLine(line);
}
}

if (validate) {
//Check schedule and network
TransitScheduleValidator.ValidationResult checkResult = TransitScheduleValidator.validateAll(ptScenario.getTransitSchedule(), ptScenario.getNetwork());
Expand Down Expand Up @@ -237,14 +264,19 @@ private Predicate<Stop> createFilter(int i) throws Exception {
/**
* Creates the pt scenario and network.
*/
private static Scenario getScenarioWithPseudoPtNetworkAndTransitVehicles(Network network, TransitSchedule schedule, String ptNetworkIdentifier) {
private Scenario getScenarioWithPseudoPtNetworkAndTransitVehicles(Network network, TransitSchedule schedule, String ptNetworkIdentifier) {
ScenarioUtils.ScenarioBuilder builder = new ScenarioUtils.ScenarioBuilder(ConfigUtils.createConfig());
builder.setNetwork(network);
builder.setTransitSchedule(schedule);
Scenario scenario = builder.build();

// add pseudo network for pt
new CreatePseudoNetwork(scenario.getTransitSchedule(), scenario.getNetwork(), ptNetworkIdentifier, 0.1, 100000.0).createNetwork();
switch (pseudoNetwork) {
case singleLinkBetweenStops ->
new CreatePseudoNetwork(scenario.getTransitSchedule(), scenario.getNetwork(), ptNetworkIdentifier, 0.1, 100000.0).createNetwork();
case withLoopLinks ->
new CreatePseudoNetworkWithLoopLinks(scenario.getTransitSchedule(), scenario.getNetwork(), ptNetworkIdentifier, 0.1, 100000.0).createNetwork();
}

// create TransitVehicle types
// see https://svn.vsp.tu-berlin.de/repos/public-svn/publications/vspwp/2014/14-24/ for veh capacities
Expand Down Expand Up @@ -449,8 +481,12 @@ private static Scenario getScenarioWithPseudoPtNetworkAndTransitVehicles(Network
// so we need to add time for passengers to board and alight
double minStopTime = 30.0;

List<Id<Link>> routeIds = new LinkedList<>();
routeIds.add(route.getRoute().getStartLinkId());
routeIds.addAll(route.getRoute().getLinkIds());
routeIds.add(route.getRoute().getEndLinkId());

for (int i = 1; i < routeStops.size(); i++) {
// TODO cater for loop link at first stop? Seems to just work without.
TransitRouteStop routeStop = routeStops.get(i);
// if there is no departure offset set (or infinity), it is the last stop of the line,
// so we don't need to care about the stop duration
Expand All @@ -462,8 +498,23 @@ private static Scenario getScenarioWithPseudoPtNetworkAndTransitVehicles(Network
// Math.max to avoid negative values of travelTime
double travelTime = Math.max(1, routeStop.getArrivalOffset().seconds() - lastDepartureOffset - 1.0 -
(stopDuration >= minStopTime ? 0 : (minStopTime - stopDuration)));
Link link = network.getLinks().get(routeStop.getStopFacility().getLinkId());
increaseLinkFreespeedIfLower(link, link.getLength() / travelTime);


Id<Link> stopLink = routeStop.getStopFacility().getLinkId();
List<Id<Link>> subRoute = new LinkedList<>();
do {
Id<Link> linkId = routeIds.removeFirst();
subRoute.add(linkId);
} while (!subRoute.contains(stopLink));

List<? extends Link> links = subRoute.stream().map(scenario.getNetwork().getLinks()::get)
.toList();

double length = links.stream().mapToDouble(Link::getLength).sum();

for (Link link : links) {
increaseLinkFreespeedIfLower(link, length / travelTime);
}
lastDepartureOffset = routeStop.getDepartureOffset().seconds();
}

Expand All @@ -481,20 +532,15 @@ private static Scenario getScenarioWithPseudoPtNetworkAndTransitVehicles(Network
return scenario;
}

private static void addHbefaMapping(VehicleType vehicleType, HbefaVehicleCategory category) {
EngineInformation carEngineInformation = vehicleType.getEngineInformation();
VehicleUtils.setHbefaVehicleCategory(carEngineInformation, String.valueOf(category));
VehicleUtils.setHbefaTechnology(carEngineInformation, "average");
VehicleUtils.setHbefaSizeClass(carEngineInformation, "average");
VehicleUtils.setHbefaEmissionsConcept(carEngineInformation, "average");
vehicleType.setNetworkMode(TransportMode.pt);
}

private static void increaseLinkFreespeedIfLower(Link link, double newFreespeed) {
if (link.getFreespeed() < newFreespeed) {
link.setFreespeed(newFreespeed);
}
public enum PseudoNetwork {
/**
* Create links between all stops and possibly duplicate stops.
*/
singleLinkBetweenStops,
/**
* Create a pseudo network with loop links at each stop.
*/
withLoopLinks,
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -590,9 +590,12 @@ public void run(Person person) {
}

// Remove all unselected plans because these are not handled
person.getPlans().stream()
.filter(p -> p != person.getSelectedPlan())
.forEach(person::removePlan);
List<Plan> plans = new ArrayList<>(person.getPlans());
for(Plan p : plans){
if (p != person.getSelectedPlan()){
person.removePlan(p);
}
}
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
import org.matsim.core.scenario.ScenarioUtils;
import org.matsim.core.utils.geometry.CoordinateTransformation;
import org.matsim.freight.carriers.*;
import org.matsim.freight.carriers.controler.CarrierModule;
import org.matsim.freight.carriers.controler.CarrierScoringFunctionFactory;
import org.matsim.freight.carriers.controller.CarrierModule;
import org.matsim.freight.carriers.controller.CarrierScoringFunctionFactory;
import org.matsim.freight.carriers.usecases.chessboard.CarrierScoringFunctionFactoryImpl;
import picocli.CommandLine;

Expand Down
6 changes: 3 additions & 3 deletions contribs/av/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@
<dependency>
<groupId>org.matsim.contrib</groupId>
<artifactId>dvrp</artifactId>
<version>2025.0-SNAPSHOT</version>
<version>${project.parent.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.matsim.contrib</groupId>
<artifactId>taxi</artifactId>
<version>2025.0-SNAPSHOT</version>
<version>${project.parent.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.matsim.contrib</groupId>
<artifactId>drt</artifactId>
<version>2025.0-SNAPSHOT</version>
<version>${project.parent.version}</version>
<scope>compile</scope>
</dependency>
</dependencies>
Expand Down
2 changes: 1 addition & 1 deletion contribs/bicycle/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<dependency>
<groupId>org.matsim.contrib</groupId>
<artifactId>osm</artifactId>
<version>2025.0-SNAPSHOT</version>
<version>${project.parent.version}</version>
<scope>compile</scope>
</dependency>
</dependencies>
Expand Down
2 changes: 1 addition & 1 deletion contribs/cadytsIntegration/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<dependency>
<groupId>org.matsim.contrib</groupId>
<artifactId>analysis</artifactId>
<version>2025.0-SNAPSHOT</version>
<version>${project.parent.version}</version>
</dependency>
</dependencies>
<inceptionYear>2012</inceptionYear>
Expand Down
2 changes: 1 addition & 1 deletion contribs/carsharing/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<dependency>
<groupId>org.matsim.contrib</groupId>
<artifactId>dvrp</artifactId>
<version>2025.0-SNAPSHOT</version>
<version>${project.parent.version}</version>
</dependency>
</dependencies>
</project>
4 changes: 2 additions & 2 deletions contribs/commercialTrafficApplications/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
<dependency>
<groupId>org.matsim.contrib</groupId>
<artifactId>freight</artifactId>
<version>2025.0-SNAPSHOT</version>
<version>${project.parent.version}</version>
</dependency>

<dependency>
<groupId>org.matsim.contrib</groupId>
<artifactId>drt</artifactId>
<version>2025.0-SNAPSHOT</version>
<version>${project.parent.version}</version>
</dependency>

</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,6 @@ private static CarrierVehicle getLightVehicle(Id<?> id, VehicleType type, Id<Lin
CarrierVehicle.Builder vBuilder = CarrierVehicle.Builder.newInstance(Id.create((id.toString() + "_lightVehicle_" + depot), Vehicle.class), homeId, type );
vBuilder.setEarliestStart(6 * 60 * 60);
vBuilder.setLatestEnd(16 * 60 * 60);
vBuilder.setType(type);
vBuilder.setTypeId(type.getId());
return vBuilder.build();
}

Expand Down
10 changes: 5 additions & 5 deletions contribs/drt-extensions/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,25 @@
<dependency>
<groupId>org.matsim.contrib</groupId>
<artifactId>drt</artifactId>
<version>2025.0-SNAPSHOT</version>
<version>${project.parent.version}</version>
</dependency>

<dependency>
<groupId>org.matsim.contrib</groupId>
<artifactId>ev</artifactId>
<version>2025.0-SNAPSHOT</version>
<version>${project.parent.version}</version>
</dependency>

<dependency>
<groupId>org.matsim.contrib</groupId>
<artifactId>informed-mode-choice</artifactId>
<version>2025.0-SNAPSHOT</version>
<version>${project.parent.version}</version>
</dependency>

<dependency>
<groupId>org.matsim.contrib</groupId>
<artifactId>simwrapper</artifactId>
<version>2025.0-SNAPSHOT</version>
<version>${project.parent.version}</version>
</dependency>

<dependency>
Expand All @@ -45,7 +45,7 @@
<dependency>
<groupId>org.matsim.contrib</groupId>
<artifactId>vsp</artifactId>
<version>2025.0-SNAPSHOT</version>
<version>${project.parent.version}</version>
<scope>test</scope>
</dependency>

Expand Down
Loading

0 comments on commit 98081de

Please sign in to comment.