From f4e5e049739d2770cb9f00e18f712dd38508de56 Mon Sep 17 00:00:00 2001 From: Luma Date: Mon, 11 Mar 2024 17:56:39 +0100 Subject: [PATCH 01/11] Migrate to new report API Signed-off-by: Luma --- .github/workflows/maven.yml | 18 +++ .../BalanceComputation.java | 4 +- .../BalanceComputationImpl.java | 60 +++---- .../balances_adjustment/util/Reports.java | 86 +++++----- .../BalanceComputationSimpleDcTest.java | 21 ++- .../util/BalanceComputationAssert.java | 10 +- ...nceComputationParametersWithExtension.json | 2 +- .../test/resources/balancedNetworkReport.txt | 60 +++---- .../resources/unbalancedNetworkReport.txt | 150 +++++++++--------- .../AbstractSensitivityAnalyser.java | 4 +- .../ucte/quality_check/GlskQualityCheck.java | 39 ++--- .../quality_check/GlskQualityProcessor.java | 10 +- .../GlskQualityProcessorTest.java | 61 ++++--- pom.xml | 4 +- 14 files changed, 266 insertions(+), 263 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index e06d78e2..a78cc1ee 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -17,6 +17,18 @@ jobs: os: [ubuntu-latest, windows-latest, macos-latest] steps: + - name: Checkout powsybl-core branch + uses: actions/checkout@v4 + with: + repository: powsybl/powsybl-core + ref: refs/heads/main + + - name: Checkout powsybl-open-loadflow branch + uses: actions/checkout@v4 + with: + repository: powsybl/powsybl-open-loadflow + ref: refs/heads/reporter_v2 + - name: Checkout sources uses: actions/checkout@v1 @@ -25,6 +37,12 @@ jobs: with: java-version: 17 + - name: Build and install powsybl-core with Maven + run: ./mvnw --batch-mode -DskipTests=true --file ../powsybl-core/pom.xml + + - name: Build and install powsybl-open-loadflow with Maven + run: ./mvnw --batch-mode -DskipTests=true --file ../powsybl-open-loadflow/pom.xml + - name: Build with Maven if: matrix.os == 'ubuntu-latest' run: mvn --batch-mode -Pjacoco install diff --git a/balances-adjustment/src/main/java/com/powsybl/balances_adjustment/balance_computation/BalanceComputation.java b/balances-adjustment/src/main/java/com/powsybl/balances_adjustment/balance_computation/BalanceComputation.java index 72ce208d..a39fcec1 100644 --- a/balances-adjustment/src/main/java/com/powsybl/balances_adjustment/balance_computation/BalanceComputation.java +++ b/balances-adjustment/src/main/java/com/powsybl/balances_adjustment/balance_computation/BalanceComputation.java @@ -6,7 +6,7 @@ */ package com.powsybl.balances_adjustment.balance_computation; -import com.powsybl.commons.reporter.Reporter; +import com.powsybl.commons.report.ReportNode; import com.powsybl.iidm.network.Network; import java.util.concurrent.CompletableFuture; @@ -22,6 +22,6 @@ public interface BalanceComputation { CompletableFuture run(Network network, String workingStateId, BalanceComputationParameters parameters); - CompletableFuture run(Network network, String workingStateId, BalanceComputationParameters parameters, Reporter reporter); + CompletableFuture run(Network network, String workingStateId, BalanceComputationParameters parameters, ReportNode reportNode); } diff --git a/balances-adjustment/src/main/java/com/powsybl/balances_adjustment/balance_computation/BalanceComputationImpl.java b/balances-adjustment/src/main/java/com/powsybl/balances_adjustment/balance_computation/BalanceComputationImpl.java index 228ef5e7..83c469ed 100644 --- a/balances-adjustment/src/main/java/com/powsybl/balances_adjustment/balance_computation/BalanceComputationImpl.java +++ b/balances-adjustment/src/main/java/com/powsybl/balances_adjustment/balance_computation/BalanceComputationImpl.java @@ -8,8 +8,8 @@ import com.powsybl.balances_adjustment.util.NetworkArea; import com.powsybl.balances_adjustment.util.Reports; -import com.powsybl.commons.reporter.Reporter; -import com.powsybl.commons.reporter.TypedValue; +import com.powsybl.commons.report.ReportNode; +import com.powsybl.commons.report.TypedValue; import com.powsybl.computation.ComputationManager; import com.powsybl.iidm.modification.scalable.Scalable; import com.powsybl.iidm.network.ComponentConstants; @@ -64,20 +64,20 @@ public BalanceComputationImpl(List areas, ComputationMan */ @Override public CompletableFuture run(Network network, String workingStateId, BalanceComputationParameters parameters) { - return this.run(network, workingStateId, parameters, Reporter.NO_OP); + return this.run(network, workingStateId, parameters, ReportNode.NO_OP); } /** * Run balances adjustment computation in several iterations */ @Override - public CompletableFuture run(Network network, String workingStateId, BalanceComputationParameters parameters, Reporter reporter) { + public CompletableFuture run(Network network, String workingStateId, BalanceComputationParameters parameters, ReportNode reportNode) { Objects.requireNonNull(network); Objects.requireNonNull(workingStateId); Objects.requireNonNull(parameters); - Objects.requireNonNull(reporter); + Objects.requireNonNull(reportNode); - BalanceComputationRunningContext context = new BalanceComputationRunningContext(areas, network, parameters, reporter); + BalanceComputationRunningContext context = new BalanceComputationRunningContext(areas, network, parameters, reportNode); BalanceComputationResult result; String initialVariantId = network.getVariantManager().getWorkingVariantId(); @@ -86,19 +86,19 @@ public CompletableFuture run(Network network, String w network.getVariantManager().setWorkingVariant(workingVariantCopyId); do { - Reporter iterationReporter = Reports.createBalanceComputationIterationReporter(reporter, context.getIterationNum()); - context.setIterationReporter(iterationReporter); + ReportNode iterationReportNode = Reports.createBalanceComputationIterationReporter(reportNode, context.getIterationNum()); + context.setIterationReportNode(iterationReportNode); // Step 1: Perform the scaling - Reporter scalingReporter = iterationReporter.createSubReporter("scaling", "Scaling"); + ReportNode scalingReportNode = iterationReportNode.newReportNode().withMessageTemplate("scaling", "Scaling").add(); context.getBalanceOffsets().forEach((area, offset) -> { Scalable scalable = area.getScalable(); double done = scalable.scale(network, offset, parameters.getScalingParameters()); - Reports.reportScaling(scalingReporter, area.getName(), offset, done); + Reports.reportScaling(scalingReportNode, area.getName(), offset, done); LOGGER.info("Iteration={}, Scaling for area {}: offset={}, done={}", context.getIterationNum(), area.getName(), offset, done); }); // Step 2: compute Load Flow - LoadFlowResult loadFlowResult = loadFlowRunner.run(network, workingVariantCopyId, computationManager, parameters.getLoadFlowParameters(), iterationReporter); + LoadFlowResult loadFlowResult = loadFlowRunner.run(network, workingVariantCopyId, computationManager, parameters.getLoadFlowParameters(), iterationReportNode); if (!isLoadFlowResultOk(context, loadFlowResult)) { LOGGER.error("Iteration={}, LoadFlow on network {} does not converge", context.getIterationNum(), network.getId()); result = new BalanceComputationResult(BalanceComputationResult.Status.FAILED, context.getIterationNum()); @@ -106,13 +106,13 @@ public CompletableFuture run(Network network, String w } // Step 3: Compute balance and mismatch for each area - Reporter mismatchReporter = iterationReporter.createSubReporter("mismatch", "Mismatch"); + ReportNode mismatchReportNode = iterationReportNode.newReportNode().withMessageTemplate("mismatch", "Mismatch").add(); for (BalanceComputationArea area : areas) { NetworkArea na = context.getNetworkArea(area); double target = area.getTargetNetPosition(); double balance = na.getNetPosition(); double mismatch = target - balance; - Reports.reportAreaMismatch(mismatchReporter, area.getName(), mismatch, target, balance); + Reports.reportAreaMismatch(mismatchReportNode, area.getName(), mismatch, target, balance); LOGGER.info("Iteration={}, Mismatch for area {}: {} (target={}, balance={})", context.getIterationNum(), area.getName(), mismatch, target, balance); context.updateAreaOffsetAndMismatch(area, mismatch); } @@ -128,16 +128,16 @@ public CompletableFuture run(Network network, String w } } while (context.getIterationNum() < parameters.getMaxNumberIterations() && result.getStatus() != BalanceComputationResult.Status.SUCCESS); - Reporter statusReporter = reporter.createSubReporter("status", "Status"); + ReportNode statusReportNode = reportNode.newReportNode().withMessageTemplate("status", "Status").add(); if (result.getStatus() == BalanceComputationResult.Status.SUCCESS) { List networkAreasName = areas.stream() .map(BalanceComputationArea::getName).collect(Collectors.toList()); - Reports.reportBalancedAreas(statusReporter, networkAreasName, result.getIterationCount()); + Reports.reportBalancedAreas(statusReportNode, networkAreasName, result.getIterationCount()); LOGGER.info("Areas {} are balanced after {} iterations", networkAreasName, result.getIterationCount()); } else { BigDecimal totalMismatch = BigDecimal.valueOf(computeTotalMismatch(context)).setScale(2, RoundingMode.UP); - Reports.reportUnbalancedAreas(statusReporter, context.getIterationNum(), totalMismatch); + Reports.reportUnbalancedAreas(statusReportNode, context.getIterationNum(), totalMismatch); LOGGER.error("Areas are unbalanced after {} iterations, total mismatch is {}", context.getIterationNum(), totalMismatch); } @@ -182,9 +182,9 @@ protected boolean isLoadFlowResultOk(BalanceComputationRunningContext context, f return false; } final var cr = list.get(0); - Reporter lfStatusReporter = context.getIterationReporter().createSubReporter("loadFlowStatus", "Checking load flow status"); + ReportNode lfStatusReportNode = context.getIterationReportNode().newReportNode().withMessageTemplate("loadFlowStatus", "Checking load flow status").add(); final var severity = cr.getStatus() == LoadFlowResult.ComponentResult.Status.CONVERGED ? TypedValue.INFO_SEVERITY : TypedValue.ERROR_SEVERITY; - Reports.reportLfStatus(lfStatusReporter, cr.getConnectedComponentNum(), cr.getSynchronousComponentNum(), cr.getStatus().name(), severity); + Reports.reportLfStatus(lfStatusReportNode, cr.getConnectedComponentNum(), cr.getSynchronousComponentNum(), cr.getStatus().name(), severity); return cr.getStatus() == LoadFlowResult.ComponentResult.Status.CONVERGED; }) ); @@ -197,19 +197,19 @@ protected static class BalanceComputationRunningContext { private final Map networkAreas; private final Map balanceOffsets = new LinkedHashMap<>(); private final Map balanceMismatches = new HashMap<>(); - private final Reporter reporter; - private Reporter iterationReporter; + private final ReportNode reportNode; + private ReportNode iterationReportNode; public BalanceComputationRunningContext(List areas, Network network, BalanceComputationParameters parameters) { - this(areas, network, parameters, Reporter.NO_OP); + this(areas, network, parameters, ReportNode.NO_OP); } - public BalanceComputationRunningContext(List areas, Network network, BalanceComputationParameters parameters, Reporter reporter) { + public BalanceComputationRunningContext(List areas, Network network, BalanceComputationParameters parameters, ReportNode reportNode) { this.iterationNum = 0; this.network = network; this.parameters = parameters; - this.reporter = reporter; - this.iterationReporter = Reporter.NO_OP; + this.reportNode = reportNode; + this.iterationReportNode = ReportNode.NO_OP; networkAreas = areas.stream().collect(Collectors.toMap(Function.identity(), ba -> ba.getNetworkAreaFactory().create(network), (v1, v2) -> v1, LinkedHashMap::new)); balanceOffsets.clear(); balanceMismatches.clear(); @@ -249,16 +249,16 @@ public void updateAreaOffsetAndMismatch(BalanceComputationArea area, double mism balanceMismatches.put(area, mismatch); } - public Reporter getReporter() { - return reporter; + public ReportNode getReportNode() { + return reportNode; } - public Reporter getIterationReporter() { - return iterationReporter; + public ReportNode getIterationReportNode() { + return iterationReportNode; } - public BalanceComputationRunningContext setIterationReporter(Reporter iterationReporter) { - this.iterationReporter = iterationReporter; + public BalanceComputationRunningContext setIterationReportNode(ReportNode iterationReportNode) { + this.iterationReportNode = iterationReportNode; return this; } } diff --git a/balances-adjustment/src/main/java/com/powsybl/balances_adjustment/util/Reports.java b/balances-adjustment/src/main/java/com/powsybl/balances_adjustment/util/Reports.java index 62413421..aacd1a0b 100644 --- a/balances-adjustment/src/main/java/com/powsybl/balances_adjustment/util/Reports.java +++ b/balances-adjustment/src/main/java/com/powsybl/balances_adjustment/util/Reports.java @@ -6,13 +6,11 @@ */ package com.powsybl.balances_adjustment.util; -import com.powsybl.commons.reporter.Report; -import com.powsybl.commons.reporter.Reporter; -import com.powsybl.commons.reporter.TypedValue; +import com.powsybl.commons.report.ReportNode; +import com.powsybl.commons.report.TypedValue; import java.math.BigDecimal; import java.util.List; -import java.util.Map; /** * @author George Budau {@literal } @@ -25,62 +23,58 @@ public final class Reports { private Reports() { } - public static void reportScaling(Reporter reporter, String areaName, double offset, double done) { - reporter.report(Report.builder() - .withKey("areaScaling") - .withDefaultMessage("Scaling for area ${areaName}: offset=${offset}, done=${done}") - .withValue(AREA_NAME, areaName) - .withValue("offset", offset) - .withValue("done", done) + public static void reportScaling(ReportNode reportNode, String areaName, double offset, double done) { + reportNode.newReportNode().withMessageTemplate("areaScaling", + "Scaling for area ${areaName}: offset=${offset}, done=${done}") + .withUntypedValue(AREA_NAME, areaName) + .withUntypedValue("offset", offset) + .withUntypedValue("done", done) .withSeverity(TypedValue.INFO_SEVERITY) - .build()); + .add(); } - public static void reportLfStatus(Reporter reporter, int networkNumCc, int networkNumSc, String status, TypedValue severity) { - reporter.report(Report.builder() - .withKey("lfStatus") - .withDefaultMessage("Network CC${networkNumCc} SC${networkNumSc} Load flow complete with status '${status}'") - .withValue("networkNumCc", networkNumCc) - .withValue("networkNumSc", networkNumSc) - .withValue("status", status) + public static void reportLfStatus(ReportNode reportNode, int networkNumCc, int networkNumSc, String status, TypedValue severity) { + reportNode.newReportNode().withMessageTemplate("lfStatus", + "Network CC${networkNumCc} SC${networkNumSc} Load flow complete with status '${status}'") + .withUntypedValue("networkNumCc", networkNumCc) + .withUntypedValue("networkNumSc", networkNumSc) + .withUntypedValue("status", status) .withSeverity(severity) - .build()); + .add(); } - public static void reportAreaMismatch(Reporter reporter, String areaName, double mismatch, double target, double balance) { - reporter.report(Report.builder() - .withKey("areaMismatch") - .withDefaultMessage("Mismatch for area ${areaName}: ${mismatch} (target=${target}, balance=${balance})") - .withValue(AREA_NAME, areaName) - .withValue("mismatch", mismatch) - .withValue("target", target) - .withValue("balance", balance) + public static void reportAreaMismatch(ReportNode reportNode, String areaName, double mismatch, double target, double balance) { + reportNode.newReportNode().withMessageTemplate("areaMismatch", + "Mismatch for area ${areaName}: ${mismatch} (target=${target}, balance=${balance})") + .withUntypedValue(AREA_NAME, areaName) + .withUntypedValue("mismatch", mismatch) + .withUntypedValue("target", target) + .withUntypedValue("balance", balance) .withSeverity(TypedValue.INFO_SEVERITY) - .build()); + .add(); } - public static void reportBalancedAreas(Reporter reporter, List networkAreasName, int iterationCount) { - reporter.report(Report.builder() - .withKey("balancedAreas") - .withDefaultMessage("Areas ${networkAreasName} are balanced after ${iterationCount} iterations") - .withValue("networkAreasName", networkAreasName.toString()) - .withValue("iterationCount", iterationCount) + public static void reportBalancedAreas(ReportNode reportNode, List networkAreasName, int iterationCount) { + reportNode.newReportNode().withMessageTemplate("balancedAreas", + "Areas ${networkAreasName} are balanced after ${iterationCount} iterations") + .withUntypedValue("networkAreasName", networkAreasName.toString()) + .withUntypedValue("iterationCount", iterationCount) .withSeverity(TypedValue.INFO_SEVERITY) - .build()); + .add(); } - public static void reportUnbalancedAreas(Reporter reporter, int iteration, BigDecimal totalMismatch) { - reporter.report(Report.builder() - .withKey("unbalancedAreas") - .withDefaultMessage("Areas are unbalanced after ${iteration} iterations, total mismatch is ${totalMismatch}") - .withValue(ITERATION, iteration) - .withValue("totalMismatch", totalMismatch.toString()) + public static void reportUnbalancedAreas(ReportNode reportNode, int iteration, BigDecimal totalMismatch) { + reportNode.newReportNode().withMessageTemplate("unbalancedAreas", + "Areas are unbalanced after ${iteration} iterations, total mismatch is ${totalMismatch}") + .withUntypedValue(ITERATION, iteration) + .withUntypedValue("totalMismatch", totalMismatch.toString()) .withSeverity(TypedValue.ERROR_SEVERITY) - .build()); + .add(); } - public static Reporter createBalanceComputationIterationReporter(Reporter reporter, int iteration) { - return reporter.createSubReporter("balanceComputation", "Balance Computation iteration '${iteration}'", - Map.of(ITERATION, new TypedValue(iteration, TypedValue.UNTYPED))); + public static ReportNode createBalanceComputationIterationReporter(ReportNode reportNode, int iteration) { + return reportNode.newReportNode().withMessageTemplate("balanceComputation", "Balance Computation iteration '${iteration}'") + .withUntypedValue(ITERATION, iteration) + .add(); } } diff --git a/balances-adjustment/src/test/java/com/powsybl/balances_adjustment/balance_computation/BalanceComputationSimpleDcTest.java b/balances-adjustment/src/test/java/com/powsybl/balances_adjustment/balance_computation/BalanceComputationSimpleDcTest.java index 7e23e3e5..3c3d12d1 100644 --- a/balances-adjustment/src/test/java/com/powsybl/balances_adjustment/balance_computation/BalanceComputationSimpleDcTest.java +++ b/balances-adjustment/src/test/java/com/powsybl/balances_adjustment/balance_computation/BalanceComputationSimpleDcTest.java @@ -8,8 +8,7 @@ import com.powsybl.balances_adjustment.util.BalanceComputationAssert; import com.powsybl.balances_adjustment.util.CountryAreaFactory; -import com.powsybl.commons.reporter.Reporter; -import com.powsybl.commons.reporter.ReporterModel; +import com.powsybl.commons.report.ReportNode; import com.powsybl.computation.ComputationManager; import com.powsybl.computation.local.LocalComputationManager; import com.powsybl.iidm.modification.scalable.Scalable; @@ -110,7 +109,7 @@ void testBalancedNetworkMockito() { LoadFlowProvider loadFlowProviderMock = new AbstractLoadFlowProviderMock() { @Override - public CompletableFuture run(Network network, ComputationManager computationManager, String workingVariantId, LoadFlowParameters parameters, Reporter reporter) { + public CompletableFuture run(Network network, ComputationManager computationManager, String workingVariantId, LoadFlowParameters parameters, ReportNode reportNode) { generatorFr.getTerminal().setP(3000); loadFr.getTerminal().setP(1800); @@ -142,7 +141,7 @@ void testConvergedLoadFlowOnMainSynchronousComponent() { LoadFlowProvider loadFlowProviderMock = new AbstractLoadFlowProviderMock() { @Override - public CompletableFuture run(Network network, ComputationManager computationManager, String workingVariantId, LoadFlowParameters parameters, Reporter reporter) { + public CompletableFuture run(Network network, ComputationManager computationManager, String workingVariantId, LoadFlowParameters parameters, ReportNode reportNode) { generatorFr.getTerminal().setP(3000); loadFr.getTerminal().setP(1800); @@ -177,7 +176,7 @@ void testUnBalancedNetworkMockito() { LoadFlowProvider loadFlowProviderMock = new AbstractLoadFlowProviderMock() { @Override - public CompletableFuture run(Network network, ComputationManager computationManager, String workingVariantId, LoadFlowParameters parameters, Reporter reporter) { + public CompletableFuture run(Network network, ComputationManager computationManager, String workingVariantId, LoadFlowParameters parameters, ReportNode reportNode) { generatorFr.getTerminal().setP(3000); loadFr.getTerminal().setP(1800); branchFrBe1.getTerminal1().setP(-516); @@ -291,9 +290,9 @@ void testBalancedNetworkAfter1ScalingReport() throws IOException { BalanceComputation balanceComputation = balanceComputationFactory.create(areas, loadFlowRunner, computationManager); - ReporterModel reporter = new ReporterModel("testBalancedNetworkReport", "Test balanced network report"); - balanceComputation.run(simpleNetwork, simpleNetwork.getVariantManager().getWorkingVariantId(), parameters, reporter).join(); - BalanceComputationAssert.assertReportEquals("/balancedNetworkReport.txt", reporter); + ReportNode reportNode = ReportNode.newRootReportNode().withMessageTemplate("testBalancedNetworkReport", "Test balanced network report").build(); + balanceComputation.run(simpleNetwork, simpleNetwork.getVariantManager().getWorkingVariantId(), parameters, reportNode).join(); + BalanceComputationAssert.assertReportEquals("/balancedNetworkReport.txt", reportNode); } @Test @@ -304,9 +303,9 @@ void testUnBalancedNetworkReport() throws IOException { BalanceComputation balanceComputation = balanceComputationFactory.create(areas, loadFlowRunner, computationManager); - ReporterModel reporter = new ReporterModel("testUnbalancedNetworkReport", "Test unbalanced network report"); - balanceComputation.run(simpleNetwork, simpleNetwork.getVariantManager().getWorkingVariantId(), parameters, reporter).join(); - BalanceComputationAssert.assertReportEquals("/unbalancedNetworkReport.txt", reporter); + ReportNode reportNode = ReportNode.newRootReportNode().withMessageTemplate("testUnbalancedNetworkReport", "Test unbalanced network report").build(); + balanceComputation.run(simpleNetwork, simpleNetwork.getVariantManager().getWorkingVariantId(), parameters, reportNode).join(); + BalanceComputationAssert.assertReportEquals("/unbalancedNetworkReport.txt", reportNode); } private abstract class AbstractLoadFlowProviderMock extends AbstractNoSpecificParametersLoadFlowProvider { diff --git a/balances-adjustment/src/test/java/com/powsybl/balances_adjustment/util/BalanceComputationAssert.java b/balances-adjustment/src/test/java/com/powsybl/balances_adjustment/util/BalanceComputationAssert.java index 8a536cf0..ca01ab92 100644 --- a/balances-adjustment/src/test/java/com/powsybl/balances_adjustment/util/BalanceComputationAssert.java +++ b/balances-adjustment/src/test/java/com/powsybl/balances_adjustment/util/BalanceComputationAssert.java @@ -7,7 +7,7 @@ package com.powsybl.balances_adjustment.util; import com.google.common.io.ByteStreams; -import com.powsybl.commons.reporter.ReporterModel; +import com.powsybl.commons.report.ReportNode; import java.io.IOException; import java.io.InputStream; @@ -25,13 +25,13 @@ public final class BalanceComputationAssert { private BalanceComputationAssert() { } - public static void assertReportEquals(String refResourceName, ReporterModel reporter) throws IOException { - assertReportEquals(BalanceComputationAssert.class.getResourceAsStream(refResourceName), reporter); + public static void assertReportEquals(String refResourceName, ReportNode reportNode) throws IOException { + assertReportEquals(BalanceComputationAssert.class.getResourceAsStream(refResourceName), reportNode); } - public static void assertReportEquals(InputStream ref, ReporterModel reporter) throws IOException { + public static void assertReportEquals(InputStream ref, ReportNode reportNode) throws IOException { StringWriter sw = new StringWriter(); - reporter.export(sw); + reportNode.print(sw); String refLogExport = normalizeLineSeparator(new String(ByteStreams.toByteArray(ref), StandardCharsets.UTF_8)); String logExport = normalizeLineSeparator(sw.toString()); diff --git a/balances-adjustment/src/test/resources/balanceComputationParametersWithExtension.json b/balances-adjustment/src/test/resources/balanceComputationParametersWithExtension.json index d7e2e29f..5a2d8c13 100644 --- a/balances-adjustment/src/test/resources/balanceComputationParametersWithExtension.json +++ b/balances-adjustment/src/test/resources/balanceComputationParametersWithExtension.json @@ -12,7 +12,7 @@ "twtSplitShuntAdmittance" : false, "shuntCompensatorVoltageControlOn" : false, "readSlackBus" : true, - "writeSlackBus" : false, + "writeSlackBus" : true, "dc" : false, "distributedSlack" : true, "balanceType" : "PROPORTIONAL_TO_GENERATION_P_MAX", diff --git a/balances-adjustment/src/test/resources/balancedNetworkReport.txt b/balances-adjustment/src/test/resources/balancedNetworkReport.txt index b770c025..efefe2fb 100644 --- a/balances-adjustment/src/test/resources/balancedNetworkReport.txt +++ b/balances-adjustment/src/test/resources/balancedNetworkReport.txt @@ -1,31 +1,31 @@ + Test balanced network report - + Balance Computation iteration '0' - + Scaling - + Load flow on network 'TestNetwork' - + Network CC0 SC0 - DC load flow completed (status=true) - + Post loading processing - Network has 3 buses and 3 branches - Network balance: active generation=4000.0 MW, active load=4000.0 MW, reactive generation=0.0 MVar, reactive load=0.0 MVar - + Checking load flow status - Network CC0 SC0 Load flow complete with status 'CONVERGED' - + Mismatch - Mismatch for area FR: 100.0 (target=1300.0, balance=1200.0) - Mismatch for area BE: -100.0 (target=-1300.0, balance=-1200.0) - + Balance Computation iteration '1' - + Scaling - Scaling for area FR: offset=100.0, done=100.0 - Scaling for area BE: offset=-100.0, done=-100.0 - + Load flow on network 'TestNetwork' - + Network CC0 SC0 - DC load flow completed (status=true) - + Post loading processing - Network has 3 buses and 3 branches - Network balance: active generation=4000.0 MW, active load=4000.0 MW, reactive generation=0.0 MVar, reactive load=0.0 MVar - + Checking load flow status - Network CC0 SC0 Load flow complete with status 'CONVERGED' - + Mismatch - Mismatch for area FR: 0.0 (target=1300.0, balance=1300.0) - Mismatch for area BE: 0.0 (target=-1300.0, balance=-1300.0) - + Status - Areas [FR, BE] are balanced after 2 iterations + + Balance Computation iteration '0' + Scaling + + Load flow on network 'TestNetwork' + + Network CC0 SC0 + + Network info + Network has 3 buses and 3 branches + Network balance: active generation=4000.0 MW, active load=4000.0 MW, reactive generation=0.0 MVar, reactive load=0.0 MVar + DC load flow completed (status=true) + + Checking load flow status + Network CC0 SC0 Load flow complete with status 'CONVERGED' + + Mismatch + Mismatch for area FR: 100.0 (target=1300.0, balance=1200.0) + Mismatch for area BE: -100.0 (target=-1300.0, balance=-1200.0) + + Balance Computation iteration '1' + + Scaling + Scaling for area FR: offset=100.0, done=100.0 + Scaling for area BE: offset=-100.0, done=-100.0 + + Load flow on network 'TestNetwork' + + Network CC0 SC0 + + Network info + Network has 3 buses and 3 branches + Network balance: active generation=4000.0 MW, active load=4000.0 MW, reactive generation=0.0 MVar, reactive load=0.0 MVar + DC load flow completed (status=true) + + Checking load flow status + Network CC0 SC0 Load flow complete with status 'CONVERGED' + + Mismatch + Mismatch for area FR: 0.0 (target=1300.0, balance=1300.0) + Mismatch for area BE: 0.0 (target=-1300.0, balance=-1300.0) + + Status + Areas [FR, BE] are balanced after 2 iterations diff --git a/balances-adjustment/src/test/resources/unbalancedNetworkReport.txt b/balances-adjustment/src/test/resources/unbalancedNetworkReport.txt index dbb75728..335d2392 100644 --- a/balances-adjustment/src/test/resources/unbalancedNetworkReport.txt +++ b/balances-adjustment/src/test/resources/unbalancedNetworkReport.txt @@ -1,76 +1,76 @@ + Test unbalanced network report - + Balance Computation iteration '0' - + Scaling - + Load flow on network 'TestNetwork' - + Network CC0 SC0 - DC load flow completed (status=true) - + Post loading processing - Network has 3 buses and 3 branches - Network balance: active generation=4000.0 MW, active load=4000.0 MW, reactive generation=0.0 MVar, reactive load=0.0 MVar - + Checking load flow status - Network CC0 SC0 Load flow complete with status 'CONVERGED' - + Mismatch - Mismatch for area FR: 100.0 (target=1300.0, balance=1200.0) - Mismatch for area BE: -200.0 (target=-1400.0, balance=-1200.0) - + Balance Computation iteration '1' - + Scaling - Scaling for area FR: offset=100.0, done=100.0 - Scaling for area BE: offset=-200.0, done=-200.0 - + Load flow on network 'TestNetwork' - + Network CC0 SC0 - DC load flow completed (status=true) - + Post loading processing - Network has 3 buses and 3 branches - Network balance: active generation=3940.0 MW, active load=4040.0 MW, reactive generation=0.0 MVar, reactive load=0.0 MVar - + Checking load flow status - Network CC0 SC0 Load flow complete with status 'CONVERGED' - + Mismatch - Mismatch for area FR: -50.0 (target=1300.0, balance=1350.0) - Mismatch for area BE: -50.0 (target=-1400.0, balance=-1350.0) - + Balance Computation iteration '2' - + Scaling - Scaling for area FR: offset=50.0, done=50.0 - Scaling for area BE: offset=-250.0, done=-250.0 - + Load flow on network 'TestNetwork' - + Network CC0 SC0 - DC load flow completed (status=true) - + Post loading processing - Network has 3 buses and 3 branches - Network balance: active generation=3880.0 MW, active load=4080.0 MW, reactive generation=0.0 MVar, reactive load=0.0 MVar - + Checking load flow status - Network CC0 SC0 Load flow complete with status 'CONVERGED' - + Mismatch - Mismatch for area FR: -50.0 (target=1300.0, balance=1350.0) - Mismatch for area BE: -50.0 (target=-1400.0, balance=-1350.0) - + Balance Computation iteration '3' - + Scaling - Scaling for area FR: offset=0.0, done=0.0 - Scaling for area BE: offset=-300.0, done=-300.0 - + Load flow on network 'TestNetwork' - + Network CC0 SC0 - DC load flow completed (status=true) - + Post loading processing - Network has 3 buses and 3 branches - Network balance: active generation=3820.0 MW, active load=4120.0 MW, reactive generation=0.0 MVar, reactive load=0.0 MVar - + Checking load flow status - Network CC0 SC0 Load flow complete with status 'CONVERGED' - + Mismatch - Mismatch for area FR: -50.0 (target=1300.0, balance=1350.0) - Mismatch for area BE: -50.0 (target=-1400.0, balance=-1350.0) - + Balance Computation iteration '4' - + Scaling - Scaling for area FR: offset=-50.0, done=-50.0 - Scaling for area BE: offset=-350.0, done=-350.0 - + Load flow on network 'TestNetwork' - + Network CC0 SC0 - DC load flow completed (status=true) - + Post loading processing - Network has 3 buses and 3 branches - Network balance: active generation=3760.0 MW, active load=4160.0 MW, reactive generation=0.0 MVar, reactive load=0.0 MVar - + Checking load flow status - Network CC0 SC0 Load flow complete with status 'CONVERGED' - + Mismatch - Mismatch for area FR: -50.0 (target=1300.0, balance=1350.0) - Mismatch for area BE: -50.0 (target=-1400.0, balance=-1350.0) - + Status - Areas are unbalanced after 5 iterations, total mismatch is 5000.00 + + Balance Computation iteration '0' + Scaling + + Load flow on network 'TestNetwork' + + Network CC0 SC0 + + Network info + Network has 3 buses and 3 branches + Network balance: active generation=4000.0 MW, active load=4000.0 MW, reactive generation=0.0 MVar, reactive load=0.0 MVar + DC load flow completed (status=true) + + Checking load flow status + Network CC0 SC0 Load flow complete with status 'CONVERGED' + + Mismatch + Mismatch for area FR: 100.0 (target=1300.0, balance=1200.0) + Mismatch for area BE: -200.0 (target=-1400.0, balance=-1200.0) + + Balance Computation iteration '1' + + Scaling + Scaling for area FR: offset=100.0, done=100.0 + Scaling for area BE: offset=-200.0, done=-200.0 + + Load flow on network 'TestNetwork' + + Network CC0 SC0 + + Network info + Network has 3 buses and 3 branches + Network balance: active generation=3940.0 MW, active load=4040.0 MW, reactive generation=0.0 MVar, reactive load=0.0 MVar + DC load flow completed (status=true) + + Checking load flow status + Network CC0 SC0 Load flow complete with status 'CONVERGED' + + Mismatch + Mismatch for area FR: -50.0 (target=1300.0, balance=1350.0) + Mismatch for area BE: -50.0 (target=-1400.0, balance=-1350.0) + + Balance Computation iteration '2' + + Scaling + Scaling for area FR: offset=50.0, done=50.0 + Scaling for area BE: offset=-250.0, done=-250.0 + + Load flow on network 'TestNetwork' + + Network CC0 SC0 + + Network info + Network has 3 buses and 3 branches + Network balance: active generation=3880.0 MW, active load=4080.0 MW, reactive generation=0.0 MVar, reactive load=0.0 MVar + DC load flow completed (status=true) + + Checking load flow status + Network CC0 SC0 Load flow complete with status 'CONVERGED' + + Mismatch + Mismatch for area FR: -50.0 (target=1300.0, balance=1350.0) + Mismatch for area BE: -50.0 (target=-1400.0, balance=-1350.0) + + Balance Computation iteration '3' + + Scaling + Scaling for area FR: offset=0.0, done=0.0 + Scaling for area BE: offset=-300.0, done=-300.0 + + Load flow on network 'TestNetwork' + + Network CC0 SC0 + + Network info + Network has 3 buses and 3 branches + Network balance: active generation=3820.0 MW, active load=4120.0 MW, reactive generation=0.0 MVar, reactive load=0.0 MVar + DC load flow completed (status=true) + + Checking load flow status + Network CC0 SC0 Load flow complete with status 'CONVERGED' + + Mismatch + Mismatch for area FR: -50.0 (target=1300.0, balance=1350.0) + Mismatch for area BE: -50.0 (target=-1400.0, balance=-1350.0) + + Balance Computation iteration '4' + + Scaling + Scaling for area FR: offset=-50.0, done=-50.0 + Scaling for area BE: offset=-350.0, done=-350.0 + + Load flow on network 'TestNetwork' + + Network CC0 SC0 + + Network info + Network has 3 buses and 3 branches + Network balance: active generation=3760.0 MW, active load=4160.0 MW, reactive generation=0.0 MVar, reactive load=0.0 MVar + DC load flow completed (status=true) + + Checking load flow status + Network CC0 SC0 Load flow complete with status 'CONVERGED' + + Mismatch + Mismatch for area FR: -50.0 (target=1300.0, balance=1350.0) + Mismatch for area BE: -50.0 (target=-1400.0, balance=-1350.0) + + Status + Areas are unbalanced after 5 iterations, total mismatch is 5000.00 diff --git a/flow-decomposition/src/main/java/com/powsybl/flow_decomposition/AbstractSensitivityAnalyser.java b/flow-decomposition/src/main/java/com/powsybl/flow_decomposition/AbstractSensitivityAnalyser.java index bcf5ee77..6de6c1ea 100644 --- a/flow-decomposition/src/main/java/com/powsybl/flow_decomposition/AbstractSensitivityAnalyser.java +++ b/flow-decomposition/src/main/java/com/powsybl/flow_decomposition/AbstractSensitivityAnalyser.java @@ -6,7 +6,7 @@ */ package com.powsybl.flow_decomposition; -import com.powsybl.commons.reporter.Reporter; +import com.powsybl.commons.report.ReportNode; import com.powsybl.computation.local.LocalComputationManager; import com.powsybl.contingency.Contingency; import com.powsybl.contingency.ContingencyContext; @@ -79,7 +79,7 @@ protected void runSensitivityAnalysis(Network network, SensitivityFactorReader f sensitivityVariableSets, sensitivityAnalysisParameters, LocalComputationManager.getDefault(), - Reporter.NO_OP + ReportNode.NO_OP ); } } diff --git a/glsk/glsk-quality-check-ucte/src/main/java/com/powsybl/glsk/ucte/quality_check/GlskQualityCheck.java b/glsk/glsk-quality-check-ucte/src/main/java/com/powsybl/glsk/ucte/quality_check/GlskQualityCheck.java index c7d77695..eb05e271 100644 --- a/glsk/glsk-quality-check-ucte/src/main/java/com/powsybl/glsk/ucte/quality_check/GlskQualityCheck.java +++ b/glsk/glsk-quality-check-ucte/src/main/java/com/powsybl/glsk/ucte/quality_check/GlskQualityCheck.java @@ -6,8 +6,7 @@ */ package com.powsybl.glsk.ucte.quality_check; -import com.powsybl.commons.reporter.Report; -import com.powsybl.commons.reporter.Reporter; +import com.powsybl.commons.report.ReportNode; import com.powsybl.glsk.api.GlskPoint; import com.powsybl.glsk.api.GlskRegisteredResource; import com.powsybl.glsk.ucte.UcteGlskPoint; @@ -20,7 +19,7 @@ import java.util.Map; import java.util.stream.Collectors; -import static com.powsybl.commons.reporter.TypedValue.WARN_SEVERITY; +import static com.powsybl.commons.report.TypedValue.WARN_SEVERITY; /** * @author Marc Erkol {@literal } @@ -37,16 +36,16 @@ class GlskQualityCheck { public static final String TSO_KEY = "TSO"; - public static void gskQualityCheck(GlskQualityCheckInput input, Reporter reporter) { - new GlskQualityCheck().generateReport(input, reporter); + public static void gskQualityCheck(GlskQualityCheckInput input, ReportNode reportNode) { + new GlskQualityCheck().generateReport(input, reportNode); } - private void generateReport(GlskQualityCheckInput input, Reporter reporter) { + private void generateReport(GlskQualityCheckInput input, ReportNode reportNode) { Map glskPointMap = input.getUcteGlskDocument().getGlskPointsForInstant(input.getInstant()); - glskPointMap.forEach((country, glskPoint) -> checkGlskPoint(glskPoint, input.getNetwork(), country, reporter)); + glskPointMap.forEach((country, glskPoint) -> checkGlskPoint(glskPoint, input.getNetwork(), country, reportNode)); } - private void checkGlskPoint(GlskPoint glskPoint, Network network, String tso, Reporter reporter) { + private void checkGlskPoint(GlskPoint glskPoint, Network network, String tso, ReportNode reportNode) { List manualGskGenerators = glskPoint.getGlskShiftKeys().stream() .filter(gskShiftKey -> gskShiftKey.getPsrType().equals(GENERATOR) && gskShiftKey.getBusinessType().equals("B43")) .flatMap(gskShiftKey -> gskShiftKey.getRegisteredResourceArrayList().stream()) @@ -68,10 +67,10 @@ private void checkGlskPoint(GlskPoint glskPoint, Network network, String tso, Re glskPoint.getGlskShiftKeys().forEach(glskShiftKey -> { if (glskShiftKey.getPsrType().equals(GENERATOR)) { glskShiftKey.getRegisteredResourceArrayList() - .forEach(resource -> checkResource(resource, network.getGenerator(resource.getGeneratorId()), "Generator", network, tso, reporter)); + .forEach(resource -> checkResource(resource, network.getGenerator(resource.getGeneratorId()), "Generator", network, tso, reportNode)); } else if (glskShiftKey.getPsrType().equals(LOAD)) { glskShiftKey.getRegisteredResourceArrayList() - .forEach(resource -> checkResource(resource, network.getLoad(resource.getLoadId()), "Load", network, tso, reporter)); + .forEach(resource -> checkResource(resource, network.getLoad(resource.getLoadId()), "Load", network, tso, reportNode)); } }); } @@ -109,39 +108,33 @@ private void createMissingLoad(Network network, VoltageLevel voltageLevel, Strin } } - private void checkResource(GlskRegisteredResource registeredResource, Injection injection, String type, Network network, String tso, Reporter reporter) { + private void checkResource(GlskRegisteredResource registeredResource, Injection injection, String type, Network network, String tso, ReportNode reportNode) { if (injection == null) { if (network.getBusBreakerView().getBus(registeredResource.getmRID()) == null) { - reporter.report(Report.builder() - .withKey("1") - .withDefaultMessage("GLSK node is not found in CGM") + reportNode.newReportNode().withMessageTemplate("1", "GLSK node is not found in CGM") .withTypedValue(NODE_ID_KEY, registeredResource.getmRID(), "") .withTypedValue(TYPE_KEY, type, "") .withTypedValue(TSO_KEY, tso, "") .withSeverity(WARN_SEVERITY) - .build()); + .add(); } else { - reporter.report(Report.builder() - .withKey("2") - .withDefaultMessage("GLSK node is present but has no running Generator or Load") + reportNode.newReportNode().withMessageTemplate("2", "GLSK node is present but has no running Generator or Load") .withTypedValue(NODE_ID_KEY, registeredResource.getmRID(), "") .withTypedValue(TYPE_KEY, type, "") .withTypedValue(TSO_KEY, tso, "") .withSeverity(WARN_SEVERITY) - .build()); + .add(); } } else { if (!injection.getTerminal().isConnected() || !injection.getTerminal().getBusBreakerView().getBus().isInMainSynchronousComponent()) { - reporter.report(Report.builder() - .withKey("3") - .withDefaultMessage("GLSK node is connected to an island") + reportNode.newReportNode().withMessageTemplate("3", "GLSK node is connected to an island") .withTypedValue(NODE_ID_KEY, registeredResource.getmRID(), "") .withTypedValue(TYPE_KEY, type, "") .withTypedValue(TSO_KEY, tso, "") .withSeverity(WARN_SEVERITY) - .build()); + .add(); } } } diff --git a/glsk/glsk-quality-check-ucte/src/main/java/com/powsybl/glsk/ucte/quality_check/GlskQualityProcessor.java b/glsk/glsk-quality-check-ucte/src/main/java/com/powsybl/glsk/ucte/quality_check/GlskQualityProcessor.java index a9e36507..df064e24 100644 --- a/glsk/glsk-quality-check-ucte/src/main/java/com/powsybl/glsk/ucte/quality_check/GlskQualityProcessor.java +++ b/glsk/glsk-quality-check-ucte/src/main/java/com/powsybl/glsk/ucte/quality_check/GlskQualityProcessor.java @@ -6,7 +6,7 @@ */ package com.powsybl.glsk.ucte.quality_check; -import com.powsybl.commons.reporter.Reporter; +import com.powsybl.commons.report.ReportNode; import com.powsybl.glsk.ucte.UcteGlskDocument; import com.powsybl.iidm.network.Network; @@ -21,12 +21,12 @@ public final class GlskQualityProcessor { private GlskQualityProcessor() { } - public static void process(String cgmName, InputStream cgmIs, InputStream glskIs, Instant localDate, Reporter reporter) { - process(UcteGlskDocument.importGlsk(glskIs), Network.read(cgmName, cgmIs), localDate, reporter); + public static void process(String cgmName, InputStream cgmIs, InputStream glskIs, Instant localDate, ReportNode reportNode) { + process(UcteGlskDocument.importGlsk(glskIs), Network.read(cgmName, cgmIs), localDate, reportNode); } - public static void process(UcteGlskDocument ucteGlskDocument, Network network, Instant instant, Reporter reporter) { + public static void process(UcteGlskDocument ucteGlskDocument, Network network, Instant instant, ReportNode reportNode) { GlskQualityCheckInput input = new GlskQualityCheckInput(ucteGlskDocument, network, instant); - GlskQualityCheck.gskQualityCheck(input, reporter); + GlskQualityCheck.gskQualityCheck(input, reportNode); } } diff --git a/glsk/glsk-quality-check-ucte/src/test/java/com/powsybl/glsk/ucte/quality_check/GlskQualityProcessorTest.java b/glsk/glsk-quality-check-ucte/src/test/java/com/powsybl/glsk/ucte/quality_check/GlskQualityProcessorTest.java index c6111363..4dbbfa13 100644 --- a/glsk/glsk-quality-check-ucte/src/test/java/com/powsybl/glsk/ucte/quality_check/GlskQualityProcessorTest.java +++ b/glsk/glsk-quality-check-ucte/src/test/java/com/powsybl/glsk/ucte/quality_check/GlskQualityProcessorTest.java @@ -6,8 +6,7 @@ */ package com.powsybl.glsk.ucte.quality_check; -import com.powsybl.commons.reporter.Report; -import com.powsybl.commons.reporter.ReporterModel; +import com.powsybl.commons.report.ReportNode; import com.powsybl.glsk.ucte.UcteGlskDocument; import com.powsybl.iidm.network.Network; import org.junit.jupiter.api.Test; @@ -33,28 +32,28 @@ private InputStream getResourceAsInputStream(String resource) { void qualityCheckWithCorrectValue() { UcteGlskDocument ucteGlskDocument = UcteGlskDocument.importGlsk(getResourceAsInputStream(COUNTRYTEST)); Network network = Network.read("testCase.xiidm", getClass().getResourceAsStream("/testCase.xiidm")); - ReporterModel reporter = new ReporterModel("defaultTask", "defaultName"); - GlskQualityProcessor.process(ucteGlskDocument, network, Instant.parse("2016-07-28T23:30:00Z"), reporter); + ReportNode reportNode = ReportNode.newRootReportNode().withMessageTemplate("defaultTask", "defaultName").build(); + GlskQualityProcessor.process(ucteGlskDocument, network, Instant.parse("2016-07-28T23:30:00Z"), reportNode); - assertTrue(reporter.getReports().isEmpty()); + assertTrue(reportNode.getChildren().isEmpty()); } @Test void qualityCheckWithError1() { UcteGlskDocument ucteGlskDocument = UcteGlskDocument.importGlsk(getResourceAsInputStream(FIRST_ERROR)); Network network = Network.read("testCase.xiidm", getClass().getResourceAsStream("/testCase.xiidm")); - ReporterModel reporter = new ReporterModel("defaultTask", "defaultName"); + ReportNode reporter = ReportNode.newRootReportNode().withMessageTemplate("defaultTask", "defaultName").build(); GlskQualityProcessor.process(ucteGlskDocument, network, Instant.parse("2016-07-28T23:30:00Z"), reporter); - assertEquals(1, reporter.getReports().size()); - Report r = reporter.getReports().stream().findFirst().get(); - assertEquals("GLSK node is not found in CGM", r.getDefaultMessage()); - assertEquals("FFR2AA2 ", r.getValue(GlskQualityCheck.NODE_ID_KEY).toString()); - assertEquals("10YFR-RTE------C", r.getValue(GlskQualityCheck.TSO_KEY).toString()); + assertEquals(1, reporter.getChildren().size()); + ReportNode r = reporter.getChildren().stream().findFirst().get(); + assertEquals("GLSK node is not found in CGM", r.getMessage()); + assertEquals("FFR2AA2 ", r.getValue(GlskQualityCheck.NODE_ID_KEY).get().toString()); + assertEquals("10YFR-RTE------C", r.getValue(GlskQualityCheck.TSO_KEY).get().toString()); //Get unique TSO count in logs - assertEquals(1, reporter.getReports().stream().filter(rep -> rep.getValue(GlskQualityCheck.TSO_KEY).toString().equals("10YFR-RTE------C")).count()); + assertEquals(1, reporter.getChildren().stream().filter(rep -> rep.getValue(GlskQualityCheck.TSO_KEY).get().toString().equals("10YFR-RTE------C")).count()); //Get log count for RTE - assertEquals(1, reporter.getReports().stream().map(rep -> rep.getValue(GlskQualityCheck.TSO_KEY).toString()).distinct().count()); + assertEquals(1, reporter.getChildren().stream().map(rep -> rep.getValue(GlskQualityCheck.TSO_KEY).get().toString()).distinct().count()); } @@ -62,42 +61,42 @@ void qualityCheckWithError1() { void qualityCheckWithError2() { UcteGlskDocument ucteGlskDocument = UcteGlskDocument.importGlsk(getResourceAsInputStream(COUNTRYTEST)); Network network = Network.read("testCase_error_2.xiidm", getClass().getResourceAsStream("/testCase_error_2.xiidm")); - ReporterModel reporter = new ReporterModel("defaultTask", "defaultName"); + ReportNode reporter = ReportNode.newRootReportNode().withMessageTemplate("defaultTask", "defaultName").build(); GlskQualityProcessor.process(ucteGlskDocument, network, Instant.parse("2016-07-28T23:30:00Z"), reporter); - assertEquals(1, reporter.getReports().size()); - Report r = reporter.getReports().stream().findFirst().get(); - assertEquals("GLSK node is present but has no running Generator or Load", r.getDefaultMessage()); - assertEquals("FFR2AA1 ", r.getValue(GlskQualityCheck.NODE_ID_KEY).toString()); - assertEquals("10YFR-RTE------C", r.getValue(GlskQualityCheck.TSO_KEY).toString()); + assertEquals(1, reporter.getChildren().size()); + ReportNode r = reporter.getChildren().stream().findFirst().get(); + assertEquals("GLSK node is present but has no running Generator or Load", r.getMessage()); + assertEquals("FFR2AA1 ", r.getValue(GlskQualityCheck.NODE_ID_KEY).get().toString()); + assertEquals("10YFR-RTE------C", r.getValue(GlskQualityCheck.TSO_KEY).get().toString()); } @Test void qualityCheckWithError3() { UcteGlskDocument ucteGlskDocument = UcteGlskDocument.importGlsk(getResourceAsInputStream(COUNTRYTEST)); Network network = Network.read("testCase_error_3.xiidm", getClass().getResourceAsStream("/testCase_error_3.xiidm")); - ReporterModel reporter = new ReporterModel("defaultTask", "defaultName"); + ReportNode reporter = ReportNode.newRootReportNode().withMessageTemplate("defaultTask", "defaultName").build(); GlskQualityProcessor.process(ucteGlskDocument, network, Instant.parse("2016-07-28T23:30:00Z"), reporter); - assertEquals(1, reporter.getReports().size()); - Report r = reporter.getReports().stream().findFirst().get(); - assertEquals("GLSK node is connected to an island", r.getDefaultMessage()); - assertEquals("FFR2AA1 ", r.getValue(GlskQualityCheck.NODE_ID_KEY).toString()); - assertEquals("10YFR-RTE------C", r.getValue(GlskQualityCheck.TSO_KEY).toString()); + assertEquals(1, reporter.getChildren().size()); + ReportNode r = reporter.getChildren().stream().findFirst().get(); + assertEquals("GLSK node is connected to an island", r.getMessage()); + assertEquals("FFR2AA1 ", r.getValue(GlskQualityCheck.NODE_ID_KEY).get().toString()); + assertEquals("10YFR-RTE------C", r.getValue(GlskQualityCheck.TSO_KEY).get().toString()); } @Test void qualityCheckLoadNotConnected() { UcteGlskDocument ucteGlskDocument = UcteGlskDocument.importGlsk(getResourceAsInputStream(COUNTRYTEST)); Network network = Network.read("testCase_error_load_not_connected.xiidm", getClass().getResourceAsStream("/testCase_error_load_not_connected.xiidm")); - ReporterModel reporter = new ReporterModel("defaultTask", "defaultName"); + ReportNode reporter = ReportNode.newRootReportNode().withMessageTemplate("defaultTask", "defaultName").build(); GlskQualityProcessor.process(ucteGlskDocument, network, Instant.parse("2016-07-28T23:30:00Z"), reporter); - assertEquals(1, reporter.getReports().size()); - Report r = reporter.getReports().stream().findFirst().get(); - assertEquals("GLSK node is connected to an island", r.getDefaultMessage()); - assertEquals("FFR2AA1 ", r.getValue(GlskQualityCheck.NODE_ID_KEY).toString()); - assertEquals("10YFR-RTE------C", r.getValue(GlskQualityCheck.TSO_KEY).toString()); + assertEquals(1, reporter.getChildren().size()); + ReportNode r = reporter.getChildren().stream().findFirst().get(); + assertEquals("GLSK node is connected to an island", r.getMessage()); + assertEquals("FFR2AA1 ", r.getValue(GlskQualityCheck.NODE_ID_KEY).get().toString()); + assertEquals("10YFR-RTE------C", r.getValue(GlskQualityCheck.TSO_KEY).get().toString()); } } diff --git a/pom.xml b/pom.xml index 1996373a..c76f6c9e 100644 --- a/pom.xml +++ b/pom.xml @@ -58,8 +58,8 @@ 17 - 6.2.0 - 1.7.0 + 6.3.0-SNAPSHOT + 1.8.0-SNAPSHOT ../distribution-entsoe/target/site/jacoco-aggregate/jacoco.xml, ../../distribution-entsoe/target/site/jacoco-aggregate/jacoco.xml, From 02e0efe2c60887a24834aef9ad014b55e6aceb2d Mon Sep 17 00:00:00 2001 From: Luma Date: Mon, 11 Mar 2024 21:55:39 +0100 Subject: [PATCH 02/11] check location of other repos Signed-off-by: Luma --- .github/workflows/maven.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index a78cc1ee..641ed724 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -17,17 +17,22 @@ jobs: os: [ubuntu-latest, windows-latest, macos-latest] steps: + - name: print environment + run: env + - name: Checkout powsybl-core branch uses: actions/checkout@v4 with: repository: powsybl/powsybl-core ref: refs/heads/main + path: powsybl-core - name: Checkout powsybl-open-loadflow branch uses: actions/checkout@v4 with: repository: powsybl/powsybl-open-loadflow ref: refs/heads/reporter_v2 + path: powsybl-open-loadflow - name: Checkout sources uses: actions/checkout@v1 From 85355baf01fb694fc61caccb18011520813e2184 Mon Sep 17 00:00:00 2001 From: Luma Date: Mon, 11 Mar 2024 22:00:29 +0100 Subject: [PATCH 03/11] check location of other repos Signed-off-by: Luma --- .github/workflows/maven.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 641ed724..d9b77c14 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -25,14 +25,14 @@ jobs: with: repository: powsybl/powsybl-core ref: refs/heads/main - path: powsybl-core + path: ../powsybl-core - name: Checkout powsybl-open-loadflow branch uses: actions/checkout@v4 with: repository: powsybl/powsybl-open-loadflow - ref: refs/heads/reporter_v2 - path: powsybl-open-loadflow + ref: refs/heads/report_v2 + path: ../powsybl-open-loadflow - name: Checkout sources uses: actions/checkout@v1 From 31e044c2cb1dd4471048951135f5c785ebfa1034 Mon Sep 17 00:00:00 2001 From: Luma Date: Tue, 12 Mar 2024 07:50:10 +0100 Subject: [PATCH 04/11] first project sources Signed-off-by: Luma --- .github/workflows/maven.yml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index d9b77c14..452e500b 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -20,22 +20,20 @@ jobs: - name: print environment run: env + - name: Checkout sources + uses: actions/checkout@v1 + - name: Checkout powsybl-core branch uses: actions/checkout@v4 with: repository: powsybl/powsybl-core ref: refs/heads/main - path: ../powsybl-core - name: Checkout powsybl-open-loadflow branch uses: actions/checkout@v4 with: repository: powsybl/powsybl-open-loadflow ref: refs/heads/report_v2 - path: ../powsybl-open-loadflow - - - name: Checkout sources - uses: actions/checkout@v1 - name: Set up JDK 17 uses: actions/setup-java@v1 From 1548d5927dcfb79c2f58aeb6e37ff7fc23837306 Mon Sep 17 00:00:00 2001 From: Luma Date: Tue, 12 Mar 2024 07:59:59 +0100 Subject: [PATCH 05/11] checkout v4 for main checkout Signed-off-by: Luma --- .github/workflows/maven.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 452e500b..2d2c61cd 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -21,19 +21,23 @@ jobs: run: env - name: Checkout sources - uses: actions/checkout@v1 + uses: actions/checkout@v4 + with: + path: main - name: Checkout powsybl-core branch uses: actions/checkout@v4 with: repository: powsybl/powsybl-core ref: refs/heads/main + path: powsybl-core - name: Checkout powsybl-open-loadflow branch uses: actions/checkout@v4 with: repository: powsybl/powsybl-open-loadflow ref: refs/heads/report_v2 + path: powsybl-open-loadflow - name: Set up JDK 17 uses: actions/setup-java@v1 @@ -41,10 +45,10 @@ jobs: java-version: 17 - name: Build and install powsybl-core with Maven - run: ./mvnw --batch-mode -DskipTests=true --file ../powsybl-core/pom.xml + run: mvn --batch-mode -DskipTests=true --file ../powsybl-core/pom.xml - name: Build and install powsybl-open-loadflow with Maven - run: ./mvnw --batch-mode -DskipTests=true --file ../powsybl-open-loadflow/pom.xml + run: mvn --batch-mode -DskipTests=true --file ../powsybl-open-loadflow/pom.xml - name: Build with Maven if: matrix.os == 'ubuntu-latest' From c32713b65b15cb2bbbe9e771d5beadbfd7306afa Mon Sep 17 00:00:00 2001 From: Luma Date: Tue, 12 Mar 2024 08:02:18 +0100 Subject: [PATCH 06/11] location of checked out projects Signed-off-by: Luma --- .github/workflows/maven.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 2d2c61cd..23dc4f8f 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -45,10 +45,10 @@ jobs: java-version: 17 - name: Build and install powsybl-core with Maven - run: mvn --batch-mode -DskipTests=true --file ../powsybl-core/pom.xml + run: mvn --batch-mode -DskipTests=true --file ./powsybl-core/pom.xml - name: Build and install powsybl-open-loadflow with Maven - run: mvn --batch-mode -DskipTests=true --file ../powsybl-open-loadflow/pom.xml + run: mvn --batch-mode -DskipTests=true --file ./powsybl-open-loadflow/pom.xml - name: Build with Maven if: matrix.os == 'ubuntu-latest' From e2d2880b2a167de688f93c9313f956b95e7542ac Mon Sep 17 00:00:00 2001 From: Luma Date: Tue, 12 Mar 2024 08:04:59 +0100 Subject: [PATCH 07/11] mvn install core and open-loadflow Signed-off-by: Luma --- .github/workflows/maven.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 23dc4f8f..578fe92b 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -45,10 +45,10 @@ jobs: java-version: 17 - name: Build and install powsybl-core with Maven - run: mvn --batch-mode -DskipTests=true --file ./powsybl-core/pom.xml + run: mvn --batch-mode -DskipTests=true --file ./powsybl-core/pom.xml install - name: Build and install powsybl-open-loadflow with Maven - run: mvn --batch-mode -DskipTests=true --file ./powsybl-open-loadflow/pom.xml + run: mvn --batch-mode -DskipTests=true --file ./powsybl-open-loadflow/pom.xml install - name: Build with Maven if: matrix.os == 'ubuntu-latest' From 5fae8cd35220749b4317c9da971b996f39269b92 Mon Sep 17 00:00:00 2001 From: Luma Date: Tue, 12 Mar 2024 08:54:24 +0100 Subject: [PATCH 08/11] powsybl-entsoe has been checked out in folder Signed-off-by: Luma --- .github/workflows/maven.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 578fe92b..1a4bd72a 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -52,16 +52,16 @@ jobs: - name: Build with Maven if: matrix.os == 'ubuntu-latest' - run: mvn --batch-mode -Pjacoco install + run: mvn --batch-mode -Pjacoco --file ./main/pom.xml install - name: Build with Maven if: matrix.os != 'ubuntu-latest' - run: mvn --batch-mode install + run: mvn --batch-mode --file ./main/pom.xml install - name: Run SonarCloud analysis if: matrix.os == 'ubuntu-latest' run: > - mvn --batch-mode -DskipTests sonar:sonar + mvn --batch-mode -DskipTests --file ./main/pom.xml sonar:sonar -Dsonar.host.url=https://sonarcloud.io -Dsonar.organization=powsybl-ci-github -Dsonar.projectKey=com.powsybl:powsybl-entsoe From efcfe497f68f67d2729a840b0b0193ff0206f631 Mon Sep 17 00:00:00 2001 From: Luma Date: Tue, 12 Mar 2024 12:14:48 +0100 Subject: [PATCH 09/11] Update emf tests after changes in tie line export Signed-off-by: Luma --- .github/workflows/maven.yml | 2 +- .../java/com/powsybl/emf/IGMmergeTests.java | 34 +++++++++---------- 2 files changed, 17 insertions(+), 19 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 1a4bd72a..e919a469 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -29,7 +29,7 @@ jobs: uses: actions/checkout@v4 with: repository: powsybl/powsybl-core - ref: refs/heads/main + ref: refs/heads/cgmes_export_tielines_as_danglingLines path: powsybl-core - name: Checkout powsybl-open-loadflow branch diff --git a/emf/src/test/java/com/powsybl/emf/IGMmergeTests.java b/emf/src/test/java/com/powsybl/emf/IGMmergeTests.java index 9d436ae4..cb742c62 100644 --- a/emf/src/test/java/com/powsybl/emf/IGMmergeTests.java +++ b/emf/src/test/java/com/powsybl/emf/IGMmergeTests.java @@ -14,7 +14,6 @@ import com.powsybl.cgmes.model.GridModelReferenceResources; import com.powsybl.commons.datasource.GenericReadOnlyDataSource; import com.powsybl.commons.datasource.ResourceSet; -import com.powsybl.iidm.modification.ReplaceTieLinesByLines; import com.powsybl.iidm.network.*; import com.powsybl.loadflow.LoadFlow; import org.junit.jupiter.api.AfterEach; @@ -75,6 +74,13 @@ void igmsSubnetworksMerge() throws IOException { // Check that we have subnetworks assertEquals(2, merged.getSubnetworks().size()); + // Once the CGM ("merged") has been built, we do not need values (p0, q0) at dangling lines + // They are the values of the equivalent injections needed when only one IGM is considered + for (TieLine tl : merged.getTieLineStream().toList()) { + tl.getDanglingLine1().setP0(0).setQ0(0); + tl.getDanglingLine2().setP0(0).setQ0(0); + } + LoadFlow.run(merged); Path mergedDir = Files.createDirectories(tmpDir.resolve("subnetworksMerge")); @@ -91,14 +97,7 @@ void igmsSubnetworksMerge() throws IOException { validate(serializedMergedNetwork, branchIds, generatorIds, voltageLevelIds); // compare - // FIXME(Luma) CGMES Export: tie lines as two separate equipment instead of a single ACLS - // Right now in CGMES we are exporting tie lines as regular lines, - // instead of two separate equipment. - // Before comparing, perform the same modification on the original network - // so that both networks are comparable - // This should be removed when we export tie lines as two separate equipment - new ReplaceTieLinesByLines().apply(merged); - compareNetwork(serializedMergedNetwork, merged); + compareNetwork(merged, serializedMergedNetwork); } @Test @@ -155,6 +154,12 @@ private Network exportAndLoad(Network network, String dirName, String country) t void cgmToCgmes() throws IOException { // read resources for BE and NL, merge the resources themselves and read a network from this set of resources Network networkBENL = createCGM(); + // Once the CGM has been built, we do not need values (p0, q0) at dangling lines + // They are the values of the equivalent injections needed when only one IGM is considered + for (TieLine tl : networkBENL.getTieLineStream().toList()) { + tl.getDanglingLine1().setP0(0).setQ0(0); + tl.getDanglingLine2().setP0(0).setQ0(0); + } Set branchIds = new HashSet<>(); Set generatorIds = new HashSet<>(); @@ -177,15 +182,8 @@ void cgmToCgmes() throws IOException { Network serializedMergedNetwork = Network.read(new GenericReadOnlyDataSource(mergedResourcesDir, "BE_NL"), null); validate(serializedMergedNetwork, branchIds, generatorIds, voltageLevelIds); - // compare - // FIXME(Luma) CGMES Export: tie lines as two separate equipment instead of a single ACLS - // Right now in CGMES we are exporting tie lines as regular lines, - // instead of two separate equipment. - // Before comparing, perform the same modification on the original network - // so that both networks are comparable - // This should be removed when we export tie lines as two separate equipment - new ReplaceTieLinesByLines().apply(networkBENL); - compareNetwork(serializedMergedNetwork, networkBENL); + // compare the serialized and reimported network with the original one + compareNetwork(networkBENL, serializedMergedNetwork); } @Test From 53847227ea574236c906a12e13c39e947a7eb71b Mon Sep 17 00:00:00 2001 From: Anne Tilloy Date: Fri, 29 Mar 2024 15:30:09 +0100 Subject: [PATCH 10/11] To snapshot. Signed-off-by: Anne Tilloy --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c76f6c9e..bd1e2eee 100644 --- a/pom.xml +++ b/pom.xml @@ -59,7 +59,7 @@ 17 6.3.0-SNAPSHOT - 1.8.0-SNAPSHOT + 1.9.0-SNAPSHOT ../distribution-entsoe/target/site/jacoco-aggregate/jacoco.xml, ../../distribution-entsoe/target/site/jacoco-aggregate/jacoco.xml, From 7ba7bdb1a573b02e762a07a5d4fc5b07aa92cec1 Mon Sep 17 00:00:00 2001 From: Anne Tilloy Date: Thu, 4 Apr 2024 13:53:36 +0200 Subject: [PATCH 11/11] -Bump to core 6.0.0 and olf 1.3.0. -Clean maven.yml. Signed-off-by: Anne Tilloy --- .github/workflows/maven.yml | 33 ++++----------------------------- pom.xml | 4 ++-- 2 files changed, 6 insertions(+), 31 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index e919a469..e06d78e2 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -17,51 +17,26 @@ jobs: os: [ubuntu-latest, windows-latest, macos-latest] steps: - - name: print environment - run: env - - name: Checkout sources - uses: actions/checkout@v4 - with: - path: main - - - name: Checkout powsybl-core branch - uses: actions/checkout@v4 - with: - repository: powsybl/powsybl-core - ref: refs/heads/cgmes_export_tielines_as_danglingLines - path: powsybl-core - - - name: Checkout powsybl-open-loadflow branch - uses: actions/checkout@v4 - with: - repository: powsybl/powsybl-open-loadflow - ref: refs/heads/report_v2 - path: powsybl-open-loadflow + uses: actions/checkout@v1 - name: Set up JDK 17 uses: actions/setup-java@v1 with: java-version: 17 - - name: Build and install powsybl-core with Maven - run: mvn --batch-mode -DskipTests=true --file ./powsybl-core/pom.xml install - - - name: Build and install powsybl-open-loadflow with Maven - run: mvn --batch-mode -DskipTests=true --file ./powsybl-open-loadflow/pom.xml install - - name: Build with Maven if: matrix.os == 'ubuntu-latest' - run: mvn --batch-mode -Pjacoco --file ./main/pom.xml install + run: mvn --batch-mode -Pjacoco install - name: Build with Maven if: matrix.os != 'ubuntu-latest' - run: mvn --batch-mode --file ./main/pom.xml install + run: mvn --batch-mode install - name: Run SonarCloud analysis if: matrix.os == 'ubuntu-latest' run: > - mvn --batch-mode -DskipTests --file ./main/pom.xml sonar:sonar + mvn --batch-mode -DskipTests sonar:sonar -Dsonar.host.url=https://sonarcloud.io -Dsonar.organization=powsybl-ci-github -Dsonar.projectKey=com.powsybl:powsybl-entsoe diff --git a/pom.xml b/pom.xml index bd1e2eee..5efff54f 100644 --- a/pom.xml +++ b/pom.xml @@ -58,8 +58,8 @@ 17 - 6.3.0-SNAPSHOT - 1.9.0-SNAPSHOT + 6.3.0 + 1.9.0 ../distribution-entsoe/target/site/jacoco-aggregate/jacoco.xml, ../../distribution-entsoe/target/site/jacoco-aggregate/jacoco.xml,