From a7e733dd8a9a1eaf80b46ff23f49fc2e2e7cd85d Mon Sep 17 00:00:00 2001 From: Martin Scheidt Date: Fri, 10 Dec 2021 18:30:08 +0100 Subject: [PATCH] fixed MinimalWorkingExample.jl with working paths --- README.md | 10 +++- data/paths/path_1_10km_nConst_vConst.yaml | 1 + data/paths/path_2_10km_nVar_vConst.yaml | 1 + data/paths/path_3_10km_nConst_vVar.yaml | 1 + .../path_4_real_Ostsachsen_DG-DN_spp_5.yaml | 1 + data/settings.yaml | 5 +- .../train_freight_V90withOreConsist.yaml | 1 + data/trains/train_passenger_IC2.yaml | 1 + .../train_passenger_SiemensDesiroClassic.yaml | 1 + examples/MinimalWorkingExample.jl | 48 +++++-------------- test/runtests.jl | 47 +++++++++--------- 11 files changed, 56 insertions(+), 61 deletions(-) diff --git a/README.md b/README.md index 35bb997..28081f0 100644 --- a/README.md +++ b/README.md @@ -17,8 +17,16 @@ Review the settings.yaml file for your appropriate settings. # Minimal working example -See folder examples. +```julia +include("../src/TrainRun.jl") +using .TrainRun +train = "data/trains/train_freight_V90withOreConsist.yaml" +running_path = "data/paths/path_1_10km_nConst_vConst.yaml" +setting = "data/settings.yaml" + +train_run = calculateDrivingDynamics(train, running_path, setting) +``` ------------ # History diff --git a/data/paths/path_1_10km_nConst_vConst.yaml b/data/paths/path_1_10km_nConst_vConst.yaml index 1e9cf39..25a1516 100644 --- a/data/paths/path_1_10km_nConst_vConst.yaml +++ b/data/paths/path_1_10km_nConst_vConst.yaml @@ -1,3 +1,4 @@ +%YAML 1.2 --- path: name: "10 km, no gradient, 160 km/h" diff --git a/data/paths/path_2_10km_nVar_vConst.yaml b/data/paths/path_2_10km_nVar_vConst.yaml index de9e27e..a5b77ed 100644 --- a/data/paths/path_2_10km_nVar_vConst.yaml +++ b/data/paths/path_2_10km_nVar_vConst.yaml @@ -1,3 +1,4 @@ +%YAML 1.2 --- path: name: "10 km, different gradient, 160 km/h" diff --git a/data/paths/path_3_10km_nConst_vVar.yaml b/data/paths/path_3_10km_nConst_vVar.yaml index a45c323..6e8c29f 100644 --- a/data/paths/path_3_10km_nConst_vVar.yaml +++ b/data/paths/path_3_10km_nConst_vVar.yaml @@ -1,3 +1,4 @@ +%YAML 1.2 --- path: name: "10 km, no gradient, different speed limits" diff --git a/data/paths/path_4_real_Ostsachsen_DG-DN_spp_5.yaml b/data/paths/path_4_real_Ostsachsen_DG-DN_spp_5.yaml index 5a152fd..865789a 100644 --- a/data/paths/path_4_real_Ostsachsen_DG-DN_spp_5.yaml +++ b/data/paths/path_4_real_Ostsachsen_DG-DN_spp_5.yaml @@ -1,3 +1,4 @@ +%YAML 1.2 --- path: name: "'infra_Ostsachsen': track id='tr_80.6212_2' name='DG-DN' -> spp_5" diff --git a/data/settings.yaml b/data/settings.yaml index 9f2ea28..9386555 100644 --- a/data/settings.yaml +++ b/data/settings.yaml @@ -1,3 +1,4 @@ +%YAML 1.2 --- settings: # settings for the simulation @@ -6,6 +7,6 @@ settings: stepSize: 10 # step size (unit depends on stepVariable s in m, t in s and v in m/s) operationModeMinimumRunningTime: true # operation mode "minimum running time" operationModeMinimumEnergyConsumption: true # operation mode "minimum energy consumption" - typeOfOutput: "CSV" # output as "julia dictionary" or as "CSV" + typeOfOutput: "julia dictionary" # output as "julia dictionary" or as "CSV" detailOfOutput: "driving course" # should the output be "reduced" or "driving course"? - csvFolderPath: "~/Desktop/TrainRun" + # csvDirectory: "~/Desktop/TrainRun" diff --git a/data/trains/train_freight_V90withOreConsist.yaml b/data/trains/train_freight_V90withOreConsist.yaml index 755f8ce..5857095 100644 --- a/data/trains/train_freight_V90withOreConsist.yaml +++ b/data/trains/train_freight_V90withOreConsist.yaml @@ -1,3 +1,4 @@ +%YAML 1.2 --- train: name: "V 90 with 10 ore wagons of type Facs 124" # (source: https://de.wikipedia.org/wiki/DB-Baureihe_V_90 and https://dybas.de/dybas/gw/gw_f_1/g124.html) diff --git a/data/trains/train_passenger_IC2.yaml b/data/trains/train_passenger_IC2.yaml index f84fe10..516efbc 100644 --- a/data/trains/train_passenger_IC2.yaml +++ b/data/trains/train_passenger_IC2.yaml @@ -1,3 +1,4 @@ +%YAML 1.2 --- train: name: "Intercity 2 (Traxx P160 AC2 + double deck coaches)" # (source: https://de.wikipedia.org/wiki/Bombardier_Twindexx_Vario#Intercity_2 and https://de.wikipedia.org/wiki/Intercity_2_(Deutsche_Bahn)) diff --git a/data/trains/train_passenger_SiemensDesiroClassic.yaml b/data/trains/train_passenger_SiemensDesiroClassic.yaml index 6692927..f755adb 100644 --- a/data/trains/train_passenger_SiemensDesiroClassic.yaml +++ b/data/trains/train_passenger_SiemensDesiroClassic.yaml @@ -1,3 +1,4 @@ +%YAML 1.2 --- train: name: "Siemens Desiro Classic" # (source: https://de.wikipedia.org/wiki/Siemens_Desiro_Classic) diff --git a/examples/MinimalWorkingExample.jl b/examples/MinimalWorkingExample.jl index 1eb8f38..92cc221 100644 --- a/examples/MinimalWorkingExample.jl +++ b/examples/MinimalWorkingExample.jl @@ -1,40 +1,18 @@ +#!/usr/bin/env julia +# -*- coding: UTF-8 -*- +# __julia-version__ = 1.7.0 +# __author__ = "Max Kannenberg" +# __copyright__ = "2021" +# __license__ = "ISC" + include("../src/TrainRun.jl") using .TrainRun +train = "data/trains/train_freight_V90withOreConsist.yaml" +running_path = "data/paths/path_1_10km_nConst_vConst.yaml" +setting = "data/settings.yaml" -# println("") -# println("________________________") -# println("") +train_run = calculateDrivingDynamics(train, running_path, setting) +runtime = last(train_run["outputArrayMinimumRunningTime"])[5] - -allPaths=[] -push!(allPaths, "../data/paths/path_1_10km_nConst_vConst.yaml") -push!(allPaths, "../data/paths/path_2_10km_nVar_vConst.yaml") -push!(allPaths, "../data/paths/path_3_10km_nConst_vVar.yaml") -push!(allPaths, "../data/paths/path_4_real_Ostsachsen_DG-DN_spp_5.yaml") - -allSettings=[] -push!(allSettings, "../data/settings.yaml") - -allTrains=[] -push!(allTrains, "../data/trains/train_freight_V90withOreConsist.yaml") -push!(allTrains, "../data/trains/train_yaml_files\\train_passenger_SiemensDesiroClassic.yaml") -push!(allTrains, "../data/trains/train_passenger_IC2.yaml") - -for pathDirectory in allPaths - # println("") - # println(" - - - - - - - - -") - # println("path: ", pathDirectory) - for trainDirectory in allTrains - # println("train: ", trainDirectory) - for settingsDirectory in allSettings - testDict=calculateDrivingDynamics(trainDirectory, pathDirectory, settingsDirectory) - - sleep(2) - - # println("") - # println("") - # println("") - end - end -end +println("The V 90 with 10 ore wagons needs $runtime seconds for 10 km with no gradient.") \ No newline at end of file diff --git a/test/runtests.jl b/test/runtests.jl index 2e9512a..dd57658 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,38 +1,39 @@ -# access in pkg mode with >>>>> ] test TrainRun <<<< +#!/usr/bin/env julia +# -*- coding: UTF-8 -*- +# __julia-version__ = 1.7.0 +# __author__ = "Max Kannenberg" +# __copyright__ = "2021" +# __license__ = "ISC" using TrainRun, Test - allPaths=[] -push!(allPaths, "../data/paths/path_1_10km_nConst_vConst.yaml") -push!(allPaths, "../data/paths/path_2_10km_nVar_vConst.yaml") -push!(allPaths, "../data/paths/path_3_10km_nConst_vVar.yaml") -push!(allPaths, "../data/paths/path_4_real_Ostsachsen_DG-DN_spp_5.yaml") +push!(allPaths, "data/paths/path_1_10km_nConst_vConst.yaml") +push!(allPaths, "data/paths/path_2_10km_nVar_vConst.yaml") +push!(allPaths, "data/paths/path_3_10km_nConst_vVar.yaml") +push!(allPaths, "data/paths/path_4_real_Ostsachsen_DG-DN_spp_5.yaml") allSettings=[] -push!(allSettings, "../data/settings.yaml") +push!(allSettings, "data/settings.yaml") allTrains=[] -push!(allTrains, "../data/trains/train_freight_V90withOreConsist.yaml") -push!(allTrains, "../data/trains/train_yaml_files\\train_passenger_SiemensDesiroClassic.yaml") -push!(allTrains, "../data/trains/train_passenger_IC2.yaml") +push!(allTrains, "data/trains/train_freight_V90withOreConsist.yaml") +push!(allTrains, "data/trains/train_passenger_SiemensDesiroClassic.yaml") +push!(allTrains, "data/trains/train_passenger_IC2.yaml") for pathDirectory in allPaths - # println("") - # println(" - - - - - - - - -") - # println("path: ", pathDirectory) - for trainDirectory in allTrains - # println("train: ", trainDirectory) - for settingsDirectory in allSettings - testDict=calculateDrivingDynamics(trainDirectory, pathDirectory, settingsDirectory) + for trainDirectory in allTrains + for settingsDirectory in allSettings + testDict=calculateDrivingDynamics(trainDirectory, pathDirectory, settingsDirectory) - sleep(2) + sleep(2) - # println("") - # println("") - # println("") - end - end + # TODO: + # compare result to test data set + end + end end println("test finished") +# TODO: +# print test results