Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
rewertvsp committed Feb 22, 2024
1 parent 06a2fbb commit 6c4d482
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,6 @@ public Integer call() throws Exception {
}
Path inputDataDirectory = Path.of(config.getContext().toURI()).getParent();

ShpOptions shpZones = new ShpOptions(shapeFileZonePath, shapeCRS, StandardCharsets.UTF_8);

indexZones = SmallScaleCommercialTrafficUtils.getIndexZones(shapeFileZonePath, shapeCRS);
indexBuildings = SmallScaleCommercialTrafficUtils.getIndexBuildings(shapeFileBuildingsPath, shapeCRS);
indexLanduse = SmallScaleCommercialTrafficUtils.getIndexLanduse(shapeFileLandusePath, shapeCRS);
Expand All @@ -243,14 +241,14 @@ public Integer call() throws Exception {

switch (usedSmallScaleCommercialTrafficType) {
case commercialPersonTraffic, goodsTraffic ->
createCarriersAndDemand(output, scenario, shpZones, resultingDataPerZone, regionLinksMap,
createCarriersAndDemand(output, scenario, resultingDataPerZone, regionLinksMap,
usedSmallScaleCommercialTrafficType.toString(),
includeExistingModels);
case completeSmallScaleCommercialTraffic -> {
createCarriersAndDemand(output, scenario, shpZones, resultingDataPerZone, regionLinksMap, "commercialPersonTraffic",
createCarriersAndDemand(output, scenario, resultingDataPerZone, regionLinksMap, "commercialPersonTraffic",
includeExistingModels);
includeExistingModels = false; // because already included in the step before
createCarriersAndDemand(output, scenario, shpZones, resultingDataPerZone, regionLinksMap, "goodsTraffic",
createCarriersAndDemand(output, scenario, resultingDataPerZone, regionLinksMap, "goodsTraffic",
includeExistingModels);
}
default -> throw new RuntimeException("No traffic type selected.");
Expand Down Expand Up @@ -424,7 +422,7 @@ private void solveSeparatedVRPs(Scenario originalScenario, Map<String, Map<Id<Li
});
}

private void createCarriersAndDemand(Path output, Scenario scenario, ShpOptions shpZones,
private void createCarriersAndDemand(Path output, Scenario scenario,
Map<String, Object2DoubleMap<String>> resultingDataPerZone,
Map<String, Map<Id<Link>, Link>> regionLinksMap, String smallScaleCommercialTrafficType,
boolean includeExistingModels) throws Exception {
Expand All @@ -451,7 +449,7 @@ else if (smallScaleCommercialTrafficType.equals("commercialPersonTraffic"))
trafficVolumePerTypeAndZone_start, trafficVolumePerTypeAndZone_stop);
}
final TripDistributionMatrix odMatrix = createTripDistribution(trafficVolumePerTypeAndZone_start,
trafficVolumePerTypeAndZone_stop, shpZones, smallScaleCommercialTrafficType, scenario, output, regionLinksMap);
trafficVolumePerTypeAndZone_stop, smallScaleCommercialTrafficType, scenario, output, regionLinksMap);
createCarriers(scenario, odMatrix, resultingDataPerZone, smallScaleCommercialTrafficType, regionLinksMap);
}

Expand Down Expand Up @@ -947,7 +945,7 @@ private static void findNearestLinkForZonesWithoutLinks(Network networkToChange,
*/
private TripDistributionMatrix createTripDistribution(
Map<TrafficVolumeGeneration.TrafficVolumeKey, Object2DoubleMap<Integer>> trafficVolume_start,
Map<TrafficVolumeGeneration.TrafficVolumeKey, Object2DoubleMap<Integer>> trafficVolume_stop, ShpOptions shpZones,
Map<TrafficVolumeGeneration.TrafficVolumeKey, Object2DoubleMap<Integer>> trafficVolume_stop,
String smallScaleCommercialTrafficType, Scenario scenario, Path output, Map<String, Map<Id<Link>, Link>> regionLinksMap)
throws Exception {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -519,16 +519,6 @@ private GravityConstantKey makeGravityKey(String fromZone, String modeOrVehType,
* @return listOfZones
*/
ArrayList<String> getListOfZones() {
// int count = 0;
// if (listOfZones.isEmpty())
// for (TripDistributionMatrixKey key : matrixCache.keySet()) {
// count++;
// System.out.println(count);
// if (!listOfZones.contains(key.getFromZone()))
// listOfZones.add(key.getFromZone());
// if (!listOfZones.contains(key.getToZone()))
// listOfZones.add(key.getToZone());
// }
return listOfZones;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,6 @@ private void weightedProbability() {
.filter(a -> a.getValue().equals(selectedLetter))
.findFirst()
.ifPresent(l -> l.setExpectedCount(l.getExpectedCount() + 1));

//After 'testCount' loops, print out the number of times each value was selected and the percentage it represents
// for (ProbabilityForValue probabilityForValue : ProbabilityDistribution) {
// System.out.println(probabilityForValue.getValue()
// + " -> expected: " + probabilityForValue.getExpectedCount()
// + "(" + String.format("%.2f", (probabilityForValue.getExpectedCount() * Math.pow(anIntAsSum,
// -1)) * 100) + " %); prob: " + ((double)Math.round(probabilityForValue.getProbability() * 1000)/10) + "%");
// }
}
public void writeResults(){
for (ProbabilityForValue probabilityForValue : ProbabilityDistribution) {
Expand Down

0 comments on commit 6c4d482

Please sign in to comment.