Commit 8f6df1df authored by clivings's avatar clivings
Browse files

I modified the following classes:

AvFlowEfficiencyCalculator

I added the condition that in order for AV-PCUs to be used, the
attribute "avOperation" must be "true"
I added the condition that if avOperation is false, then pcu_car or
pcu_truck will be used. "sharedAv" does not have this condition,
becaused sharedAvs are not allowed on links that don't have autonomous
operation.
I added PCU values for truck
I added PCU values for truck_av
I added PCU values for sharedAv, aka the taxis, which are the same as
those for prav5

FlowEfficiencyConfigurator

added FREIGHT_TRUCK_ID
added FREIGHT_TRUCK_AV_ID
gave "truck" and "truckAv" vehicles a maximum speed of 22.22m/s which is
80km/h, since this is (apparently?) the maximum speed for these vehicles
in Switzerland
gave "truck" and "truckAv" vehicles the default capacities, which would
need to be changed if we ever did detailed freight logistics stuff with
labor costs and driving time etc.

ASTRAConfigurator

added "truck" and "truckAv" to allowedModes
parent 3dc7b0bf
......@@ -15,7 +15,7 @@ public class ASTRAConfigurator {
Set<String> allowedModes = new HashSet<>(link.getAllowedModes());
if (allowedModes.contains("car")) {
allowedModes.addAll(Arrays.asList("av", "prav3", "prav4", "prav5", "car_passenger"));
allowedModes.addAll(Arrays.asList("av", "prav3", "prav4", "prav5", "car_passenger", "truck", "truckAv"));
}
link.setAllowedModes(allowedModes);
......
......@@ -42,8 +42,8 @@ public class RunASTRA2018002 {
// Adjust config (they need to stay in the correct order!)
SwissModeChoiceConfigurator.configure(config);
SharedAVConfigurator.configure(config);
PrivateAVConfigurator.configure(config);
FlowEfficiencyConfigurator.configure(config);
PrivateAVConfigurator.configure(config, year);
FlowEfficiencyConfigurator.configure(config, year);
ASTRAConfigurator.configure(config);
// Load scenario
......
......@@ -6,23 +6,30 @@ import org.matsim.vehicles.VehicleType;
public class AvFlowEfficiencyCalculator implements FlowEfficiencyCalculator {
private double flowEfficiency;
private int year;
public AvFlowEfficiencyCalculator(double flowEfficiency) {
public AvFlowEfficiencyCalculator(int year, double flowEfficiency) {
this.flowEfficiency = flowEfficiency;
this.year = year;
}
public AvFlowEfficiencyCalculator() {
this(1.0);
public AvFlowEfficiencyCalculator(int year) {
this(year, 1.0);
}
@Override
public double calculateFlowEfficiency(Vehicle vehicle, Link link) {
// define the pcu for each vehicle type and link type.
// define the pcu for each vehicle type and link type and if automated operation is allowed.
// first get vehicle type and link type.
// first get vehicle type and link type and AV Operation permissions.
VehicleType vehicletype = vehicle.getType();
String linktype = (String) link.getAttributes().getAttribute(
"osm.way.highway");
Boolean rawAvOperation = (Boolean) link.getAttributes().getAttribute("avOperation");
boolean avOperation = rawAvOperation != null && rawAvOperation;
// we discovered through an error message when testing this code that
// the Switzerland scenario has links that have no osm.way.highway
// classification.
......@@ -97,15 +104,27 @@ public class AvFlowEfficiencyCalculator implements FlowEfficiencyCalculator {
final Double pcu_prav5_trunk = 0.77;
final Double pcu_prav5_secondaryfast = 0.83;
final Double pcu_prav5_secondaryslow = 0.80;
final Double pcu_sharedAv_motorway = 0.83;
final Double pcu_sharedAv_trunk = 0.77;
final Double pcu_sharedAv_secondaryfast = 0.83;
final Double pcu_sharedAv_secondaryslow = 0.80;
final Double pcu_truck = 4.00;
final Double pcu_truckAv_motorway = 3.08;
final Double pcu_truckAv_trunk = 3.08;
final Double pcu_truckAv_secondaryfast = 3.33;
final Double pcu_truckAv_secondaryslow = 3.20;
// the PCU for car is our reference.
if (vehicletype.getId().equals(
FlowEfficiencyConfigurator.CONVENTIONAL_VEHICLE_TYPE_ID)) {
flowEfficiency = pcu_car;
}
// prav3 vehicles where autonomous operation IS allowed
else if (vehicletype.getId()
.equals(FlowEfficiencyConfigurator.PRAV3_ID)) {
.equals(FlowEfficiencyConfigurator.PRAV3_ID) && avOperation == true) {
if (linktype.equals("motorway")) {
flowEfficiency = one / pcu_prav3_motorway;
......@@ -117,15 +136,20 @@ public class AvFlowEfficiencyCalculator implements FlowEfficiencyCalculator {
|| linktype.equals("secondary")) {
flowEfficiency = one / pcu_prav3_secondaryfast;
} else { // thus this PCU should be assigned to prav3s on OSM
} else { // thus this PCU should be assigned on OSM
// highway categories "tertiary", "unclassified", and
// "residential"
flowEfficiency = one / pcu_prav3_secondaryslow;
}
}
else if (vehicletype.getId()
.equals(FlowEfficiencyConfigurator.PRAV4_ID)) {
//prav3 vehicles where autonomous operation IS NOT allowed
} else if (vehicletype.getId()
.equals(FlowEfficiencyConfigurator.PRAV3_ID) && avOperation == false){
flowEfficiency = one / pcu_car;
//prav4 vehicles where autonomous operation IS allowed
} else if (vehicletype.getId()
.equals(FlowEfficiencyConfigurator.PRAV4_ID) && avOperation == true) {
if (linktype.equals("motorway")) {
flowEfficiency = one / pcu_prav4_motorway;
......@@ -137,12 +161,20 @@ public class AvFlowEfficiencyCalculator implements FlowEfficiencyCalculator {
|| linktype.equals("secondary")) {
flowEfficiency = one / pcu_prav4_secondaryfast;
} else { // thus this PCU should be assigned to prav4s on OSM
} else { // thus this PCU should be assigned on OSM
// highway categories "tertiary", "unclassified", and
// "residential"
flowEfficiency = one / pcu_prav4_secondaryslow;
}
} else {
//prav4 vehicles where autonomous operation IS NOT allowed
} else if (vehicletype.getId()
.equals(FlowEfficiencyConfigurator.PRAV4_ID) && avOperation == false){
flowEfficiency = one / pcu_car;
//prav5 vehicles where autonomous operation IS allowed
} else if (vehicletype.getId()
.equals(FlowEfficiencyConfigurator.PRAV5_ID) && avOperation == true){
if (linktype.equals("motorway")) {
flowEfficiency = one / pcu_prav5_motorway;
......@@ -154,11 +186,69 @@ public class AvFlowEfficiencyCalculator implements FlowEfficiencyCalculator {
|| linktype.equals("secondary")) {
flowEfficiency = one / pcu_prav5_secondaryfast;
} else { // thus this PCU should be assigned to prav5s on OSM
} else { // thus this PCU should be assigned on OSM
// highway categories "tertiary", "unclassified", and
// "residential"
flowEfficiency = one / pcu_prav5_secondaryslow;
}
//prav5 vehicles where autonomous operation IS NOT allowed
} else if (vehicletype.getId()
.equals(FlowEfficiencyConfigurator.PRAV5_ID) && avOperation == false){
flowEfficiency = one / pcu_car;
//sharedAV vehicles are only allowed to operate where autonomous operation IS allowed
} else if (vehicletype.getId()
.equals(FlowEfficiencyConfigurator.SHARED_AV_VEHICLE_TYPE_ID) && avOperation == true){
if (linktype.equals("motorway")) {
flowEfficiency = one / pcu_sharedAv_motorway;
} else if (linktype.equals("trunk")) {
flowEfficiency = one / pcu_sharedAv_trunk;
} else if (linktype.equals("primary")
|| linktype.equals("secondary")) {
flowEfficiency = one / pcu_sharedAv_secondaryfast;
} else { // thus this PCU should be assigned on OSM
// highway categories "tertiary", "unclassified", and
// "residential"
flowEfficiency = one / pcu_sharedAv_secondaryslow;
}
// conventional trucks
} else if (vehicletype.getId()
.equals(FlowEfficiencyConfigurator.FREIGHT_TRUCK_ID)){
flowEfficiency = one / pcu_truck;
// Now AV-Trucks on roads where autonomous operation IS allowed
} else if (vehicletype.getId()
.equals(FlowEfficiencyConfigurator.FREIGHT_TRUCK_AV_ID) && avOperation == true){
if (linktype.equals("motorway")) {
flowEfficiency = one / pcu_truckAv_motorway;
} else if (linktype.equals("trunk")) {
flowEfficiency = one / pcu_truckAv_trunk;
} else if (linktype.equals("primary")
|| linktype.equals("secondary")) {
flowEfficiency = one / pcu_truckAv_secondaryfast;
} else { // thus this PCU should be assigned on OSM
// highway categories "tertiary", "unclassified", and
// "residential"
flowEfficiency = one / pcu_truckAv_secondaryslow;
}
// Now AV-Trucks on roads where autonomous operation IS NOT allowed
} else if (vehicletype.getId()
.equals(FlowEfficiencyConfigurator.FREIGHT_TRUCK_AV_ID) && avOperation == false){
flowEfficiency = one / pcu_truck;
} else {
flowEfficiency = pcu_car;
}
// TODO: eventually include freight and small busses and taxis (since we
......
......@@ -21,8 +21,10 @@ public class FlowEfficiencyConfigurator {
static final public Id<VehicleType> PRAV4_ID = Id.create("prav4", VehicleType.class);
static final public Id<VehicleType> PRAV5_ID = Id.create("prav5", VehicleType.class);
static final public Id<VehicleType> PASSENGER_VEHICLE_TYPE_ID = Id.create("car_passenger", VehicleType.class);
static final public Id<VehicleType> FREIGHT_TRUCK_ID = Id.create("truck", VehicleType.class);
static final public Id<VehicleType> FREIGHT_TRUCK_AV_ID = Id.create("truckAv", VehicleType.class);
static public void configure(Config config) {
static public void configure(Config config, int year) {
// Load vehicles by vehicle type
config.qsim().setVehiclesSource(VehiclesSource.modeVehicleTypesFromVehiclesData);
......@@ -34,7 +36,7 @@ public class FlowEfficiencyConfigurator {
if (privateConfig.getUsePrivateAVs() || sharedConfig.getUseSharedAVs()) {
// With the AvFlowEfficiencyCalculator we can distinguish between HLS
// and other roads in combination with vehicle types
FlowEfficiencyCalculator calculator = new AvFlowEfficiencyCalculator();
FlowEfficiencyCalculator calculator = new AvFlowEfficiencyCalculator(year);
FlowEfficiencyCalculator.INSTANCE.set(calculator);
} else {
// Set the calculator instance (not the best design, but works)
......@@ -81,6 +83,18 @@ public class FlowEfficiencyConfigurator {
.createVehicleType(PRAV5_ID);
prav5VehicleType.setCapacity(defaultCapacity);
scenario.getVehicles().addVehicleType(prav5VehicleType);
VehicleType truckVehicleType = VehicleUtils.getFactory() //
.createVehicleType(FREIGHT_TRUCK_ID);
truckVehicleType.setCapacity(defaultCapacity);
truckVehicleType.setMaximumVelocity(22.22);
scenario.getVehicles().addVehicleType(truckVehicleType);
VehicleType truckAvVehicleType = VehicleUtils.getFactory() //
.createVehicleType(FREIGHT_TRUCK_AV_ID);
truckAvVehicleType.setCapacity(defaultCapacity);
truckAvVehicleType.setMaximumVelocity(22.22);
scenario.getVehicles().addVehicleType(truckAvVehicleType);
for (Person person : scenario.getPopulation().getPersons().values()) {
Id<Vehicle> vehicleId = Id.createVehicleId(person.getId().toString() + "_car_passenger");
......
......@@ -18,7 +18,7 @@ import org.matsim.core.scenario.ScenarioUtils;
public class AssignPrivatAVs {
static public final String AV_AVAILABILITY_ATTRIBUTE = "prAvAvail";
static public void main(Scenario scenario) {
static public void main(Scenario scenario, int year) {
//Config config = ConfigUtils.loadConfig(args[0]);
//Scenario scenario = ScenarioUtils.loadScenario(config);
Random random = new Random(1);
......
......@@ -25,7 +25,7 @@ public class PrivateAVConfigurator {
static final public Collection<String> PRAV_MODES = Arrays.asList(PRAV_3, PRAV_4, PRAV_5);
static public void configure(Config config) {
static public void configure(Config config, int year) {
PrivateAVConfigGroup privateConfig = (PrivateAVConfigGroup) config.getModules()
.get(PrivateAVConfigGroup.GROUP_NAME);
......@@ -78,7 +78,7 @@ public class PrivateAVConfigurator {
throw new IllegalStateException("No point of assigning private AVs if usePrivateAVs = false");
}
AssignPrivatAVs.main(scenario);
AssignPrivatAVs.main(scenario, year);
}
}
}
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