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

A number of changes:

- Consider bike availability (no bike allowed for FOR_NONE)
- Set car cost to 0.26 CHF/km
- Use age/20 in front of betaAge (seems to be more reasonable)
parent 66800f66
......@@ -15,6 +15,8 @@ import ch.ethz.matsim.baseline_scenario.config.CommandLine;
import ch.ethz.matsim.baseline_scenario.config.CommandLine.ConfigurationException;
import ch.ethz.matsim.discrete_mode_choice.modules.AbstractDiscreteModeChoiceExtension;
import ch.ethz.matsim.discrete_mode_choice.modules.DiscreteModeChoiceModule;
import ch.ethz.matsim.discrete_mode_choice.modules.config.DiscreteModeChoiceConfigGroup;
import ch.ethz.matsim.discrete_mode_choice.modules.config.ModeAvailabilityConfigGroup;
import ch.ethz.matsim.projects.astra_2018_002.mode_choice.SwissUtilityParameters.UtilitySet;
import ch.ethz.matsim.projects.astra_2018_002.mode_choice.cost.CostModel;
import ch.ethz.matsim.projects.astra_2018_002.mode_choice.cost.CostParameters;
......@@ -22,6 +24,7 @@ import ch.ethz.matsim.projects.astra_2018_002.mode_choice.cost.CostParameters;
public class SwissDiscreteModeChoiceModule extends AbstractDiscreteModeChoiceExtension {
public final static String COMMAND_LINE_PREFIX = "utility";
public static final String SWISS_ESTIMATOR_NAME = "Swiss";
public static final String SWISS_MODE_AVAILABILITY_NAME = "SwissModeAvailability";
private final UtilitySet utilitySet;
private final boolean useRouteChoice;
......@@ -41,6 +44,7 @@ public class SwissDiscreteModeChoiceModule extends AbstractDiscreteModeChoiceExt
protected void installExtension() {
install(new DiscreteModeChoiceModule());
bindTripEstimator(SWISS_ESTIMATOR_NAME).to(SwissUtilityEstimator.class);
bindModeAvailability(SWISS_MODE_AVAILABILITY_NAME).to(SwissModeAvailability.class);
}
@Provides
......@@ -79,4 +83,10 @@ public class SwissDiscreteModeChoiceModule extends AbstractDiscreteModeChoiceExt
return new CostParameters();
}
@Provides
public SwissModeAvailability provideSwissModeAvailability(DiscreteModeChoiceConfigGroup dmcConfig) {
ModeAvailabilityConfigGroup maConfig = dmcConfig.getCarModeAvailabilityConfig();
return new SwissModeAvailability(maConfig.getAvailableModes());
}
}
package ch.ethz.matsim.projects.astra_2018_002.mode_choice;
import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;
import org.matsim.api.core.v01.TransportMode;
import org.matsim.api.core.v01.population.Person;
import ch.ethz.matsim.discrete_mode_choice.model.DiscreteModeChoiceTrip;
import ch.ethz.matsim.discrete_mode_choice.model.mode_availability.CarModeAvailability;
public class SwissModeAvailability extends CarModeAvailability {
public SwissModeAvailability(Collection<String> modes) {
super(modes);
}
@Override
public Collection<String> getAvailableModes(Person person, List<DiscreteModeChoiceTrip> trips) {
boolean bikeAvailability = !"FOR_NONE".equals((String) person.getAttributes().getAttribute("bikeAvailability"));
if (!bikeAvailability) {
return super.getAvailableModes(person, trips).stream().filter(m -> !TransportMode.bike.equals(m))
.collect(Collectors.toSet());
}
return super.getAvailableModes(person, trips);
}
}
......@@ -16,7 +16,6 @@ import org.matsim.households.Household;
import ch.ethz.matsim.discrete_mode_choice.modules.ConstraintModule;
import ch.ethz.matsim.discrete_mode_choice.modules.DiscreteModeChoiceConfigurator;
import ch.ethz.matsim.discrete_mode_choice.modules.EstimatorModule;
import ch.ethz.matsim.discrete_mode_choice.modules.ModeAvailabilityModule;
import ch.ethz.matsim.discrete_mode_choice.modules.ModelModule.ModelType;
import ch.ethz.matsim.discrete_mode_choice.modules.SelectorModule;
import ch.ethz.matsim.discrete_mode_choice.modules.TourFinderModule;
......@@ -42,7 +41,7 @@ public class SwissModeChoiceConfigurator {
dmcConfig.setTourFinder(TourFinderModule.ACTIVITY_BASED);
dmcConfig.getActivityTourFinderConfigGroup().setActivityType("home");
dmcConfig.setModeAvailability(ModeAvailabilityModule.CAR);
dmcConfig.setModeAvailability(SwissDiscreteModeChoiceModule.SWISS_MODE_AVAILABILITY_NAME);
dmcConfig.getCarModeAvailabilityConfig().setAvailableModes(Arrays.asList("car", "bike", "pt", "walk"));
dmcConfig.setTourConstraints(
......@@ -83,6 +82,8 @@ public class SwissModeChoiceConfigurator {
for (Id<Person> memberId : household.getMemberIds()) {
Person person = scenario.getPopulation().getPersons().get(memberId);
person.getAttributes().putAttribute("bikeAvailability",
household.getAttributes().getAttribute("bikeAvailability"));
person.getAttributes().putAttribute("householdIncome", household.getIncome().getIncome());
person.getAttributes().putAttribute("spRegion", household.getAttributes().getAttribute("spRegion"));
person.getAttributes().putAttribute("municipalityType",
......
......@@ -38,8 +38,8 @@ public class SwissUtilityEstimator extends BaseUtilityEstimator {
PersonVariables personVariables) {
double utility = 0.0;
utility += socioParameters.betaAge * personVariables.age_10a;
utility += socioParameters.betaAgeSquared * Math.pow(personVariables.age_10a, 2.0);
utility += socioParameters.betaAge * personVariables.age_20a;
utility += socioParameters.betaAgeSquared * Math.pow(personVariables.age_20a, 2.0);
utility += socioParameters.betaIncome * personVariables.income_1000CHF;
utility += socioParameters.betaIncomeSquared * Math.pow(personVariables.income_1000CHF, 2.0);
......
......@@ -661,7 +661,7 @@ public class SwissUtilityParameters {
}
public enum UtilitySet {
CHAPTER_3_2_1, CHAPTER_3_2_2, CHAPTER_3_2_3, APPENDIX_A5, CUSTOM
CHAPTER_3_2_1, CHAPTER_3_2_2, CHAPTER_3_2_3, APPENDIX_A5, CUSTOM, ZERO
}
static public SwissUtilityParameters build(UtilitySet set, boolean useRouteChoice, boolean onlySignificant) {
......@@ -678,6 +678,8 @@ public class SwissUtilityParameters {
return buildAppendix(useRouteChoice, onlySignificant);
case CUSTOM:
return buildCustom(useRouteChoice, onlySignificant);
case ZERO:
return new SwissUtilityParameters();
default:
throw new IllegalStateException();
}
......
......@@ -44,7 +44,7 @@ public abstract class BaseUtilityEstimator extends AbstractTripRouterEstimator {
List<TripCandidate> previousTrips, List<? extends PlanElement> routedTrip) {
PersonVariables personVariables = new PersonVariables();
personVariables.age_10a = 0.1 * (double) (Integer) person.getAttributes().getAttribute("age");
personVariables.age_20a = ((double) (Integer) person.getAttributes().getAttribute("age")) / 20.0;
personVariables.income_1000CHF = (Double) person.getAttributes().getAttribute("householdIncome") * 1e-3;
personVariables.isMale = ((String) person.getAttributes().getAttribute("sex")).equals("m");
personVariables.carAlwaysAvailable = ((String) person.getAttributes().getAttribute("carAvail"))
......
package ch.ethz.matsim.projects.astra_2018_002.mode_choice.base;
public class PersonVariables {
public double age_10a = 0;
public double age_20a = 0;
public double income_1000CHF = 0.0;
public boolean isMale = false;
public boolean carAlwaysAvailable = false;
......
package ch.ethz.matsim.projects.astra_2018_002.mode_choice.cost;
public class CostParameters {
public double carCostPerKm = 0.17;
public double carCostPerKm = 0.26;
public double avCostPerKm = 0.4;
public double ptCostPerKm = 0.25;
......
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