Skip to content

Commit

Permalink
Average dashboard drt (#78)
Browse files Browse the repository at this point in the history
* average drt dashboard wip

* bump to matsim-2025.0.PR3254

* use GridMap instead of XY

* bump to java 21

* move to dashboard package + add some dashboards

* move to dashboard package + add some dashboards

* update config (ReplanningAnnealerConfigGroup)

* enable plan inheritance analysis via config

* average dashboard + analysis WIP

* re-structure tables

* customize dashboard + add todo

* add average emissions dashboard infrastructure WIP

* bump to matsim 2025 PR 3271

* finalize average emissions dashboard

* average noise dashboard

* use new append option rather than renaming existing dashboards. needs to be tested though

* checkstyle

* update drt config to fix tests

* bump up maven compiler + jacoco

* actions v4

* handle drt groups in KelheimDrtFareHandler (by not cleaning map :/ )

---------

Co-authored-by: tschlenther <[email protected]>
  • Loading branch information
simei94 and tschlenther authored Jun 4, 2024
1 parent 3d48fa6 commit 82cad54
Show file tree
Hide file tree
Showing 29 changed files with 1,321 additions and 86 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ jobs:

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
java-version: 17
java-version: 21
architecture: x64
distribution: adopt
cache: maven
Expand All @@ -32,7 +32,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
java-version: 17
java-version: 21
architecture: x64
distribution: adopt
cache: maven
Expand All @@ -51,7 +51,7 @@ jobs:
strategy:
fail-fast: false
matrix:
java: [17]
java: [21]

steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -80,7 +80,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
java-version: 17
java-version: 21
architecture: x64
distribution: adopt
cache: maven
Expand Down
2 changes: 1 addition & 1 deletion input/test.config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
<parameterset type="AnnealingVariable" >
<param name="annealParameter" value="globalInnovationRate" />
<param name="annealType" value="sigmoid" />
<param name="defaultSubpopulation" value="person" />
<param name="subpopulation" value="person" />
<!-- this parameter enters the exponential and sigmoid formulas. May be an iteration or a share, i.e. 0.5 for halfLife at 50% of iterations. Exponential: startValue / exp(it/halfLife) -->
<param name="halfLife" value="0.5" />
<!-- sigmoid: 1/(1+e^(shapeFactor*(it - halfLife))); geometric: startValue * shapeFactor^it; msa: startValue / it^shapeFactor -->
Expand Down
38 changes: 15 additions & 23 deletions input/test.with-drt.config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
<parameterset type="AnnealingVariable" >
<param name="annealParameter" value="globalInnovationRate" />
<param name="annealType" value="sigmoid" />
<param name="defaultSubpopulation" value="person" />
<param name="subpopulation" value="person" />
<!-- this parameter enters the exponential and sigmoid formulas. May be an iteration or a share, i.e. 0.5 for halfLife at 50% of iterations. Exponential: startValue / exp(it/halfLife) -->
<param name="halfLife" value="0.5" />
<!-- sigmoid: 1/(1+e^(shapeFactor*(it - halfLife))); geometric: startValue * shapeFactor^it; msa: startValue / it^shapeFactor -->
Expand Down Expand Up @@ -292,15 +292,10 @@
<!-- &lt;!&ndash; Weights to sample an additional drt passenger. E.g. 70 % +0 pax, 30 % +1 pax. Please specify at least two values. &ndash;&gt;-->
<!-- <param name="drtCompanionSamplingWeights" value="16517.0,2084.0,532.0,163.0,20.0,5.0,0.0,0.0" />-->
<!-- </parameterset>-->
<parameterset type="zonalSystem" >
<!-- size of square cells used for demand aggregation. Depends on demand, supply and network. Often used with values in the range of 500 - 2000 m -->
<param name="cellSize" value="null" />
<!-- Defines how the target link of a zone is determined (e.g. for rebalancing). Possible values are [random,mostCentral]. Default behavior is mostCentral, where all vehicles are sent to the same link. -->
<param name="zoneTargetLinkSelection" value="mostCentral" />
<!-- Logic for generation of zones for the DRT zonal system. Value can be: [GridFromNetwork, ShapeFile]. -->
<param name="zonesGeneration" value="ShapeFile" />
<!-- allows to configure zones. Used with zonesGeneration=ShapeFile -->
<param name="zonesShapeFile" value="https://svn.vsp.tu-berlin.de/repos/public-svn/matsim/scenarios/countries/de/kelheim/projects/KelRide/AVServiceAreas/input/shp/kelheim-v2.0-drtZonalAnalysisSystem.shp" />
<parameterset type="zonalSystem">
<parameterset type="SquareGridZoneSystem">
<param name="cellSize" value="500"/>
</parameterset>
</parameterset>
</parameterset>

Expand Down Expand Up @@ -329,16 +324,10 @@

<!-- Writes out detailed DRT customer stats in each iteration. True by default. -->
<param name="writeDetailedCustomerStats" value="true"/>

<parameterset type="zonalSystem" >
<!-- size of square cells used for demand aggregation. Depends on demand, supply and network. Often used with values in the range of 500 - 2000 m -->
<param name="cellSize" value="null" />
<!-- Defines how the target link of a zone is determined (e.g. for rebalancing). Possible values are [random,mostCentral]. Default behavior is mostCentral, where all vehicles are sent to the same link. -->
<param name="zoneTargetLinkSelection" value="mostCentral" />
<!-- Logic for generation of zones for the DRT zonal system. Value can be: [GridFromNetwork, ShapeFile]. -->
<param name="zonesGeneration" value="ShapeFile" />
<!-- allows to configure zones. Used with zonesGeneration=ShapeFile -->
<param name="zonesShapeFile" value="https://svn.vsp.tu-berlin.de/repos/public-svn/matsim/scenarios/countries/de/kelheim/projects/KelRide/AVServiceAreas/input/shp/kelheim-v2.0-drtZonalAnalysisSystem.shp" />
<parameterset type="zonalSystem">
<parameterset type="SquareGridZoneSystem">
<param name="cellSize" value="500"/>
</parameterset>
</parameterset>
</parameterset>
</module>
Expand All @@ -349,9 +338,12 @@

<!-- Used for estimation of travel times for VrpOptimizer by means of the exponential moving average. The weighting decrease, alpha, must be in (0,1]. We suggest small values of alpha, e.g. 0.05. The averaging starts from the initial travel time estimates. If not provided, the free-speed TTs is used as the initial estimates For more info see comments in: VrpTravelTimeEstimator, VrpTravelTimeModules, DvrpModule. -->
<param name="travelTimeEstimationAlpha" value="0.05" />
<parameterset type="travelTimeMatrix">
<param name="cellSize" value="200"/>
</parameterset>
<parameterset type="travelTimeMatrix">
<parameterset type="SquareGridZoneSystem">
<param name="cellSize" value="200"/>
</parameterset>
<param name="maxNeighborDistance" value="1000"/>
</parameterset>
</module>

</config>
2 changes: 1 addition & 1 deletion input/v3.1/kelheim-v3.1-25pct.kexi.config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
<parameterset type="AnnealingVariable" >
<param name="annealParameter" value="globalInnovationRate" />
<param name="annealType" value="sigmoid" />
<param name="defaultSubpopulation" value="person" />
<param name="subpopulation" value="person" />
<!-- this parameter enters the exponential and sigmoid formulas. May be an iteration or a share, i.e. 0.5 for halfLife at 50% of iterations. Exponential: startValue / exp(it/halfLife) -->
<param name="halfLife" value="0.5" />
<!-- sigmoid: 1/(1+e^(shapeFactor*(it - halfLife))); geometric: startValue * shapeFactor^it; msa: startValue / it^shapeFactor -->
Expand Down
2 changes: 1 addition & 1 deletion input/v3.1/kelheim-v3.1-config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
<parameterset type="AnnealingVariable" >
<param name="annealParameter" value="globalInnovationRate" />
<param name="annealType" value="sigmoid" />
<param name="defaultSubpopulation" value="person" />
<param name="subpopulation" value="person" />
<!-- this parameter enters the exponential and sigmoid formulas. May be an iteration or a share, i.e. 0.5 for halfLife at 50% of iterations. Exponential: startValue / exp(it/halfLife) -->
<param name="halfLife" value="0.5" />
<!-- sigmoid: 1/(1+e^(shapeFactor*(it - halfLife))); geometric: startValue * shapeFactor^it; msa: startValue / it^shapeFactor -->
Expand Down
44 changes: 35 additions & 9 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>16.0-PR2878</version>
<version>2025.0-PR3271</version>

<!-- snapshot == not recommended: rather use PR-labelled release!-->
<!-- <version>16.0-SNAPSHOT</matsim.version>-->
Expand All @@ -27,7 +27,7 @@

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.release>17</maven.compiler.release>
<maven.compiler.release>21</maven.compiler.release>
</properties>

<distributionManagement>
Expand Down Expand Up @@ -88,11 +88,30 @@
</exclusions>
</dependency>

<!-- <dependency>-->
<!-- &lt;!&ndash; Include the JUnit testing library. Not transitive. &ndash;&gt;-->
<!-- <groupId>junit</groupId>-->
<!-- <artifactId>junit</artifactId>-->
<!-- <version>4.13.2</version>-->
<!-- <scope>test</scope>-->
<!-- </dependency>-->

<!-- Test dependencies -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<!-- Include the JUnit testing library. Not transitive. -->
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.24.2</version>
<scope>test</scope>
</dependency>

Expand Down Expand Up @@ -187,9 +206,16 @@
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.13.0</version>
<version>2.16.1</version>
</dependency>

<dependency>
<groupId>org.apache.avro</groupId>
<artifactId>avro</artifactId>
<version>1.11.3</version>
</dependency>


</dependencies>

<build>
Expand All @@ -208,7 +234,7 @@
<forkCount>1</forkCount>
<reuseForks>false</reuseForks>
<!-- avoid out of memory errors: -->
<argLine>@{argLine} -Xmx6500m -Djava.awt.headless=true -Dmatsim.preferLocalDtds=true</argLine>
<argLine>@{argLine} -Djava.awt.headless=true -Dmatsim.preferLocalDtds=true</argLine>
<!--necessary in tu berlin gitlab. BUT not good in other places, so solve by command line switch only where needed. kai, nov'18-->
<!--<useSystemClassLoader>false</useSystemClassLoader>-->
</configuration>
Expand All @@ -217,7 +243,7 @@
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.8</version>
<version>0.8.12</version>
<executions>
<execution>
<goals>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public Integer call() throws Exception {
log.info("Running on {}", runDirectory);

//this is to avoid overriding
renameExistingDashboardYAMLs(runDirectory);
// renameExistingDashboardYAMLs(runDirectory);

Path configPath = ApplicationUtils.matchInput("config.xml", runDirectory);
Config config = ConfigUtils.loadConfig(configPath.toString());
Expand All @@ -88,7 +88,7 @@ public Integer call() throws Exception {
}

try {
sw.generate(runDirectory);
sw.generate(runDirectory, true);
sw.run(runDirectory);
} catch (IOException e) {
throw new RuntimeException(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
import org.matsim.core.utils.geometry.CoordinateTransformation;
import org.matsim.core.utils.geometry.geotools.MGC;
import org.matsim.core.utils.geometry.transformations.TransformationFactory;
import org.matsim.core.utils.gis.ShapeFileReader;
import org.matsim.core.utils.gis.GeoFileReader;
import org.matsim.core.utils.io.IOUtils;
import org.matsim.freight.carriers.*;
import org.matsim.vehicles.Vehicle;
Expand Down Expand Up @@ -103,7 +103,7 @@ public static void main(String[] args) {

//read in service area map
PreparedGeometryFactory factory = new PreparedGeometryFactory();
Map<String, PreparedGeometry> serviceAreas = StreamEx.of(ShapeFileReader.getAllFeatures(IOUtils.getFileUrl(INPUT_SERVICE_AREAS_SHAPE)))
Map<String, PreparedGeometry> serviceAreas = StreamEx.of(GeoFileReader.getAllFeatures(IOUtils.getFileUrl(INPUT_SERVICE_AREAS_SHAPE)))
.mapToEntry(sf -> (String) sf.getAttribute("name"), sf -> factory.create((Geometry) sf.getDefaultGeometry()))
.collect(toMap(Map.Entry::getKey, Map.Entry::getValue));

Expand Down Expand Up @@ -300,8 +300,6 @@ private static Carrier buildCarrier(String areaName, Collection<Stop> stops, Net
CarrierVehicle.Builder vBuilder = CarrierVehicle.Builder.newInstance(Id.create((areaName + "_shuttle"), Vehicle.class), depotLink, vehicleType);
vBuilder.setEarliestStart(0 * 60 * 60);
vBuilder.setLatestEnd(24 * 60 * 60);
vBuilder.setType(vehicleType);
vBuilder.setTypeId(vehicleType.getId());
CarrierVehicle vehicle = vBuilder.build();
carrier.getCarrierCapabilities().getCarrierVehicles().put(vehicle.getId(), vehicle);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
import org.matsim.simwrapper.Dashboard;
import org.matsim.simwrapper.Header;
import org.matsim.simwrapper.Layout;
import org.matsim.simwrapper.viz.GridMap;
import org.matsim.simwrapper.viz.Links;
import org.matsim.simwrapper.viz.Table;
import org.matsim.simwrapper.viz.XYTime;

/**
* this is basically equivalent to the standard emissions dashboard
Expand Down Expand Up @@ -88,14 +88,14 @@ public void configure(Header header, Layout layout) {
viz.center = data.context().getCenter();
viz.width = 3.0;
});
layout.row("second").el(XYTime.class, (viz, data) -> {
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!";
viz.height = 12.0;
viz.file = data.compute(KelheimOfflineAirPollutionAnalysisByEngineInformation.class, "emissions_grid_per_day.xyt.csv", new String[0]);
});
layout.row("third")
.el(XYTime.class, (viz, data) -> {
.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!";
viz.height = 12.;
Expand Down
Loading

0 comments on commit 82cad54

Please sign in to comment.