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

Separate private av utilities from car

parent 3e401f0b
...@@ -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.TripVariablesSharedAv;
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,7 +204,7 @@ public class SwissUtilityEstimator extends BaseUtilityEstimator { ...@@ -203,7 +204,7 @@ public class SwissUtilityEstimator extends BaseUtilityEstimator {
} }
@Override @Override
public double estimateAvTrip(DiscreteModeChoiceTrip trip, PersonVariables personVariables, public double estimateSharedAvTrip(DiscreteModeChoiceTrip trip, PersonVariables personVariables,
TripVariablesSharedAv tripVariables) { TripVariablesSharedAv tripVariables) {
double utility = 0.0; double utility = 0.0;
...@@ -232,13 +233,32 @@ public class SwissUtilityEstimator extends BaseUtilityEstimator { ...@@ -232,13 +233,32 @@ 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;
utility += parameters.prav.alpha;
utility += parameters.prav.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) //
......
...@@ -162,7 +162,11 @@ public class SwissUtilityParameters { ...@@ -162,7 +162,11 @@ public class SwissUtilityParameters {
public PtParameters pt = new PtParameters(); public PtParameters pt = new PtParameters();
// VI) Private AV // VI) Private AV
public class PrivateAVParameters extends CarParameters { public class PrivateAVParameters {
public double alpha = 0.0;
public double betaTravelTime = 0.0;
public double constantAccessEgressWalkTime_min = 0.0;
} }
public PrivateAVParameters prav = new PrivateAVParameters(); public PrivateAVParameters prav = new PrivateAVParameters();
......
...@@ -83,25 +83,26 @@ public abstract class BaseUtilityEstimator extends AbstractTripRouterEstimator { ...@@ -83,25 +83,26 @@ 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 SharedAVModule.AV_POOL: case SharedAVModule.AV_POOL:
case SharedAVModule.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,
TripVariablesSharedAv 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) {
TripVariablesSharedAv tripVariables = new TripVariablesSharedAv(); TripVariablesSharedAv tripVariables = new TripVariablesSharedAv();
...@@ -137,7 +138,7 @@ public abstract class BaseUtilityEstimator extends AbstractTripRouterEstimator { ...@@ -137,7 +138,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 +236,44 @@ public abstract class BaseUtilityEstimator extends AbstractTripRouterEstimator { ...@@ -235,11 +236,44 @@ public abstract class BaseUtilityEstimator extends AbstractTripRouterEstimator {
return estimatePtTrip(trip, personVariables, tripVariables); return estimatePtTrip(trip, personVariables, tripVariables);
} }
abstract protected double estimatePrivateVehicleTrip(DiscreteModeChoiceTrip trip, PersonVariables personVariables, abstract protected double estimatePrivateAVTrip(DiscreteModeChoiceTrip trip, PersonVariables personVariables,
TripVariablesCar tripVariables, String mode); TripVariablesPrivateAv tripVariables);
private double estimatePrivateAVTrip(PersonVariables personVariables, DiscreteModeChoiceTrip trip,
List<? extends PlanElement> elements) {
TripVariablesPrivateAv tripVariables = new TripVariablesPrivateAv();
Leg leg = (Leg) elements.get(0);
double travelDistance_km = leg.getRoute().getDistance() / 1000.0;
tripVariables.travelTime_min = leg.getTravelTime() / 60.0;
tripVariables.travelCost_CHF = costModel.calculateCarTravelCost(travelDistance_km);
tripVariables.crowflyDistance_km = CoordUtils.calcEuclideanDistance(trip.getOriginActivity().getCoord(),
trip.getDestinationActivity().getCoord());
switch (((Leg) elements.get(0)).getMode()) {
case "prav3":
tripVariables.automationLevel = 3;
break;
case "prav4":
tripVariables.automationLevel = 4;
break;
case "prav5":
tripVariables.automationLevel = 5;
break;
default:
new IllegalStateException("Unknown private AV mode given.");
}
return estimatePrivateAVTrip(trip, personVariables, tripVariables);
}
abstract protected double estimateCarTrip(DiscreteModeChoiceTrip trip, PersonVariables personVariables,
TripVariablesCar tripVariables);
private double estimatePrivateVehicleTrip(PersonVariables personVariables, DiscreteModeChoiceTrip trip, private double estimateCarTrip(PersonVariables personVariables, DiscreteModeChoiceTrip trip,
List<? extends PlanElement> elements, String mode) { List<? extends PlanElement> elements) {
TripVariablesCar tripVariables = new TripVariablesCar(); TripVariablesCar tripVariables = new TripVariablesCar();
Leg leg = (Leg) elements.get(0); Leg leg = (Leg) elements.get(0);
...@@ -249,8 +283,8 @@ public abstract class BaseUtilityEstimator extends AbstractTripRouterEstimator { ...@@ -249,8 +283,8 @@ public abstract class BaseUtilityEstimator extends AbstractTripRouterEstimator {
tripVariables.travelCost_CHF = costModel.calculateCarTravelCost(travelDistance_km); tripVariables.travelCost_CHF = costModel.calculateCarTravelCost(travelDistance_km);
/* /*
* TODO: Right now we don't define parking cost or parking search time * TODO: Right now we don't define parking cost or parking search time TODO: Add
* TODO: Add different costs for private AVs here. * different costs for private AVs here.
*/ */
tripVariables.parkingSearchTime_min = 0.0; tripVariables.parkingSearchTime_min = 0.0;
...@@ -262,7 +296,7 @@ public abstract class BaseUtilityEstimator extends AbstractTripRouterEstimator { ...@@ -262,7 +296,7 @@ public abstract class BaseUtilityEstimator extends AbstractTripRouterEstimator {
tripVariables.crowflyDistance_km = CoordUtils.calcEuclideanDistance(trip.getOriginActivity().getCoord(), tripVariables.crowflyDistance_km = CoordUtils.calcEuclideanDistance(trip.getOriginActivity().getCoord(),
trip.getDestinationActivity().getCoord()); trip.getDestinationActivity().getCoord());
return estimatePrivateVehicleTrip(trip, personVariables, tripVariables, mode); return estimateCarTrip(trip, personVariables, tripVariables);
} }
abstract protected double estimateWalkTrip(DiscreteModeChoiceTrip trip, PersonVariables personVariables, abstract protected double estimateWalkTrip(DiscreteModeChoiceTrip trip, PersonVariables personVariables,
......
package ch.ethz.matsim.projects.astra_2018_002.mode_choice.base; package ch.ethz.matsim.projects.astra_2018_002.mode_choice.base;
public class TripVariablesPrivateAv { public class TripVariablesPrivateAv {
public int automationLevel = 0;
public double travelTime_min = 0.0; public double travelTime_min = 0.0;
public double travelCost_CHF = 0.0; public double travelCost_CHF = 0.0;
public double parkingCost_CHF = 0.0;
public double delay_min = 0.0;
public double travelDistance_km = 0.0; public double travelDistance_km = 0.0;
public double crowflyDistance_km = 0.0; public double crowflyDistance_km = 0.0;
} }
...@@ -54,7 +54,7 @@ public class TestUtility { ...@@ -54,7 +54,7 @@ public class TestUtility {
double ptUtility = estimator.estimatePtTrip(trip, personVariables, tripVariablesPt); double ptUtility = estimator.estimatePtTrip(trip, personVariables, tripVariablesPt);
TripVariablesCar tripVariablesCar = new TripVariablesCar(); TripVariablesCar tripVariablesCar = new TripVariablesCar();
double carUtility = estimator.estimatePrivateVehicleTrip(trip, personVariables, tripVariablesCar, "car"); double carUtility = estimator.estimateCarTrip(trip, personVariables, tripVariablesCar);
System.out.println("Walk utility: " + walkUtility); System.out.println("Walk utility: " + walkUtility);
System.out.println("Bike utility: " + bikeUtility); System.out.println("Bike utility: " + bikeUtility);
......
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