Skip to content

Commit

Permalink
moved small scale commercial generation to new contrib
Browse files Browse the repository at this point in the history
  • Loading branch information
rewertvsp committed Jan 22, 2024
1 parent 6c3b3cf commit 73b7359
Show file tree
Hide file tree
Showing 41 changed files with 63 additions and 569 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@
import java.util.List;
import java.util.Map;

import static org.matsim.smallScaleCommercialTrafficGeneration.SCTUtils.*;

/**
* @author Ricardo Ewert
*
Expand All @@ -58,7 +56,7 @@ void testReadOfDataDistributionPerZoneAndBuildingAnalysis() throws IOException {
Map<String, Object2DoubleMap<String>> resultingDataPerZone = LanduseBuildingAnalysis
.createInputDataDistribution(output, landuseCategoriesAndDataConnection,
inputDataDirectory, usedLanduseConfiguration,
getIndexLanduse(inputDataDirectory), getZoneIndex(inputDataDirectory), getIndexBuildings(inputDataDirectory), buildingsPerZone);
SCTUtils.getIndexLanduse(inputDataDirectory), SCTUtils.getZoneIndex(inputDataDirectory), SCTUtils.getIndexBuildings(inputDataDirectory), buildingsPerZone);

Assertions.assertEquals(3, resultingDataPerZone.size(), MatsimTestUtils.EPSILON);

Expand Down Expand Up @@ -145,10 +143,10 @@ void testReadOfDataDistributionPerZoneAndBuildingAnalysis() throws IOException {
}

// tests if the reading of the buildings works correctly
List<SimpleFeature> buildingsFeatures = getIndexBuildings(inputDataDirectory).getAllFeatures();
List<SimpleFeature> buildingsFeatures = SCTUtils.getIndexBuildings(inputDataDirectory).getAllFeatures();
Assertions.assertEquals(31, buildingsFeatures.size(), MatsimTestUtils.EPSILON);
LanduseBuildingAnalysis.analyzeBuildingType(buildingsFeatures, buildingsPerZone,
landuseCategoriesAndDataConnection, getIndexLanduse(inputDataDirectory), getZoneIndex(inputDataDirectory));
landuseCategoriesAndDataConnection, SCTUtils.getIndexLanduse(inputDataDirectory), SCTUtils.getZoneIndex(inputDataDirectory));

Assertions.assertEquals(3, buildingsPerZone.size(), MatsimTestUtils.EPSILON);
Assertions.assertTrue(buildingsPerZone.containsKey("testArea1_area1"));
Expand Down Expand Up @@ -245,7 +243,7 @@ void testLanduseDistribution() throws IOException {
Map<String, Object2DoubleMap<String>> resultingDataPerZone = LanduseBuildingAnalysis
.createInputDataDistribution(output, landuseCategoriesAndDataConnection,
inputDataDirectory, usedLanduseConfiguration,
getIndexLanduse(inputDataDirectory), getZoneIndex(inputDataDirectory), getIndexBuildings(inputDataDirectory), buildingsPerZone);
SCTUtils.getIndexLanduse(inputDataDirectory), SCTUtils.getZoneIndex(inputDataDirectory), SCTUtils.getIndexBuildings(inputDataDirectory), buildingsPerZone);

Assertions.assertEquals(3, resultingDataPerZone.size(), MatsimTestUtils.EPSILON);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import org.matsim.api.core.v01.Id;
import org.matsim.api.core.v01.Scenario;
import org.matsim.api.core.v01.network.Link;
import org.matsim.application.options.ShpOptions;
import org.matsim.core.config.Config;
import org.matsim.core.config.ConfigUtils;
import org.matsim.core.scenario.ScenarioUtils;
Expand All @@ -34,9 +33,7 @@

import java.io.IOException;
import java.net.URISyntaxException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@
import java.nio.file.Path;
import java.util.*;

import static org.matsim.smallScaleCommercialTrafficGeneration.SCTUtils.*;

/**
* @author Ricardo Ewert
*
Expand All @@ -66,7 +64,7 @@ void testTrafficVolumeGenerationCommercialPersonTraffic() throws IOException {
Map<String, Object2DoubleMap<String>> resultingDataPerZone = LanduseBuildingAnalysis
.createInputDataDistribution(output, landuseCategoriesAndDataConnection,
inputDataDirectory, usedLanduseConfiguration,
getIndexLanduse(inputDataDirectory), getZoneIndex(inputDataDirectory), getIndexBuildings(inputDataDirectory), buildingsPerZone);
SCTUtils.getIndexLanduse(inputDataDirectory), SCTUtils.getZoneIndex(inputDataDirectory), SCTUtils.getIndexBuildings(inputDataDirectory), buildingsPerZone);


String usedTrafficType = "commercialPersonTraffic";
Expand Down Expand Up @@ -192,7 +190,7 @@ void testTrafficVolumeGenerationGoodsTraffic() throws IOException {
Map<String, Object2DoubleMap<String>> resultingDataPerZone = LanduseBuildingAnalysis
.createInputDataDistribution(output, landuseCategoriesAndDataConnection,
inputDataDirectory, usedLanduseConfiguration,
getIndexLanduse(inputDataDirectory), getZoneIndex(inputDataDirectory), getIndexBuildings(inputDataDirectory), buildingsPerZone);
SCTUtils.getIndexLanduse(inputDataDirectory), SCTUtils.getZoneIndex(inputDataDirectory), SCTUtils.getIndexBuildings(inputDataDirectory), buildingsPerZone);

String usedTrafficType = "goodsTraffic";
double sample = 1.;
Expand Down Expand Up @@ -517,15 +515,15 @@ void testReducingDemandAfterAddingExistingScenarios_goods() throws Exception {
Map<String, Object2DoubleMap<String>> resultingDataPerZone = LanduseBuildingAnalysis
.createInputDataDistribution(output, landuseCategoriesAndDataConnection,
inputDataDirectory, usedLanduseConfiguration,
getIndexLanduse(inputDataDirectory), getZoneIndex(inputDataDirectory), getIndexBuildings(inputDataDirectory), buildingsPerZone);
SCTUtils.getIndexLanduse(inputDataDirectory), SCTUtils.getZoneIndex(inputDataDirectory), SCTUtils.getIndexBuildings(inputDataDirectory), buildingsPerZone);

Map<TrafficVolumeKey, Object2DoubleMap<Integer>> trafficVolumePerTypeAndZone_start = TrafficVolumeGeneration
.createTrafficVolume_start(resultingDataPerZone, output, sample, modesORvehTypes, usedTrafficType);
Map<TrafficVolumeKey, Object2DoubleMap<Integer>> trafficVolumePerTypeAndZone_stop = TrafficVolumeGeneration
.createTrafficVolume_stop(resultingDataPerZone, output, sample, modesORvehTypes, usedTrafficType);

Map<String, Map<Id<Link>, Link>> regionLinksMap = GenerateSmallScaleCommercialTrafficDemand
.filterLinksForZones(scenario, getZoneIndex(inputDataDirectory), buildingsPerZone);
.filterLinksForZones(scenario, SCTUtils.getZoneIndex(inputDataDirectory), buildingsPerZone);

SmallScaleCommercialTrafficUtils.readExistingModels(scenario, sample, regionLinksMap);

Expand Down Expand Up @@ -672,15 +670,15 @@ void testReducingDemandAfterAddingExistingScenarios_commercialPersonTraffic() th
Map<String, Object2DoubleMap<String>> resultingDataPerZone = LanduseBuildingAnalysis
.createInputDataDistribution(output, landuseCategoriesAndDataConnection,
inputDataDirectory, usedLanduseConfiguration,
getIndexLanduse(inputDataDirectory), getZoneIndex(inputDataDirectory), getIndexBuildings(inputDataDirectory), buildingsPerZone);
SCTUtils.getIndexLanduse(inputDataDirectory), SCTUtils.getZoneIndex(inputDataDirectory), SCTUtils.getIndexBuildings(inputDataDirectory), buildingsPerZone);

Map<TrafficVolumeKey, Object2DoubleMap<Integer>> trafficVolumePerTypeAndZone_start = TrafficVolumeGeneration
.createTrafficVolume_start(resultingDataPerZone, output, sample, modesORvehTypes, usedTrafficType);
Map<TrafficVolumeKey, Object2DoubleMap<Integer>> trafficVolumePerTypeAndZone_stop = TrafficVolumeGeneration
.createTrafficVolume_stop(resultingDataPerZone, output, sample, modesORvehTypes, usedTrafficType);

Map<String, Map<Id<Link>, Link>> regionLinksMap = GenerateSmallScaleCommercialTrafficDemand
.filterLinksForZones(scenario, getZoneIndex(inputDataDirectory), buildingsPerZone);
.filterLinksForZones(scenario, SCTUtils.getZoneIndex(inputDataDirectory), buildingsPerZone);

SmallScaleCommercialTrafficUtils.readExistingModels(scenario, sample, regionLinksMap);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE config SYSTEM "http://www.matsim.org/files/dtd/config_v2.dtd">
<config>
<module name="global" >
<param name="coordinateSystem" value="EPSG:4326" />
<param name="defaultDelimiter" value=";" />
<param name="insistingOnDeprecatedConfigVersion" value="false" />
<!-- "global" number of threads. This number is used, e.g., for replanning, but NOT in QSim. This can typically be set to as many cores as you have available, or possibly even slightly more. -->
<param name="numberOfThreads" value="2" />
<param name="randomSeed" value="4177" />
</module>
<module name="vehicles" >
<param name="vehiclesFile" value="vehicleTypes.xml" />
</module>
<module name="controller" >
<param name="firstIteration" value="0" />
<!-- Default=1000. Last Iteration of a simulation. -->
<param name="lastIteration" value="0" />
<!-- Defines which mobility simulation will be used. Currently supported: qsim JDEQSim hermes
Depending on the chosen mobsim, you'll have to add additional config modules to configure the corresponding mobsim.
For 'qsim', add a module 'qsim' to the config. -->
<param name="mobsim" value="qsim" />
<param name="outputDirectory" value="test/output/org/matsim/smallScaleCommercialTrafficGeneration/RunGenerateSmallScaleCommercialTrafficTest/testMainRunAndResults/" />
<!-- Possible values: failIfDirectoryExists, overwriteExistingFiles, deleteDirectoryIfExists -->
<param name="overwriteFiles" value="overwriteExistingFiles" />
<!-- The type of routing (least cost path) algorithm used, may have the values: [Dijkstra, AStarLandmarks, SpeedyALT] -->
<param name="routingAlgorithmType" value="SpeedyALT" />
<!-- An identifier for the current run which is used as prefix for output files and mentioned in output xml files etc. -->
<param name="runId" value="test" />

</module>
<module name="network" >
<!-- The Coordinates Reference System in which the coordinates are expressed in the input file. At import, the coordinates will be converted to the coordinate system defined in "global", and willbe converted back at export. If not specified, no conversion happens. -->
<param name="inputCRS" value="EPSG:4326" />
<param name="inputChangeEventsFile" value="null" />
<param name="inputNetworkFile" value="https://raw.githubusercontent.com/matsim-org/matsim-libs/master/examples/scenarios/freight-chessboard-9x9/grid9x9.xml" />
<param name="laneDefinitionsFile" value="null" />
<param name="timeVariantNetwork" value="false" />
</module>
<module name="vspExperimental" >
<!-- (do not use except of you have to) There was a problem with pt interaction scoring. Some people solved it by overwriting the parameters of the pt interaction activity type. Doing this now throws an Exception. If you still insist on doing this, set the following to true. -->
<param name="isAbleToOverwritePtInteractionParams" value="false" />
<param name="isGeneratingBoardingDeniedEvent" value="false" />
<!-- if an approximation of the opportunity cost of time is included into the radius calculation for location choice.`true' will be faster, but it is an approximation. Default is `true'; `false' is available for backwards compatibility. -->
<param name="isUsingOpportunityCostOfTimeForLocationChoice" value="true" />
<param name="logitScaleParamForPlansRemoval" value="1.0" />
<!-- Options: | ignore | info | warn | abort | . When violating VSP defaults, this results in nothing, logfile infos, logfile warnings, or aborts. Members of VSP should use `abort' or talk to kai. -->
<param name="vspDefaultsCheckingLevel" value="abort" />
<!-- if true then writes output_events in output directory. default is `false'. Will only work when lastIteration is multiple of events writing interval -->
<param name="writingOutputEvents" value="true" />
</module>

</config>

0 comments on commit 73b7359

Please sign in to comment.