Skip to content

Commit

Permalink
Merge pull request #68 from ie3-institute/ck/#66-optionallyRemoveSwit…
Browse files Browse the repository at this point in the history
…ches

Allow to remove switches when converting
  • Loading branch information
t-ober authored Aug 25, 2021
2 parents d7e55e1 + eb91814 commit 4a3213d
Show file tree
Hide file tree
Showing 21 changed files with 981 additions and 312 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# simBench2pdsm
[![Build Status](https://travis-ci.org/ie3-institute/simbench4ie3.svg?branch=master)](https://travis-ci.org/ie3-institute/simbench4ie3)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/c339035212004716bab94c774da476aa)](https://app.codacy.com/gh/ie3-institute/simbench4ie3?utm_source=github.com&utm_medium=referral&utm_content=ie3-institute/simbench4ie3&utm_campaign=Badge_Grade_Dashboard)
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/793affe18cd44718a66b07b2a7c45258)](https://www.codacy.com/gh/ie3-institute/simBench2psdm/dashboard?utm_source=github.com&utm_medium=referral&utm_content=ie3-institute/simBench2psdm&utm_campaign=Badge_Grade)
[![codecov](https://codecov.io/gh/ie3-institute/simBench2psdm/branch/master/graph/badge.svg)](https://codecov.io/gh/ie3-institute/simBench2psdm)
[![License](https://img.shields.io/github/license/ie3-institute/simbench4ie3)](https://github.com/ie3-institute/simbench4ie3/blob/master/LICENSE)

Expand Down
5 changes: 3 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ ext {
}

group = 'com.github.ie3-institute'
description = 'simbench4ie3'
description = 'simbench2psdm'
version = '1.1-SNAPSHOT'
sourceCompatibility = javaVersion
targetCompatibility = javaVersion
Expand Down Expand Up @@ -53,7 +53,7 @@ dependencies {
}

/* util functions */
implementation ('com.github.ie3-institute:PowerSystemUtils:1.5.3') {
implementation ('com.github.ie3-institute:PowerSystemUtils:1.6-SNAPSHOT') {
/* Exclude nested logging and ie3 related dependencies */
exclude group: 'org.slf4j', module: 'slf4j-api'
exclude group: 'com.github.ie3-institute'
Expand All @@ -74,6 +74,7 @@ dependencies {
// NEW scala libs //
// CORE Scala //
implementation "org.scala-lang:scala-library:$scalaBinaryVersion"
implementation 'org.scala-lang.modules:scala-parallel-collections_2.13:1.0.3'

// TEST Scala //
testImplementation "org.scalatest:scalatest_${scalaVersion}:3.2.0"
Expand Down
18 changes: 18 additions & 0 deletions docs/diagrams/RemoveSwitches.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
@startuml

(*) --> "Choose all closed switches"
--> "Identify switch groups"
note right: By iterating over all existing switches\nand building bags of nodes, that are\ndirectly connected via switches.If a node\n of a following switch is already in a bag,\nthen add the switch to thisswitch group.
--> "Take the next switch group"
--> "Identify main node"
note left: By counting the occurrences of\nthis node within all nodes of\nthat switch group. If all nodes\noccur only once, take the first\none.
--> "Build collapsing mapping"
note left: By assigning all nodes\nof a switch group to the\nmain node.
if "Last group" then
-->[true] "Consider mapping when converting node models"
--> "Do not convert switch models"
--> (*)
else
-->[false] "Take the next switch group"

@enduml
File renamed without changes.
109 changes: 109 additions & 0 deletions inputData/config/mvLvNoSwitches.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
# Simple config to convert all models that comprise mv and lv -- either single or connected
io {
input {
csv = {
fileEncoding = "UTF-8"
fileEnding = ".csv"
separator = ";"
directoryHierarchy = false
}
}

output {
csv = {
fileEncoding = "UTF-8"
fileEnding = ".csv"
separator = ";"
directoryHierarchy = false
}

targetFolder = "convertedData/mvLvNoSwitches"
compress = true
}

simbenchCodes = [
"1-MVLV-comm-3.403-0-no_sw",
"1-MVLV-comm-3.403-1-no_sw",
"1-MVLV-comm-3.403-2-no_sw",
"1-MVLV-comm-4.416-0-no_sw",
"1-MVLV-comm-4.416-1-no_sw",
"1-MVLV-comm-4.416-2-no_sw",
"1-MVLV-comm-5.401-0-no_sw",
"1-MVLV-comm-5.401-1-no_sw",
"1-MVLV-comm-5.401-2-no_sw",
"1-MVLV-rural-1.108-0-no_sw",
"1-MVLV-rural-1.108-1-no_sw",
"1-MVLV-rural-1.108-2-no_sw",
"1-MVLV-rural-2.107-0-no_sw",
"1-MVLV-rural-2.107-1-no_sw",
"1-MVLV-rural-2.107-2-no_sw",
"1-MVLV-rural-4.101-0-no_sw",
"1-MVLV-rural-4.101-1-no_sw",
"1-MVLV-rural-4.101-2-no_sw",
"1-MVLV-semiurb-3.202-0-no_sw",
"1-MVLV-semiurb-3.202-1-no_sw",
"1-MVLV-semiurb-3.202-2-no_sw",
"1-MVLV-semiurb-4.201-0-no_sw",
"1-MVLV-semiurb-4.201-1-no_sw",
"1-MVLV-semiurb-4.201-2-no_sw",
"1-MVLV-semiurb-5.220-0-no_sw",
"1-MVLV-semiurb-5.220-1-no_sw",
"1-MVLV-semiurb-5.220-2-no_sw",
"1-MVLV-urban-5.303-0-no_sw",
"1-MVLV-urban-5.303-1-no_sw",
"1-MVLV-urban-5.303-2-no_sw",
"1-MVLV-urban-6.305-0-no_sw",
"1-MVLV-urban-6.305-1-no_sw",
"1-MVLV-urban-6.305-2-no_sw",
"1-MVLV-urban-6.309-0-no_sw",
"1-MVLV-urban-6.309-1-no_sw",
"1-MVLV-urban-6.309-2-no_sw",
"1-LV-rural1--0-no_sw",
"1-LV-rural1--1-no_sw",
"1-LV-rural1--2-no_sw",
"1-LV-rural2--0-no_sw",
"1-LV-rural2--1-no_sw",
"1-LV-rural2--2-no_sw",
"1-LV-rural3--0-no_sw",
"1-LV-rural3--1-no_sw",
"1-LV-rural3--2-no_sw",
"1-LV-semiurb4--0-no_sw",
"1-LV-semiurb4--1-no_sw",
"1-LV-semiurb4--2-no_sw",
"1-LV-semiurb5--0-no_sw",
"1-LV-semiurb5--1-no_sw",
"1-LV-semiurb5--2-no_sw",
"1-LV-urban6--0-no_sw",
"1-LV-urban6--1-no_sw",
"1-LV-urban6--2-no_sw",
// "1-MV-comm--0-no_sw",
"1-MV-comm--1-no_sw",
"1-MV-comm--2-no_sw",
"1-MV-rural--0-no_sw",
"1-MV-rural--1-no_sw",
"1-MV-rural--2-no_sw",
"1-MV-semiurb--0-no_sw",
"1-MV-semiurb--1-no_sw",
"1-MV-semiurb--2-no_sw",
"1-MV-urban--0-no_sw",
"1-MV-urban--1-no_sw",
"1-MV-urban--2-no_sw",
# Causing memory issues
#"1-MVLV-comm-all-0-no_sw",
#"1-MVLV-comm-all-1-no_sw",
#"1-MVLV-comm-all-2-no_sw",
#"1-MVLV-rural-all-0-no_sw",
#"1-MVLV-rural-all-1-no_sw",
#"1-MVLV-rural-all-2-no_sw",
#"1-MVLV-semiurb-all-0-no_sw",
#"1-MVLV-semiurb-all-1-no_sw",
#"1-MVLV-semiurb-all-2-no_sw",
#"1-MVLV-urban-all-0-no_sw",
#"1-MVLV-urban-all-1-no_sw",
#"1-MVLV-urban-all-2-no_sw",
]
}

conversion {
removeSwitches = true
}
25 changes: 16 additions & 9 deletions src/main/resources/config-template.conf
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,20 @@ CsvConfig {
directoryHierarchy = "Boolean" | false
}

io.simbenchCodes = ["String"]
io.input {
download.baseUrl = "String" | "http://141.51.193.167/simbench/gui/usecase/download"
download.folder = "String" | "inputData/download/"
download.failOnExistingFiles = "Boolean" | false
csv = CsvConfig
io {
simbenchCodes = ["String"]
input {
download.baseUrl = "String" | "http://141.51.193.167/simbench/gui/usecase/download"
download.folder = "String" | "inputData/download/"
download.failOnExistingFiles = "Boolean" | false
csv = CsvConfig
}
output {
csv = CsvConfig
targetFolder = "String" | "convertedData"
compress = "Boolean" | true
}
}
io.output.csv = CsvConfig
io.output.targetFolder = "String" | "convertedData"
io.output.compress = "Boolean" | true
conversion {
removeSwitches = "Boolean" | false
}
54 changes: 45 additions & 9 deletions src/main/scala/edu/ie3/simbench/config/SimbenchConfig.scala
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
// generated by tscfg 0.9.98 on Tue Oct 27 11:46:02 CET 2020
// generated by tscfg 0.9.986 on Mon Aug 09 20:12:24 CEST 2021
// source: src/main/resources/config-template.conf

package edu.ie3.simbench.config

final case class SimbenchConfig(
conversion: SimbenchConfig.Conversion,
io: SimbenchConfig.Io
)
object SimbenchConfig {
Expand All @@ -20,8 +21,10 @@ object SimbenchConfig {
$tsCfgValidator: $TsCfgValidator
): SimbenchConfig.CsvConfig = {
SimbenchConfig.CsvConfig(
directoryHierarchy = c.hasPathOrNull("directoryHierarchy") && c
.getBoolean("directoryHierarchy"),
directoryHierarchy =
c.hasPathOrNull("directoryHierarchy") && c.getBoolean(
"directoryHierarchy"
),
fileEncoding =
if (c.hasPathOrNull("fileEncoding")) c.getString("fileEncoding")
else "UTF-8",
Expand All @@ -34,14 +37,31 @@ object SimbenchConfig {
}
}

final case class Conversion(
removeSwitches: scala.Boolean
)
object Conversion {
def apply(
c: com.typesafe.config.Config,
parentPath: java.lang.String,
$tsCfgValidator: $TsCfgValidator
): SimbenchConfig.Conversion = {
SimbenchConfig.Conversion(
removeSwitches = c.hasPathOrNull("removeSwitches") && c.getBoolean(
"removeSwitches"
)
)
}
}

final case class Io(
input: SimbenchConfig.Io.Input,
output: SimbenchConfig.Io.Output,
simbenchCodes: scala.List[java.lang.String]
)
object Io {
final case class Input(
csv: CsvConfig,
csv: SimbenchConfig.CsvConfig,
download: SimbenchConfig.Io.Input.Download
)
object Input {
Expand All @@ -60,8 +80,10 @@ object SimbenchConfig {
baseUrl =
if (c.hasPathOrNull("baseUrl")) c.getString("baseUrl")
else "http://141.51.193.167/simbench/gui/usecase/download",
failOnExistingFiles = c.hasPathOrNull("failOnExistingFiles") && c
.getBoolean("failOnExistingFiles"),
failOnExistingFiles =
c.hasPathOrNull("failOnExistingFiles") && c.getBoolean(
"failOnExistingFiles"
),
folder =
if (c.hasPathOrNull("folder")) c.getString("folder")
else "inputData/download/"
Expand All @@ -75,7 +97,7 @@ object SimbenchConfig {
$tsCfgValidator: $TsCfgValidator
): SimbenchConfig.Io.Input = {
SimbenchConfig.Io.Input(
csv = CsvConfig(
csv = SimbenchConfig.CsvConfig(
if (c.hasPathOrNull("csv")) c.getConfig("csv")
else com.typesafe.config.ConfigFactory.parseString("csv{}"),
parentPath + "csv.",
Expand All @@ -93,7 +115,7 @@ object SimbenchConfig {

final case class Output(
compress: scala.Boolean,
csv: CsvConfig,
csv: SimbenchConfig.CsvConfig,
targetFolder: java.lang.String
)
object Output {
Expand All @@ -104,7 +126,7 @@ object SimbenchConfig {
): SimbenchConfig.Io.Output = {
SimbenchConfig.Io.Output(
compress = !c.hasPathOrNull("compress") || c.getBoolean("compress"),
csv = CsvConfig(
csv = SimbenchConfig.CsvConfig(
if (c.hasPathOrNull("csv")) c.getConfig("csv")
else com.typesafe.config.ConfigFactory.parseString("csv{}"),
parentPath + "csv.",
Expand Down Expand Up @@ -145,6 +167,12 @@ object SimbenchConfig {
val $tsCfgValidator: $TsCfgValidator = new $TsCfgValidator()
val parentPath: java.lang.String = ""
val $result = SimbenchConfig(
conversion = SimbenchConfig.Conversion(
if (c.hasPathOrNull("conversion")) c.getConfig("conversion")
else com.typesafe.config.ConfigFactory.parseString("conversion{}"),
parentPath + "conversion.",
$tsCfgValidator
),
io = SimbenchConfig.Io(
if (c.hasPathOrNull("io")) c.getConfig("io")
else com.typesafe.config.ConfigFactory.parseString("io{}"),
Expand Down Expand Up @@ -191,6 +219,14 @@ object SimbenchConfig {
badPaths += s"'$path': ${e.getClass.getName}(${e.getMessage})"
}

def addInvalidEnumValue(
path: java.lang.String,
value: java.lang.String,
enumName: java.lang.String
): Unit = {
badPaths += s"'$path': invalid value $value for enumeration $enumName"
}

def validate(): Unit = {
if (badPaths.nonEmpty) {
throw new com.typesafe.config.ConfigException(
Expand Down
Loading

0 comments on commit 4a3213d

Please sign in to comment.