Commit 4cfe724f authored by clivings's avatar clivings
Browse files

Merge branch 'AVFlowEfficiencyCalculator' into 'master'

Av flow efficiency calculator

See merge request !5
parents 82a87506 653a17e1
package ch.ethz.matsim.projects.astra_2018_002.flow_efficiency;
import org.matsim.api.core.v01.network.Link;
import org.matsim.vehicles.Vehicle;
import org.matsim.vehicles.VehicleType;
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);
}
@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.
VehicleType vehicletype = vehicle.getType();
String linktype = (String) link.getAttributes().getAttribute("osm.way.highway");
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:
// 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
// motorway
// trunk
// primary, secondary
// tertiary, unclassified, residential
//
// 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
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.
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.
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("carVehicleType")) {
flowEfficiency = pcu_car;
}
else if (vehicletype.equals("prav3VehicleType")) {
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("prav4VehicleType")){
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("prav5VehicleType");
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?)
return flowEfficiency;
}
}
......@@ -25,9 +25,9 @@ public class FlowEfficiencyConfigurator {
// Set the calculator instance (not the best design, but works)
// TODO: Here we will be able to distinguish between HLS and other roads in
// combination with vehicle types
FlowEfficiencyCalculator calculator = new StaticFlowEfficiencyCalculator();
// With the AvFlowEfficiencyCalculator we can distinguish between HLS
//and other roads in combination with vehicle types
FlowEfficiencyCalculator calculator = new AvFlowEfficiencyCalculator();
FlowEfficiencyCalculator.INSTANCE.set(calculator);
}
......
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