Skip to content

Commit

Permalink
use FareZoneBasedPtFareHandler instead of DistanceBasedPtFareHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
simei94 committed Aug 8, 2024
1 parent 99b3b72 commit a6d0ef8
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 4 deletions.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PROJCS["ETRS_1989_UTM_Zone_32N",GEOGCS["GCS_ETRS_1989",DATUM["D_ETRS_1989",SPHEROID["GRS_1980",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",500000.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",9.0],PARAMETER["Scale_Factor",0.9996],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0]]
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<!--<version>14.0-PR1452</version>-->

<!-- snapshot == not recommended: rather use PR-labelled release!-->
<version>2025.0-PR3388</version>
<version>2025.0-PR3382</version>
</parent>


Expand Down
54 changes: 54 additions & 0 deletions src/main/R/analysis/deutschlandtarifPricesAnalysis.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
library(tidyverse)

prices <- read.csv(file="../../shared-svn/projects/DiTriMo/data/deutschlandtarif_prices/deutschlandtarif_prices.csv")

prices20 <- prices %>%
filter(km <= 20)

prices100 <- prices %>%
filter(km <= 100)

prices1000 <- prices %>%
filter(km <= 1000)

pricesAbove100 <- prices %>%
filter(km >= 100)

linear20 <- lm(price ~ km, data = prices20)
linear100 <- lm(price ~ km, data = prices100)
linear1000 <- lm(price ~ km, data = prices1000)
linear <- lm(price ~ km, data = prices)
linearAbove100 <- lm(price ~ km, data = pricesAbove100)

# Create a dataframe for the lines
lines_df <- data.frame(
intercept = c(coef(linear)[1], coef(linear20)[1], coef(linear100)[1], coef(linear1000)[1], coef(linearAbove100)[1]),
slope = c(coef(linear)[2], coef(linear20)[2], coef(linear100)[2], coef(linear1000)[2], coef(linearAbove100)[2]),
label = c("1-2000km", "1-20km", "1-100km", "1-1000km", "100-2000km")
)

ggplot(prices, aes(x = km, y = price)) +
geom_point() + # Scatter plot of the data points
geom_abline(data = lines_df, aes(intercept = intercept, slope = slope, color = label), linewidth=.75) +
scale_color_manual(values = c("red", "lightblue", "orange3", "purple4", "pink")) + # Manually setting colors
labs(title = "Deutschlandtarif linear functions",
x = "km",
y = "price [€]",
color = "Model") + # Legend title
theme_minimal()

lines_df_relevant <- data.frame(
intercept = c(coef(linear100)[1], coef(linearAbove100)[1]),
slope = c(coef(linear100)[2], coef(linearAbove100)[2]),
label = c("1-100km", "100-2000km")
)

ggplot(prices, aes(x = km, y = price)) +
geom_point() + # Scatter plot of the data points
geom_abline(data = lines_df_relevant, aes(intercept = intercept, slope = slope, color = label), linewidth=.75) +
scale_color_manual(values = c("red", "blue"), labels = c("1-100km y = 0.272x + 1.67", "100-2000km y = 0.11x + 26.89")) + # Manually setting colors
labs(title = "Deutschlandtarif linear functions",
x = "km",
y = "price [€]",
color = "Model") + # Legend title
theme_minimal()
15 changes: 12 additions & 3 deletions src/main/java/org/matsim/run/LausitzScenario.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
import org.matsim.simwrapper.SimWrapperConfigGroup;
import org.matsim.simwrapper.SimWrapperModule;
import picocli.CommandLine;
import playground.vsp.pt.fare.DistanceBasedPtFareParams;
import playground.vsp.pt.fare.PtFareConfigGroup;
import playground.vsp.pt.fare.PtFareModule;
import playground.vsp.scoring.IncomeDependentUtilityOfMoneyPersonScoringParameters;

import javax.annotation.Nullable;
Expand Down Expand Up @@ -109,7 +112,14 @@ protected Config prepareConfig(Config config) {
config.qsim().setUsePersonIdForMissingVehicleId(false);
config.routing().setAccessEgressType(RoutingConfigGroup.AccessEgressType.accessEgressModeToLink);

// TODO: Config options
// set pt fare calc model to fareZoneBased = fare of vvo tarifzone 20 is paid for trips within fare zone
// every other trip: Deutschlandtarif
// for more info see FareZoneBasedPtFareHandler class in vsp contrib
PtFareConfigGroup ptFareConfigGroup = ConfigUtils.addOrGetModule(config, PtFareConfigGroup.class);
ptFareConfigGroup.setPtFareCalculationModel(PtFareConfigGroup.PtFareCalculationModels.fareZoneBased);

DistanceBasedPtFareParams fareParams = ConfigUtils.addOrGetModule(config, DistanceBasedPtFareParams.class);
fareParams.setFareZoneShp("vvo_tarifzone20/vvo_tarifzone20_hoyerswerda_utm32n.shp");

// TODO: recreate counts format with car and trucks

Expand Down Expand Up @@ -140,8 +150,7 @@ protected void prepareControler(Controler controler) {
controler.addOverridingModule(new AbstractModule() {
@Override
public void install() {
install(new LausitzPtFareModule());

install(new PtFareModule());
bind(ScoringParametersForPerson.class).to(IncomeDependentUtilityOfMoneyPersonScoringParameters.class).asEagerSingleton();

addTravelTimeBinding(TransportMode.ride).to(networkTravelTime());
Expand Down

0 comments on commit a6d0ef8

Please sign in to comment.