Commit 11ff522e authored by clivings's avatar clivings
Browse files

I corrected AvFlowEfficiencyCalculator

Now the types compared by the if-statements should match, with both
being vehicletype Ids. 
parent 46ad1470
......@@ -4,13 +4,13 @@ import org.matsim.api.core.v01.network.Link;
import org.matsim.vehicles.Vehicle;
import org.matsim.vehicles.VehicleType;
public class AvFlowEfficiencyCalculator implements FlowEfficiencyCalculator{
public class AvFlowEfficiencyCalculator implements FlowEfficiencyCalculator {
private double flowEfficiency;
public AvFlowEfficiencyCalculator(double flowEfficiency) {
this.flowEfficiency = flowEfficiency;
}
public AvFlowEfficiencyCalculator() {
// TODO Auto-generated constructor stub
this(1.0);
......@@ -19,125 +19,152 @@ public class AvFlowEfficiencyCalculator implements FlowEfficiencyCalculator{
@Override
public double calculateFlowEfficiency(Vehicle vehicle, Link link) {
// define the pcu for each vehicle type and link type.
// first get vehicle type and link type.
// first get vehicle type and link type.
VehicleType vehicletype = vehicle.getType();
String linktype = (String) link.getAttributes().getAttribute("osm.way.highway");
//we discovered through an error message when testing this code that the Switzerland scenario has links that have no osm.way.highway classification.
//Thus we need to give them one to avoid a null error.
if (linktype == null){
String linktype = (String) link.getAttributes().getAttribute(
"osm.way.highway");
// we discovered through an error message when testing this code that
// the Switzerland scenario has links that have no osm.way.highway
// classification.
// Thus we need to give them one to avoid a null error.
if (linktype == null) {
linktype = "unclassified";
}
// Why these PCUs?
//
// Currently four link categories are being used for determining the PCU of an autonomous vehicle (av).
// In the PCU-Faktorenmodell delivered by EBP on March 29th, 2019 per e-mail:
// Currently four link categories are being used for determining the PCU
// of an autonomous vehicle (av).
// In the PCU-Faktorenmodell delivered by EBP on March 29th, 2019 per
// e-mail:
// HLS, 120km/h
// HLS, 80-100km/h
// untergeordnet, 60-80km/h
// untergeordnet, 30-50km/h
//
// Currently these four categories will be assigned the following OSM categories
// Currently these four categories will be assigned the following OSM
// categories
// motorway
// trunk
// primary, secondary
// tertiary, unclassified, residential
//
// But the speed limits used by EBP actually correspond to the following Swiss road categories:
// But the speed limits used by EBP actually correspond to the following
// Swiss road categories:
// Autobahn
// Autostrasse
// Strasse Ausserorts
// Strasse Innerorts
//
// Autobahn and Autostrasse comfortably parallel the OSM categories motorway and trunk.
// But the two subordinate road categories are defined by the geographic area they are located within, not by a road category per se.
// Thus using the OSM categories probably does not reflect the reality on the ground very well.
// TODO: create a "within settlement boundaries" and "outside settlement boundaries" method
// to differentiate between non-motorway, non-trunk links instead of using OSM categories
// since this would more closely resemble the Swiss traffic regulations regarding speed limits
// and very likely how licensure for autonomous vehicles will be granted (either inside or outside settlement limits, rather than by
// speed limit or OSM road class).
// TODO: make the code look for these pcus in the config file, to improve usability
// Autobahn and Autostrasse comfortably parallel the OSM categories
// motorway and trunk.
// But the two subordinate road categories are defined by the geographic
// area they are located within, not by a road category per se.
// Thus using the OSM categories probably does not reflect the reality
// on the ground very well.
// TODO: create a "within settlement boundaries" and
// "outside settlement boundaries" method
// to differentiate between non-motorway, non-trunk links instead of
// using OSM categories
// since this would more closely resemble the Swiss traffic regulations
// regarding speed limits
// and very likely how licensure for autonomous vehicles will be granted
// (either inside or outside settlement limits, rather than by
// speed limit or OSM road class).
// TODO: make the code look for these pcus in the config file, to
// improve usability
final Double pcu_car = 1.00;
final Double one = 1.00;
// It was decided that for now, prav3s be clustered with cars. But this allows in future for a differentiation to be made.
// It was decided that for now, prav3s be clustered with cars. But this
// allows in future for a differentiation to be made.
final Double pcu_prav3_motorway = 1.00;
final Double pcu_prav3_trunk = 1.00;
final Double pcu_prav3_secondaryfast = 1.00;
final Double pcu_prav3_secondaryslow = 1.00;
// It was decided that for now, prav4s be clustered with prav5s. But this allows in the future for a differentiation to be made.
// It was decided that for now, prav4s be clustered with prav5s. But
// this allows in the future for a differentiation to be made.
final Double pcu_prav4_motorway = 0.83;
final Double pcu_prav4_trunk = 0.77;
final Double pcu_prav4_secondaryfast = 0.83;
final Double pcu_prav4_secondaryslow = 0.80;
final Double pcu_prav5_motorway = 0.83;
final Double pcu_prav5_trunk = 0.77;
final Double pcu_prav5_secondaryfast = 0.83;
final Double pcu_prav5_secondaryslow = 0.80;
// the PCU for car is our reference.
if(vehicletype.equals(FlowEfficiencyConfigurator.CONVENTIONAL_VEHICLE_TYPE_ID)) {
// the PCU for car is our reference.
if (vehicletype.getId().equals(
FlowEfficiencyConfigurator.CONVENTIONAL_VEHICLE_TYPE_ID)) {
flowEfficiency = pcu_car;
}
else if (vehicletype.equals(FlowEfficiencyConfigurator.PRAV3_ID)) {
if (linktype.equals("motorway")){
flowEfficiency = one/pcu_prav3_motorway;
}else if (linktype.equals("trunk")){
flowEfficiency = one/pcu_prav3_trunk;
}else if (linktype.equals("primary") || linktype.equals("secondary")){
flowEfficiency = one/pcu_prav3_secondaryfast;
}else { // thus this PCU should be assigned to prav3s on OSM highway categories "tertiary", "unclassified", and "residential"
flowEfficiency = one/pcu_prav3_secondaryslow;
else if (vehicletype.getId()
.equals(FlowEfficiencyConfigurator.PRAV3_ID)) {
if (linktype.equals("motorway")) {
flowEfficiency = one / pcu_prav3_motorway;
} else if (linktype.equals("trunk")) {
flowEfficiency = one / pcu_prav3_trunk;
} else if (linktype.equals("primary")
|| linktype.equals("secondary")) {
flowEfficiency = one / pcu_prav3_secondaryfast;
} else { // thus this PCU should be assigned to prav3s on OSM
// highway categories "tertiary", "unclassified", and
// "residential"
flowEfficiency = one / pcu_prav3_secondaryslow;
}
}
else if (vehicletype.equals(FlowEfficiencyConfigurator.PRAV4_ID)){
if (linktype.equals("motorway")){
flowEfficiency = one/pcu_prav4_motorway;
}else if (linktype.equals("trunk")){
flowEfficiency = one/pcu_prav4_trunk;
}else if (linktype.equals("primary") || linktype.equals("secondary")){
flowEfficiency = one/pcu_prav4_secondaryfast;
}else { // thus this PCU should be assigned to prav4s on OSM highway categories "tertiary", "unclassified", and "residential"
flowEfficiency = one/pcu_prav4_secondaryslow;
else if (vehicletype.getId()
.equals(FlowEfficiencyConfigurator.PRAV4_ID)) {
if (linktype.equals("motorway")) {
flowEfficiency = one / pcu_prav4_motorway;
} else if (linktype.equals("trunk")) {
flowEfficiency = one / pcu_prav4_trunk;
} else if (linktype.equals("primary")
|| linktype.equals("secondary")) {
flowEfficiency = one / pcu_prav4_secondaryfast;
} else { // thus this PCU should be assigned to prav4s on OSM
// highway categories "tertiary", "unclassified", and
// "residential"
flowEfficiency = one / pcu_prav4_secondaryslow;
}
}
else {vehicletype.equals(FlowEfficiencyConfigurator.PRAV5_ID);
if (linktype.equals("motorway")){
flowEfficiency = one/pcu_prav5_motorway;
}else if (linktype.equals("trunk")){
flowEfficiency = one/pcu_prav5_trunk;
}else if (linktype.equals("primary") || linktype.equals("secondary")){
flowEfficiency = one/pcu_prav5_secondaryfast;
}else { // thus this PCU should be assigned to prav5s on OSM highway categories "tertiary", "unclassified", and "residential"
flowEfficiency = one/pcu_prav5_secondaryslow;
} else {
if (linktype.equals("motorway")) {
flowEfficiency = one / pcu_prav5_motorway;
} else if (linktype.equals("trunk")) {
flowEfficiency = one / pcu_prav5_trunk;
} else if (linktype.equals("primary")
|| linktype.equals("secondary")) {
flowEfficiency = one / pcu_prav5_secondaryfast;
} else { // thus this PCU should be assigned to prav5s on OSM
// highway categories "tertiary", "unclassified", and
// "residential"
flowEfficiency = one / pcu_prav5_secondaryslow;
}
}
//TODO: eventually include freight and small busses and taxis (since we are defining vehicle type by mode, correct?)
// TODO: eventually include freight and small busses and taxis (since we
// are defining vehicle type by mode, correct?)
return flowEfficiency;
}
}
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