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

Merge branch 'cleanup' into 'master'

Some code cleanup for mode choice and private AVs

See merge request !4
parents e6abffff 49b0038f
# How to run a simulaton with private AVs
Private AVs can be activated via the `private_av` config group:
```xml
<module name="private_av">
<param name="usePrivateAVs" value="true" />
</module>
```
Likewise, this option can be set via the command line:
```
java [...] --config:private_av.usePrivateAVs true
```
# How to create the partial scenarios # How to create the partial scenarios
This repository only contains code to run the requested scenarios in the ASTRA 2018/002 project. For the sake of avoiding code duplication, the scenario cutting code is still located in the [baseline_scenario](https://github.com/matsim-eth/baseline_scenario) repository, specifically in the (synpop)[https://github.com/matsim-eth/baseline_scenario/tree/synpop] branch. This repository only contains code to run the requested scenarios in the ASTRA 2018/002 project. For the sake of avoiding code duplication, the scenario cutting code is still located in the [baseline_scenario](https://github.com/matsim-eth/baseline_scenario) repository, specifically in the (synpop)[https://github.com/matsim-eth/baseline_scenario/tree/synpop] branch.
......
package ch.ethz.matsim.projects.astra_2018_002;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import org.matsim.api.core.v01.Scenario;
import org.matsim.api.core.v01.network.Link;
public class ASTRAConfigurator {
static public void adjustNetwork(Scenario scenario) {
// TODO: only until we actually assign allowed modes via the pipeline
for (Link link : scenario.getNetwork().getLinks().values()) {
Set<String> allowedModes = new HashSet<>(link.getAllowedModes());
if (allowedModes.contains("car")) {
allowedModes.addAll(Arrays.asList("prav3", "prav4", "prav5"));
}
link.setAllowedModes(allowedModes);
}
}
}
...@@ -18,7 +18,7 @@ import com.google.inject.Singleton; ...@@ -18,7 +18,7 @@ import com.google.inject.Singleton;
import ch.ethz.matsim.av.framework.AVQSimPlugin; import ch.ethz.matsim.av.framework.AVQSimPlugin;
import ch.ethz.matsim.baseline_scenario.transit.simulation.BaselineTransitPlugin; import ch.ethz.matsim.baseline_scenario.transit.simulation.BaselineTransitPlugin;
import ch.ethz.matsim.projects.astra_2018_002.av.dynamics.AVModesQSimPlugin; import ch.ethz.matsim.projects.astra_2018_002.shared_av.dynamics.AVModesQSimPlugin;
public class ASTRAQSimModule extends AbstractModule { public class ASTRAQSimModule extends AbstractModule {
@Override @Override
......
package ch.ethz.matsim.projects.astra_2018_002; package ch.ethz.matsim.projects.astra_2018_002;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.Scenario;
import org.matsim.api.core.v01.network.Link;
import org.matsim.core.config.Config; import org.matsim.core.config.Config;
import org.matsim.core.config.ConfigUtils; import org.matsim.core.config.ConfigUtils;
import org.matsim.core.controler.Controler; import org.matsim.core.controler.Controler;
...@@ -17,17 +12,17 @@ import ch.ethz.matsim.baseline_scenario.traffic.BaselineTrafficModule; ...@@ -17,17 +12,17 @@ import ch.ethz.matsim.baseline_scenario.traffic.BaselineTrafficModule;
import ch.ethz.matsim.baseline_scenario.transit.BaselineTransitModule; import ch.ethz.matsim.baseline_scenario.transit.BaselineTransitModule;
import ch.ethz.matsim.baseline_scenario.transit.routing.DefaultEnrichedTransitRoute; import ch.ethz.matsim.baseline_scenario.transit.routing.DefaultEnrichedTransitRoute;
import ch.ethz.matsim.baseline_scenario.transit.routing.DefaultEnrichedTransitRouteFactory; import ch.ethz.matsim.baseline_scenario.transit.routing.DefaultEnrichedTransitRouteFactory;
import ch.ethz.matsim.projects.astra_2018_002.av.AVConfigurator;
import ch.ethz.matsim.projects.astra_2018_002.av.AssignPrivatAVs;
import ch.ethz.matsim.projects.astra_2018_002.flow_efficiency.FlowEfficiencyConfigurator; import ch.ethz.matsim.projects.astra_2018_002.flow_efficiency.FlowEfficiencyConfigurator;
import ch.ethz.matsim.projects.astra_2018_002.mode_choice.SwissDiscreteModeChoiceModule; import ch.ethz.matsim.projects.astra_2018_002.mode_choice.SwissDiscreteModeChoiceModule;
import ch.ethz.matsim.projects.astra_2018_002.mode_choice.SwissModeChoiceConfigurator; import ch.ethz.matsim.projects.astra_2018_002.mode_choice.SwissModeChoiceConfigurator;
import ch.ethz.matsim.projects.astra_2018_002.mode_choice.SwissUtilityParameters.UtilitySet; import ch.ethz.matsim.projects.astra_2018_002.mode_choice.SwissUtilityParameters.UtilitySet;
import ch.ethz.matsim.projects.astra_2018_002.private_av.PrivateAVConfigurator;
import ch.ethz.matsim.projects.astra_2018_002.shared_av.SharedAVConfigurator;
import ch.sbb.matsim.routing.pt.raptor.SwissRailRaptorModule; import ch.sbb.matsim.routing.pt.raptor.SwissRailRaptorModule;
public class RunASTRA2018002 { public class RunASTRA2018002 {
static public void main(String[] args) throws ConfigurationException { static public void main(String[] args) throws ConfigurationException {
CommandLine cmd = new CommandLine.Builder(args) // CommandLine cmd = new CommandLine.Builder(args) //
.requireOptions("config-path", "model") // .requireOptions("config-path", "model") //
.allowOptions("use-route-choice", "use-only-significant", "utility-parameters", "crossing-penalty") // .allowOptions("use-route-choice", "use-only-significant", "utility-parameters", "crossing-penalty") //
.allowPrefixes(SwissDiscreteModeChoiceModule.COMMAND_LINE_PREFIX) // .allowPrefixes(SwissDiscreteModeChoiceModule.COMMAND_LINE_PREFIX) //
...@@ -45,11 +40,11 @@ public class RunASTRA2018002 { ...@@ -45,11 +40,11 @@ public class RunASTRA2018002 {
// Load config // Load config
Config config = ConfigUtils.loadConfig(cmd.getOptionStrict("config-path")); Config config = ConfigUtils.loadConfig(cmd.getOptionStrict("config-path"));
// Adjust config // Adjust config (they need to stay in the correct order!)
SwissModeChoiceConfigurator.configure(config); SwissModeChoiceConfigurator.configure(config);
FlowEfficiencyConfigurator.configure(config); FlowEfficiencyConfigurator.configure(config);
AVConfigurator.configure(config); SharedAVConfigurator.configure(config);
PrivateAVConfigurator.configure(config);
cmd.applyConfiguration(config); cmd.applyConfiguration(config);
// Load scenario // Load scenario
...@@ -57,22 +52,11 @@ public class RunASTRA2018002 { ...@@ -57,22 +52,11 @@ public class RunASTRA2018002 {
scenario.getPopulation().getFactory().getRouteFactories().setRouteFactory(DefaultEnrichedTransitRoute.class, scenario.getPopulation().getFactory().getRouteFactories().setRouteFactory(DefaultEnrichedTransitRoute.class,
new DefaultEnrichedTransitRouteFactory()); new DefaultEnrichedTransitRouteFactory());
ScenarioUtils.loadScenario(scenario); ScenarioUtils.loadScenario(scenario);
// TODO: only until we actually assign allowed modes via the pipeline
for (Link link : scenario.getNetwork().getLinks().values()) {
Set<String> allowedModes = new HashSet<>(link.getAllowedModes());
if (allowedModes.contains("car")) {
allowedModes.addAll(Arrays.asList("prav3", "prav4", "prav5"));
}
link.setAllowedModes(allowedModes);
}
// Adjust scenario // Adjust scenario
SwissModeChoiceConfigurator.copyHousholdAttributes(scenario); SwissModeChoiceConfigurator.copyHousholdAttributes(scenario);
AssignPrivatAVs.main(scenario);
FlowEfficiencyConfigurator.defineVehicleTypes(scenario); FlowEfficiencyConfigurator.defineVehicleTypes(scenario);
ASTRAConfigurator.adjustNetwork(scenario);
// Set up controller // Set up controller
Controler controller = new Controler(scenario); Controler controller = new Controler(scenario);
...@@ -81,7 +65,7 @@ public class RunASTRA2018002 { ...@@ -81,7 +65,7 @@ public class RunASTRA2018002 {
controller.addOverridingModule(new ASTRAModule()); controller.addOverridingModule(new ASTRAModule());
controller.addOverridingModule( controller.addOverridingModule(
new BaselineTrafficModule(cmd.getOption("crossing-penalty").map(Double::parseDouble).orElse(3.0))); new BaselineTrafficModule(cmd.getOption("crossing-penalty").map(Double::parseDouble).orElse(3.0)));
AVConfigurator.configureController(controller); SharedAVConfigurator.configureController(controller);
UtilitySet utilitySet = Enum.valueOf(UtilitySet.class, cmd.getOptionStrict("model")); UtilitySet utilitySet = Enum.valueOf(UtilitySet.class, cmd.getOptionStrict("model"));
boolean useRouteChoice = cmd.getOption("use-route-choice").map(Boolean::parseBoolean).orElse(true); boolean useRouteChoice = cmd.getOption("use-route-choice").map(Boolean::parseBoolean).orElse(true);
......
...@@ -11,7 +11,7 @@ import org.matsim.api.core.v01.population.Person; ...@@ -11,7 +11,7 @@ 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.DiscreteModeChoiceTrip;
import ch.ethz.matsim.discrete_mode_choice.model.mode_availability.CarModeAvailability; import ch.ethz.matsim.discrete_mode_choice.model.mode_availability.CarModeAvailability;
import ch.ethz.matsim.projects.astra_2018_002.av.AssignPrivatAVs; import ch.ethz.matsim.projects.astra_2018_002.private_av.AssignPrivatAVs;
public class SwissModeAvailability extends CarModeAvailability { public class SwissModeAvailability extends CarModeAvailability {
public SwissModeAvailability(Collection<String> modes) { public SwissModeAvailability(Collection<String> modes) {
...@@ -21,7 +21,7 @@ public class SwissModeAvailability extends CarModeAvailability { ...@@ -21,7 +21,7 @@ public class SwissModeAvailability extends CarModeAvailability {
@Override @Override
public Collection<String> getAvailableModes(Person person, List<DiscreteModeChoiceTrip> trips) { public Collection<String> getAvailableModes(Person person, List<DiscreteModeChoiceTrip> trips) {
boolean bikeAvailability = !"FOR_NONE".equals((String) person.getAttributes().getAttribute("bikeAvailability")); boolean bikeAvailability = !"FOR_NONE".equals((String) person.getAttributes().getAttribute("bikeAvailability"));
Set<String> modes = new HashSet<>(); Set<String> modes = new HashSet<>();
if (!bikeAvailability) { if (!bikeAvailability) {
...@@ -30,14 +30,13 @@ public class SwissModeAvailability extends CarModeAvailability { ...@@ -30,14 +30,13 @@ public class SwissModeAvailability extends CarModeAvailability {
} else { } else {
modes.addAll(super.getAvailableModes(person, trips)); modes.addAll(super.getAvailableModes(person, trips));
} }
String pravAvailability = (String) person.getAttributes().getAttribute(AssignPrivatAVs.AV_AVAILABILITY_ATTRIBUTE); String pravAvailability = (String) person.getAttributes()
.getAttribute(AssignPrivatAVs.AV_AVAILABILITY_ATTRIBUTE);
if (!pravAvailability.equals("noPrav")) {
if (pravAvailability != null && !pravAvailability.equals("noPrav")) {
modes.add(pravAvailability); modes.add(pravAvailability);
} }
System.err.println(modes);
return modes; return modes;
} }
......
...@@ -36,7 +36,7 @@ public class SwissModeChoiceConfigurator { ...@@ -36,7 +36,7 @@ public class SwissModeChoiceConfigurator {
dmcConfig.setTripEstimator(SwissDiscreteModeChoiceModule.SWISS_ESTIMATOR_NAME); dmcConfig.setTripEstimator(SwissDiscreteModeChoiceModule.SWISS_ESTIMATOR_NAME);
dmcConfig.setTourEstimator(EstimatorModule.CUMULATIVE); dmcConfig.setTourEstimator(EstimatorModule.CUMULATIVE);
dmcConfig.setCachedModes(Arrays.asList("car", "bike", "pt", "walk", "prav3", "prav4", "prav5")); dmcConfig.setCachedModes(Arrays.asList("car", "bike", "pt", "walk"));
dmcConfig.setTourFinder(TourFinderModule.ACTIVITY_BASED); dmcConfig.setTourFinder(TourFinderModule.ACTIVITY_BASED);
dmcConfig.getActivityTourFinderConfigGroup().setActivityType("home"); dmcConfig.getActivityTourFinderConfigGroup().setActivityType("home");
...@@ -49,12 +49,7 @@ public class SwissModeChoiceConfigurator { ...@@ -49,12 +49,7 @@ public class SwissModeChoiceConfigurator {
dmcConfig.setTripConstraints(Arrays.asList(ConstraintModule.TRANSIT_WALK)); dmcConfig.setTripConstraints(Arrays.asList(ConstraintModule.TRANSIT_WALK));
dmcConfig.getVehicleTourConstraintConfig().setHomeType(HomeType.USE_ACTIVITY_TYPE); dmcConfig.getVehicleTourConstraintConfig().setHomeType(HomeType.USE_ACTIVITY_TYPE);
dmcConfig.getVehicleTourConstraintConfig().setRestrictedModes(Arrays.asList("car", "bike", "prav3", "prav4", "prav5")); dmcConfig.getVehicleTourConstraintConfig().setRestrictedModes(Arrays.asList("car", "bike"));
config.plansCalcRoute().setNetworkModes(Arrays.asList("car","prav3", "prav4", "prav5"));
config.qsim().setMainModes(Arrays.asList("car","prav3", "prav4", "prav5"));
config.travelTimeCalculator().setAnalyzedModes("car,prav3,prav4,prav5");
config.travelTimeCalculator().setSeparateModes(false);
// These parameters are only used by SwissRailRaptor. We configure the // These parameters are only used by SwissRailRaptor. We configure the
// parameters here in a way that SRR searches for the route with the shortest // parameters here in a way that SRR searches for the route with the shortest
...@@ -80,15 +75,6 @@ public class SwissModeChoiceConfigurator { ...@@ -80,15 +75,6 @@ public class SwissModeChoiceConfigurator {
ModeRoutingParams walkParams = config.plansCalcRoute().getModeRoutingParams().get(TransportMode.walk); ModeRoutingParams walkParams = config.plansCalcRoute().getModeRoutingParams().get(TransportMode.walk);
walkParams.setBeelineDistanceFactor(1.3); walkParams.setBeelineDistanceFactor(1.3);
walkParams.setTeleportedModeSpeed(1.2); // 4.32 km/h walkParams.setTeleportedModeSpeed(1.2); // 4.32 km/h
ModeParams prav3Params = new ModeParams("prav3");
config.planCalcScore().addModeParams(prav3Params);
ModeParams prav4Params = new ModeParams("prav4");
config.planCalcScore().addModeParams(prav4Params);
ModeParams prav5Params = new ModeParams("prav5");
config.planCalcScore().addModeParams(prav5Params);
} }
static public void copyHousholdAttributes(Scenario scenario) { static public void copyHousholdAttributes(Scenario scenario) {
......
...@@ -8,10 +8,11 @@ import org.matsim.pt.transitSchedule.api.TransitSchedule; ...@@ -8,10 +8,11 @@ import org.matsim.pt.transitSchedule.api.TransitSchedule;
import ch.ethz.matsim.discrete_mode_choice.model.DiscreteModeChoiceTrip; import ch.ethz.matsim.discrete_mode_choice.model.DiscreteModeChoiceTrip;
import ch.ethz.matsim.projects.astra_2018_002.mode_choice.base.BaseUtilityEstimator; import ch.ethz.matsim.projects.astra_2018_002.mode_choice.base.BaseUtilityEstimator;
import ch.ethz.matsim.projects.astra_2018_002.mode_choice.base.PersonVariables; import ch.ethz.matsim.projects.astra_2018_002.mode_choice.base.PersonVariables;
import ch.ethz.matsim.projects.astra_2018_002.mode_choice.base.TripVariablesAv;
import ch.ethz.matsim.projects.astra_2018_002.mode_choice.base.TripVariablesBike; import ch.ethz.matsim.projects.astra_2018_002.mode_choice.base.TripVariablesBike;
import ch.ethz.matsim.projects.astra_2018_002.mode_choice.base.TripVariablesCar; import ch.ethz.matsim.projects.astra_2018_002.mode_choice.base.TripVariablesCar;
import ch.ethz.matsim.projects.astra_2018_002.mode_choice.base.TripVariablesPrivateAv;
import ch.ethz.matsim.projects.astra_2018_002.mode_choice.base.TripVariablesPt; import ch.ethz.matsim.projects.astra_2018_002.mode_choice.base.TripVariablesPt;
import ch.ethz.matsim.projects.astra_2018_002.mode_choice.base.TripVariablesSharedAv;
import ch.ethz.matsim.projects.astra_2018_002.mode_choice.base.TripVariablesWalk; import ch.ethz.matsim.projects.astra_2018_002.mode_choice.base.TripVariablesWalk;
import ch.ethz.matsim.projects.astra_2018_002.mode_choice.cost.CostModel; import ch.ethz.matsim.projects.astra_2018_002.mode_choice.cost.CostModel;
...@@ -203,8 +204,8 @@ public class SwissUtilityEstimator extends BaseUtilityEstimator { ...@@ -203,8 +204,8 @@ public class SwissUtilityEstimator extends BaseUtilityEstimator {
} }
@Override @Override
public double estimateAvTrip(DiscreteModeChoiceTrip trip, PersonVariables personVariables, public double estimateSharedAvTrip(DiscreteModeChoiceTrip trip, PersonVariables personVariables,
TripVariablesAv tripVariables) { TripVariablesSharedAv tripVariables) {
double utility = 0.0; double utility = 0.0;
// TODO: Right now we use utilties from car and waiting is not scored! // TODO: Right now we use utilties from car and waiting is not scored!
...@@ -232,19 +233,54 @@ public class SwissUtilityEstimator extends BaseUtilityEstimator { ...@@ -232,19 +233,54 @@ public class SwissUtilityEstimator extends BaseUtilityEstimator {
} }
@Override @Override
public double estimatePrivateVehicleTrip(DiscreteModeChoiceTrip trip, PersonVariables personVariables, public double estimatePrivateAVTrip(DiscreteModeChoiceTrip trip, PersonVariables personVariables,
TripVariablesCar tripVariables, String mode) { TripVariablesPrivateAv tripVariables) {
double utility = 0.0;
double betaTravelTime = 0.0;
switch (tripVariables.automationLevel) {
case LEVEL3:
betaTravelTime = parameters.prav.betaTravelTimeLevel3;
break;
case LEVEL4:
betaTravelTime = parameters.prav.betaTravelTimeLevel4;
break;
case LEVEL5:
betaTravelTime = parameters.prav.betaTravelTimeLevel5;
break;
default:
throw new IllegalStateException();
}
utility += parameters.prav.alpha;
utility += betaTravelTime * tripVariables.travelTime_min;
utility += parameters.betaCost //
* interaction(tripVariables.crowflyDistance_km, parameters.referenceCrowflyDistance_km,
parameters.lambdaCostCrowflyDistance) //
* tripVariables.travelCost_CHF;
utility += parameters.walk.betaTravelTime * parameters.prav.constantAccessEgressWalkTime_min;
return utility;
}
@Override
public double estimateCarTrip(DiscreteModeChoiceTrip trip, PersonVariables personVariables,
TripVariablesCar tripVariables) {
double utility = 0.0; double utility = 0.0;
utility += parameters.car.alpha; utility += parameters.car.alpha;
// TODO: Consider private AV VOT here.
utility += parameters.car.betaTravelTime // utility += parameters.car.betaTravelTime //
* interaction(tripVariables.travelDistance_km, parameters.referenceDistance_km, * interaction(tripVariables.travelDistance_km, parameters.referenceDistance_km,
parameters.car.lambdaTravelTimeDistance) // parameters.car.lambdaTravelTimeDistance) //
* tripVariables.travelTime_min; * tripVariables.travelTime_min;
utility += parameters.car.betaParkingSearchTime * tripVariables.parkingSearchTime_min; double parkingSearchTime_min = tripVariables.parkingSearchTime_min
+ parameters.car.constantParkingSearchPenalty_min;
utility += parameters.car.betaParkingSearchTime * parkingSearchTime_min;
utility += parameters.betaCost // utility += parameters.betaCost //
* interaction(tripVariables.travelDistance_km, parameters.referenceDistance_km, * interaction(tripVariables.travelDistance_km, parameters.referenceDistance_km,
parameters.car.lambdaCostDistance) // parameters.car.lambdaCostDistance) //
...@@ -273,6 +309,8 @@ public class SwissUtilityEstimator extends BaseUtilityEstimator { ...@@ -273,6 +309,8 @@ public class SwissUtilityEstimator extends BaseUtilityEstimator {
parameters.lambdaDelayDistance) // parameters.lambdaDelayDistance) //
* tripVariables.delay_min; * tripVariables.delay_min;
utility += parameters.walk.betaTravelTime * parameters.car.constantAccessEgressWalkTime_min;
return utility; return utility;
} }
......
...@@ -112,7 +112,6 @@ public class SwissUtilityParameters { ...@@ -112,7 +112,6 @@ public class SwissUtilityParameters {
public double betaTravelTime = 0.0; public double betaTravelTime = 0.0;
public double betaParkingSearchTime = 0.0; public double betaParkingSearchTime = 0.0;
public double betaParkingCost = 0.0; public double betaParkingCost = 0.0;
public double betaAccessEgressTime = 0.0;
public double betaAlwaysAvailable = 0.0; public double betaAlwaysAvailable = 0.0;
...@@ -123,9 +122,9 @@ public class SwissUtilityParameters { ...@@ -123,9 +122,9 @@ public class SwissUtilityParameters {
public double lambdaTravelTimeDistance = 0.0; public double lambdaTravelTimeDistance = 0.0;
public double lambdaCostDistance = 0.0; public double lambdaCostDistance = 0.0;
public double constantAccessEgressWalkTime_min = 0.0; public double constantAccessEgressWalkTime_min = 0.0;
public double constantParkingSearchPenalty = 0.0; public double constantParkingSearchPenalty_min = 0.0;
} }
public CarParameters car = new CarParameters(); public CarParameters car = new CarParameters();
...@@ -162,6 +161,19 @@ public class SwissUtilityParameters { ...@@ -162,6 +161,19 @@ public class SwissUtilityParameters {
public PtParameters pt = new PtParameters(); public PtParameters pt = new PtParameters();
// VI) Private AV
public class PrivateAVParameters {
public double alpha = 0.0;
public double betaTravelTimeLevel3 = 0.0;
public double betaTravelTimeLevel4 = 0.0;
public double betaTravelTimeLevel5 = 0.0;
public double constantAccessEgressWalkTime_min = 0.0;
}
public PrivateAVParameters prav = new PrivateAVParameters();
/** /**
* Chapter 3.2.1: Modell with linear utility function WITHOUT sociodemographics * Chapter 3.2.1: Modell with linear utility function WITHOUT sociodemographics
*/ */
......
...@@ -17,9 +17,10 @@ import ch.ethz.matsim.baseline_scenario.transit.routing.EnrichedTransitRoute; ...@@ -17,9 +17,10 @@ import ch.ethz.matsim.baseline_scenario.transit.routing.EnrichedTransitRoute;
import ch.ethz.matsim.discrete_mode_choice.components.estimators.AbstractTripRouterEstimator; import ch.ethz.matsim.discrete_mode_choice.components.estimators.AbstractTripRouterEstimator;
import ch.ethz.matsim.discrete_mode_choice.model.DiscreteModeChoiceTrip; import ch.ethz.matsim.discrete_mode_choice.model.DiscreteModeChoiceTrip;
import ch.ethz.matsim.discrete_mode_choice.model.trip_based.candidates.TripCandidate; import ch.ethz.matsim.discrete_mode_choice.model.trip_based.candidates.TripCandidate;
import ch.ethz.matsim.projects.astra_2018_002.av.ASTRAAVModule; import ch.ethz.matsim.projects.astra_2018_002.mode_choice.base.TripVariablesPrivateAv.AutomationLevel;
import ch.ethz.matsim.projects.astra_2018_002.av.routing.ExtendedAVRoute;
import ch.ethz.matsim.projects.astra_2018_002.mode_choice.cost.CostModel; import ch.ethz.matsim.projects.astra_2018_002.mode_choice.cost.CostModel;
import ch.ethz.matsim.projects.astra_2018_002.shared_av.SharedAVModule;
import ch.ethz.matsim.projects.astra_2018_002.shared_av.routing.ExtendedAVRoute;
/** /**
* Estimates trip utilities based on * Estimates trip utilities based on
...@@ -83,27 +84,28 @@ public abstract class BaseUtilityEstimator extends AbstractTripRouterEstimator { ...@@ -83,27 +84,28 @@ public abstract class BaseUtilityEstimator extends AbstractTripRouterEstimator {
return estimateWalkTrip(personVariables, trip, routedTrip); return estimateWalkTrip(personVariables, trip, routedTrip);
case TransportMode.bike: case TransportMode.bike:
return estimateBikeTrip(personVariables, trip, routedTrip); return estimateBikeTrip(personVariables, trip, routedTrip);
case TransportMode.car:
case "prav3": case "prav3":
case "prav4": case "prav4":
case "prav5": case "prav5":
return estimatePrivateVehicleTrip(personVariables, trip, routedTrip, mode); return estimatePrivateAVTrip(personVariables, trip, routedTrip);
case TransportMode.car:
return estimateCarTrip(personVariables, trip, routedTrip);
case TransportMode.pt: case TransportMode.pt:
return estimatePtTrip(personVariables, trip, routedTrip); return estimatePtTrip(personVariables, trip, routedTrip);
case ASTRAAVModule.AV_POOL: case SharedAVModule.AV_POOL:
case ASTRAAVModule.AV_TAXI: case SharedAVModule.AV_TAXI:
return estimateAvTrip(personVariables, trip, routedTrip); return estimateSharedAvTrip(personVariables, trip, routedTrip);
default: default:
throw new IllegalStateException("Unknown mode: " + mode); throw new IllegalStateException("Unknown mode: " + mode);
} }
} }
abstract protected double estimateAvTrip(DiscreteModeChoiceTrip trip, PersonVariables personVariables, abstract protected double estimateSharedAvTrip(DiscreteModeChoiceTrip trip, PersonVariables personVariables,
TripVariablesAv tripVariables); TripVariablesSharedAv tripVariables);
private double estimateAvTrip(PersonVariables personVariables, DiscreteModeChoiceTrip trip, private double estimateSharedAvTrip(PersonVariables personVariables, DiscreteModeChoiceTrip trip,
List<? extends PlanElement> elements) { List<? extends PlanElement> elements) {
TripVariablesAv tripVariables = new TripVariablesAv(); TripVariablesSharedAv tripVariables = new TripVariablesSharedAv();
double travelDistance_km = 0.0; double travelDistance_km = 0.0;
double totalTravelTime = 0.0; double totalTravelTime = 0.0;
...@@ -119,8 +121,8 @@ public abstract class BaseUtilityEstimator extends AbstractTripRouterEstimator { ...@@ -119,8 +121,8 @@ public abstract class BaseUtilityEstimator extends AbstractTripRouterEstimator {
tripVariables.accessEgressTime_min += leg.getTravelTime() / 60.0; tripVariables.accessEgressTime_min += leg.getTravelTime() / 60.0;
travelDistance_km += leg.getRoute().getDistance() / 1000.0; travelDistance_km += leg.getRoute().getDistance() / 1000.0;
break; break;
case ASTRAAVModule.AV_POOL: case SharedAVModule.AV_POOL:
case ASTRAAVModule.AV_TAXI: case SharedAVModule.AV_TAXI:
ExtendedAVRoute route = (ExtendedAVRoute) leg.getRoute(); ExtendedAVRoute route = (ExtendedAVRoute) leg.getRoute();
tripVariables.inVehicleTime_min += route.getTravelTime() / 60.0; tripVariables.inVehicleTime_min += route.getTravelTime() / 60.0;
tripVariables.waitingTime_min += route.getWaitingTime() / 60.0; tripVariables.waitingTime_min += route.getWaitingTime() / 60.0;
...@@ -137,7 +139,7 @@ public abstract class BaseUtilityEstimator extends AbstractTripRouterEstimator { ...@@ -137,7 +139,7 @@ public abstract class BaseUtilityEstimator extends AbstractTripRouterEstimator {
tripVariables.delay_min = calculateDelay(trip, totalTravelTime) / 60.0; tripVariables.delay_min = calculateDelay(trip, totalTravelTime) / 60.0;
tripVariables.travelDistance_km = travelDistance_km; tripVariables.travelDistance_km = travelDistance_km;
return estimateAvTrip(trip, personVariables, tripVariables); return estimateSharedAvTrip(trip, personVariables, tripVariables);
} }
abstract protected double estimatePtTrip(DiscreteModeChoiceTrip trip, PersonVariables personVariables, abstract protected double estimatePtTrip(DiscreteModeChoiceTrip trip, PersonVariables personVariables,
...@@ -235,11 +237,44 @@ public abstract class BaseUtilityEstimator extends AbstractTripRouterEstimator { ...@@ -235,11 +237,44 @@ public abstract class BaseUtilityEstimator extends AbstractTripRouterEstimator {
return estimatePtTrip(trip, personVariables, tripVariables); return estimatePtTrip(trip, personVariables, tripVariables);
} }