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

Merge branch 'shared-utilities' into 'master'

Shared utilities

See merge request !9
parents 0c72b263 96434978
...@@ -30,6 +30,10 @@ ...@@ -30,6 +30,10 @@
<name>bintray</name> <name>bintray</name>
<url>https://schweizerischebundesbahnen.bintray.com/simba.mvn</url> <url>https://schweizerischebundesbahnen.bintray.com/simba.mvn</url>
</repository> </repository>
<repository>
<id>matsim-eth-packagecloud</id>
<url>https://packagecloud.io/eth-ivt/matsim/maven2</url>
</repository>
</repositories> </repositories>
<build> <build>
...@@ -87,5 +91,11 @@ ...@@ -87,5 +91,11 @@
<version>0.10.2</version> <version>0.10.2</version>
<type>pom</type> <type>pom</type>
</dependency> </dependency>
<dependency>
<groupId>ch.ethz.matsim</groupId>
<artifactId>av_cost_calculator</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies> </dependencies>
</project> </project>
\ No newline at end of file
...@@ -23,8 +23,9 @@ import ch.sbb.matsim.routing.pt.raptor.SwissRailRaptorModule; ...@@ -23,8 +23,9 @@ 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") //
.allowOptions("use-route-choice", "use-only-significant", "utility-parameters", "crossing-penalty") // .allowOptions("use-route-choice", "use-only-significant", "utility-parameters", "crossing-penalty",
"model") //
.allowPrefixes(SwissDiscreteModeChoiceModule.COMMAND_LINE_PREFIX) // .allowPrefixes(SwissDiscreteModeChoiceModule.COMMAND_LINE_PREFIX) //
.build(); .build();
...@@ -59,7 +60,7 @@ public class RunASTRA2018002 { ...@@ -59,7 +60,7 @@ public class RunASTRA2018002 {
new BaselineTrafficModule(cmd.getOption("crossing-penalty").map(Double::parseDouble).orElse(3.0))); new BaselineTrafficModule(cmd.getOption("crossing-penalty").map(Double::parseDouble).orElse(3.0)));
SharedAVConfigurator.configureController(controller); SharedAVConfigurator.configureController(controller);
UtilitySet utilitySet = Enum.valueOf(UtilitySet.class, cmd.getOptionStrict("model")); UtilitySet utilitySet = Enum.valueOf(UtilitySet.class, cmd.getOption("model").orElse("ZERO"));
boolean useRouteChoice = cmd.getOption("use-route-choice").map(Boolean::parseBoolean).orElse(true); boolean useRouteChoice = cmd.getOption("use-route-choice").map(Boolean::parseBoolean).orElse(true);
boolean useOnlySignificant = cmd.getOption("use-only-significant").map(Boolean::parseBoolean).orElse(false); boolean useOnlySignificant = cmd.getOption("use-only-significant").map(Boolean::parseBoolean).orElse(false);
controller.addOverridingModule( controller.addOverridingModule(
......
...@@ -6,6 +6,7 @@ import org.matsim.facilities.ActivityFacilities; ...@@ -6,6 +6,7 @@ import org.matsim.facilities.ActivityFacilities;
import org.matsim.pt.transitSchedule.api.TransitSchedule; 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.SwissUtilityParameters.SharedAVParameters;
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.TripVariablesBike; import ch.ethz.matsim.projects.astra_2018_002.mode_choice.base.TripVariablesBike;
...@@ -201,27 +202,23 @@ public class SwissUtilityEstimator extends BaseUtilityEstimator { ...@@ -201,27 +202,23 @@ public class SwissUtilityEstimator extends BaseUtilityEstimator {
TripVariablesSharedAv tripVariables) { TripVariablesSharedAv tripVariables) {
double utility = 0.0; double utility = 0.0;
SharedAVParameters avParameters = tripVariables.isPooled ? parameters.pooled_av : parameters.taxi_av;
// 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!
utility += parameters.car.alpha; utility += avParameters.alpha;
utility += parameters.car.betaTravelTime // utility += avParameters.betaTravelTime //
* interaction(tripVariables.travelDistance_km, parameters.referenceDistance_km,
parameters.car.lambdaTravelTimeDistance) //
* tripVariables.inVehicleTime_min; * tripVariables.inVehicleTime_min;
utility += avParameters.betaWaitingTime //
* tripVariables.waitingTime_min;
utility += parameters.betaCost // utility += parameters.betaCost //
* interaction(tripVariables.travelDistance_km, parameters.referenceDistance_km, * interaction(tripVariables.crowflyDistance_km, parameters.referenceCrowflyDistance_km,
parameters.car.lambdaCostDistance) // parameters.lambdaCostCrowflyDistance) //
* interaction(personVariables.income_1000CHF, parameters.referenceIncome_1000CHF,
parameters.lambdaCostIncome) //
* tripVariables.travelCost_CHF; * tripVariables.travelCost_CHF;
utility += parameters.betaDelay
* interaction(tripVariables.travelDistance_km, parameters.referenceDistance_km,
parameters.lambdaDelayDistance) //
* tripVariables.delay_min;
return utility; return utility;
} }
......
...@@ -178,6 +178,17 @@ public class SwissUtilityParameters { ...@@ -178,6 +178,17 @@ public class SwissUtilityParameters {
public PrivateAVParameters prav = new PrivateAVParameters(); public PrivateAVParameters prav = new PrivateAVParameters();
// VII) Shared AV
public class SharedAVParameters {
public double alpha = 0.0;
public double betaTravelTime = 0.0;
public double betaWaitingTime = 0.0;
}
public SharedAVParameters taxi_av = new SharedAVParameters();
public SharedAVParameters pooled_av = new SharedAVParameters();
/** /**
* Chapter 3.2.1: Modell with linear utility function WITHOUT sociodemographics * Chapter 3.2.1: Modell with linear utility function WITHOUT sociodemographics
*/ */
......
...@@ -133,6 +133,9 @@ public abstract class BaseUtilityEstimator extends AbstractTripRouterEstimator { ...@@ -133,6 +133,9 @@ public abstract class BaseUtilityEstimator extends AbstractTripRouterEstimator {
double travelDistance_km = 0.0; double travelDistance_km = 0.0;
double totalTravelTime = 0.0; double totalTravelTime = 0.0;
boolean foundTaxi = false;
boolean foundPooled = false;
for (PlanElement element : elements) { for (PlanElement element : elements) {
if (element instanceof Leg) { if (element instanceof Leg) {
Leg leg = (Leg) element; Leg leg = (Leg) element;
...@@ -149,6 +152,11 @@ public abstract class BaseUtilityEstimator extends AbstractTripRouterEstimator { ...@@ -149,6 +152,11 @@ public abstract class BaseUtilityEstimator extends AbstractTripRouterEstimator {
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;
travelDistance_km += route.getDistance() / 1000.0; travelDistance_km += route.getDistance() / 1000.0;
String operatorId = route.getOperatorId().toString();
foundTaxi |= operatorId.equals(SharedAVModule.AV_TAXI);
foundPooled |= operatorId.equals(SharedAVModule.AV_POOL);
break; break;
default: default:
throw new IllegalStateException("Unknown mode on AV trip: " + leg.getMode()); throw new IllegalStateException("Unknown mode on AV trip: " + leg.getMode());
...@@ -156,11 +164,20 @@ public abstract class BaseUtilityEstimator extends AbstractTripRouterEstimator { ...@@ -156,11 +164,20 @@ public abstract class BaseUtilityEstimator extends AbstractTripRouterEstimator {
} }
} }
tripVariables.travelCost_CHF = costModel.calculateCarTravelCost(travelDistance_km); tripVariables.travelCost_CHF = costModel.calculateSharedAvTravelCost(travelDistance_km, foundPooled);
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;
tripVariables.crowflyDistance_km = CoordUtils.calcEuclideanDistance(trip.getOriginActivity().getCoord(),
trip.getDestinationActivity().getCoord()) * 1e-3;
if (foundTaxi ^ foundPooled) {
tripVariables.isPooled = foundPooled;
} else {
throw new IllegalStateException("Did not find taxi or pool operator.");
}
return estimateSharedAvTrip(trip, personVariables, tripVariables); return estimateSharedAvTrip(trip, personVariables, tripVariables);
} }
...@@ -277,7 +294,7 @@ public abstract class BaseUtilityEstimator extends AbstractTripRouterEstimator { ...@@ -277,7 +294,7 @@ public abstract class BaseUtilityEstimator extends AbstractTripRouterEstimator {
double travelDistance_km = leg.getRoute().getDistance() / 1000.0; double travelDistance_km = leg.getRoute().getDistance() / 1000.0;
tripVariables.travelTime_min = leg.getTravelTime() / 60.0; tripVariables.travelTime_min = leg.getTravelTime() / 60.0;
tripVariables.travelCost_CHF = costModel.calculateCarTravelCost(travelDistance_km); tripVariables.travelCost_CHF = costModel.calculatePrivateAvTravelCost(travelDistance_km);
tripVariables.crowflyDistance_km = CoordUtils.calcEuclideanDistance(trip.getOriginActivity().getCoord(), tripVariables.crowflyDistance_km = CoordUtils.calcEuclideanDistance(trip.getOriginActivity().getCoord(),
trip.getDestinationActivity().getCoord()); trip.getDestinationActivity().getCoord());
......
...@@ -9,4 +9,7 @@ public class TripVariablesSharedAv { ...@@ -9,4 +9,7 @@ public class TripVariablesSharedAv {
public double delay_min = 0.0; public double delay_min = 0.0;
public double travelDistance_km = 0.0; public double travelDistance_km = 0.0;
public boolean isPooled = false;
public double crowflyDistance_km = 0.0;
} }
...@@ -14,8 +14,16 @@ public class CostModel { ...@@ -14,8 +14,16 @@ public class CostModel {
return parameters.carCostPerKm_CHF * distance_km; return parameters.carCostPerKm_CHF * distance_km;
} }
public double calculateAvTravelCost(double distance_km) { public double calculatePrivateAvTravelCost(double distance_km) {
return parameters.avCostPerKm_CHF * distance_km; return parameters.privateAvCostPerKm_CHF * distance_km;
}
public double calculateSharedAvTravelCost(double distance_km, boolean isPooled) {
if (isPooled) {
return parameters.pooledAvCostPerKm_CHF * distance_km;
} else {
return parameters.taxiAvCostPerKm_CHF * distance_km;
}
} }
public double calculatePtTravelCost(PersonVariables personVariables, TripVariablesPt tripVariables) { public double calculatePtTravelCost(PersonVariables personVariables, TripVariablesPt tripVariables) {
......
...@@ -2,7 +2,10 @@ package ch.ethz.matsim.projects.astra_2018_002.mode_choice.cost; ...@@ -2,7 +2,10 @@ package ch.ethz.matsim.projects.astra_2018_002.mode_choice.cost;
public class CostParameters { public class CostParameters {
public double carCostPerKm_CHF = 0.26; public double carCostPerKm_CHF = 0.26;
public double avCostPerKm_CHF = 0.4; public double privateAvCostPerKm_CHF = 0.4;
public double pooledAvCostPerKm_CHF = 0.4;
public double taxiAvCostPerKm_CHF = 0.4;
public double ptCostPerKm_CHF = 0.6; public double ptCostPerKm_CHF = 0.6;
public double ptCostMinimum_CHF = 2.7; public double ptCostMinimum_CHF = 2.7;
......
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