Commit 82a87506 authored by Sebastian Hörl's avatar Sebastian Hörl
Browse files

Update cost model

parent d8d314a9
......@@ -178,21 +178,14 @@ public class SwissUtilityEstimator extends BaseUtilityEstimator {
utility += estimateRegion(parameters.pt.region, personVariables);
utility += estimateMunicipalityType(parameters.pt.municipalityType, personVariables);
switch (personVariables.ptSubscription) {
case GA:
if (personVariables.hasGeneralSubscription) {
utility += parameters.pt.betaSubscriptionGA;
break;
case Halbtax:
} else if (personVariables.hasHalbtaxSubscription) {
utility += parameters.pt.betaSubscriptionHalbtax;
break;
case None:
utility += parameters.pt.betaSubscriptionNone;
break;
case Regional:
} else if (personVariables.hasRegionalSubscription) {
utility += parameters.pt.betaSubscriptionRegional;
break;
default:
throw new IllegalStateException();
} else {
utility += parameters.pt.betaSubscriptionNone;
}
utility += parameters.betaDelay
......
......@@ -57,15 +57,9 @@ public abstract class BaseUtilityEstimator extends AbstractTripRouterEstimator {
.equals("always");
personVariables.regionIndex = (Integer) person.getAttributes().getAttribute("spRegion");
if ((Boolean) person.getAttributes().getAttribute("ptHasGA")) {
personVariables.ptSubscription = PersonVariables.PtSubscription.GA;
} else if ((Boolean) person.getAttributes().getAttribute("ptHasHalbtax")) {
personVariables.ptSubscription = PersonVariables.PtSubscription.Halbtax;
} else if ((Boolean) person.getAttributes().getAttribute("ptHasVerbund")) {
personVariables.ptSubscription = PersonVariables.PtSubscription.Regional;
} else {
personVariables.ptSubscription = PersonVariables.PtSubscription.None;
}
personVariables.hasGeneralSubscription = (Boolean) person.getAttributes().getAttribute("ptHasGA");
personVariables.hasHalbtaxSubscription = (Boolean) person.getAttributes().getAttribute("ptHasHalbtax");
personVariables.hasRegionalSubscription = (Boolean) person.getAttributes().getAttribute("ptHasVerbund");
switch ((String) person.getAttributes().getAttribute("municipalityType")) {
case "rural":
......@@ -264,7 +258,7 @@ public abstract class BaseUtilityEstimator extends AbstractTripRouterEstimator {
trip.getOriginActivity().getCoord()) * 1e-3;
tripVariables.destinationHomeDistance_km = CoordUtils.calcEuclideanDistance(personVariables.homeLocation,
trip.getDestinationActivity().getCoord()) * 1e-3;
tripVariables.travelCost_CHF = costModel.calculatePtTravelCost(personVariables, tripVariables);
return estimatePtTrip(trip, personVariables, tripVariables);
......
......@@ -10,11 +10,9 @@ public class PersonVariables {
public boolean carAlwaysAvailable = false;
public Coord homeLocation = new Coord(0.0, 0.0);
public enum PtSubscription {
None, Halbtax, Regional, GA
}
public PtSubscription ptSubscription = PtSubscription.None;
public boolean hasHalbtaxSubscription = false;
public boolean hasRegionalSubscription = false;
public boolean hasGeneralSubscription = false;
public int regionIndex = 0;
......
......@@ -23,24 +23,20 @@ public class CostModel {
* TODO: Later on, we should have a more complex cost model here.
*/
switch (personVariables.ptSubscription) {
case GA:
return Math.max(parameters.ptCostMinimumGA, parameters.ptCostPerKmGA * tripVariables.inVehicleDistance_km);
case Halbtax:
return Math.max(parameters.ptCostMinimumHalfFare,
parameters.ptCostPerKmHalfFare * tripVariables.inVehicleDistance_km);
case None:
return Math.max(parameters.ptCostMinimum, parameters.ptCostPerKm * tripVariables.inVehicleDistance_km);
case Regional:
if (personVariables.hasGeneralSubscription) {
return 0.0;
}
if (personVariables.hasRegionalSubscription) {
if (tripVariables.originHomeDistance_km <= parameters.ptRegionalRadius_km
&& tripVariables.destinationHomeDistance_km <= parameters.ptRegionalRadius_km) {
return 0.0;
} else {
return Math.max(parameters.ptCostMinimumRegional,
parameters.ptCostPerKmRegional * tripVariables.inVehicleDistance_km);
}
default:
throw new IllegalStateException();
}
double fullCost = Math.max(parameters.ptCostMinimum,
parameters.ptCostPerKm * tripVariables.inVehicleDistance_km);
return personVariables.hasHalbtaxSubscription ? 0.5 * fullCost : fullCost;
}
}
......@@ -5,14 +5,7 @@ public class CostParameters {
public double avCostPerKm = 0.4;
public double ptCostPerKm = 0.8;
public double ptCostPerKmHalfFare = 0.8 * 0.5;
public double ptCostPerKmGA = 0.0;
public double ptCostPerKmRegional = 0.8;
public double ptCostMinimum = 2.7;
public double ptCostMinimumHalfFare = 2.7 * 0.5;
public double ptCostMinimumGA = 0.0;
public double ptCostMinimumRegional = 2.7;
public double ptRegionalRadius_km = 15.0;
}
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