Commit de74a8a6 authored by Sebastian Hörl's avatar Sebastian Hörl
Browse files

Properly consider truck and truckAv for PCU flow analysis

parent 76b1e5d5
......@@ -38,6 +38,8 @@ public class FlowListener implements LinkEnterEventHandler {
private final Vehicle PRAV3;
private final Vehicle PRAV4;
private final Vehicle PRAV5;
private final Vehicle TRUCK;
private final Vehicle TRUCK_AV;
public FlowListener(Collection<Link> links, double startTime, double endTime, double interval,
FlowEfficiencyCalculator flowEfficiencyCalculator, Vehicles vehicles) {
......@@ -74,6 +76,10 @@ public class FlowListener implements LinkEnterEventHandler {
vehicles.getVehicleTypes().get(FlowEfficiencyConfigurator.PRAV4_ID));
this.PRAV5 = vehicles.getFactory().createVehicle(Id.createVehicleId("prav5"),
vehicles.getVehicleTypes().get(FlowEfficiencyConfigurator.PRAV5_ID));
this.TRUCK = vehicles.getFactory().createVehicle(Id.createVehicleId("truck"),
vehicles.getVehicleTypes().get(FlowEfficiencyConfigurator.FREIGHT_TRUCK_ID));
this.TRUCK_AV = vehicles.getFactory().createVehicle(Id.createVehicleId("truckAv"),
vehicles.getVehicleTypes().get(FlowEfficiencyConfigurator.FREIGHT_TRUCK_AV_ID));
}
public class CountItem {
......@@ -88,8 +94,12 @@ public class FlowListener implements LinkEnterEventHandler {
public int level5Vehicles;
public int level4Vehicles;
public int level3Vehicles;
public int automatedTrucks;
public double pcus;
// PCU
public double pcusVehicles;
public double pcusTrucks;
public double pcusAll;
}
private AnalysisVehicle getAnaysisVehicle(Id<Vehicle> vehicleId) {
......@@ -109,6 +119,9 @@ public class FlowListener implements LinkEnterEventHandler {
vehicle.automationLevel = 5;
vehicle.isShared = true;
vehicle.isPooled = true;
} else if (rawVehicleId.contains("truckAv")) {
vehicle.isTruck = true;
vehicle.automationLevel = 5;
} else if (rawVehicleId.contains("truck")) {
vehicle.isTruck = true;
}
......@@ -116,48 +129,68 @@ public class FlowListener implements LinkEnterEventHandler {
return vehicle;
}
private Vehicle getAutomationLevelVehicle(int automationLevel) {
switch (automationLevel) {
case 3:
return PRAV3;
case 4:
return PRAV4;
case 5:
return PRAV5;
default:
return CONVENTIONAL;
private Vehicle getAutomationLevelVehicle(int automationLevel, boolean isTruck) {
if (isTruck) {
if (automationLevel == 5) {
return TRUCK_AV;
} else {
return TRUCK;
}
} else {
switch (automationLevel) {
case 3:
return PRAV3;
case 4:
return PRAV4;
case 5:
return PRAV5;
default:
return CONVENTIONAL;
}
}
}
private void modifyCountItem(CountItem item, AnalysisVehicle analysisVehicle, Vehicle vehicle, Link link) {
switch (analysisVehicle.automationLevel) {
case 3:
item.level3Vehicles++;
break;
case 4:
item.level4Vehicles++;
break;
case 5:
item.level5Vehicles++;
break;
default:
item.conventionalVehicles++;
break;
}
double flowEfficiency = flowEfficiencyCalculator.calculateFlowEfficiency(vehicle, link);
if (!analysisVehicle.isTruck) {
switch (analysisVehicle.automationLevel) {
case 3:
item.level3Vehicles++;
break;
case 4:
item.level4Vehicles++;
break;
case 5:
item.level5Vehicles++;
break;
default:
item.conventionalVehicles++;
break;
}
if (analysisVehicle.isShared) {
if (analysisVehicle.isPooled) {
item.pooledVehicles++;
if (analysisVehicle.isShared) {
if (analysisVehicle.isPooled) {
item.pooledVehicles++;
} else {
item.taxiVehicles++;
}
} else {
item.taxiVehicles++;
item.privateVehicles++;
}
} else if (analysisVehicle.isTruck) {
item.truckVehicles++;
item.pcusVehicles += 1.0 / flowEfficiency;
} else {
item.privateVehicles++;
item.truckVehicles++;
if (analysisVehicle.automationLevel == 5) {
item.automatedTrucks++;
}
item.pcusTrucks += 1.0 / flowEfficiency;
}
item.pcus += 1.0 / flowEfficiencyCalculator.calculateFlowEfficiency(vehicle, link);
item.pcusAll += 1.0 / flowEfficiency;
}
@Override
......@@ -167,7 +200,7 @@ public class FlowListener implements LinkEnterEventHandler {
Link link = links.get(linkIndex);
AnalysisVehicle analysisVehicle = getAnaysisVehicle(event.getVehicleId());
Vehicle vehicle = getAutomationLevelVehicle(analysisVehicle.automationLevel);
Vehicle vehicle = getAutomationLevelVehicle(analysisVehicle.automationLevel, analysisVehicle.isTruck);
CountItem totalItem = totalItems[linkIndex];
modifyCountItem(totalItem, analysisVehicle, vehicle, link);
......
......@@ -97,7 +97,7 @@ public class RunFlowAnalysis {
int morningPeakIndex = 8 - 5;
int eveningPeakIndex = 17 - 5;
Collection<SimpleFeature> features = new ArrayList<>(links.size());
PolylineFeatureFactory featureFactory = new PolylineFeatureFactory.Builder() //
.setCrs(crs) //
......@@ -113,30 +113,39 @@ public class RunFlowAnalysis {
.addAttribute("day_taxi", Integer.class) //
.addAttribute("day_conv", Integer.class) //
.addAttribute("day_truck", Integer.class) //
.addAttribute("day_level5", Integer.class) //
.addAttribute("day_level4", Integer.class) //
.addAttribute("day_level3", Integer.class) //
.addAttribute("day_pass5", Integer.class) //
.addAttribute("day_pass4", Integer.class) //
.addAttribute("day_pass3", Integer.class) //
.addAttribute("day_truck5", Integer.class) //
.addAttribute("day_pcu", Double.class) //
.addAttribute("day_pcut", Double.class) //
.addAttribute("day_pcup", Double.class) //
//
.addAttribute("am_priv", Integer.class) //
.addAttribute("am_pool", Integer.class) //
.addAttribute("am_taxi", Integer.class) //
.addAttribute("am_conv", Integer.class) //
.addAttribute("am_truck", Integer.class) //
.addAttribute("am_level5", Integer.class) //
.addAttribute("am_level4", Integer.class) //
.addAttribute("am_level3", Integer.class) //
.addAttribute("am_pass5", Integer.class) //
.addAttribute("am_pass4", Integer.class) //
.addAttribute("am_pass3", Integer.class) //
.addAttribute("am_truck5", Integer.class) //
.addAttribute("am_pcu", Double.class) //
.addAttribute("am_pcut", Double.class) //
.addAttribute("am_pcup", Double.class) //
//
.addAttribute("pm_priv", Integer.class) //
.addAttribute("pm_pool", Integer.class) //
.addAttribute("pm_taxi", Integer.class) //
.addAttribute("pm_conv", Integer.class) //
.addAttribute("pm_truck", Integer.class) //
.addAttribute("pm_level5", Integer.class) //
.addAttribute("pm_level4", Integer.class) //
.addAttribute("pm_level3", Integer.class) //
.addAttribute("pm_pass5", Integer.class) //
.addAttribute("pm_pass4", Integer.class) //
.addAttribute("pm_pass3", Integer.class) //
.addAttribute("pm_truck5", Integer.class) //
.addAttribute("pm_pcu", Double.class) //
.addAttribute("pm_pcut", Double.class) //
.addAttribute("pm_pcup", Double.class) //
//
.create();
......@@ -171,7 +180,10 @@ public class RunFlowAnalysis {
totalItem.level5Vehicles, //
totalItem.level4Vehicles, //
totalItem.level3Vehicles, //
totalItem.pcus, //
totalItem.automatedTrucks, //
totalItem.pcusAll, //
totalItem.pcusTrucks, //
totalItem.pcusVehicles, //
//
morningItem.privateVehicles, //
morningItem.pooledVehicles, //
......@@ -181,7 +193,10 @@ public class RunFlowAnalysis {
morningItem.level5Vehicles, //
morningItem.level4Vehicles, //
morningItem.level3Vehicles, //
morningItem.pcus, //
morningItem.automatedTrucks, //
morningItem.pcusAll, //
morningItem.pcusTrucks, //
morningItem.pcusVehicles, //
//
eveningItem.privateVehicles, //
eveningItem.pooledVehicles, //
......@@ -191,7 +206,10 @@ public class RunFlowAnalysis {
eveningItem.level5Vehicles, //
eveningItem.level4Vehicles, //
eveningItem.level3Vehicles, //
eveningItem.pcus, //
eveningItem.automatedTrucks, //
eveningItem.pcusAll, //
eveningItem.pcusTrucks, //
eveningItem.pcusVehicles, //
//
}, null);
features.add(feature);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment