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

Consider online costs and make waiting time estimation configurable

parent 754f660f
......@@ -17,6 +17,7 @@ import ch.ethz.matsim.projects.astra_2018_002.mode_choice.SwissDiscreteModeChoic
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.private_av.PrivateAVConfigurator;
import ch.ethz.matsim.projects.astra_2018_002.shared_av.SharedAVConfigGroup;
import ch.ethz.matsim.projects.astra_2018_002.shared_av.SharedAVConfigurator;
import ch.sbb.matsim.routing.pt.raptor.SwissRailRaptorModule;
......@@ -29,8 +30,15 @@ public class RunASTRA2018002 {
.allowPrefixes(SwissDiscreteModeChoiceModule.COMMAND_LINE_PREFIX) //
.build();
SharedAVConfigGroup sharedConfig = new SharedAVConfigGroup();
sharedConfig.setUseSharedAVs(true);
sharedConfig.setTaxiFleetSize(1000);
sharedConfig.setActiveServiceArea("fribourg");
sharedConfig.setUseCostCalculator(true);
sharedConfig.setCostCalculatorScalingFactor(1000.0);
// Load config
Config config = ConfigUtils.loadConfig(cmd.getOptionStrict("config-path"));
Config config = ConfigUtils.loadConfig(cmd.getOptionStrict("config-path"), sharedConfig);
config.controler().setWriteEventsInterval(1);
// Adjust config (they need to stay in the correct order!)
......
......@@ -22,6 +22,7 @@ import ch.ethz.matsim.projects.astra_2018_002.mode_choice.cost.CostModel;
import ch.ethz.matsim.projects.astra_2018_002.mode_choice.cost.CostParameters;
import ch.ethz.matsim.projects.astra_2018_002.mode_choice.outside.OutsideConstraint;
import ch.ethz.matsim.projects.astra_2018_002.mode_choice.outside.SwissTourFinder;
import ch.ethz.matsim.projects.astra_2018_002.shared_av.pricing.SharedAVTravelCost;
public class SwissDiscreteModeChoiceModule extends AbstractDiscreteModeChoiceExtension {
public final static String COMMAND_LINE_PREFIX = "utility";
......@@ -76,8 +77,8 @@ public class SwissDiscreteModeChoiceModule extends AbstractDiscreteModeChoiceExt
@Provides
@Singleton
public CostModel provideCostModel(SwissUtilityParameters parameters) {
return new CostModel(parameters.costs);
public CostModel provideCostModel(SwissUtilityParameters parameters, SharedAVTravelCost sharedCost) {
return new CostModel(parameters.costs, sharedCost);
}
@Provides
......
......@@ -2,12 +2,15 @@ package ch.ethz.matsim.projects.astra_2018_002.mode_choice.cost;
import ch.ethz.matsim.projects.astra_2018_002.mode_choice.base.PersonVariables;
import ch.ethz.matsim.projects.astra_2018_002.mode_choice.base.TripVariablesPt;
import ch.ethz.matsim.projects.astra_2018_002.shared_av.pricing.SharedAVTravelCost;
public class CostModel {
private final CostParameters parameters;
private final SharedAVTravelCost shared;
public CostModel(CostParameters parameters) {
public CostModel(CostParameters parameters, SharedAVTravelCost shared) {
this.parameters = parameters;
this.shared = shared;
}
public double calculateCarTravelCost(double distance_km) {
......@@ -19,11 +22,7 @@ public class CostModel {
}
public double calculateSharedAvTravelCost(double distance_km, boolean isPooled) {
if (isPooled) {
return parameters.pooledAvCostPerKm_CHF * distance_km;
} else {
return parameters.taxiAvCostPerKm_CHF * distance_km;
}
return shared.getTravelCost(distance_km, isPooled);
}
public double calculatePtTravelCost(PersonVariables personVariables, TripVariablesPt tripVariables) {
......
......@@ -18,6 +18,7 @@ import ch.ethz.matsim.projects.astra_2018_002.mode_choice.base.TripVariablesPt;
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.CostParameters;
import ch.ethz.matsim.projects.astra_2018_002.shared_av.pricing.DefaultSharedAVTravelCost;
public class TestUtility {
static public void main(String[] args) throws ConfigurationException {
......@@ -26,7 +27,7 @@ public class TestUtility {
.build();
CostParameters costParameters = new CostParameters();
CostModel costModel = new CostModel(costParameters);
CostModel costModel = new CostModel(costParameters, new DefaultSharedAVTravelCost(costParameters));
SwissUtilityParameters parameters = SwissUtilityParameters.build(UtilitySet.APPENDIX_A5, true, false);
SwissUtilityParameters.adaptFromCommandLine(parameters, cmd);
......
......@@ -19,6 +19,13 @@ public class SharedAVConfigGroup extends ReflectiveConfigGroup {
private final static String WAITING_TIME_ZONE_ATTRIBUTE = "waitingTimeZoneAttribute";
private final static String COST_CALCULATOR_SCALING_FACTOR = "costCalculatorScalingFactor";
private final static String COST_CALCULATOR_HORIZON = "costCalculatorHorizon";
private final static String WAITING_TIME_ESTIMATOR_START_TIME = "waitingTimeEstimatorStartTime";
private final static String WAITING_TIME_ESTIMATOR_END_TIME = "waitingTimeEstimatorEndTime";
private final static String WAITING_TIME_ESTIMATOR_INTERVAL = "waitingTimeEstimatorInterval";
private final static String WAITING_TIME_ESTIMATOR_HORIZON = "waitingTimeEstimatorHorizon";
private final static String WAITING_TIME_ESTIMATOR_FALLBACK_VALUE = "waitingTimeEstimatorFallbackValue";
private boolean useSharedAVs = false;
private boolean useCostCalculator = false;
......@@ -34,6 +41,13 @@ public class SharedAVConfigGroup extends ReflectiveConfigGroup {
private String waitingTimeZoneShapefile = "waiting_time_zones.shp";
private double costCalculatorScalingFactor = 1.0;
private int costCalculatorHorizon = 10;
private double waitingTimeEstimatorStartTime = 8.0 * 3600.0;
private double waitingTimeEstimatorEndTime = 22.0 * 3600.0;
private double waitingTimeEstimatorInterval = 900.0;
private int waitingTimeEstimatorHorizon = 10;
private double waitingTimeEstimatorFallbackValue = 300.0;
public SharedAVConfigGroup() {
super(GROUP_NAME);
......@@ -138,4 +152,64 @@ public class SharedAVConfigGroup extends ReflectiveConfigGroup {
public void setCostCalculatorScalingFactor(double costCalculatorScalingFactor) {
this.costCalculatorScalingFactor = costCalculatorScalingFactor;
}
@StringGetter(COST_CALCULATOR_HORIZON)
public int getCostCalculatorHorzion() {
return costCalculatorHorizon;
}
@StringSetter(COST_CALCULATOR_HORIZON)
public void setCostCalculatorHorzion(int costCalculatorHorizon) {
this.costCalculatorHorizon = costCalculatorHorizon;
}
@StringGetter(WAITING_TIME_ESTIMATOR_START_TIME)
public double getWaitingTimeEstimatorStartTime() {
return waitingTimeEstimatorStartTime;
}
@StringSetter(WAITING_TIME_ESTIMATOR_START_TIME)
public void setWaitingTimeEstimatorStartTime(double waitingTimeEstimatorStartTime) {
this.waitingTimeEstimatorStartTime = waitingTimeEstimatorStartTime;
}
@StringGetter(WAITING_TIME_ESTIMATOR_END_TIME)
public double getWaitingTimeEstimatorEndTime() {
return waitingTimeEstimatorEndTime;
}
@StringSetter(WAITING_TIME_ESTIMATOR_END_TIME)
public void setWaitingTimeEstimatorEndTime(double waitingTimeEstimatorEndTime) {
this.waitingTimeEstimatorEndTime = waitingTimeEstimatorEndTime;
}
@StringGetter(WAITING_TIME_ESTIMATOR_INTERVAL)
public double getWaitingTimeEstimatorInterval() {
return waitingTimeEstimatorInterval;
}
@StringSetter(WAITING_TIME_ESTIMATOR_INTERVAL)
public void setWaitingTimeEstimatorInterval(double waitingTimeEstimatorInterval) {
this.waitingTimeEstimatorInterval = waitingTimeEstimatorInterval;
}
@StringGetter(WAITING_TIME_ESTIMATOR_HORIZON)
public int getWaitingTimeEstimatorHorizon() {
return waitingTimeEstimatorHorizon;
}
@StringSetter(WAITING_TIME_ESTIMATOR_HORIZON)
public void getWaitingTimeEstimatorHorizon(int waitingTimeEstimatorHorizon) {
this.waitingTimeEstimatorHorizon = waitingTimeEstimatorHorizon;
}
@StringGetter(WAITING_TIME_ESTIMATOR_FALLBACK_VALUE)
public double getWaitingTimeEstimatorFallbackValue() {
return waitingTimeEstimatorFallbackValue;
}
@StringSetter(WAITING_TIME_ESTIMATOR_FALLBACK_VALUE)
public void setWaitingTimeEstimatorFallbackValue(double waitingTimeEstimatorFallbackValue) {
this.waitingTimeEstimatorFallbackValue = waitingTimeEstimatorFallbackValue;
}
}
......@@ -78,7 +78,9 @@ public class SharedAVConfigurator {
if (sharedConfig.getUseCostCalculator()) {
double scalingFactor = sharedConfig.getCostCalculatorScalingFactor();
controller.addOverridingModule(new AVPricingModule(scalingFactor, 10));
int horizon = sharedConfig.getCostCalculatorHorzion();
controller.addOverridingModule(new AVPricingModule(scalingFactor, horizon));
}
}
}
......
......@@ -30,7 +30,10 @@ import ch.ethz.matsim.av.framework.AVUtils;
import ch.ethz.matsim.av.routing.AVRouteFactory;
import ch.ethz.matsim.discrete_mode_choice.modules.AbstractDiscreteModeChoiceExtension;
import ch.ethz.matsim.projects.astra_2018_002.flow_efficiency.FlowEfficiencyConfigurator;
import ch.ethz.matsim.projects.astra_2018_002.mode_choice.cost.CostParameters;
import ch.ethz.matsim.projects.astra_2018_002.shared_av.analysis.WaitingTimeListener;
import ch.ethz.matsim.projects.astra_2018_002.shared_av.pricing.DefaultSharedAVTravelCost;
import ch.ethz.matsim.projects.astra_2018_002.shared_av.pricing.SharedAVTravelCost;
import ch.ethz.matsim.projects.astra_2018_002.shared_av.routing.ASTRAAVRoutingModule;
import ch.ethz.matsim.projects.astra_2018_002.shared_av.service_area.ServiceArea;
import ch.ethz.matsim.projects.astra_2018_002.shared_av.service_area.ServiceAreaConstraint;
......@@ -152,25 +155,25 @@ public class SharedAVModule extends AbstractDiscreteModeChoiceExtension {
@Singleton
@Named(AV_TAXI)
private ZonalWaitingTime provideAvTaxiWaitingTime(@Named(AVModule.AV_MODE) Network network,
List<WaitingTimeZone> waitingTimeZones) {
return provideAvWaitingTime(AV_TAXI, network, waitingTimeZones);
List<WaitingTimeZone> waitingTimeZones, SharedAVConfigGroup sharedConfig) {
return provideAvWaitingTime(AV_TAXI, network, waitingTimeZones, sharedConfig);
}
@Provides
@Singleton
@Named(AV_POOL)
private ZonalWaitingTime provideAvPoolWaitingTime(@Named(AVModule.AV_MODE) Network network,
List<WaitingTimeZone> waitingTimeZones) {
return provideAvWaitingTime(AV_POOL, network, waitingTimeZones);
List<WaitingTimeZone> waitingTimeZones, SharedAVConfigGroup sharedConfig) {
return provideAvWaitingTime(AV_POOL, network, waitingTimeZones, sharedConfig);
}
private ZonalWaitingTime provideAvWaitingTime(String mode, Network network,
List<WaitingTimeZone> waitingTimeZones) {
double estimationStartTime = 8.0 * 3600.0;
double estimationEndTime = 22.0 * 3600.0;
double estimationInterval = 900.0;
int horizon = 10;
double defaultWaitingTime = 300.0;
private ZonalWaitingTime provideAvWaitingTime(String mode, Network network, List<WaitingTimeZone> waitingTimeZones,
SharedAVConfigGroup sharedConfig) {
double estimationStartTime = sharedConfig.getWaitingTimeEstimatorStartTime();
double estimationEndTime = sharedConfig.getWaitingTimeEstimatorEndTime();
double estimationInterval = sharedConfig.getWaitingTimeEstimatorInterval();
int horizon = sharedConfig.getWaitingTimeEstimatorHorizon();
double defaultWaitingTime = sharedConfig.getWaitingTimeEstimatorFallbackValue();
return new ZonalWaitingTime(mode, estimationStartTime, estimationEndTime, estimationInterval, horizon,
defaultWaitingTime, network, waitingTimeZones);
......@@ -190,4 +193,10 @@ public class SharedAVModule extends AbstractDiscreteModeChoiceExtension {
public VehicleType provideVehicleType(Scenario scenario) {
return scenario.getVehicles().getVehicleTypes().get(FlowEfficiencyConfigurator.SHARED_AV_VEHICLE_TYPE_ID);
}
@Singleton
@Provides
public SharedAVTravelCost provideTravelCost(CostParameters costParameters) {
return new DefaultSharedAVTravelCost(costParameters);
}
}
......@@ -86,4 +86,11 @@ public class AVPricingModule extends AbstractModule {
return new CostCalculatorExecutor(workingDirectory, sourceURL);
}
@Singleton
@Provides
public SharedAVTravelCost provideTravelCost(@Named(SharedAVModule.AV_TAXI) AVPricingListener taxiListener,
@Named(SharedAVModule.AV_POOL) AVPricingListener pooledListener) {
return new OnlineSharedAVTravelCost(taxiListener, pooledListener);
}
}
package ch.ethz.matsim.projects.astra_2018_002.shared_av.pricing;
import ch.ethz.matsim.projects.astra_2018_002.mode_choice.cost.CostParameters;
public class DefaultSharedAVTravelCost implements SharedAVTravelCost {
private final CostParameters costParameters;
public DefaultSharedAVTravelCost(CostParameters costParameters) {
this.costParameters = costParameters;
}
@Override
public double getTravelCost(double distance_km, boolean isPooled) {
if (isPooled) {
return costParameters.pooledAvCostPerKm_CHF * distance_km;
} else {
return costParameters.taxiAvCostPerKm_CHF * distance_km;
}
}
}
package ch.ethz.matsim.projects.astra_2018_002.shared_av.pricing;
public class OnlineSharedAVTravelCost implements SharedAVTravelCost {
private final AVPricingListener taxiListener;
private final AVPricingListener pooledListener;
public OnlineSharedAVTravelCost(AVPricingListener taxiListener, AVPricingListener pooledListener) {
this.taxiListener = taxiListener;
this.pooledListener = pooledListener;
}
@Override
public double getTravelCost(double distance_km, boolean isPooled) {
if (isPooled) {
return pooledListener.getPricePerKm() * distance_km;
} else {
return taxiListener.getPricePerKm() * distance_km;
}
}
}
package ch.ethz.matsim.projects.astra_2018_002.shared_av.pricing;
public interface SharedAVTravelCost {
public double getTravelCost(double distance_km, boolean isPooled);
}
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