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

Fix car assignment for Scenario B

parent 63248d6b
......@@ -21,8 +21,6 @@ public class AssignPrivatAVs {
static public final Boolean freight_av = false;
static public void main(Scenario scenario, int year, String ASTRA_Scenario) {
//Config config = ConfigUtils.loadConfig(args[0]);
//Scenario scenario = ScenarioUtils.loadScenario(config);
Random random = new Random(1);
for (Person person : scenario.getPopulation().getPersons().values()) {
......@@ -161,6 +159,8 @@ public class AssignPrivatAVs {
}
}
carAvailability = (String) person.getAttributes().getAttribute("carAvail");
//now, for the agents that still have cars, aka whose attribute "carAvail" still equals "always" or "sometimes"...
//let us assign which one of them has a car capable of autonomous operation...
if(carAvailability.equals(string1)|| carAvailability.equals(string2)){
......@@ -211,6 +211,8 @@ public class AssignPrivatAVs {
}
}
carAvailability = (String) person.getAttributes().getAttribute("carAvail");
//now, for the agents that still have cars, aka whose attribute "carAvail" still equals "always" or "sometimes"...
//let us assign which one of them has a car capable of autonomous operation...
if(carAvailability.equals(string1)|| carAvailability.equals(string2)){
......@@ -261,6 +263,8 @@ public class AssignPrivatAVs {
}
}
carAvailability = (String) person.getAttributes().getAttribute("carAvail");
//now, for the agents that still have cars, aka whose attribute "carAvail" still equals "always" or "sometimes"...
//let us assign which one of them has a car capable of autonomous operation...
if(carAvailability.equals(string1)|| carAvailability.equals(string2)){
......@@ -304,12 +308,12 @@ public class AssignPrivatAVs {
person.getAttributes().putAttribute("carAvail", carAvailability);
} else { // make sure that those agents who "never" have a car available also do not have an private av available,and to
// prevent "null" exceptions from Java, which occur when a variable, such as the attribute "prAvAvail" don't have a value
person.getAttributes().putAttribute(AV_AVAILABILITY_ATTRIBUTE,"noPrav");
person.getAttributes().putAttribute("carAvail", "never");
}
} else { // make sure that those agents who "never" have a car available also do not have an private av available,and to
// prevent "null" exceptions from Java, which occur when a variable, such as the attribute "prAvAvail" don't have a value
person.getAttributes().putAttribute(AV_AVAILABILITY_ATTRIBUTE,"noPrav");
person.getAttributes().putAttribute("carAvail", "never");
}
}
}
......@@ -381,10 +385,33 @@ public class AssignPrivatAVs {
}
/*int countTotal = 0;
int countCarAvail = 0;
int countPravAvail = 0;
//Population population = scenario.getPopulation();
for (Person person : scenario.getPopulation().getPersons().values()) {
if (!person.getId().toString().contains("freight")) {
String carAvailability = (String) person.getAttributes().getAttribute("carAvail");
String pravAvailability = (String) person.getAttributes().getAttribute(AV_AVAILABILITY_ATTRIBUTE);
if (!carAvailability.equals("never")) {
countCarAvail++;
}
if (pravAvailability.equals("prav5")) {
countPravAvail++;
}
if (!carAvailability.equals("never") && pravAvailability.equals("prav5")) {
throw new IllegalStateException();
}
countTotal++;
}
}
//PopulationUtils.writePopulation(population, args[1]);
System.out.println(String.format("Car availability: %.2f%%", 100.0 * (double) countCarAvail / countTotal));
System.out.println(String.format("Prav availability: %.2f%%", 100.0 * (double) countPravAvail / countTotal));
System.out.println(String.format("Prav share: %.2f%%", 100.0 * (double) countPravAvail / (countPravAvail + countCarAvail)));*/
}
}
\ No newline at end of file
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