diff --git a/CHANGELOG.md b/CHANGELOG.md
index 906b0568f..4e63bdc8b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,14 @@
All notable changes to this project will be documented in this file.
+### 6.3 (2024-07)
+- Include additional trip analysis and updated dashboard
+ - Mode share is now analyzed by age, income, employment, economic_status
+- Updated population, which now include reference modes for certain persons
+ - The reference modes represent modes that a person has actually used in reality
+ - Allows to evaluate the quality of the model in terms of mode choice
+- ReplanningAnnealer module is now activated by default
+
### 6.2 (2024-06)
- Updated network and gtfs schedule
- Network is now based on late 2022 osm data
diff --git a/Makefile b/Makefile
index 6655fe6bc..09c9b6940 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
JAR := matsim-berlin-*.jar
-V := v6.2
+V := v6.3
CRS := EPSG:25832
p := input/$V
@@ -155,9 +155,17 @@ $p/berlin-static-$V-25pct.plans.xml.gz: $p/berlin-only-$V-25pct.plans.xml.gz $p/
$(sc) prepare lookup-regiostar --input $@ --output $@ --xls $(germany)/RegioStaR-Referenzdateien.xlsx
-$p/berlin-activities-$V-25pct.plans.xml.gz: $p/berlin-static-$V-25pct.plans.xml.gz
+$p/berlin-activities-$V-25pct.plans.xml.gz: $p/berlin-static-$V-25pct.plans.xml.gz $p/berlin-$V-facilities.xml.gz $p/berlin-$V-network.xml.gz
$(sc) prepare activity-sampling --seed 1 --input $< --output $@ --persons src/main/python/table-persons.csv --activities src/main/python/table-activities.csv
+ $(sc) prepare assign-reference-population --population $@ --output $@\
+ --persons src/main/python/table-persons.csv\
+ --activities src/main/python/table-activities.csv\
+ --shp $(germany)/../matsim-berlin/data/SrV/zones/zones.shp\
+ --shp-crs $(CRS)\
+ --facilities $(word 2,$^)\
+ --network $(word 3,$^)\
+
$p/berlin-initial-$V-25pct.plans.xml.gz: $p/berlin-activities-$V-25pct.plans.xml.gz $p/berlin-$V-facilities.xml.gz $p/berlin-$V-network.xml.gz
$(sc) prepare init-location-choice\
--input $<\
@@ -196,7 +204,7 @@ $p/commercialFacilities.xml.gz:
--landuseShapeFileName $(berlin)/input/shp/berlinBrandenburg_landuse_4326.shp\
--shapeFileLanduseTypeColumn "fclass"\
--shapeCRS "EPSG:4326"\
- --pathToInvestigationAreaData $p/commercialTraffic/investigationAreaData.csv
+ --pathToInvestigationAreaData input/commercialTrafficAreaData.csv
$p/berlin-small-scale-commercialTraffic-$V-25pct.plans.xml.gz: $p/berlin-$V-network.xml.gz $p/commercialFacilities.xml.gz
$(sc) prepare generate-small-scale-commercial-traffic\
@@ -249,6 +257,15 @@ eval-opt: $p/berlin-initial-$V-25pct.experienced_plans.xml.gz
$(sc) run --mode "routeChoice" --iterations 20 --all-car --output "output/eval-$(ERROR_METRIC)" --25pct --population "berlin-$V-25pct.plans_$(ERROR_METRIC).xml.gz"\
--config $p/berlin-$V.config.xml
+$p/berlin-$V-25pct.plans_cadyts.xml.gz:
+ $(sc) prepare extract-plans-idx\
+ --input output/cadyts/cadyts.output_plans.xml.gz\
+ --output $p/berlin-$V-25pct.plans_selection_cadyts.csv
+
+ $(sc) prepare select-plans-idx\
+ --input $p/berlin-cadyts-input-$V-25pct.plans.xml.gz\
+ --csv $p/berlin-$V-25pct.plans_selection_cadyts.csv\
+ --output $@
# These depend on the output of optimization runs
$p/berlin-$V-25pct.plans-initial.xml.gz: $p/berlin-$V-facilities.xml.gz $p/berlin-$V-network.xml.gz $p/berlin-longHaulFreight-$V-25pct.plans.xml.gz
@@ -300,5 +317,8 @@ prepare-calibration: $p/berlin-cadyts-input-$V-25pct.plans.xml.gz $p/berlin-$V-n
prepare-initial: $p/berlin-$V-25pct.plans-initial.xml.gz $p/berlin-$V-network-with-pt.xml.gz
echo "Done"
+prepare-drt: $p/berlin-$V.drt-by-rndLocations-10000vehicles-4seats.xml.gz
+ echo "Done"
+
prepare: $p/berlin-$V-10pct.plans.xml.gz
echo "Done"
\ No newline at end of file
diff --git a/checkstyle.xml b/checkstyle.xml
index 8c49465e7..d7bed60d2 100644
--- a/checkstyle.xml
+++ b/checkstyle.xml
@@ -251,5 +251,115 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/input/commercialTraffic/config_demand.xml b/input/commercialTraffic/config_demand.xml
deleted file mode 100644
index fe72019b1..000000000
--- a/input/commercialTraffic/config_demand.xml
+++ /dev/null
@@ -1,579 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/input/commercialTraffic/investigationAreaData.csv b/input/commercialTrafficAreaData.csv
similarity index 100%
rename from input/commercialTraffic/investigationAreaData.csv
rename to input/commercialTrafficAreaData.csv
diff --git a/input/v6.2/berlin-v6.2.config.xml b/input/v6.2/berlin-v6.2.config.xml
index ede0d75ac..1ba9337c6 100644
--- a/input/v6.2/berlin-v6.2.config.xml
+++ b/input/v6.2/berlin-v6.2.config.xml
@@ -130,8 +130,8 @@
-
-
+
+
diff --git a/input/v6.3/area/area.dbf b/input/v6.3/area/area.dbf
new file mode 100644
index 000000000..2caa1f7d9
Binary files /dev/null and b/input/v6.3/area/area.dbf differ
diff --git a/input/v6.3/area/area.poly b/input/v6.3/area/area.poly
new file mode 100644
index 000000000..ceba25a93
--- /dev/null
+++ b/input/v6.3/area/area.poly
@@ -0,0 +1,13 @@
+area
+1
+ 13.219000451630821 52.804645826658245
+ 13.563415935578835 52.7636439833311
+ 13.762958239770938 52.64337190957148
+ 13.816260636096226 52.400094305830414
+ 13.644052894122218 52.18278453619655
+ 13.0713938156531 52.178684351863836
+ 12.744745797146848 52.345425181394226
+ 12.983923216555192 52.79644545799282
+ 13.219000451630821 52.804645826658245
+END
+END
diff --git a/input/v6.3/area/area.prj b/input/v6.3/area/area.prj
new file mode 100644
index 000000000..f45cbadf0
--- /dev/null
+++ b/input/v6.3/area/area.prj
@@ -0,0 +1 @@
+GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]]
\ No newline at end of file
diff --git a/input/v6.3/area/area.shp b/input/v6.3/area/area.shp
new file mode 100644
index 000000000..a5b387f11
Binary files /dev/null and b/input/v6.3/area/area.shp differ
diff --git a/input/v6.3/area/area.shx b/input/v6.3/area/area.shx
new file mode 100644
index 000000000..a4a038216
Binary files /dev/null and b/input/v6.3/area/area.shx differ
diff --git a/input/commercialTraffic/commercial_VehicleTypes_CV.xml b/input/v6.3/berlin-v6.3-vehicleTypes.xml
similarity index 78%
rename from input/commercialTraffic/commercial_VehicleTypes_CV.xml
rename to input/v6.3/berlin-v6.3-vehicleTypes.xml
index 303da3522..84ef8b727 100644
--- a/input/commercialTraffic/commercial_VehicleTypes_CV.xml
+++ b/input/v6.3/berlin-v6.3-vehicleTypes.xml
@@ -2,6 +2,56 @@
+
+
+
+
+ 1
+ serial
+ 1
+
+
+
+
+
+
+
+
+ 1
+ serial
+ 1
+
+
+
+
+
+
+
+
+ 1
+ serial
+ 1
+
+
+
+
+
+
+
+
+
+ 1
+ serial
+ 1
+
+
+
+
+
+
+
+
+
Golf 1.4 Trendline
@@ -135,7 +185,7 @@
Heavy Vehicle 40t
-
+
diff --git a/input/v6.3/berlin-v6.3.config.xml b/input/v6.3/berlin-v6.3.config.xml
new file mode 100644
index 000000000..7c3f3744d
--- /dev/null
+++ b/input/v6.3/berlin-v6.3.config.xml
@@ -0,0 +1,218 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/input/v6.3/berlin-v6.3.drt-config.xml b/input/v6.3/berlin-v6.3.drt-config.xml
new file mode 100644
index 000000000..3365acd48
--- /dev/null
+++ b/input/v6.3/berlin-v6.3.drt-config.xml
@@ -0,0 +1,138 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/input/v6.2/params/mc_params1.yaml b/input/v6.3/params/mc_params1.yaml
similarity index 100%
rename from input/v6.2/params/mc_params1.yaml
rename to input/v6.3/params/mc_params1.yaml
diff --git a/input/v6.2/params/mc_params2.yaml b/input/v6.3/params/mc_params2.yaml
similarity index 100%
rename from input/v6.2/params/mc_params2.yaml
rename to input/v6.3/params/mc_params2.yaml
diff --git a/input/v6.2/params/mc_params3.yaml b/input/v6.3/params/mc_params3.yaml
similarity index 100%
rename from input/v6.2/params/mc_params3.yaml
rename to input/v6.3/params/mc_params3.yaml
diff --git a/input/v6.2/params/mc_params4.yaml b/input/v6.3/params/mc_params4.yaml
similarity index 100%
rename from input/v6.2/params/mc_params4.yaml
rename to input/v6.3/params/mc_params4.yaml
diff --git a/input/v6.2/params/mc_params5.yaml b/input/v6.3/params/mc_params5.yaml
similarity index 100%
rename from input/v6.2/params/mc_params5.yaml
rename to input/v6.3/params/mc_params5.yaml
diff --git a/input/v6.3/pt-area/pt-area.cpg b/input/v6.3/pt-area/pt-area.cpg
new file mode 100644
index 000000000..3ad133c04
--- /dev/null
+++ b/input/v6.3/pt-area/pt-area.cpg
@@ -0,0 +1 @@
+UTF-8
\ No newline at end of file
diff --git a/input/v6.3/pt-area/pt-area.dbf b/input/v6.3/pt-area/pt-area.dbf
new file mode 100644
index 000000000..0234ef438
Binary files /dev/null and b/input/v6.3/pt-area/pt-area.dbf differ
diff --git a/input/v6.3/pt-area/pt-area.prj b/input/v6.3/pt-area/pt-area.prj
new file mode 100644
index 000000000..bd846aeb2
--- /dev/null
+++ b/input/v6.3/pt-area/pt-area.prj
@@ -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]]
\ No newline at end of file
diff --git a/input/v6.3/pt-area/pt-area.qmd b/input/v6.3/pt-area/pt-area.qmd
new file mode 100644
index 000000000..e5cd6b250
--- /dev/null
+++ b/input/v6.3/pt-area/pt-area.qmd
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ +proj=utm +zone=33 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs
+ 0
+ 0
+
+
+
+
+ false
+
+
+
+
diff --git a/input/v6.3/pt-area/pt-area.shp b/input/v6.3/pt-area/pt-area.shp
new file mode 100644
index 000000000..dc4679f12
Binary files /dev/null and b/input/v6.3/pt-area/pt-area.shp differ
diff --git a/input/v6.3/pt-area/pt-area.shx b/input/v6.3/pt-area/pt-area.shx
new file mode 100644
index 000000000..afe362e65
Binary files /dev/null and b/input/v6.3/pt-area/pt-area.shx differ
diff --git a/pom.xml b/pom.xml
index 8911c7ebd..e789e2812 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
matsim-all
- 2025.0-PR3292
+ 2025.0-PR3350
@@ -15,7 +15,7 @@
4.0.0
com.github.matsim-scenarios
matsim-berlin
- 6.2
+ 6.3-SNAPSHOT
MATSim Open Berlin scenario
MATSim Open Berlin scenario
@@ -245,7 +245,7 @@
org.apache.poi
poi-ooxml
- 5.2.5
+ 5.3.0
@@ -261,7 +261,7 @@
me.tongfei
progressbar
- 0.10.0
+ 0.10.1
@@ -418,12 +418,17 @@
org.apache.maven.plugins
maven-checkstyle-plugin
- 3.2.0
+ 3.4.0
com.puppycrawl.tools
checkstyle
- 10.6.0
+ 10.17.0
+
+
+ com.github.sevntu-checkstyle
+ sevntu-checks
+ 1.44.1
diff --git a/src/main/java/org/matsim/dashboard/BerlinDashboardProvider.java b/src/main/java/org/matsim/dashboard/BerlinDashboardProvider.java
index b3c230aae..3567536eb 100644
--- a/src/main/java/org/matsim/dashboard/BerlinDashboardProvider.java
+++ b/src/main/java/org/matsim/dashboard/BerlinDashboardProvider.java
@@ -21,8 +21,10 @@ public class BerlinDashboardProvider implements DashboardProvider {
@Override
public List getDashboards(Config config, SimWrapper simWrapper) {
- TripDashboard trips = new TripDashboard("mode_share_ref.csv", "mode_share_per_dist_ref.csv", "mode_users_ref.csv");
- trips.setAnalysisArgs("--match-id", "^berlin.+", "--shp-filter", "none");
+ TripDashboard trips = new TripDashboard("mode_share_ref.csv", "mode_share_per_dist_ref.csv", "mode_users_ref.csv")
+ .setAnalysisArgs("--match-id", "^berlin.+", "--shp-filter", "none")
+ .withChoiceEvaluation(true)
+ .withGroupedRefData("mode_share_per_group_dist_ref.csv", "age", "income", "employment", "economic_status");
return List.of(
trips,
diff --git a/src/main/java/org/matsim/prepare/FilterRelevantAgents.java b/src/main/java/org/matsim/prepare/FilterRelevantAgents.java
index e263bf0fe..455bf3f14 100644
--- a/src/main/java/org/matsim/prepare/FilterRelevantAgents.java
+++ b/src/main/java/org/matsim/prepare/FilterRelevantAgents.java
@@ -175,7 +175,7 @@ private Coord getCoordinate(Activity act) {
return coord;
}
- private LeastCostPathCalculator createRouter(Network network) {
+ private static LeastCostPathCalculator createRouter(Network network) {
FreeSpeedTravelTime travelTime = new FreeSpeedTravelTime();
LeastCostPathCalculatorFactory factory = new SpeedyALTFactory();
diff --git a/src/main/java/org/matsim/prepare/RunOpenBerlinCalibration.java b/src/main/java/org/matsim/prepare/RunOpenBerlinCalibration.java
index fd4162201..67a46d3e7 100644
--- a/src/main/java/org/matsim/prepare/RunOpenBerlinCalibration.java
+++ b/src/main/java/org/matsim/prepare/RunOpenBerlinCalibration.java
@@ -44,6 +44,8 @@
import org.matsim.core.scoring.SumScoringFunction;
import org.matsim.core.scoring.functions.*;
import org.matsim.core.utils.geometry.CoordUtils;
+import org.matsim.prepare.opt.ExtractPlanIndexFromType;
+import org.matsim.prepare.population.AssignReferencePopulation;
import org.matsim.prepare.choices.ComputePlanChoices;
import org.matsim.prepare.choices.ComputeTripChoices;
import org.matsim.prepare.counts.CreateCountsFromGeoPortalBerlin;
@@ -86,7 +88,7 @@
CreateCountsFromGeoPortalBerlin.class, CreateCountsFromVMZOld.class, CreateCountsFromVMZ.class, ReprojectNetwork.class, RunActivitySampling.class,
MergePlans.class, SplitActivityTypesDuration.class, CleanPopulation.class, CleanAttributes.class,
GenerateSmallScaleCommercialTrafficDemand.class, CreateDataDistributionOfStructureData.class,
- RunCountOptimization.class, SelectPlansFromIndex.class,
+ RunCountOptimization.class, SelectPlansFromIndex.class, ExtractPlanIndexFromType.class, AssignReferencePopulation.class,
ExtractRelevantFreightTrips.class, CheckCarAvailability.class, FixSubtourModes.class, ComputeTripChoices.class, ComputePlanChoices.class,
ApplyNetworkParams.class, SetCarAvailabilityByAge.class, CreateDrtVehicles.class
})
@@ -161,11 +163,10 @@ protected Config prepareConfig(Config config) {
SimWrapperConfigGroup sw = ConfigUtils.addOrGetModule(config, SimWrapperConfigGroup.class);
+ config.replanningAnnealer().setActivateAnnealingModule(false);
+
if (sample.isSet()) {
double sampleSize = sample.getSample();
-
- // All car leads to much more congestion even if scaled up compared to a normal run
- // therefore scaling is increased a bit more
double countScale = allCar ? CAR_FACTOR : 1;
config.qsim().setFlowCapFactor(sampleSize * countScale);
@@ -185,9 +186,13 @@ protected Config prepareConfig(Config config) {
log.info("Running with flow and storage capacity: {} / {}", config.qsim().getFlowCapFactor(), config.qsim().getStorageCapFactor());
- if (allCar)
+ if (allCar) {
config.transit().setUseTransit(false);
+ // Disable dashboards, for all car runs, these take too many resources
+ sw.defaultDashboards = SimWrapperConfigGroup.Mode.disabled;
+ }
+
// Required for all calibration strategies
for (String subpopulation : List.of("person", "commercialPersonTraffic", "commercialPersonTraffic_service", "goodsTraffic")) {
config.replanning().addStrategySettings(
@@ -244,6 +249,17 @@ protected Config prepareConfig(Config config) {
);
}
+ // Agents should generally use the faster routes, this is without any mode choice
+ config.scoring().getModes().values().forEach(m -> {
+ // Only time goes into the score
+ m.setMarginalUtilityOfTraveling(-config.scoring().getPerforming_utils_hr());
+ m.setConstant(0);
+ m.setMarginalUtilityOfDistance(0);
+ m.setDailyMonetaryConstant(0);
+ m.setDailyUtilityConstant(0);
+ m.setMonetaryDistanceRate(0);
+ });
+
config.controller().setRunId("cadyts");
config.controller().setOutputDirectory("./output/cadyts-" + scaleFactor);
@@ -343,7 +359,7 @@ protected void prepareScenario(Scenario scenario) {
}
}
- private Coord getCoord(Scenario scenario, Activity act) {
+ private static Coord getCoord(Scenario scenario, Activity act) {
if (act.getCoord() != null)
return act.getCoord();
@@ -383,14 +399,12 @@ public ScoringFunction createNewScoringFunction(Person person) {
Config config = controler.getConfig();
- // Only use cadyts, not the usual scoring
-// final ScoringParameters params = parameters.getScoringParameters(person);
-// sumScoringFunction.addScoringFunction(new CharyparNagelLegScoring(params, controler.getScenario().getNetwork()));
-// sumScoringFunction.addScoringFunction(new CharyparNagelActivityScoring(params));
-// sumScoringFunction.addScoringFunction(new CharyparNagelAgentStuckScoring(params));
+ // Not using the usual scoring, just cadyts + travel time
+ // final ScoringParameters params = parameters.getScoringParameters(person);
+ // sumScoringFunction.addScoringFunction(new CharyparNagelLegScoring(params, controler.getScenario().getNetwork()));
final CadytsScoring scoringFunction = new CadytsScoring<>(person.getSelectedPlan(), config, cadytsContext);
- scoringFunction.setWeightOfCadytsCorrection(config.scoring().getBrainExpBeta());
+ scoringFunction.setWeightOfCadytsCorrection(30 * config.scoring().getBrainExpBeta());
sumScoringFunction.addScoringFunction(scoringFunction);
return sumScoringFunction;
diff --git a/src/main/java/org/matsim/prepare/choices/ComputePlanChoices.java b/src/main/java/org/matsim/prepare/choices/ComputePlanChoices.java
index 21cf2208a..3e2bc5769 100644
--- a/src/main/java/org/matsim/prepare/choices/ComputePlanChoices.java
+++ b/src/main/java/org/matsim/prepare/choices/ComputePlanChoices.java
@@ -6,20 +6,19 @@
import org.apache.commons.csv.CSVPrinter;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
-import org.matsim.api.core.v01.Scenario;
import org.matsim.api.core.v01.population.Leg;
import org.matsim.api.core.v01.population.Person;
import org.matsim.api.core.v01.population.Plan;
import org.matsim.api.core.v01.population.Population;
import org.matsim.application.MATSimAppCommand;
+import org.matsim.application.analysis.population.TripAnalysis;
import org.matsim.application.options.ScenarioOptions;
-import org.matsim.application.options.ShpOptions;
import org.matsim.core.config.Config;
import org.matsim.core.config.ConfigUtils;
import org.matsim.core.config.groups.PlansConfigGroup;
import org.matsim.core.controler.Controler;
import org.matsim.core.controler.OutputDirectoryHierarchy;
-import org.matsim.core.population.PopulationUtils;
+import org.matsim.core.population.PersonUtils;
import org.matsim.core.population.algorithms.ParallelPersonAlgorithmUtils;
import org.matsim.core.population.algorithms.PersonAlgorithm;
import org.matsim.core.router.*;
@@ -29,6 +28,8 @@
import org.matsim.modechoice.estimators.DefaultLegScoreEstimator;
import org.matsim.modechoice.estimators.FixedCostsEstimator;
import org.matsim.modechoice.search.TopKChoicesGenerator;
+import org.matsim.prepare.population.Attributes;
+import org.matsim.simwrapper.SimWrapperConfigGroup;
import picocli.CommandLine;
import javax.annotation.Nullable;
@@ -36,6 +37,7 @@
import java.nio.file.Path;
import java.util.*;
import java.util.concurrent.ConcurrentLinkedQueue;
+import java.util.regex.Pattern;
@CommandLine.Command(
@@ -50,30 +52,26 @@ public class ComputePlanChoices implements MATSimAppCommand, PersonAlgorithm {
* Rows for the result table.
*/
private final Queue> rows = new ConcurrentLinkedQueue<>();
+ private final MainModeIdentifier mmi = new DefaultAnalysisMainModeIdentifier();
@CommandLine.Mixin
private ScenarioOptions scenario;
- @CommandLine.Mixin
- private ShpOptions shp;
- @CommandLine.Option(names = "--trips", description = "Input trips from survey data, in matsim-python-tools format.", required = true)
- private Path input;
- @CommandLine.Option(names = "--facilities", description = "Shp file with facilities", required = true)
- private Path facilities;
@CommandLine.Option(names = "--top-k", description = "Use top k estimates", defaultValue = "9")
private int topK;
@CommandLine.Option(names = "--modes", description = "Modes to include in estimation", split = ",")
private Set modes;
+ @CommandLine.Option(names = "--id-filter", description = "Filter for person ids")
+ private Pattern idFilter;
@CommandLine.Option(names = "--time-util-only", description = "Reset scoring for estimation and only use time utility", defaultValue = "false")
private boolean timeUtil;
@CommandLine.Option(names = "--calc-scores", description = "Perform pseudo scoring for each plan", defaultValue = "false")
private boolean calcScores;
- @CommandLine.Option(names = "--plan-candidates", description = "Method to generate plan candidates", defaultValue = "bestK")
+ @CommandLine.Option(names = "--plan-candidates", description = "Method to generate plan candidates", defaultValue = "diverse")
private PlanCandidates planCandidates = PlanCandidates.bestK;
-
- @CommandLine.Option(names = "--output", description = "Path to output csv.", required = true)
+ @CommandLine.Option(names = "--output", description = "Path to output csv.", defaultValue = "plan-choices.csv")
private Path output;
private ThreadLocal thread;
private ProgressBar pb;
- private MainModeIdentifier mmi = new DefaultAnalysisMainModeIdentifier();
+ private double globalAvgIncome;
public static void main(String[] args) {
new ComputePlanChoices().execute(args);
@@ -82,13 +80,8 @@ public static void main(String[] args) {
@Override
public Integer call() throws Exception {
- if (!shp.isDefined()) {
- log.error("No shapefile defined. Please specify a shapefile for the zones using the --shp option.");
- return 2;
- }
-
- if (!Files.exists(input)) {
- log.error("Input file does not exist: " + input);
+ if (!output.getFileName().toString().contains(".csv")) {
+ log.error("Output file must be a csv file");
return 2;
}
@@ -97,8 +90,11 @@ public Integer call() throws Exception {
config.controller().setLastIteration(0);
config.controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles);
+ SimWrapperConfigGroup sw = ConfigUtils.addOrGetModule(config, SimWrapperConfigGroup.class);
+ sw.defaultDashboards = SimWrapperConfigGroup.Mode.disabled;
+
if (timeUtil) {
- // All utilities expect travel time become zero
+ // All utilities except travel time become zero
config.scoring().setMarginalUtlOfWaitingPt_utils_hr(0);
config.scoring().setUtilityOfLineSwitch(0);
@@ -118,6 +114,10 @@ public Integer call() throws Exception {
topK = 2;
}
+ if (idFilter != null) {
+ log.info("Using person id filter: {}", idFilter);
+ }
+
Controler controler = this.scenario.createControler();
controler.addOverridingModule(InformedModeChoiceModule.newBuilder()
@@ -136,14 +136,7 @@ public Integer call() throws Exception {
Injector injector = controler.getInjector();
- PlanBuilder.addVehiclesToScenario(injector.getInstance(Scenario.class));
-
-
- Population population = PopulationUtils.createPopulation(config);
-
- PlanBuilder builder = new PlanBuilder(shp, new ShpOptions(facilities, null, null), population.getFactory());
-
- builder.createPlans(input).forEach(population::addPerson);
+ Population population = controler.getScenario().getPopulation();
thread = ThreadLocal.withInitial(() ->
new Ctx(
@@ -160,17 +153,32 @@ public Integer call() throws Exception {
)
);
+ globalAvgIncome = population.getPersons().values().stream()
+ .map(PersonUtils::getIncome)
+ .filter(Objects::nonNull)
+ .mapToDouble(d -> d)
+ .filter(dd -> dd > 0)
+ .average()
+ .orElse(Double.NaN);
+
pb = new ProgressBar("Computing plan choices", population.getPersons().size());
ParallelPersonAlgorithmUtils.run(population, Runtime.getRuntime().availableProcessors(), this);
pb.close();
- try (CSVPrinter csv = new CSVPrinter(Files.newBufferedWriter(output), CSVFormat.DEFAULT)) {
+ String out = output.toString().replace(".csv", "-%s_%d.csv".formatted(planCandidates, topK));
+
+ log.info("Writing {} choices to {}", rows.size(), out);
+
+ try (CSVPrinter csv = new CSVPrinter(Files.newBufferedWriter(Path.of(out)), CSVFormat.DEFAULT.builder().setCommentMarker('#').build())) {
// header
List