Skip to content

Commit

Permalink
Merge pull request #25 from matsim-vsp/calibration
Browse files Browse the repository at this point in the history
More flexible calibration
  • Loading branch information
rakow authored Dec 18, 2023
2 parents de029a2 + f7615c1 commit 225f151
Show file tree
Hide file tree
Showing 13 changed files with 1,099 additions and 477 deletions.
26 changes: 23 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,8 @@ Scenarios created with the `matsim-application` contrib provide an interface tha
# -------------------------------------------------------------------
# 5. CALIBRATION: Automatic calibration for MATSim scenario.

from matsim.calibration import create_calibration, ASCCalibrator, utils, study_as_df

modes = ["walk", "car", "pt", "bike"]
fixed_mode = "walk"
target = {
Expand All @@ -246,11 +248,29 @@ target = {
"car": 0.359
}

study, obj = calibration.create_mode_share_study("calib", "./matsim-scenario-1.0-SNAPSHOT.jar",
"./scenarios/input/scenario-v1.0-10pct.config.xml",
modes, fixed_mode, target)
def filter_persons(df):
return df[df.subpopulation == "person"]

def filter_modes(df):
return df[df.main_mode.isin(modes)]

study, obj = create_calibration("calib", ASCCalibrator(modes, initial, target, fixed_mode=fixed_mode,
lr=utils.linear_scheduler(start=0.25, interval=10)),
"./matsim-scenario-1.0-SNAPSHOT.jar",
"./scenarios/input/scenario-v1.0-10pct.config.xml",
args="--config:controler.lastIteration 400",
jvm_args="-Xmx12G -Xmx12G -XX:+AlwaysPreTouch -XX:+UseParallelGC",
transform_persons=filter_persons,
transform_trips=filter_modes,
chain_runs=utils.default_chain_scheduler, debug=False)

study.optimize(obj, 10)

df = study_as_df(study)
df.to_csv("report.csv")

from matsim.calibration.plot import plot_study

plot_study(study)

```
Loading

0 comments on commit 225f151

Please sign in to comment.