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

Consider different cost reduction for rail and non-rail

parent f47e2e6b
......@@ -28,13 +28,13 @@ public class RunASTRA2018002 {
CommandLine cmd = new CommandLine.Builder(args) //
.requireOptions("config-path", "year", "ASTRA_Scenario") //
.allowOptions("use-route-choice", "use-only-significant", "utility-parameters", "crossing-penalty",
"model", "pt-cost-reduction") //
"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"
// 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(),
......
......@@ -95,7 +95,7 @@ public class SwissDiscreteModeChoiceModule extends AbstractDiscreteModeChoiceExt
@Provides
@Singleton
public CostModel provideCostModel(SwissUtilityParameters parameters, SharedAVTravelCost sharedCost) {
boolean usePtCostReduction = cmd.getOption("pt-cost-reduction").map(Boolean::parseBoolean).orElse(true);
boolean usePtCostReduction = year >= 2050;
return new CostModel(parameters.costs, sharedCost, year, usePtCostReduction);
}
......
......@@ -211,13 +211,10 @@ public abstract class BaseUtilityEstimator extends AbstractTripRouterEstimator {
abstract protected double estimatePtTrip(DiscreteModeChoiceTrip trip, PersonVariables personVariables,
TripVariablesPt tripVariables);
private TripVariablesPt.MainMode updatePtMainMode(EnrichedTransitRoute route, TripVariablesPt.MainMode current) {
String mainMode = transitSchedule.getTransitLines().get(route.getTransitLineId()).getRoutes()
.get(route.getTransitRouteId()).getTransportMode();
if (current.equals(TripVariablesPt.MainMode.Rail) || mainMode.equals("rail")) {
private TripVariablesPt.MainMode updatePtMainMode(String transportMode, TripVariablesPt.MainMode current) {
if (current.equals(TripVariablesPt.MainMode.Rail) || transportMode.equals("rail")) {
return TripVariablesPt.MainMode.Rail;
} else if (current.equals(TripVariablesPt.MainMode.Tram) || mainMode.equals("tram")) {
} else if (current.equals(TripVariablesPt.MainMode.Tram) || transportMode.equals("tram")) {
return TripVariablesPt.MainMode.Tram;
} else {
return TripVariablesPt.MainMode.Bus;
......@@ -250,6 +247,7 @@ public abstract class BaseUtilityEstimator extends AbstractTripRouterEstimator {
int numberOfVehicularTrips = 0;
boolean isFirstWaitingTime = true;
double inVehicleDistance_km = 0.0;
double inRailDistance_km = 0.0;
double totalTravelTime = 0.0;
double totalTravelDistance = 0.0;
......@@ -271,6 +269,8 @@ public abstract class BaseUtilityEstimator extends AbstractTripRouterEstimator {
break;
case TransportMode.pt:
EnrichedTransitRoute route = (EnrichedTransitRoute) leg.getRoute();
String transportMode = transitSchedule.getTransitLines().get(route.getTransitLineId()).getRoutes()
.get(route.getTransitRouteId()).getTransportMode();
tripVariables.inVehicleTime_min += route.getInVehicleTime() / 60.0;
......@@ -280,10 +280,15 @@ public abstract class BaseUtilityEstimator extends AbstractTripRouterEstimator {
isFirstWaitingTime = false;
}
tripVariables.mainMode = updatePtMainMode(route, tripVariables.mainMode);
tripVariables.mainMode = updatePtMainMode(transportMode, tripVariables.mainMode);
inVehicleDistance_km += route.getDistance() / 1000.0;
numberOfVehicularTrips++;
if (transportMode.equals("rail")) {
inRailDistance_km += route.getDistance() / 1000.0;
}
break;
default:
throw new IllegalStateException("Unknown mode in PT trip: " + leg.getMode());
......@@ -305,6 +310,7 @@ public abstract class BaseUtilityEstimator extends AbstractTripRouterEstimator {
tripVariables.destinationHomeDistance_km = CoordUtils.calcEuclideanDistance(personVariables.homeLocation,
trip.getDestinationActivity().getCoord()) * 1e-3;
tripVariables.railShare = inVehicleDistance_km > 0.0 ? inRailDistance_km / inVehicleDistance_km : 0.0;
tripVariables.travelCost_CHF = costModel.calculatePtTravelCost(personVariables, tripVariables);
return estimatePtTrip(trip, personVariables, tripVariables);
......
......@@ -25,4 +25,6 @@ public class TripVariablesPt {
public double originHomeDistance_km;
public double destinationHomeDistance_km;
public double railShare = 0.0;
}
......@@ -47,9 +47,11 @@ public class CostModel {
double fullCost = Math.max(parameters.ptCostMinimum_CHF,
parameters.ptCostPerKm_CHF * tripVariables.inVehicleDistance_km);
if (year >= 2050 && usePtCostReduction) {
fullCost *= 0.6; // Scaling for automation
if (year >= 2050 && usePtCostReduction) { // Scaling for automation
double reduction = parameters.ptRailReduction * tripVariables.railShare
+ parameters.ptNonRailReducation * (1.0 - tripVariables.railShare);
fullCost *= (1.0 - reduction);
}
if (personVariables.hasHalbtaxSubscription) {
......
......@@ -11,4 +11,7 @@ public class CostParameters {
public double ptCostMinimum_CHF = 2.7;
public double ptRegionalRadius_km = 15.0;
public double ptRailReduction = 0.2;
public double ptNonRailReducation = 0.4;
}
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