Commit 6d2db22d authored by clivings's avatar clivings
Browse files

pushing truck vehicle definitions and stuff

parent fb884b9a
......@@ -26,13 +26,15 @@ import ch.sbb.matsim.routing.pt.raptor.SwissRailRaptorModule;
public class RunASTRA2018002 {
static public void main(String[] args) throws ConfigurationException {
CommandLine cmd = new CommandLine.Builder(args) //
.requireOptions("config-path", "year") //
.requireOptions("config-path", "year", "ASTRA_Scenario") //
.allowOptions("use-route-choice", "use-only-significant", "utility-parameters", "crossing-penalty",
"model") //
.allowPrefixes(SwissDiscreteModeChoiceModule.COMMAND_LINE_PREFIX) //
.build();
int year = Integer.parseInt(cmd.getOptionStrict("year"));
String ASTRA_Scenario = cmd.getOptionStrict("ASTRA_Scenario");
//To do: make it throw an error if it isn't "A" or "B"
// Load config
Config config = ConfigUtils.loadConfig(cmd.getOptionStrict("config-path"), new PrivateAVConfigGroup(),
......@@ -55,7 +57,7 @@ public class RunASTRA2018002 {
// Adjust scenario
SwissModeChoiceConfigurator.copyHousholdAttributes(scenario);
FlowEfficiencyConfigurator.defineVehicleTypes(scenario, year);
PrivateAVConfigurator.assignPrivateAVs(scenario, year);
PrivateAVConfigurator.assignPrivateAVs(scenario, year, ASTRA_Scenario);
ASTRAConfigurator.checkNetwork(scenario, year);
// Set up controller
......
......@@ -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, int year) {
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);
......@@ -37,42 +37,114 @@ public class AssignPrivatAVs {
// levels of automation require the driver to still be able to instantly take over (up to Level 3) or the driver can only
// allow the car to drive alone in certain situations, and we do not have time to come up with a way to consider a vehicle whose
// VOT changes depending on the links it is driving on.
if(carAvailability.equals(string1)|| carAvailability.equals(string2)){
double r = random.nextDouble();
if (r <= 0.4200) {//produces "true" 42.05% of the time
if( ASTRA_Scenario.equals("A")&& year >= 2050){
if(carAvailability.equals(string1)|| carAvailability.equals(string2)){
double r = random.nextDouble();
person.getAttributes().putAttribute(AV_AVAILABILITY_ATTRIBUTE,"car");
person.getAttributes().putAttribute("carAvail", carAvailability);
} else if (r <= 0.66) {//produces "true" 65.91% of the time: because the first step took 42.05% of the agents already,
// then this step will only consider the next 23.86% of agents
if (r <= 0.68500) {//produces "true" 68.50% of the time
person.getAttributes().putAttribute(AV_AVAILABILITY_ATTRIBUTE,"car");
person.getAttributes().putAttribute("carAvail", carAvailability);
//currently only differentiating between conventional vehicles and "highly automated, highly networked" vehicles
/*} else if (r <= 0.66) {//produces "true" 65.91% of the time: because the first step took 42.05% of the agents already,
// then this step will only consider the next 23.86% of agents
person.getAttributes().putAttribute(AV_AVAILABILITY_ATTRIBUTE,"prav3");
person.getAttributes().putAttribute("carAvail", "never");
} else if (r <= 0.82){
person.getAttributes().putAttribute(AV_AVAILABILITY_ATTRIBUTE,"prav4");
person.getAttributes().putAttribute("carAvail", "never");
*/
} else {
person.getAttributes().putAttribute(AV_AVAILABILITY_ATTRIBUTE,"prav5");
person.getAttributes().putAttribute("carAvail", "never");
}
person.getAttributes().putAttribute(AV_AVAILABILITY_ATTRIBUTE,"prav3");
} 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 if (ASTRA_Scenario.equals("A")&& year >= 2040){
if(carAvailability.equals(string1)|| carAvailability.equals(string2)){
double r = random.nextDouble();
if (r <= 0.94300) {//produces "true" 94.30% of the time
person.getAttributes().putAttribute(AV_AVAILABILITY_ATTRIBUTE,"car");
person.getAttributes().putAttribute("carAvail", carAvailability);
//currently only differentiating between conventional vehicles and "highly automated, highly networked" vehicles
/*} else if (r <= 0.66) {//produces "true" 65.91% of the time: because the first step took 42.05% of the agents already,
// then this step will only consider the next 23.86% of agents
person.getAttributes().putAttribute(AV_AVAILABILITY_ATTRIBUTE,"prav3");
person.getAttributes().putAttribute("carAvail", "never");
} else if (r <= 0.82){
person.getAttributes().putAttribute(AV_AVAILABILITY_ATTRIBUTE,"prav4");
person.getAttributes().putAttribute("carAvail", "never");
*/
} else {
person.getAttributes().putAttribute(AV_AVAILABILITY_ATTRIBUTE,"prav5");
person.getAttributes().putAttribute("carAvail", "never");
}
} else if (r <= 0.82){
person.getAttributes().putAttribute(AV_AVAILABILITY_ATTRIBUTE,"prav4");
} 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 if (ASTRA_Scenario.equals("A")&& year >= 2030){
if(carAvailability.equals(string1)|| carAvailability.equals(string2)){
double r = random.nextDouble();
} else {
person.getAttributes().putAttribute(AV_AVAILABILITY_ATTRIBUTE,"prav5");
if (r <= 0.99500) {//produces "true" 99.50% of the time
person.getAttributes().putAttribute(AV_AVAILABILITY_ATTRIBUTE,"car");
person.getAttributes().putAttribute("carAvail", carAvailability);
//currently only differentiating between conventional vehicles and "highly automated, highly networked" vehicles
/*} else if (r <= 0.66) {//produces "true" 65.91% of the time: because the first step took 42.05% of the agents already,
// then this step will only consider the next 23.86% of agents
person.getAttributes().putAttribute(AV_AVAILABILITY_ATTRIBUTE,"prav3");
person.getAttributes().putAttribute("carAvail", "never");
} else if (r <= 0.82){
person.getAttributes().putAttribute(AV_AVAILABILITY_ATTRIBUTE,"prav4");
person.getAttributes().putAttribute("carAvail", "never");
*/
} else {
person.getAttributes().putAttribute(AV_AVAILABILITY_ATTRIBUTE,"prav5");
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");
}
} 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 if (ASTRA_Scenario.equals("A")&& year < 2030){
if(carAvailability.equals(string1)|| carAvailability.equals(string2)){
person.getAttributes().putAttribute(AV_AVAILABILITY_ATTRIBUTE,"car");
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");
}
// should also set selected plan to choose AV in order to start the
// scenario with the percentages given by TP5 as a starting point....
}
}
// should also set selected plan to choose AV in order to start the
// scenario with the percentages given by TP5 as a starting point....
for (Person person : scenario.getPopulation().getPersons().values()) {
for (Plan plan : person.getPlans()){
for (PlanElement element : plan.getPlanElements()) {
......
......@@ -69,7 +69,7 @@ public class PrivateAVConfigurator {
}
}
static public void assignPrivateAVs(Scenario scenario, int year) {
static public void assignPrivateAVs(Scenario scenario, int year, String ASTRA_Scenario) {
PrivateAVConfigGroup privateConfig = (PrivateAVConfigGroup) scenario.getConfig().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, year);
AssignPrivatAVs.main(scenario, year, ASTRA_Scenario);
}
}
}
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