Skip to content

Commit

Permalink
Merge pull request #3048 from matsim-org/skimmatricesLittleBugfix
Browse files Browse the repository at this point in the history
Skimmatrices little bugfix
  • Loading branch information
jfbischoff authored Jan 11, 2024
2 parents ca20784 + 18ed3b4 commit 5cadc8a
Showing 1 changed file with 25 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ public final void loadSamplingPointsFromFile(String filename) throws IOException
int idx = Integer.parseInt(parts[1]);
double x = Double.parseDouble(parts[2]);
double y = Double.parseDouble(parts[3]);
final int length = idx > maxIdx ? idx : maxIdx;
final int length = Math.max(idx, maxIdx);
Coord[] coords = this.coordsPerZone.computeIfAbsent(zoneId, k -> new Coord[length + 1]);
if (coords.length < (idx + 1)) {
Coord[] tmp = new Coord[idx + 1];
Expand Down Expand Up @@ -453,10 +453,25 @@ public final void calculateAndWritePTMatrices(String networkFilename,
double endTime,
Config config,
String outputPrefix,
BiPredicate<TransitLine, TransitRoute> trainDetector) throws IOException {
BiPredicate<TransitLine, TransitRoute> trainDetector,
PTSkimMatrices.CoordAggregator coordAggregator) throws IOException {

var matrices = calculatePTMatrices(networkFilename,
transitScheduleFilename, startTime, endTime, config, trainDetector);
transitScheduleFilename, startTime, endTime, config, trainDetector, coordAggregator);
writePTMatricesAsCSV(matrices, outputPrefix);
}
public final void calculateAndWritePTMatrices(String networkFilename,
String transitScheduleFilename,
double startTime,
double endTime,
Config config,
String outputPrefix,
BiPredicate<TransitLine, TransitRoute> trainDetector
) throws IOException {

var matrices = calculatePTMatrices(networkFilename,
transitScheduleFilename, startTime, endTime, config, trainDetector, new PTSkimMatrices.CoordAggregator() {
});
writePTMatricesAsCSV(matrices, outputPrefix);
}

Expand All @@ -476,11 +491,12 @@ public final void writePTMatricesAsCSV(PTSkimMatrices.PtIndicators<String> matri
}

public final PTSkimMatrices.PtIndicators<String> calculatePTMatrices(String networkFilename,
String transitScheduleFilename,
double startTime,
double endTime,
Config config,
BiPredicate<TransitLine, TransitRoute> trainDetector) {
String transitScheduleFilename,
double startTime,
double endTime,
Config config,
BiPredicate<TransitLine, TransitRoute> trainDetector,
PTSkimMatrices.CoordAggregator coordAggregator) {
Scenario scenario = ScenarioUtils.createScenario(config);
log.info("loading schedule from " + transitScheduleFilename);
new TransitScheduleReader(scenario).readFile(transitScheduleFilename);
Expand All @@ -494,8 +510,7 @@ public final PTSkimMatrices.PtIndicators<String> calculatePTMatrices(String netw

log.info("calc PT matrices for " + Time.writeTime(startTime) + " - " + Time.writeTime(endTime));
PTSkimMatrices.PtIndicators<String> matrices = PTSkimMatrices.calculateSkimMatrices(
raptorData, this.coordsPerZone, startTime, endTime, 120, raptorParameters, this.numberOfThreads, trainDetector, new PTSkimMatrices.CoordAggregator() {
});
raptorData, this.coordsPerZone, startTime, endTime, 120, raptorParameters, this.numberOfThreads, trainDetector, coordAggregator);
return matrices;

}
Expand Down

0 comments on commit 5cadc8a

Please sign in to comment.