Skip to content
Merged
Show file tree
Hide file tree
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 Apr 16, 2025
0a77289
Create MappingResults.java
Sebasss-h Apr 17, 2025
1acfea4
Check style
Sebasss-h Apr 17, 2025
c709850
Fix
Sebasss-h Apr 17, 2025
b5fad73
Test Multi Lines ?
Sebasss-h Apr 18, 2025
4089718
Test Multi Lines
Sebasss-h Apr 22, 2025
a7b822a
Test Multi Lines elementName
Sebasss-h Apr 24, 2025
470379c
Refactor UcteMappingTest for improved readability and logic.
OpenSuze Apr 24, 2025
2eac7d6
Handle null values for elementName in UcteMapping.
OpenSuze Apr 24, 2025
8ffa76c
Test Line Switch Position
Sebasss-h Apr 24, 2025
4b74b1c
Merge remote-tracking branch 'origin/ucteMapping' into ucteMapping
Sebasss-h Apr 24, 2025
e398128
Test Weird Cases (missing line)
Sebasss-h Apr 25, 2025
9bf4a5e
TieLines and Duplicate Values
Sebasss-h May 6, 2025
399bba1
Correction UCTEMapping
Sebasss-h May 6, 2025
b249e63
Refactoring 1 UcteMapping
Sebasss-h May 7, 2025
e1f6b01
Add importNetworkInPc and searching bugs
Sebasss-h May 12, 2025
836f2e5
Solving and detecting problems UcteMappingTest
Sebasss-h May 13, 2025
fb4c94d
Solving and detecting problems UcteMappingTest
Sebasss-h May 14, 2025
6e2496b
Solving and detecting problems testRealNetwork
Sebasss-h May 14, 2025
2c302bc
Adding isFictitious filter
Sebasss-h May 14, 2025
2138b81
UcteMapping mapNetworks2
Sebasss-h May 22, 2025
cd70139
UcteMapping mapNetworks2
Sebasss-h May 22, 2025
1759760
Merge branch 'main' into ucteMapping
Sebasss-h May 22, 2025
5667b91
UcteMapping line "clean"
Sebasss-h May 23, 2025
81d3026
Removing impact Trm algorithm
Sebasss-h May 23, 2025
1dead70
Put private package visibility ucte mapping
Sebasss-h May 23, 2025
6dc9252
Fix country filtering incorrect implementation
Sebasss-h May 23, 2025
c2c40f4
Improve readability of the code and overall performance
Sebasss-h May 23, 2025
845b1ff
Improve return statements
Sebasss-h May 23, 2025
49b1791
DuplicateCheck method
Sebasss-h May 27, 2025
1255c30
DuplicateCheck method in mapNetworks
Sebasss-h May 27, 2025
44fdc6b
Refactor Uctemapping function
Sebasss-h Jun 4, 2025
5a1848e
UcteMapper function and fix-tests
Sebasss-h Jun 5, 2025
a8caada
Fix tests and update code comments
Sebasss-h Jun 6, 2025
5fe88bf
Implement UCteMapper in TrmAlgorithm and identify bug in test
Sebasss-h Jun 13, 2025
40137a1
Fix TrmAlgorithm
Sebasss-h Jun 13, 2025
739e123
rollback file modifications
murgeyseb Jun 16, 2025
c422bf8
rollback file modifications
murgeyseb Jun 16, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/main/java/com/rte_france/trm_algorithm/MappingResults.java
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 src/main/java/com/rte_france/trm_algorithm/UcteMapping.java
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) {
Comment thread
OpenSuze marked this conversation as resolved.
Outdated

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);
}

Comment thread
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() {
Comment thread
OpenSuze marked this conversation as resolved.
Outdated
}

}
59 changes: 59 additions & 0 deletions src/test/java/com/rte_france/trm_algorithm/UcteMappingTest.java
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");
Comment thread
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);
Comment thread
OpenSuze marked this conversation as resolved.
Outdated
}
}
}
Comment thread
Sebasss-h marked this conversation as resolved.
Outdated
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