-
Notifications
You must be signed in to change notification settings - Fork 0
Mapping branches in new UCT #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 6 commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
333c39c
UCTE mapping for one line
Sebasss-h 0a77289
Create MappingResults.java
Sebasss-h 1acfea4
Check style
Sebasss-h c709850
Fix
Sebasss-h b5fad73
Test Multi Lines ?
Sebasss-h 4089718
Test Multi Lines
Sebasss-h a7b822a
Test Multi Lines elementName
Sebasss-h 470379c
Refactor UcteMappingTest for improved readability and logic.
OpenSuze 2eac7d6
Handle null values for elementName in UcteMapping.
OpenSuze 8ffa76c
Test Line Switch Position
Sebasss-h 4b74b1c
Merge remote-tracking branch 'origin/ucteMapping' into ucteMapping
Sebasss-h e398128
Test Weird Cases (missing line)
Sebasss-h 9bf4a5e
TieLines and Duplicate Values
Sebasss-h 399bba1
Correction UCTEMapping
Sebasss-h b249e63
Refactoring 1 UcteMapping
Sebasss-h e1f6b01
Add importNetworkInPc and searching bugs
Sebasss-h 836f2e5
Solving and detecting problems UcteMappingTest
Sebasss-h fb4c94d
Solving and detecting problems UcteMappingTest
Sebasss-h 6e2496b
Solving and detecting problems testRealNetwork
Sebasss-h 2c302bc
Adding isFictitious filter
Sebasss-h 2138b81
UcteMapping mapNetworks2
Sebasss-h cd70139
UcteMapping mapNetworks2
Sebasss-h 1759760
Merge branch 'main' into ucteMapping
Sebasss-h 5667b91
UcteMapping line "clean"
Sebasss-h 81d3026
Removing impact Trm algorithm
Sebasss-h 1dead70
Put private package visibility ucte mapping
Sebasss-h 6dc9252
Fix country filtering incorrect implementation
Sebasss-h c2c40f4
Improve readability of the code and overall performance
Sebasss-h 845b1ff
Improve return statements
Sebasss-h 49b1791
DuplicateCheck method
Sebasss-h 1255c30
DuplicateCheck method in mapNetworks
Sebasss-h 44fdc6b
Refactor Uctemapping function
Sebasss-h 5a1848e
UcteMapper function and fix-tests
Sebasss-h a8caada
Fix tests and update code comments
Sebasss-h 5fe88bf
Implement UCteMapper in TrmAlgorithm and identify bug in test
Sebasss-h 40137a1
Fix TrmAlgorithm
Sebasss-h 739e123
rollback file modifications
murgeyseb c422bf8
rollback file modifications
murgeyseb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
src/main/java/com/rte_france/trm_algorithm/MappingResults.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| /* | ||
| * Copyright (c) 2024, RTE (http://www.rte-france.com) | ||
| * This Source Code Form is subject to the terms of the Mozilla Public | ||
| * License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| * file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
| * SPDX-License-Identifier: MPL-2.0 | ||
| */ | ||
| package com.rte_france.trm_algorithm; | ||
|
|
||
| /** | ||
| * @author Sebastian Huaraca {@literal <sebastian.huaracalapa at rte-france.com>} | ||
| */ | ||
|
|
||
| public record MappingResults(String lineFromMarketBasedNetwork, String lineFromReferenceNetwork, boolean mappingFound) { | ||
|
|
||
| } |
66 changes: 66 additions & 0 deletions
66
src/main/java/com/rte_france/trm_algorithm/UcteMapping.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| /* | ||
| * Copyright (c) 2024, RTE (http://www.rte-france.com) | ||
| * This Source Code Form is subject to the terms of the Mozilla Public | ||
| * License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| * file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
| * SPDX-License-Identifier: MPL-2.0 | ||
| */ | ||
| package com.rte_france.trm_algorithm; | ||
|
|
||
| import com.powsybl.iidm.network.Line; | ||
| import com.powsybl.iidm.network.Network; | ||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
|
|
||
| /** | ||
| * @author Sebastian Huaraca {@literal <sebastian.huaracalapa at rte-france.com>} | ||
| */ | ||
|
|
||
| public final class UcteMapping { | ||
| private static final Logger LOGGER = LoggerFactory.getLogger(UcteMapping.class); | ||
|
|
||
| public static MappingResults mapNetworks(Network networkReference, Network networkMarketBased, String marketBasedId) { | ||
|
|
||
| String voltageLevelSide1 = getVoltageLevelSide1(marketBasedId); | ||
| String voltageLevelSide2 = getVoltageLevelSide2(marketBasedId); | ||
| String orderCode = getOrderCode(marketBasedId); | ||
|
|
||
| List<Line> matchLine = new ArrayList<>(); | ||
| networkReference.getLines().forEach(line -> { | ||
| String idLine = line.getId(); | ||
|
|
||
| if (getVoltageLevelSide1(idLine).equals(voltageLevelSide1) && getVoltageLevelSide2(idLine).equals(voltageLevelSide2) && getOrderCode(idLine).equals(orderCode)) { | ||
| matchLine.add(line); | ||
| } | ||
|
|
||
|
OpenSuze marked this conversation as resolved.
Outdated
|
||
| }); | ||
| int nombreLines = matchLine.size(); | ||
|
|
||
| if (nombreLines > 1) { | ||
| LOGGER.error("Several matching lines found for: {}", marketBasedId); | ||
| } else if (nombreLines == 0) { | ||
| LOGGER.error("No matching line found for: {}", marketBasedId); | ||
| } else { | ||
| return new MappingResults(marketBasedId, matchLine.get(0).getId(), true); | ||
| } | ||
| return new MappingResults(marketBasedId, "", false); | ||
| } | ||
|
|
||
| private static String getOrderCode(String id) { | ||
| return id.substring(18); | ||
| } | ||
|
|
||
| private static String getVoltageLevelSide2(String id) { | ||
| return id.substring(9, 16); | ||
| } | ||
|
|
||
| private static String getVoltageLevelSide1(String id) { | ||
| return id.substring(0, 7); | ||
| } | ||
|
|
||
| private UcteMapping() { | ||
|
OpenSuze marked this conversation as resolved.
Outdated
|
||
| } | ||
|
|
||
| } | ||
59 changes: 59 additions & 0 deletions
59
src/test/java/com/rte_france/trm_algorithm/UcteMappingTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| /* | ||
| * Copyright (c) 2024, RTE (http://www.rte-france.com) | ||
| * This Source Code Form is subject to the terms of the Mozilla Public | ||
| * License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| * file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
| * SPDX-License-Identifier: MPL-2.0 | ||
| */ | ||
| package com.rte_france.trm_algorithm; | ||
|
|
||
| import com.powsybl.iidm.network.Line; | ||
| import com.powsybl.iidm.network.Network; | ||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
|
|
||
| import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
|
||
| /** | ||
| * @author Sebastian Huaraca {@literal <sebastian.huaracalapa at rte-france.com>} | ||
| */ | ||
|
|
||
| public class UcteMappingTest { | ||
| @Test | ||
| void testMapIdenticalLine() { | ||
| Network networkReference = TestUtils.importNetwork("TestCase12Nodes/TestCase12Nodes.uct"); | ||
| Network networkMarketBased = TestUtils.importNetwork("TestCase12Nodes/TestCase12Nodes.uct"); | ||
| Line line = networkMarketBased.getLine("BBE1AA1 BBE2AA1 1"); | ||
| MappingResults mappingResults = UcteMapping.mapNetworks(networkReference, networkMarketBased, line.getId()); | ||
| String lineId = mappingResults.lineFromReferenceNetwork(); | ||
| assertEquals("BBE1AA1 BBE2AA1 1", lineId); | ||
| } | ||
|
|
||
| @Test | ||
| void testMapExistingLine() { | ||
| Network networkReference = TestUtils.importNetwork("TestCase12Nodes/TestCase12Nodes_NewId.uct"); | ||
| Network networkMarketBased = TestUtils.importNetwork("TestCase12Nodes/TestCase12Nodes.uct"); | ||
| Line line = networkMarketBased.getLine("BBE1AA1 BBE2AA1 1"); | ||
| MappingResults mappingResults = UcteMapping.mapNetworks(networkReference, networkMarketBased, line.getId()); | ||
| String lineId = mappingResults.lineFromReferenceNetwork(); | ||
| assertEquals("BBE1AA12 BBE2AA11 1", lineId); | ||
| System.out.println(); | ||
| } | ||
|
|
||
| @Test | ||
| void testMultiLines() { | ||
| //Network networkReference = TestUtils.importNetwork("TestCase12Nodes/TestCase12Nodes_NewId.uct"); | ||
| //Network networkMarketBased = TestUtils.importNetwork("TestCase12Nodes/TestCase12Nodes.uct"); | ||
|
Sebasss-h marked this conversation as resolved.
Outdated
|
||
| Network networkReference = TestUtils.importNetwork("TestCase12Nodes/TestCase12Nodes.uct"); | ||
| Network networkMarketBased = TestUtils.importNetwork("TestCase12Nodes/TestCase12Nodes_NewId.uct"); | ||
| List<Line> lines = new ArrayList<>(); | ||
| lines = networkMarketBased.getLineStream().toList(); | ||
| for (Line line : lines) { | ||
| MappingResults mappingResults = UcteMapping.mapNetworks(networkReference, networkMarketBased, line.getId()); | ||
| String lineId = mappingResults.lineFromReferenceNetwork(); | ||
| System.out.println(line + " || " + lineId); | ||
|
OpenSuze marked this conversation as resolved.
Outdated
|
||
| } | ||
| } | ||
| } | ||
|
Sebasss-h marked this conversation as resolved.
Outdated
|
||
38 changes: 38 additions & 0 deletions
38
src/test/resources/com/rte_france/trm_algorithm/TestCase12Nodes/TestCase12Nodes_NewId.uct
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| ##C 2007.05.01 | ||
| ##N | ||
| ##ZBE | ||
| BBE1AA12 BE1 0 2 400.00 2500.00 0.00000 -1500.0 0.00000 9000.00 -9000.0 9000.00 -9000.0 | ||
| BBE2AA11 BE2 0 2 400.00 1000.00 0.00000 -3000.0 0.00000 9000.00 -9000.0 9000.00 -9000.0 | ||
| BBE3AA1 BE3 0 2 400.00 1500.00 0.00000 -2500.0 0.00000 9000.00 -9000.0 9000.00 -9000.0 | ||
| ##ZDE | ||
| DDE1AA1 DE1 0 2 400.00 3500.00 0.00000 -2500.0 0.00000 9000.00 -9000.0 9000.00 -9000.0 | ||
| DDE2AA1 DE2 0 2 400.00 3000.00 0.00000 -2000.0 0.00000 9000.00 -9000.0 9000.00 -9000.0 | ||
| DDE3AA1 DE3 0 2 400.00 2000.00 0.00000 -1500.0 0.00000 9000.00 -9000.0 9000.00 -9000.0 | ||
| ##ZFR | ||
| FFR1AA1 FR1 0 2 400.00 1000.00 0.00000 -2000.0 0.00000 9000.00 -9000.0 9000.00 -9000.0 | ||
| FFR2AA1 FR2 0 2 400.00 3500.00 0.00000 -2000.0 0.00000 9000.00 -9000.0 9000.00 -9000.0 | ||
| FFR3AA1 FR3 0 2 400.00 1500.00 0.00000 -3000.0 0.00000 9000.00 -9000.0 9000.00 -9000.0 | ||
| ##ZNL | ||
| NNL1AA1 NL1 0 2 400.00 1000.00 0.00000 -1500.0 0.00000 9000.00 -9000.0 9000.00 -9000.0 | ||
| NNL2AA1 NL2 0 2 400.00 1000.00 0.00000 -500.00 0.00000 9000.00 -9000.0 9000.00 -9000.0 | ||
| NNL3AA1 NL3 0 2 400.00 2500.00 0.00000 -2000.0 0.00000 9000.00 -9000.0 9000.00 -9000.0 | ||
| ##L | ||
| BBE1AA12 BBE2AA11 1 0 0.0000 10.000 0.000000 5000 | ||
| BBE1AA12 BBE3AA1 1 0 0.0000 10.000 0.000000 5000 | ||
| FFR1AA1 FFR2AA1 1 0 0.0000 10.000 0.000000 5000 | ||
| FFR1AA1 FFR3AA1 1 0 0.0000 10.000 0.000000 5000 | ||
| FFR2AA1 FFR3AA1 1 0 0.0000 10.000 0.000000 5000 | ||
| DDE1AA1 DDE2AA1 1 0 0.0000 10.000 0.000000 5000 | ||
| DDE1AA1 DDE3AA1 1 0 0.0000 10.000 0.000000 5000 | ||
| DDE2AA1 DDE3AA1 1 0 0.0000 10.000 0.000000 5000 | ||
| NNL1AA1 NNL2AA1 1 0 0.0000 10.000 0.000000 5000 | ||
| NNL1AA1 NNL3AA1 1 0 0.0000 10.000 0.000000 5000 | ||
| NNL2AA1 NNL3AA1 1 0 0.0000 10.000 0.000000 5000 | ||
| FFR2AA1 DDE3AA1 1 0 0.0000 10.000 0.000000 5000 | ||
| DDE2AA1 NNL3AA1 1 0 0.0000 10.000 0.000000 5000 | ||
| NNL2AA1 BBE3AA1 1 0 0.0000 10.000 0.000000 5000 | ||
| BBE2AA11 FFR3AA1 1 0 0.0000 10.000 0.000000 5000 | ||
| ##T | ||
| BBE2AA11 BBE3AA1 1 0 400.0 400.0 1000. 0.0000 10.000 0.000000 0.0 5000 PST | ||
| ##R | ||
| BBE2AA11 BBE3AA1 1 -0.68 90.00 16 0 SYMM |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.