Skip to content

Commit

Permalink
update MATSim: use DashboardUtils and new pt fare implementation (wit…
Browse files Browse the repository at this point in the history
…h old values and logic)
  • Loading branch information
tschlenther committed Oct 2, 2024
1 parent f1bd941 commit 43a6b27
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 97 deletions.
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<artifactId>matsim-all</artifactId>

<!-- PR-labelled release -->
<version>2025.0-PR3402</version> <!-- PR3402 is from August 09, '24, when TS fixed bugs and included damages in NoiseAnalysis -->
<version>2025.0-PR3501</version> <!-- PR3501 is from October 01, 2024 -->

<!-- snapshot == not recommended: rather use PR-labelled release!-->
<!-- <version>16.0-SNAPSHOT</matsim.version>-->
Expand All @@ -15,7 +15,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.github.matsim-scenarios</groupId>
<artifactId>matsim-kelheim</artifactId>
<version>3.x-SNAPSHOT</version>
<version>2024.2-SNAPSHOT</version>

<name>MATSim Kelheim Model</name>
<description>A transport model of the district of Kelheim and it's surroundings</description>
Expand Down Expand Up @@ -212,7 +212,7 @@
<dependency>
<groupId>org.apache.avro</groupId>
<artifactId>avro</artifactId>
<version>1.11.3</version>
<version>1.12.0</version>
</dependency>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,12 @@
package org.matsim.dashboard;

import org.matsim.analysis.postAnalysis.emissions.EmissionsPostProcessingAverageAnalysis;
import org.matsim.simwrapper.Dashboard;
import org.matsim.simwrapper.Data;
import org.matsim.simwrapper.Header;
import org.matsim.simwrapper.Layout;
import org.matsim.simwrapper.*;
import org.matsim.simwrapper.viz.*;

import java.util.ArrayList;
import java.util.List;

import static org.matsim.dashboard.AverageKelheimNoiseDashboard.*;

/**
* Average emissions dashboard for several runs with the same config but a different random seed.
*/
Expand Down Expand Up @@ -130,21 +125,16 @@ public void configure(Header header, Layout layout) {
layout.row("second").el(GridMap.class, (viz, data) -> {
viz.title = "CO₂ Emissions";
viz.description = "per day. Be aware that CO2 values are provided in the simulation sample size!";
setGridMapStandards(viz);
DashboardUtils.setGridMapStandards(viz, data, "EPSG:25832");
viz.file = postProcess(data, "mean_emissions_grid_per_day.xyt.csv");
});
layout.row("third")
.el(GridMap.class, (viz, data) -> {
viz.title = "CO₂ Emissions";
viz.description = "per hour. Be aware that CO2 values are provided in the simulation sample size!";
setGridMapStandards(viz);
DashboardUtils.setGridMapStandards(viz, data, "EPSG:25832");
viz.file = postProcess(data, "mean_emissions_grid_per_hour.csv");
});
}

private static void setGridMapStandards(GridMap viz) {
viz.projection = "EPSG:25832";
viz.setColorRamp(new double[]{30, 40, 50, 60, 70}, new String[]{DARK_BLUE, LIGHT_BLUE, YELLOW, SAND, ORANGE, RED});
viz.height = 12.0;
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package org.matsim.dashboard;

import org.matsim.analysis.postAnalysis.NoiseAverageAnalysis;
import org.matsim.simwrapper.Dashboard;
import org.matsim.simwrapper.Data;
import org.matsim.simwrapper.Header;
import org.matsim.simwrapper.Layout;
import org.matsim.run.RunKelheimScenario;
import org.matsim.simwrapper.*;
import org.matsim.simwrapper.viz.ColorScheme;
import org.matsim.simwrapper.viz.GridMap;
import org.matsim.simwrapper.viz.MapPlot;
Expand All @@ -23,12 +21,7 @@ public class AverageKelheimNoiseDashboard implements Dashboard {
private final List<String> dirs;
private final Integer noRuns;
private static final String NOISE = "noise";
static final String DARK_BLUE = "#1175b3";
static final String LIGHT_BLUE = "#95c7df";
static final String ORANGE = "#f4a986";
static final String RED = "#cc0c27";
static final String SAND = "#dfb095";
static final String YELLOW = "#dfdb95";


public AverageKelheimNoiseDashboard(List<String> dirs, Integer noRuns) {
this.dirs = dirs;
Expand Down Expand Up @@ -78,38 +71,28 @@ public void configure(Header header, Layout layout) {
.el(GridMap.class, (viz, data) -> {
viz.title = "Noise Immissions (Grid)";
viz.description = "Total Noise Immissions per day";
setGridMapStandards(viz, data);
DashboardUtils.setGridMapStandards(viz, data, "EPSG:25832");
viz.file = postProcess(data, "mean_immission_per_day.avro");
})
.el(GridMap.class, (viz, data) -> {
viz.title = "Hourly Noise Immissions (Grid)";
viz.description = "Noise Immissions per hour";
setGridMapStandards(viz, data);
DashboardUtils.setGridMapStandards(viz, data, "EPSG:25832");
viz.file = postProcess(data, "mean_immission_per_hour.avro");
});
layout.row("damages")
.el(GridMap.class, (viz, data) -> {
viz.title = "Daily Noise Damages (Grid)";
viz.description = "Total Noise Damages per day [€]";
setGridMapStandards(viz, data);
DashboardUtils.setGridMapStandards(viz, data, "EPSG:25832");
viz.file = postProcess(data, "mean_damages_receiverPoint_per_day.avro");
})
.el(GridMap.class, (viz, data) -> {
viz.title = "Hourly Noise Damages (Grid)";
viz.description = "Noise Damages per hour [€]";
setGridMapStandards(viz, data);
DashboardUtils.setGridMapStandards(viz, data, "EPSG:25832");
viz.file = postProcess(data, "mean_damages_receiverPoint_per_hour.avro");
});
}

private static void setGridMapStandards(GridMap viz, Data data) {
viz.height = 12.0;
viz.cellSize = 250;
viz.opacity = 0.1;
viz.maxHeight = 40;
viz.projection = "EPSG:25832";
viz.center = data.context().getCenter();
viz.zoom = data.context().mapZoomLevel;
viz.setColorRamp(new double[]{30, 40, 50, 60, 70}, new String[]{DARK_BLUE, LIGHT_BLUE, YELLOW, SAND, ORANGE, RED});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.matsim.analysis.postAnalysis.emissions.KelheimOfflineAirPollutionAnalysisByEngineInformation;
import org.matsim.application.prepare.network.CreateGeoJsonNetwork;
import org.matsim.simwrapper.Dashboard;
import org.matsim.simwrapper.DashboardUtils;
import org.matsim.simwrapper.Header;
import org.matsim.simwrapper.Layout;
import org.matsim.simwrapper.viz.GridMap;
Expand Down Expand Up @@ -94,21 +95,16 @@ public void configure(Header header, Layout layout) {
layout.row("second").el(GridMap.class, (viz, data) -> {
viz.title = "CO₂ Emissions";
viz.description = "per day. Be aware that CO2 values are provided in the simulation sample size!";
setGridMapStandards(viz, 12.0, data.compute(KelheimOfflineAirPollutionAnalysisByEngineInformation.class, "emissions_grid_per_day.xyt.csv", new String[0]));

DashboardUtils.setGridMapStandards(viz, data, "EPSG:25832");
viz.file = data.compute(KelheimOfflineAirPollutionAnalysisByEngineInformation.class, "emissions_grid_per_day.xyt.csv", new String[0]);
});
layout.row("third")
.el(GridMap.class, (viz, data) -> {
viz.title = "CO₂ Emissions";
viz.description = "per hour. Be aware that CO2 values are provided in the simulation sample size!";
setGridMapStandards(viz, 12., data.compute(KelheimOfflineAirPollutionAnalysisByEngineInformation.class, "emissions_grid_per_hour.csv"));
DashboardUtils.setGridMapStandards(viz, data, "EPSG:25832");
viz.file = data.compute(KelheimOfflineAirPollutionAnalysisByEngineInformation.class, "emissions_grid_per_hour.csv");
});
}

private static void setGridMapStandards(GridMap viz, double height, String data) {
viz.height = height;
viz.projection = "EPSG:25832";
viz.file = data;
viz.setColorRamp(new double[]{30, 40, 50, 60, 70}, new String[]{DARK_BLUE, LIGHT_BLUE, YELLOW, SAND, ORANGE, RED});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public Integer call() throws Exception {
new DrtDashboardProvider().getDashboards(config, sw).forEach(sw::addDashboard);
}
if (noise){
sw.addDashboard(new NoiseDashboard());
sw.addDashboard(new NoiseDashboard(config.global().getCoordinateSystem()));
}

try {
Expand Down
34 changes: 0 additions & 34 deletions src/main/java/org/matsim/run/KelheimPtFareModule.java

This file was deleted.

30 changes: 17 additions & 13 deletions src/main/java/org/matsim/run/RunKelheimScenario.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import org.matsim.contrib.dvrp.run.DvrpModule;
import org.matsim.contrib.dvrp.run.DvrpQSimComponents;
import org.matsim.contrib.dvrp.trafficmonitoring.DvrpModeLimitedMaxSpeedTravelTimeModule;
import org.matsim.contrib.vsp.pt.fare.PtFareModule;
import org.matsim.contrib.vsp.scenario.SnzActivities;
import org.matsim.core.api.experimental.events.EventsManager;
import org.matsim.core.config.Config;
Expand All @@ -62,8 +63,8 @@
import org.matsim.simwrapper.SimWrapperModule;
import org.matsim.vehicles.VehicleType;
import picocli.CommandLine;
import playground.vsp.pt.fare.DistanceBasedPtFareParams;
import playground.vsp.pt.fare.PtFareConfigGroup;
import org.matsim.contrib.vsp.pt.fare.DistanceBasedPtFareParams;
import org.matsim.contrib.vsp.pt.fare.PtFareConfigGroup;
import playground.vsp.scoring.IncomeDependentUtilityOfMoneyPersonScoringParameters;

import javax.annotation.Nullable;
Expand Down Expand Up @@ -221,16 +222,18 @@ protected Config prepareConfig(Config config) {

// Minimum fare (e.g. short trip or 1 zone ticket)
distanceBasedPtFareParams.setMinFare(2.0);
// Division between long trip and short trip (unit: m)
distanceBasedPtFareParams.setLongDistanceTripThreshold(50000);
// y = ax + b --> a value, for short trips
distanceBasedPtFareParams.setNormalTripSlope(0.00017);
// y = ax + b --> b value, for short trips
distanceBasedPtFareParams.setNormalTripIntercept(1.6);
// y = ax + b --> a value, for long trips
distanceBasedPtFareParams.setLongDistanceTripSlope(0.00025);
// y = ax + b --> b value, for long trips
distanceBasedPtFareParams.setLongDistanceTripIntercept(30);

distanceBasedPtFareParams.setTransactionPartner("pt-operator");
DistanceBasedPtFareParams.DistanceClassLinearFareFunctionParams shortDistance = distanceBasedPtFareParams.getOrCreateDistanceClassFareParams(50000);
shortDistance.setFareIntercept(1.6);
shortDistance.setFareSlope(0.00017);

DistanceBasedPtFareParams.DistanceClassLinearFareFunctionParams longDistance = distanceBasedPtFareParams.getOrCreateDistanceClassFareParams(Double.POSITIVE_INFINITY);
longDistance.setFareIntercept(30);
longDistance.setFareSlope(0.00025);
distanceBasedPtFareParams.setOrder(1);

ptFareConfigGroup.addParameterSet(distanceBasedPtFareParams);

//enable plan inheritance analysis
config.planInheritance().setEnabled(true);
Expand Down Expand Up @@ -291,7 +294,8 @@ protected void prepareControler(Controler controler) {
controler.addOverridingModule(new AbstractModule() {
@Override
public void install() {
install(new KelheimPtFareModule());
// install(new KelheimPtFareModule());
install(new PtFareModule());
install(new SwissRailRaptorModule());
install(new PersonMoneyEventsAnalysisModule());
install(new SimWrapperModule());
Expand Down

0 comments on commit 43a6b27

Please sign in to comment.