Skip to content

Commit

Permalink
update config and calibration
Browse files Browse the repository at this point in the history
  • Loading branch information
rakow committed Nov 20, 2023
1 parent e8458e3 commit 1994d6c
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 25 deletions.
20 changes: 15 additions & 5 deletions input/v1.0/lausitz-v1.0-100pct.config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@

<module name="network">
<param name="inputNetworkFile"
value="https://svn.vsp.tu-berlin.de/repos/public-svn/matsim/scenarios/countries/de/lausitz/input/v1.0/lausitz-v1.0-network-with-pt.xml.gz"/>
value="./lausitz-v1.0-network-with-pt.xml.gz"/>
<param name="laneDefinitionsFile" value="null"/>
</module>

<module name="plans">
<param name="inputPlansFile"
value="https://svn.vsp.tu-berlin.de/repos/public-svn/matsim/scenarios/countries/de/lausitz/input/v1.0//lausitz-v1.0-100pct.plans-initial.xml.gz"/>
value="./lausitz-v1.0-100pct.plans-initial.xml.gz"/>
<param name="removingUnnecessaryPlanAttributes" value="true"/>
</module>

Expand All @@ -39,13 +39,13 @@
</module>

<module name="transit">
<param name="transitScheduleFile" value="https://svn.vsp.tu-berlin.de/repos/public-svn/matsim/scenarios/countries/de/lausitz/input/v1.0//lausitz-v1.0-transitSchedule.xml.gz"/>
<param name="vehiclesFile" value="https://svn.vsp.tu-berlin.de/repos/public-svn/matsim/scenarios/countries/de/lausitz/input/v1.0//lausitz-v1.0-transitVehicles.xml.gz"/>
<param name="transitScheduleFile" value="./lausitz-v1.0-transitSchedule.xml.gz"/>
<param name="vehiclesFile" value="./lausitz-v1.0-transitVehicles.xml.gz"/>
<param name="useTransit" value="true"/>
</module>

<module name="counts">
<param name="inputCountsFile" value="https://svn.vsp.tu-berlin.de/repos/public-svn/matsim/scenarios/countries/de/lausitz/input/v1.0//lausitz-v1.0-counts-car-bast.xml.gz"/>
<param name="inputCountsFile" value="./lausitz-v1.0-counts-car-bast.xml.gz"/>
</module>

<module name="planscalcroute">
Expand Down Expand Up @@ -75,6 +75,16 @@
<param name="insertingWaitingVehiclesBeforeDrivingVehicles" value="true"/>
</module>

<module name="simwrapper" >
<parameterset type="params" >
<param name="context" value="" />
<param name="mapCenter" value="14.5,51.53" />
<param name="mapZoomLevel" value="6.8" />
<param name="sampleSize" value="1" />
<param name="shp" value="../shp/lausitz.shp" />
</parameterset>
</module>

<module name="ReplanningAnnealer" >
<param name="activateAnnealingModule" value="true" />
<parameterset type="AnnealingVariable" >
Expand Down
6 changes: 0 additions & 6 deletions src/main/java/org/matsim/run/RunLausitzScenario.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,6 @@ protected Config prepareConfig(Config config) {

SimWrapperConfigGroup simWrapper = ConfigUtils.addOrGetModule(config, SimWrapperConfigGroup.class);

// Path is relative to config
simWrapper.defaultParams().shp = "../shp/lausitz.shp";
simWrapper.defaultParams().mapCenter = "14.5,51.53";
simWrapper.defaultParams().mapZoomLevel = 6.8;
simWrapper.defaultParams().sampleSize = 1d;

if (sample.isSet()) {
config.controller().setOutputDirectory(sample.adjustName(config.controller().getOutputDirectory()));
config.plans().setInputFile(sample.adjustName(config.plans().getInputFile()));
Expand Down
21 changes: 9 additions & 12 deletions src/main/python/calibrate.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import os

import geopandas as gpd
import os
import pandas as pd

try:
Expand Down Expand Up @@ -32,8 +31,8 @@
fixed_mode = "walk"
initial = {
"bike": -0.141210,
"pt": 0.0781477780346438,
"car": 0.871977390743304,
"pt": 0,
"car": 0,
"ride": -2.22873502992
}

Expand All @@ -59,20 +58,18 @@ def filter_persons(persons):


def filter_modes(df):
df = df[df.main_mode != "freight"]
# Set multi-modal trips to pt
df.loc[df.main_mode.str.startswith("pt_"), "main_mode"] = "pt"

return df

return df[df.main_mode.isin(modes)]

# FIXME: Adjust paths and config

study, obj = calibration.create_mode_share_study("calib", "matsim-template-1.0.jar",
"../scenarios/metropole-ruhr-v1.0/input/metropole-ruhr-v1.4-3pct.config.xml",
study, obj = calibration.create_mode_share_study("calib", "matsim-lausitz-1.x-SNAPSHOT-e8458e3.jar",
"../input/v1.0/lausitz-v1.0-100pct.config.xml",
modes, target,
initial_asc=initial,
args="--10pct",
jvm_args="-Xmx75G -Xmx75G -XX:+AlwaysPreTouch",
args="--25pct",
jvm_args="-Xmx60G -Xmx60G -XX:+AlwaysPreTouch -XX:+UseParallelGC",
transform_persons=filter_persons, transform_trips=filter_modes,
lr=calibration.linear_lr_scheduler(start=0.3, interval=8),
chain_runs=calibration.default_chain_scheduler)
Expand Down
8 changes: 6 additions & 2 deletions src/main/sh/setup.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
#!/bin/bash
#!/usr/bin/env bash

python3 -m venv env
source env/bin/activate

module load gcc/9.2.0

pip install --upgrade pip
pip install matsim optuna geopandas rtree pygeos
pip install optuna geopandas rtree pygeos

# Download latest calibration script
wget "https://github.com/matsim-vsp/matsim-python-tools/raw/master/matsim/calibration.py"
wget "https://github.com/matsim-vsp/matsim-python-tools/raw/master/matsim/analysis.py"

0 comments on commit 1994d6c

Please sign in to comment.