diff --git a/data/rao-result/rao-result-api/src/main/java/com/powsybl/openrao/data/raoresult/api/OptimizationStepsExecuted.java b/data/rao-result/rao-result-api/src/main/java/com/powsybl/openrao/data/raoresult/api/OptimizationStepsExecuted.java index d50a16e469..546a1ee06e 100644 --- a/data/rao-result/rao-result-api/src/main/java/com/powsybl/openrao/data/raoresult/api/OptimizationStepsExecuted.java +++ b/data/rao-result/rao-result-api/src/main/java/com/powsybl/openrao/data/raoresult/api/OptimizationStepsExecuted.java @@ -7,54 +7,18 @@ package com.powsybl.openrao.data.raoresult.api; -import java.util.Collections; -import java.util.Set; - /** * Enum representing the different optimizations the rao went through * * @author Martin Belthle {@literal } */ -public enum OptimizationStepsExecuted { - SECOND_PREVENTIVE_FELLBACK_TO_INITIAL_SITUATION(true, true, false, Collections.emptySet()), - FIRST_PREVENTIVE_FELLBACK_TO_INITIAL_SITUATION(false, true, false, Collections.emptySet()), - SECOND_PREVENTIVE_IMPROVED_FIRST(true, false, false, Set.of(SECOND_PREVENTIVE_FELLBACK_TO_INITIAL_SITUATION)), - SECOND_PREVENTIVE_FELLBACK_TO_FIRST_PREVENTIVE_SITUATION(true, false, true, Set.of(SECOND_PREVENTIVE_FELLBACK_TO_INITIAL_SITUATION)), - FIRST_PREVENTIVE_ONLY(false, false, false, Set.of(FIRST_PREVENTIVE_FELLBACK_TO_INITIAL_SITUATION, SECOND_PREVENTIVE_IMPROVED_FIRST, SECOND_PREVENTIVE_FELLBACK_TO_FIRST_PREVENTIVE_SITUATION, SECOND_PREVENTIVE_FELLBACK_TO_INITIAL_SITUATION)); - - private final boolean secondPreventive; - private final boolean fellBackToInitialSituation; - private final boolean fellBackToFirstPreventiveSituation; - private final Set possibleOverwrite; - - OptimizationStepsExecuted(boolean secondPreventive, boolean fellBackToInitialSituation, boolean fellBackToFirstPreventiveSituation, Set possibleOverwrite) { - this.secondPreventive = secondPreventive; - this.fellBackToInitialSituation = fellBackToInitialSituation; - this.fellBackToFirstPreventiveSituation = fellBackToFirstPreventiveSituation; - this.possibleOverwrite = possibleOverwrite; - } - - public boolean hasRunSecondPreventive() { - return secondPreventive; - } - - public boolean hasFallenBackToInitialSituation() { - return fellBackToInitialSituation; - } - - public boolean hasFallenBackToFirstPreventiveSituation() { - return fellBackToFirstPreventiveSituation; - } - - public Set getPossibleOverwrite() { - return possibleOverwrite; - } +public final class OptimizationStepsExecuted { + public static final String FIRST_PREVENTIVE_ONLY = "The RAO only went through first preventive"; + public static final String FIRST_PREVENTIVE_FELLBACK_TO_INITIAL_SITUATION = "First preventive fell back to initial situation"; + public static final String SECOND_PREVENTIVE_IMPROVED_FIRST = "Second preventive improved first preventive results"; + public static final String SECOND_PREVENTIVE_FELLBACK_TO_INITIAL_SITUATION = "Second preventive fell back to initial situation"; + public static final String SECOND_PREVENTIVE_FELLBACK_TO_FIRST_PREVENTIVE_SITUATION = "Second preventive fell back to first preventive results"; - public boolean isOverwritePossible(OptimizationStepsExecuted optimizationStepsExecuted) { - if (!getPossibleOverwrite().isEmpty()) { - return getPossibleOverwrite().contains(optimizationStepsExecuted); - } - return false; - } + private OptimizationStepsExecuted() { } } diff --git a/data/rao-result/rao-result-api/src/main/java/com/powsybl/openrao/data/raoresult/api/RaoResult.java b/data/rao-result/rao-result-api/src/main/java/com/powsybl/openrao/data/raoresult/api/RaoResult.java index dd4ac07557..063dec52fd 100644 --- a/data/rao-result/rao-result-api/src/main/java/com/powsybl/openrao/data/raoresult/api/RaoResult.java +++ b/data/rao-result/rao-result-api/src/main/java/com/powsybl/openrao/data/raoresult/api/RaoResult.java @@ -430,9 +430,9 @@ default boolean isActivated(State state, NetworkAction networkAction) { /** * Know which RAO steps were executed by the RAO */ - OptimizationStepsExecuted getOptimizationStepsExecuted(); + String getExecutionDetails(); - void setOptimizationStepsExecuted(OptimizationStepsExecuted optimizationStepsExecuted); + void setExecutionDetails(String executionDetails); /** * Indicates whether the all the CNECs of a given type at a given instant are secure. diff --git a/data/rao-result/rao-result-api/src/main/java/com/powsybl/openrao/data/raoresult/api/RaoResultClone.java b/data/rao-result/rao-result-api/src/main/java/com/powsybl/openrao/data/raoresult/api/RaoResultClone.java index 11b2a81492..a16ee7b155 100644 --- a/data/rao-result/rao-result-api/src/main/java/com/powsybl/openrao/data/raoresult/api/RaoResultClone.java +++ b/data/rao-result/rao-result-api/src/main/java/com/powsybl/openrao/data/raoresult/api/RaoResultClone.java @@ -162,8 +162,8 @@ public Map, Double> getOptimizedSetPointsOnState(State state) { } @Override - public void setOptimizationStepsExecuted(OptimizationStepsExecuted optimizationStepsExecuted) { - raoResult.setOptimizationStepsExecuted(optimizationStepsExecuted); + public void setExecutionDetails(String executionDetails) { + raoResult.setExecutionDetails(executionDetails); } @Override @@ -182,7 +182,7 @@ public boolean isSecure() { } @Override - public OptimizationStepsExecuted getOptimizationStepsExecuted() { - return raoResult.getOptimizationStepsExecuted(); + public String getExecutionDetails() { + return raoResult.getExecutionDetails(); } } diff --git a/data/rao-result/rao-result-api/src/test/java/com/powsybl/openrao/data/raoresult/api/MockRaoResult.java b/data/rao-result/rao-result-api/src/test/java/com/powsybl/openrao/data/raoresult/api/MockRaoResult.java index ed7d4e8a50..6fb59a560a 100644 --- a/data/rao-result/rao-result-api/src/test/java/com/powsybl/openrao/data/raoresult/api/MockRaoResult.java +++ b/data/rao-result/rao-result-api/src/test/java/com/powsybl/openrao/data/raoresult/api/MockRaoResult.java @@ -161,12 +161,12 @@ public Map, Double> getOptimizedSetPointsOnState(State state) { } @Override - public OptimizationStepsExecuted getOptimizationStepsExecuted() { + public String getExecutionDetails() { return null; } @Override - public void setOptimizationStepsExecuted(OptimizationStepsExecuted optimizationStepsExecuted) { + public void setExecutionDetails(String executionDetails) { //not used } diff --git a/data/rao-result/rao-result-api/src/test/java/com/powsybl/openrao/data/raoresult/api/OptimizationStepsExecutedTest.java b/data/rao-result/rao-result-api/src/test/java/com/powsybl/openrao/data/raoresult/api/OptimizationStepsExecutedTest.java deleted file mode 100644 index a8fd74f7e5..0000000000 --- a/data/rao-result/rao-result-api/src/test/java/com/powsybl/openrao/data/raoresult/api/OptimizationStepsExecutedTest.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (c) 2023, 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/. - */ - -package com.powsybl.openrao.data.raoresult.api; - -import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.*; - -/** - * @author Martin Belthle {@literal } - */ - -class OptimizationStepsExecutedTest { - - @Test - void testFirstPrevOnly() { - OptimizationStepsExecuted optimizationStepsExecuted = OptimizationStepsExecuted.FIRST_PREVENTIVE_ONLY; - assertFalse(optimizationStepsExecuted.hasRunSecondPreventive()); - assertFalse(optimizationStepsExecuted.hasFallenBackToFirstPreventiveSituation()); - assertFalse(optimizationStepsExecuted.hasFallenBackToInitialSituation()); - assertTrue(optimizationStepsExecuted.isOverwritePossible(OptimizationStepsExecuted.SECOND_PREVENTIVE_IMPROVED_FIRST)); - assertTrue(optimizationStepsExecuted.isOverwritePossible(OptimizationStepsExecuted.FIRST_PREVENTIVE_FELLBACK_TO_INITIAL_SITUATION)); - assertTrue(optimizationStepsExecuted.isOverwritePossible(OptimizationStepsExecuted.SECOND_PREVENTIVE_FELLBACK_TO_FIRST_PREVENTIVE_SITUATION)); - assertFalse(optimizationStepsExecuted.isOverwritePossible(OptimizationStepsExecuted.FIRST_PREVENTIVE_ONLY)); - assertTrue(optimizationStepsExecuted.isOverwritePossible(OptimizationStepsExecuted.SECOND_PREVENTIVE_FELLBACK_TO_INITIAL_SITUATION)); - } - - @Test - void testFirstPrevFellback() { - OptimizationStepsExecuted optimizationStepsExecuted = OptimizationStepsExecuted.FIRST_PREVENTIVE_FELLBACK_TO_INITIAL_SITUATION; - assertFalse(optimizationStepsExecuted.hasRunSecondPreventive()); - assertFalse(optimizationStepsExecuted.hasFallenBackToFirstPreventiveSituation()); - assertTrue(optimizationStepsExecuted.hasFallenBackToInitialSituation()); - assertFalse(optimizationStepsExecuted.isOverwritePossible(OptimizationStepsExecuted.SECOND_PREVENTIVE_IMPROVED_FIRST)); - assertFalse(optimizationStepsExecuted.isOverwritePossible(OptimizationStepsExecuted.FIRST_PREVENTIVE_FELLBACK_TO_INITIAL_SITUATION)); - assertFalse(optimizationStepsExecuted.isOverwritePossible(OptimizationStepsExecuted.SECOND_PREVENTIVE_FELLBACK_TO_FIRST_PREVENTIVE_SITUATION)); - assertFalse(optimizationStepsExecuted.isOverwritePossible(OptimizationStepsExecuted.FIRST_PREVENTIVE_ONLY)); - assertFalse(optimizationStepsExecuted.isOverwritePossible(OptimizationStepsExecuted.SECOND_PREVENTIVE_FELLBACK_TO_INITIAL_SITUATION)); - } - - @Test - void testSecondPrevImprovedFirst() { - OptimizationStepsExecuted optimizationStepsExecuted = OptimizationStepsExecuted.SECOND_PREVENTIVE_IMPROVED_FIRST; - assertTrue(optimizationStepsExecuted.hasRunSecondPreventive()); - assertFalse(optimizationStepsExecuted.hasFallenBackToFirstPreventiveSituation()); - assertFalse(optimizationStepsExecuted.hasFallenBackToInitialSituation()); - assertFalse(optimizationStepsExecuted.isOverwritePossible(OptimizationStepsExecuted.SECOND_PREVENTIVE_IMPROVED_FIRST)); - assertFalse(optimizationStepsExecuted.isOverwritePossible(OptimizationStepsExecuted.FIRST_PREVENTIVE_FELLBACK_TO_INITIAL_SITUATION)); - assertFalse(optimizationStepsExecuted.isOverwritePossible(OptimizationStepsExecuted.SECOND_PREVENTIVE_FELLBACK_TO_FIRST_PREVENTIVE_SITUATION)); - assertFalse(optimizationStepsExecuted.isOverwritePossible(OptimizationStepsExecuted.FIRST_PREVENTIVE_ONLY)); - assertTrue(optimizationStepsExecuted.isOverwritePossible(OptimizationStepsExecuted.SECOND_PREVENTIVE_FELLBACK_TO_INITIAL_SITUATION)); - } - - @Test - void testSecondPrevFellbackToStart() { - OptimizationStepsExecuted optimizationStepsExecuted = OptimizationStepsExecuted.SECOND_PREVENTIVE_FELLBACK_TO_INITIAL_SITUATION; - assertTrue(optimizationStepsExecuted.hasRunSecondPreventive()); - assertFalse(optimizationStepsExecuted.hasFallenBackToFirstPreventiveSituation()); - assertTrue(optimizationStepsExecuted.hasFallenBackToInitialSituation()); - assertFalse(optimizationStepsExecuted.isOverwritePossible(OptimizationStepsExecuted.SECOND_PREVENTIVE_IMPROVED_FIRST)); - assertFalse(optimizationStepsExecuted.isOverwritePossible(OptimizationStepsExecuted.FIRST_PREVENTIVE_FELLBACK_TO_INITIAL_SITUATION)); - assertFalse(optimizationStepsExecuted.isOverwritePossible(OptimizationStepsExecuted.SECOND_PREVENTIVE_FELLBACK_TO_FIRST_PREVENTIVE_SITUATION)); - assertFalse(optimizationStepsExecuted.isOverwritePossible(OptimizationStepsExecuted.FIRST_PREVENTIVE_ONLY)); - assertFalse(optimizationStepsExecuted.isOverwritePossible(OptimizationStepsExecuted.SECOND_PREVENTIVE_FELLBACK_TO_INITIAL_SITUATION)); - } - - @Test - void testSecondPreventiveFellbackToFirstPrevResult() { - OptimizationStepsExecuted optimizationStepsExecuted = OptimizationStepsExecuted.SECOND_PREVENTIVE_FELLBACK_TO_FIRST_PREVENTIVE_SITUATION; - assertTrue(optimizationStepsExecuted.hasRunSecondPreventive()); - assertTrue(optimizationStepsExecuted.hasFallenBackToFirstPreventiveSituation()); - assertFalse(optimizationStepsExecuted.hasFallenBackToInitialSituation()); - assertFalse(optimizationStepsExecuted.isOverwritePossible(OptimizationStepsExecuted.SECOND_PREVENTIVE_IMPROVED_FIRST)); - assertFalse(optimizationStepsExecuted.isOverwritePossible(OptimizationStepsExecuted.FIRST_PREVENTIVE_FELLBACK_TO_INITIAL_SITUATION)); - assertFalse(optimizationStepsExecuted.isOverwritePossible(OptimizationStepsExecuted.SECOND_PREVENTIVE_FELLBACK_TO_FIRST_PREVENTIVE_SITUATION)); - assertFalse(optimizationStepsExecuted.isOverwritePossible(OptimizationStepsExecuted.FIRST_PREVENTIVE_ONLY)); - assertTrue(optimizationStepsExecuted.isOverwritePossible(OptimizationStepsExecuted.SECOND_PREVENTIVE_FELLBACK_TO_INITIAL_SITUATION)); - } -} diff --git a/data/rao-result/rao-result-impl/src/main/java/com/powsybl/openrao/data/raoresult/impl/RaoResultImpl.java b/data/rao-result/rao-result-impl/src/main/java/com/powsybl/openrao/data/raoresult/impl/RaoResultImpl.java index ebb6399a6e..fa11b042b1 100644 --- a/data/rao-result/rao-result-impl/src/main/java/com/powsybl/openrao/data/raoresult/impl/RaoResultImpl.java +++ b/data/rao-result/rao-result-impl/src/main/java/com/powsybl/openrao/data/raoresult/impl/RaoResultImpl.java @@ -42,8 +42,8 @@ public class RaoResultImpl implements RaoResult { private final Crac crac; - private ComputationStatus sensitivityStatus; - private final Map sensitivityStatusPerState = new HashMap<>(); + private ComputationStatus computationStatus; + private final Map computationStatusPerState = new HashMap<>(); private final Map flowCnecResults = new HashMap<>(); private final Map angleCnecResults = new HashMap<>(); private final Map voltageCnecResults = new HashMap<>(); @@ -51,28 +51,28 @@ public class RaoResultImpl implements RaoResult { private final Map, RangeActionResult> rangeActionResults = new HashMap<>(); private final Map costResults = new HashMap<>(); - private OptimizationStepsExecuted optimizationStepsExecuted = OptimizationStepsExecuted.FIRST_PREVENTIVE_ONLY; + private String executionDetails = OptimizationStepsExecuted.FIRST_PREVENTIVE_ONLY; public RaoResultImpl(Crac crac) { this.crac = crac; } public void setComputationStatus(ComputationStatus computationStatus) { - this.sensitivityStatus = computationStatus; + this.computationStatus = computationStatus; } public void setComputationStatus(State state, ComputationStatus computationStatus) { - this.sensitivityStatusPerState.put(state, computationStatus); + this.computationStatusPerState.put(state, computationStatus); } @Override public ComputationStatus getComputationStatus() { - return sensitivityStatus; + return computationStatus; } @Override public ComputationStatus getComputationStatus(State state) { - return sensitivityStatusPerState.getOrDefault(state, ComputationStatus.DEFAULT); + return computationStatusPerState.getOrDefault(state, ComputationStatus.DEFAULT); } private Instant checkOptimizedInstant(Instant optimizedInstant, FlowCnec flowCnec) { @@ -324,12 +324,8 @@ private State lookupState(String contingencyId, Instant instant) { } @Override - public void setOptimizationStepsExecuted(OptimizationStepsExecuted optimizationStepsExecuted) { - if (this.optimizationStepsExecuted.equals(OptimizationStepsExecuted.FIRST_PREVENTIVE_ONLY)) { - this.optimizationStepsExecuted = optimizationStepsExecuted; - } else { - throw new OpenRaoException("The RaoResult object should not be modified outside of its usual routine"); - } + public void setExecutionDetails(String executionDetails) { + this.executionDetails = executionDetails; } private boolean instantHasNoNegativeMargin(Instant optimizedInstant, PhysicalParameter... u) { @@ -376,8 +372,8 @@ public boolean isSecure(Instant optimizedInstant, PhysicalParameter... u) { if (ComputationStatus.FAILURE.equals(getComputationStatus())) { return false; } - if (sensitivityStatusPerState.keySet().stream().filter(state -> optimizedInstant.equals(state.getInstant())) - .anyMatch(state -> ComputationStatus.FAILURE.equals(sensitivityStatusPerState.get(state)))) { + if (computationStatusPerState.keySet().stream().filter(state -> optimizedInstant.equals(state.getInstant())) + .anyMatch(state -> ComputationStatus.FAILURE.equals(computationStatusPerState.get(state)))) { return false; } return instantHasNoNegativeMargin(optimizedInstant, u); @@ -389,7 +385,7 @@ public boolean isSecure(PhysicalParameter... u) { } @Override - public OptimizationStepsExecuted getOptimizationStepsExecuted() { - return optimizationStepsExecuted; + public String getExecutionDetails() { + return executionDetails; } } diff --git a/data/rao-result/rao-result-impl/src/test/java/com/powsybl/openrao/data/raoresult/impl/RaoResultImplTest.java b/data/rao-result/rao-result-impl/src/test/java/com/powsybl/openrao/data/raoresult/impl/RaoResultImplTest.java index 95cd4bd5b8..c5cbef6996 100644 --- a/data/rao-result/rao-result-impl/src/test/java/com/powsybl/openrao/data/raoresult/impl/RaoResultImplTest.java +++ b/data/rao-result/rao-result-impl/src/test/java/com/powsybl/openrao/data/raoresult/impl/RaoResultImplTest.java @@ -230,17 +230,11 @@ void testCostResults() { } @Test - void testOptimizedStepsExecuted() { + void testExecutionDetails() { setUp(); - assertFalse(raoResult.getOptimizationStepsExecuted().hasRunSecondPreventive()); - raoResult.setOptimizationStepsExecuted(OptimizationStepsExecuted.FIRST_PREVENTIVE_FELLBACK_TO_INITIAL_SITUATION); - assertEquals(OptimizationStepsExecuted.FIRST_PREVENTIVE_FELLBACK_TO_INITIAL_SITUATION, raoResult.getOptimizationStepsExecuted()); - OpenRaoException exception = assertThrows(OpenRaoException.class, () -> raoResult.setOptimizationStepsExecuted(OptimizationStepsExecuted.FIRST_PREVENTIVE_ONLY)); - assertEquals("The RaoResult object should not be modified outside of its usual routine", exception.getMessage()); - exception = assertThrows(OpenRaoException.class, () -> raoResult.setOptimizationStepsExecuted(OptimizationStepsExecuted.SECOND_PREVENTIVE_FELLBACK_TO_FIRST_PREVENTIVE_SITUATION)); - assertEquals("The RaoResult object should not be modified outside of its usual routine", exception.getMessage()); - exception = assertThrows(OpenRaoException.class, () -> raoResult.setOptimizationStepsExecuted(OptimizationStepsExecuted.FIRST_PREVENTIVE_FELLBACK_TO_INITIAL_SITUATION)); - assertEquals("The RaoResult object should not be modified outside of its usual routine", exception.getMessage()); + assertEquals(OptimizationStepsExecuted.FIRST_PREVENTIVE_ONLY, raoResult.getExecutionDetails()); + raoResult.setExecutionDetails(OptimizationStepsExecuted.FIRST_PREVENTIVE_FELLBACK_TO_INITIAL_SITUATION); + assertEquals(OptimizationStepsExecuted.FIRST_PREVENTIVE_FELLBACK_TO_INITIAL_SITUATION, raoResult.getExecutionDetails()); } @Test diff --git a/data/rao-result/rao-result-io/rao-result-json/src/main/java/com/powsybl/openrao/data/raoresult/io/json/RaoResultJsonConstants.java b/data/rao-result/rao-result-io/rao-result-json/src/main/java/com/powsybl/openrao/data/raoresult/io/json/RaoResultJsonConstants.java index f6807ce568..eb8f370506 100644 --- a/data/rao-result/rao-result-io/rao-result-json/src/main/java/com/powsybl/openrao/data/raoresult/io/json/RaoResultJsonConstants.java +++ b/data/rao-result/rao-result-io/rao-result-json/src/main/java/com/powsybl/openrao/data/raoresult/io/json/RaoResultJsonConstants.java @@ -13,7 +13,6 @@ import com.powsybl.openrao.data.crac.api.State; import com.powsybl.iidm.network.TwoSides; import com.powsybl.openrao.data.raoresult.api.ComputationStatus; -import com.powsybl.openrao.data.raoresult.api.OptimizationStepsExecuted; import org.apache.commons.lang3.StringUtils; import java.util.Arrays; @@ -28,8 +27,9 @@ public final class RaoResultJsonConstants { private RaoResultJsonConstants() { } - public static final String RAO_RESULT_IO_VERSION = "1.6"; + public static final String RAO_RESULT_IO_VERSION = "1.7"; // v1.6 : voltage cnecs' voltage values are divided into minVoltage and maxVoltage + // v1.7 : replaced "optimizationStepsExecuted" with "executionDetails" // header public static final String TYPE = "type"; @@ -120,6 +120,7 @@ private RaoResultJsonConstants() { // optimized steps executed by the RAO public static final String OPTIMIZATION_STEPS_EXECUTED = "optimizationStepsExecuted"; + public static final String EXECUTION_DETAILS = "executionDetails"; public static final String FIRST_PREVENTIVE_ONLY = "The RAO only went through first preventive"; public static final String FIRST_PREVENTIVE_FELLBACK = "First preventive fellback to initial situation"; public static final String SECOND_PREVENTIVE_IMPROVED_FIRST = "Second preventive improved first preventive results"; @@ -245,40 +246,6 @@ public static ComputationStatus deserializeStatus(String stringValue) { }; } - public static String serializeOptimizedStepsExecuted(OptimizationStepsExecuted optimizationStepsExecuted) { - switch (optimizationStepsExecuted) { - case FIRST_PREVENTIVE_ONLY: - return FIRST_PREVENTIVE_ONLY; - case FIRST_PREVENTIVE_FELLBACK_TO_INITIAL_SITUATION: - return FIRST_PREVENTIVE_FELLBACK; - case SECOND_PREVENTIVE_IMPROVED_FIRST: - return SECOND_PREVENTIVE_IMPROVED_FIRST; - case SECOND_PREVENTIVE_FELLBACK_TO_FIRST_PREVENTIVE_SITUATION: - return SECOND_PREVENTIVE_FELLBACK_TO_FIRST_PREVENTIVE_SITUATION; - case SECOND_PREVENTIVE_FELLBACK_TO_INITIAL_SITUATION: - return SECOND_PREVENTIVE_FELLBACK_TO_INITIAL_SITUATION; - default: - throw new OpenRaoException(String.format("Unsupported optimization steps executed %s", optimizationStepsExecuted)); - } - } - - public static OptimizationStepsExecuted deserializeOptimizedStepsExecuted(String stringValue) { - switch (stringValue) { - case FIRST_PREVENTIVE_ONLY: - return OptimizationStepsExecuted.FIRST_PREVENTIVE_ONLY; - case FIRST_PREVENTIVE_FELLBACK: - return OptimizationStepsExecuted.FIRST_PREVENTIVE_FELLBACK_TO_INITIAL_SITUATION; - case SECOND_PREVENTIVE_IMPROVED_FIRST: - return OptimizationStepsExecuted.SECOND_PREVENTIVE_IMPROVED_FIRST; - case SECOND_PREVENTIVE_FELLBACK_TO_FIRST_PREVENTIVE_SITUATION: - return OptimizationStepsExecuted.SECOND_PREVENTIVE_FELLBACK_TO_FIRST_PREVENTIVE_SITUATION; - case SECOND_PREVENTIVE_FELLBACK_TO_INITIAL_SITUATION: - return OptimizationStepsExecuted.SECOND_PREVENTIVE_FELLBACK_TO_INITIAL_SITUATION; - default: - throw new OpenRaoException(String.format("Unrecognized optimization steps executed %s", stringValue)); - } - } - // state comparator public static final Comparator STATE_COMPARATOR = (s1, s2) -> { if (s1.getInstant().getOrder() != s2.getInstant().getOrder()) { diff --git a/data/rao-result/rao-result-io/rao-result-json/src/main/java/com/powsybl/openrao/data/raoresult/io/json/deserializers/RaoResultDeserializer.java b/data/rao-result/rao-result-io/rao-result-json/src/main/java/com/powsybl/openrao/data/raoresult/io/json/deserializers/RaoResultDeserializer.java index a309dc0a65..d493d87ad9 100644 --- a/data/rao-result/rao-result-io/rao-result-json/src/main/java/com/powsybl/openrao/data/raoresult/io/json/deserializers/RaoResultDeserializer.java +++ b/data/rao-result/rao-result-io/rao-result-json/src/main/java/com/powsybl/openrao/data/raoresult/io/json/deserializers/RaoResultDeserializer.java @@ -55,7 +55,6 @@ public RaoResult deserialize(JsonParser jsonParser, DeserializationContext deser while (jsonParser.nextToken() != JsonToken.END_OBJECT) { switch (jsonParser.getCurrentName()) { - case INFO: //no need to import this jsonParser.nextToken(); @@ -66,7 +65,12 @@ public RaoResult deserialize(JsonParser jsonParser, DeserializationContext deser break; case OPTIMIZATION_STEPS_EXECUTED: - raoResult.setOptimizationStepsExecuted(deserializeOptimizedStepsExecuted(jsonParser.nextTextValue())); + checkDeprecatedField(jsonParser, RAO_RESULT_TYPE, jsonFileVersion, "1.6"); + raoResult.setExecutionDetails(jsonParser.nextTextValue()); + break; + + case EXECUTION_DETAILS: + raoResult.setExecutionDetails(jsonParser.nextTextValue()); break; case COMPUTATION_STATUS_MAP: diff --git a/data/rao-result/rao-result-io/rao-result-json/src/main/java/com/powsybl/openrao/data/raoresult/io/json/serializers/RangeActionResultArraySerializer.java b/data/rao-result/rao-result-io/rao-result-json/src/main/java/com/powsybl/openrao/data/raoresult/io/json/serializers/RangeActionResultArraySerializer.java index 151295078c..74b66a461f 100644 --- a/data/rao-result/rao-result-io/rao-result-json/src/main/java/com/powsybl/openrao/data/raoresult/io/json/serializers/RangeActionResultArraySerializer.java +++ b/data/rao-result/rao-result-io/rao-result-json/src/main/java/com/powsybl/openrao/data/raoresult/io/json/serializers/RangeActionResultArraySerializer.java @@ -33,8 +33,8 @@ private RangeActionResultArraySerializer() { static void serialize(RaoResult raoResult, Crac crac, JsonGenerator jsonGenerator) throws IOException { List> sortedListOfRangeActions = crac.getRangeActions().stream() - .sorted(Comparator.comparing(RangeAction::getId)) - .toList(); + .sorted(Comparator.comparing(RangeAction::getId)) + .toList(); jsonGenerator.writeArrayFieldStart(RaoResultJsonConstants.RANGEACTION_RESULTS); for (RangeAction rangeAction : sortedListOfRangeActions) { @@ -58,9 +58,12 @@ private static void serializeRangeActionResult(RangeAction rangeAction, RaoRe .sorted(RaoResultJsonConstants.STATE_COMPARATOR) .toList(); - Map> activatedSetpoints = statesWhenRangeActionIsActivated.stream().collect(Collectors.toMap( - Function.identity(), state -> Pair.of(safeGetOptimizedTap(raoResult, state, rangeAction), safeGetOptimizedSetpoint(raoResult, state, rangeAction)) - )); + Map> activatedSetpoints = statesWhenRangeActionIsActivated.stream() + .collect(Collectors.toMap( + Function.identity(), state -> Pair.of(safeGetOptimizedTap(raoResult, state, rangeAction), + safeGetOptimizedSetpoint(raoResult, state, rangeAction)), + (x, y) -> x, + LinkedHashMap::new)); writeStateToTapAndSetpointArray(jsonGenerator, activatedSetpoints, RaoResultJsonConstants.STATES_ACTIVATED); jsonGenerator.writeEndObject(); diff --git a/data/rao-result/rao-result-io/rao-result-json/src/main/java/com/powsybl/openrao/data/raoresult/io/json/serializers/RaoResultSerializer.java b/data/rao-result/rao-result-io/rao-result-json/src/main/java/com/powsybl/openrao/data/raoresult/io/json/serializers/RaoResultSerializer.java index 63a25c91dd..26224cdfb9 100644 --- a/data/rao-result/rao-result-io/rao-result-json/src/main/java/com/powsybl/openrao/data/raoresult/io/json/serializers/RaoResultSerializer.java +++ b/data/rao-result/rao-result-io/rao-result-json/src/main/java/com/powsybl/openrao/data/raoresult/io/json/serializers/RaoResultSerializer.java @@ -9,7 +9,6 @@ import com.powsybl.openrao.commons.Unit; import com.powsybl.openrao.data.crac.api.Crac; import com.powsybl.openrao.data.raoresult.api.ComputationStatus; -import com.powsybl.openrao.data.raoresult.api.OptimizationStepsExecuted; import com.powsybl.openrao.data.raoresult.api.RaoResult; import com.powsybl.openrao.searchtreerao.result.impl.FailedRaoResultImpl; import com.fasterxml.jackson.core.JsonGenerator; @@ -45,10 +44,9 @@ public void serialize(RaoResult raoResult, JsonGenerator jsonGenerator, Serializ // computation status ComputationStatus computationStatus = raoResult.getComputationStatus(); jsonGenerator.writeStringField(COMPUTATION_STATUS, serializeStatus(computationStatus)); + jsonGenerator.writeStringField(EXECUTION_DETAILS, raoResult.getExecutionDetails()); if (!(raoResult instanceof FailedRaoResultImpl)) { - OptimizationStepsExecuted optimizationStepsExecuted = raoResult.getOptimizationStepsExecuted(); - jsonGenerator.writeStringField(OPTIMIZATION_STEPS_EXECUTED, serializeOptimizedStepsExecuted(optimizationStepsExecuted)); CostResultMapSerializer.serialize(raoResult, crac, jsonGenerator); ComputationStatusMapSerializer.serialize(raoResult, crac, jsonGenerator); FlowCnecResultArraySerializer.serialize(raoResult, crac, flowUnits, jsonGenerator); diff --git a/data/rao-result/rao-result-io/rao-result-json/src/test/java/com/powsybl/openrao/data/raoresult/io/json/ImporterRetrocompatibilityTest.java b/data/rao-result/rao-result-io/rao-result-json/src/test/java/com/powsybl/openrao/data/raoresult/io/json/ImporterRetrocompatibilityTest.java index 95da991987..e9926d0424 100644 --- a/data/rao-result/rao-result-io/rao-result-json/src/test/java/com/powsybl/openrao/data/raoresult/io/json/ImporterRetrocompatibilityTest.java +++ b/data/rao-result/rao-result-io/rao-result-json/src/test/java/com/powsybl/openrao/data/raoresult/io/json/ImporterRetrocompatibilityTest.java @@ -198,6 +198,17 @@ void importV1Point6Test() throws IOException { testBaseContentOfV1Point6RaoResult(raoResult, crac); } + @Test + void importV1Point7Test() throws IOException { + InputStream raoResultFile = getClass().getResourceAsStream("/retrocompatibility/v1.7/rao-result-v1.7.json"); + InputStream cracFile = getClass().getResourceAsStream("/retrocompatibility/v1.7/crac-for-rao-result-v1.7.json"); + + Crac crac = Crac.read("crac-for-rao-result-v1.7.json", cracFile, getMockedNetwork()); + RaoResult raoResult = new RaoResultJsonImporter().importData(raoResultFile, crac); + + testBaseContentOfV1Point7RaoResult(raoResult, crac); + } + @Test void importV1Point3TestFieldDeprecationTest() throws IOException { InputStream cracFile = getClass().getResourceAsStream("/retrocompatibility/v1.3/crac-for-rao-result-v1.3.json"); @@ -835,4 +846,11 @@ private void testBaseContentOfV1Point6RaoResult(RaoResult importedRaoResult, Cra assertEquals(ComputationStatus.FAILURE, importedRaoResult.getComputationStatus(crac.getState("contingency1Id", curativeInstant))); assertEquals(ComputationStatus.DEFAULT, importedRaoResult.getComputationStatus(crac.getState("contingency2Id", autoInstant))); } + + private void testBaseContentOfV1Point7RaoResult(RaoResult importedRaoResult, Crac crac) { + + testBaseContentOfV1Point6RaoResult(importedRaoResult, crac); + // check execution details + assertEquals("Custom execution details", importedRaoResult.getExecutionDetails()); + } } diff --git a/data/rao-result/rao-result-io/rao-result-json/src/test/java/com/powsybl/openrao/data/raoresult/io/json/RaoResultJsonConstantsTest.java b/data/rao-result/rao-result-io/rao-result-json/src/test/java/com/powsybl/openrao/data/raoresult/io/json/RaoResultJsonConstantsTest.java index 1ad71c9893..4183e57527 100644 --- a/data/rao-result/rao-result-io/rao-result-json/src/test/java/com/powsybl/openrao/data/raoresult/io/json/RaoResultJsonConstantsTest.java +++ b/data/rao-result/rao-result-io/rao-result-json/src/test/java/com/powsybl/openrao/data/raoresult/io/json/RaoResultJsonConstantsTest.java @@ -11,7 +11,6 @@ import com.powsybl.openrao.data.crac.api.Crac; import com.powsybl.openrao.data.crac.api.Instant; import com.powsybl.openrao.data.crac.api.State; -import com.powsybl.openrao.data.raoresult.api.OptimizationStepsExecuted; import org.junit.jupiter.api.Test; import org.mockito.Mockito; @@ -141,22 +140,4 @@ void testCompareStates() { assertEquals(1, STATE_COMPARATOR.compare(state1, state2)); assertEquals(-1, STATE_COMPARATOR.compare(state2, state1)); } - - @Test - void testSerializeOptimizedStepsExecuted() { - assertEquals("The RAO only went through first preventive", serializeOptimizedStepsExecuted(OptimizationStepsExecuted.FIRST_PREVENTIVE_ONLY)); - assertEquals("First preventive fellback to initial situation", serializeOptimizedStepsExecuted(OptimizationStepsExecuted.FIRST_PREVENTIVE_FELLBACK_TO_INITIAL_SITUATION)); - assertEquals("Second preventive improved first preventive results", serializeOptimizedStepsExecuted(OptimizationStepsExecuted.SECOND_PREVENTIVE_IMPROVED_FIRST)); - assertEquals("Second preventive fellback to initial situation", serializeOptimizedStepsExecuted(OptimizationStepsExecuted.SECOND_PREVENTIVE_FELLBACK_TO_INITIAL_SITUATION)); - assertEquals("Second preventive fellback to first preventive results", serializeOptimizedStepsExecuted(OptimizationStepsExecuted.SECOND_PREVENTIVE_FELLBACK_TO_FIRST_PREVENTIVE_SITUATION)); - } - - @Test - void testDeserializeOptimizedStepsExecuted() { - assertEquals(OptimizationStepsExecuted.FIRST_PREVENTIVE_ONLY, deserializeOptimizedStepsExecuted("The RAO only went through first preventive")); - assertEquals(OptimizationStepsExecuted.FIRST_PREVENTIVE_FELLBACK_TO_INITIAL_SITUATION, deserializeOptimizedStepsExecuted("First preventive fellback to initial situation")); - assertEquals(OptimizationStepsExecuted.SECOND_PREVENTIVE_IMPROVED_FIRST, deserializeOptimizedStepsExecuted("Second preventive improved first preventive results")); - assertEquals(OptimizationStepsExecuted.SECOND_PREVENTIVE_FELLBACK_TO_INITIAL_SITUATION, deserializeOptimizedStepsExecuted("Second preventive fellback to initial situation")); - assertEquals(OptimizationStepsExecuted.SECOND_PREVENTIVE_FELLBACK_TO_FIRST_PREVENTIVE_SITUATION, deserializeOptimizedStepsExecuted("Second preventive fellback to first preventive results")); - } } diff --git a/data/rao-result/rao-result-io/rao-result-json/src/test/java/com/powsybl/openrao/data/raoresult/io/json/RaoResultSerializerTest.java b/data/rao-result/rao-result-io/rao-result-json/src/test/java/com/powsybl/openrao/data/raoresult/io/json/RaoResultSerializerTest.java new file mode 100644 index 0000000000..59380c98be --- /dev/null +++ b/data/rao-result/rao-result-io/rao-result-json/src/test/java/com/powsybl/openrao/data/raoresult/io/json/RaoResultSerializerTest.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2021, 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/. + */ +package com.powsybl.openrao.data.raoresult.io.json; + +import com.powsybl.openrao.data.crac.api.Crac; +import com.powsybl.openrao.data.crac.impl.utils.ExhaustiveCracCreation; +import com.powsybl.openrao.data.raoresult.api.RaoResult; +import com.powsybl.openrao.data.raoresult.impl.utils.ExhaustiveRaoResultCreation; +import org.junit.jupiter.api.Test; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.nio.charset.StandardCharsets; +import java.util.Properties; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * @author Philippe Edwards {@literal } + */ +class RaoResultSerializerTest { + + @Test + void testSerialize() throws IOException { + // get exhaustive CRAC and RaoResult + Crac crac = ExhaustiveCracCreation.create(); + RaoResult raoResult = ExhaustiveRaoResultCreation.create(crac); + + // export RaoResult + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + Properties properties = new Properties(); + properties.setProperty("rao-result.export.json.flows-in-amperes", "true"); + properties.setProperty("rao-result.export.json.flows-in-megawatts", "true"); + new RaoResultJsonExporter().exportData(raoResult, crac, properties, outputStream); + String outputString = outputStream.toString(); + + // import expected json to compare + InputStream inputStream = getClass().getResourceAsStream("/rao-result.json"); + String inputString = new String(inputStream.readAllBytes(), StandardCharsets.UTF_8); + + assertEquals(inputString, outputString); + } + +} diff --git a/data/rao-result/rao-result-io/rao-result-json/src/test/resources/rao-result.json b/data/rao-result/rao-result-io/rao-result-json/src/test/resources/rao-result.json new file mode 100644 index 0000000000..8304dcdf6c --- /dev/null +++ b/data/rao-result/rao-result-io/rao-result-json/src/test/resources/rao-result.json @@ -0,0 +1,558 @@ +{ + "type" : "RAO_RESULT", + "version" : "1.7", + "info" : "Generated by Open RAO http://farao-community.github.io", + "computationStatus" : "default", + "executionDetails" : "The RAO only went through first preventive", + "costResults" : { + "initial" : { + "functionalCost" : 100.00, + "virtualCost" : { + "loopFlow" : 0.00, + "MNEC" : 0.00 + } + }, + "preventive" : { + "functionalCost" : 80.00, + "virtualCost" : { + "loopFlow" : 0.00, + "MNEC" : 0.00 + } + }, + "auto" : { + "functionalCost" : -20.00, + "virtualCost" : { + "loopFlow" : 15.00, + "MNEC" : 20.00 + } + }, + "curative" : { + "functionalCost" : -50.00, + "virtualCost" : { + "loopFlow" : 10.00, + "MNEC" : 2.00 + } + } + }, + "computationStatusMap" : [ ], + "flowCnecResults" : [ { + "flowCnecId" : "cnec1outageId", + "initial" : { + "ampere" : { + "margin" : 1121.00, + "relativeMargin" : 1122.00, + "side2" : { + "flow" : 1120.50, + "loopFlow" : 1123.50, + "commercialFlow" : 1124.50 + } + }, + "megawatt" : { + "margin" : 1111.00, + "relativeMargin" : 1112.00, + "side2" : { + "flow" : 1110.50, + "loopFlow" : 1113.50, + "commercialFlow" : 1114.50, + "zonalPtdfSum" : 0.600000 + } + } + }, + "preventive" : { + "ampere" : { + "margin" : 1221.00, + "relativeMargin" : 1222.00, + "side2" : { + "flow" : 1220.50, + "loopFlow" : 1223.50, + "commercialFlow" : 1224.50 + } + }, + "megawatt" : { + "margin" : 1211.00, + "relativeMargin" : 1212.00, + "side2" : { + "flow" : 1210.50, + "loopFlow" : 1213.50, + "commercialFlow" : 1214.50, + "zonalPtdfSum" : 0.600000 + } + } + } + }, { + "flowCnecId" : "cnec1prevId", + "initial" : { + "ampere" : { + "margin" : 1121.00, + "relativeMargin" : 1122.00, + "side2" : { + "flow" : 1120.50, + "loopFlow" : 1123.50, + "commercialFlow" : 1124.50 + } + }, + "megawatt" : { + "margin" : 1111.00, + "relativeMargin" : 1112.00, + "side2" : { + "flow" : 1110.50, + "loopFlow" : 1113.50, + "commercialFlow" : 1114.50, + "zonalPtdfSum" : 0.600000 + } + } + }, + "preventive" : { + "ampere" : { + "margin" : 1221.00, + "relativeMargin" : 1222.00, + "side2" : { + "flow" : 1220.50, + "loopFlow" : 1223.50, + "commercialFlow" : 1224.50 + } + }, + "megawatt" : { + "margin" : 1211.00, + "relativeMargin" : 1212.00, + "side2" : { + "flow" : 1210.50, + "loopFlow" : 1213.50, + "commercialFlow" : 1214.50, + "zonalPtdfSum" : 0.600000 + } + } + } + }, { + "flowCnecId" : "cnec2prevId", + "initial" : { + "ampere" : { + "margin" : 2121.00, + "relativeMargin" : 2122.00, + "side1" : { + "flow" : 2120.00, + "loopFlow" : 2123.00, + "commercialFlow" : 2124.00 + }, + "side2" : { + "flow" : 2120.50, + "loopFlow" : 2123.50, + "commercialFlow" : 2124.50 + } + }, + "megawatt" : { + "margin" : 2111.00, + "relativeMargin" : 2112.00, + "side1" : { + "flow" : 2110.00, + "loopFlow" : 2113.00, + "commercialFlow" : 2114.00, + "zonalPtdfSum" : 0.200000 + }, + "side2" : { + "flow" : 2110.50, + "loopFlow" : 2113.50, + "commercialFlow" : 2114.50, + "zonalPtdfSum" : 0.700000 + } + } + }, + "preventive" : { + "ampere" : { + "margin" : 2221.00, + "relativeMargin" : 2222.00, + "side1" : { + "flow" : 2220.00, + "loopFlow" : 2223.00, + "commercialFlow" : 2224.00 + }, + "side2" : { + "flow" : 2220.50, + "loopFlow" : 2223.50, + "commercialFlow" : 2224.50 + } + }, + "megawatt" : { + "margin" : 2211.00, + "relativeMargin" : 2212.00, + "side1" : { + "flow" : 2210.00, + "loopFlow" : 2213.00, + "commercialFlow" : 2214.00, + "zonalPtdfSum" : 0.200000 + }, + "side2" : { + "flow" : 2210.50, + "loopFlow" : 2213.50, + "commercialFlow" : 2214.50, + "zonalPtdfSum" : 0.700000 + } + } + } + }, { + "flowCnecId" : "cnec3autoId", + "initial" : { + "ampere" : { + "margin" : 3121.00, + "side1" : { + "flow" : 3120.00 + }, + "side2" : { + "flow" : 3120.50 + } + }, + "megawatt" : { + "margin" : 3111.00, + "side1" : { + "flow" : 3110.00 + }, + "side2" : { + "flow" : 3110.50 + } + } + }, + "preventive" : { + "ampere" : { + "margin" : 3221.00, + "side1" : { + "flow" : 3220.00 + }, + "side2" : { + "flow" : 3220.50 + } + }, + "megawatt" : { + "margin" : 3211.00, + "side1" : { + "flow" : 3210.00 + }, + "side2" : { + "flow" : 3210.50 + } + } + }, + "auto" : { + "ampere" : { + "margin" : 3321.00, + "side1" : { + "flow" : 3320.00 + }, + "side2" : { + "flow" : 3320.50 + } + }, + "megawatt" : { + "margin" : 3311.00, + "side1" : { + "flow" : 3310.00 + }, + "side2" : { + "flow" : 3310.50 + } + } + }, + "curative" : { + "ampere" : { + "margin" : 3321.00, + "side1" : { + "flow" : 3320.00 + }, + "side2" : { + "flow" : 3320.50 + } + }, + "megawatt" : { + "margin" : 3311.00, + "side1" : { + "flow" : 3310.00 + }, + "side2" : { + "flow" : 3310.50 + } + } + } + }, { + "flowCnecId" : "cnec3curId", + "initial" : { + "ampere" : { + "margin" : 3121.00, + "side1" : { + "flow" : 3120.00 + }, + "side2" : { + "flow" : 3120.50 + } + }, + "megawatt" : { + "margin" : 3111.00, + "side1" : { + "flow" : 3110.00 + }, + "side2" : { + "flow" : 3110.50 + } + } + }, + "preventive" : { + "ampere" : { + "margin" : 3221.00, + "side1" : { + "flow" : 3220.00 + }, + "side2" : { + "flow" : 3220.50 + } + }, + "megawatt" : { + "margin" : 3211.00, + "side1" : { + "flow" : 3210.00 + }, + "side2" : { + "flow" : 3210.50 + } + } + }, + "auto" : { + "ampere" : { + "margin" : 3321.00, + "side1" : { + "flow" : 3320.00 + }, + "side2" : { + "flow" : 3320.50 + } + }, + "megawatt" : { + "margin" : 3311.00, + "side1" : { + "flow" : 3310.00 + }, + "side2" : { + "flow" : 3310.50 + } + } + }, + "curative" : { + "ampere" : { + "margin" : 3421.00, + "side1" : { + "flow" : 3420.00 + }, + "side2" : { + "flow" : 3420.50 + } + }, + "megawatt" : { + "margin" : 3411.00, + "side1" : { + "flow" : 3410.00 + }, + "side2" : { + "flow" : 3410.50 + } + } + } + }, { + "flowCnecId" : "cnec3prevId", + "initial" : { + "ampere" : { + "margin" : 3121.00, + "side1" : { + "flow" : 3120.00 + }, + "side2" : { + "flow" : 3120.50 + } + }, + "megawatt" : { + "margin" : 3111.00, + "side1" : { + "flow" : 3110.00 + }, + "side2" : { + "flow" : 3110.50 + } + } + }, + "preventive" : { + "ampere" : { + "margin" : 3221.00, + "side1" : { + "flow" : 3220.00 + }, + "side2" : { + "flow" : 3220.50 + } + }, + "megawatt" : { + "margin" : 3211.00, + "side1" : { + "flow" : 3210.00 + }, + "side2" : { + "flow" : 3210.50 + } + } + } + }, { + "flowCnecId" : "cnec4prevId", + "initial" : { + "ampere" : { + "margin" : 4121.00, + "relativeMargin" : 4122.00, + "side1" : { + "flow" : 4120.00 + } + }, + "megawatt" : { + "margin" : 4111.00, + "relativeMargin" : 4112.00, + "side1" : { + "flow" : 4110.00, + "zonalPtdfSum" : 0.400000 + } + } + }, + "preventive" : { + "ampere" : { + "margin" : 4221.00, + "relativeMargin" : 4222.00, + "side1" : { + "flow" : 4220.00 + } + }, + "megawatt" : { + "margin" : 4211.00, + "relativeMargin" : 4212.00, + "side1" : { + "flow" : 4210.00, + "zonalPtdfSum" : 0.400000 + } + } + } + } ], + "angleCnecResults" : [ { + "angleCnecId" : "angleCnecId", + "initial" : { + "degree" : { + "angle" : 3135.00, + "margin" : 3131.00 + } + }, + "preventive" : { + "degree" : { + "angle" : 3235.00, + "margin" : 3231.00 + } + }, + "auto" : { + "degree" : { + "angle" : 3335.00, + "margin" : 3331.00 + } + }, + "curative" : { + "degree" : { + "angle" : 3435.00, + "margin" : 3431.00 + } + } + } ], + "voltageCnecResults" : [ { + "voltageCnecId" : "voltageCnecId", + "initial" : { + "kilovolt" : { + "margin" : 4141.00, + "minVoltage" : 4146.00, + "maxVoltage" : 4156.00 + } + }, + "preventive" : { + "kilovolt" : { + "margin" : 4241.00, + "minVoltage" : 4246.00, + "maxVoltage" : 4256.00 + } + }, + "auto" : { + "kilovolt" : { + "margin" : 4341.00, + "minVoltage" : 4346.00, + "maxVoltage" : 4356.00 + } + }, + "curative" : { + "kilovolt" : { + "margin" : 4441.00, + "minVoltage" : 4446.00, + "maxVoltage" : 4456.00 + } + } + } ], + "networkActionResults" : [ { + "networkActionId" : "complexNetworkActionId", + "activatedStates" : [ { + "instant" : "preventive" + } ] + }, { + "networkActionId" : "injectionSetpointRaId", + "activatedStates" : [ { + "instant" : "auto", + "contingency" : "contingency2Id" + } ] + }, { + "networkActionId" : "pstSetpointRaId", + "activatedStates" : [ { + "instant" : "curative", + "contingency" : "contingency1Id" + } ] + } ], + "rangeActionResults" : [ { + "rangeActionId" : "counterTradeRange1Id" + }, { + "rangeActionId" : "hvdcRange1Id", + "initialSetpoint" : 0.0, + "activatedStates" : [ { + "instant" : "preventive", + "setpoint" : -1000.0 + } ] + }, { + "rangeActionId" : "hvdcRange2Id", + "initialSetpoint" : -100.0, + "activatedStates" : [ { + "instant" : "curative", + "contingency" : "contingency1Id", + "setpoint" : 100.0 + }, { + "instant" : "curative", + "contingency" : "contingency2Id", + "setpoint" : 400.0 + } ] + }, { + "rangeActionId" : "injectionRange1Id", + "initialSetpoint" : 100.0, + "activatedStates" : [ { + "instant" : "curative", + "contingency" : "contingency1Id", + "setpoint" : -300.0 + } ] + }, { + "rangeActionId" : "pstRange1Id", + "initialSetpoint" : 0.0, + "activatedStates" : [ { + "instant" : "preventive", + "setpoint" : 3.0 + } ] + }, { + "rangeActionId" : "pstRange2Id", + "initialSetpoint" : 1.5 + }, { + "rangeActionId" : "pstRange3Id", + "initialSetpoint" : 1.0 + }, { + "rangeActionId" : "pstRange4Id" + }, { + "rangeActionId" : "pstRange5Id" + } ] +} \ No newline at end of file diff --git a/data/rao-result/rao-result-io/rao-result-json/src/test/resources/retrocompatibility/v1.6/rao-result-v1.6.json b/data/rao-result/rao-result-io/rao-result-json/src/test/resources/retrocompatibility/v1.6/rao-result-v1.6.json index b5ad9c4f86..5346d0027d 100644 --- a/data/rao-result/rao-result-io/rao-result-json/src/test/resources/retrocompatibility/v1.6/rao-result-v1.6.json +++ b/data/rao-result/rao-result-io/rao-result-json/src/test/resources/retrocompatibility/v1.6/rao-result-v1.6.json @@ -1,6 +1,6 @@ { "type" : "RAO_RESULT", - "version" : "1.5", + "version" : "1.6", "info" : "Generated by FARAO http://farao-community.github.io", "computationStatus" : "default", "optimizationStepsExecuted" : "The RAO only went through first preventive", diff --git a/data/rao-result/rao-result-io/rao-result-json/src/test/resources/retrocompatibility/v1.7/crac-for-rao-result-v1.7.json b/data/rao-result/rao-result-io/rao-result-json/src/test/resources/retrocompatibility/v1.7/crac-for-rao-result-v1.7.json new file mode 100644 index 0000000000..d9dd91b03c --- /dev/null +++ b/data/rao-result/rao-result-io/rao-result-json/src/test/resources/retrocompatibility/v1.7/crac-for-rao-result-v1.7.json @@ -0,0 +1,409 @@ +{ + "type" : "CRAC", + "version" : "1.5", + "info" : "Generated by FARAO http://farao-community.github.io", + "id" : "exhaustiveCracId", + "name" : "exhaustiveCracName", + "networkElementsNamePerId" : { + "ineId" : "ineName", + "ne5Id" : "ne5Name", + "eneId" : "eneName", + "ne2Id" : "ne2Name", + "voltageCnecNeId" : "voltageCnecNeName", + "generator2Id" : "generator2Name", + "to-close" : "to-close-name" + }, + "contingencies" : [ { + "id" : "contingency1Id", + "networkElementsIds" : [ "ne1Id" ] + }, { + "id" : "contingency2Id", + "networkElementsIds" : [ "ne2Id", "ne3Id" ] + } ], + "flowCnecs" : [ { + "id" : "cnec1outageId", + "name" : "cnec1outageId", + "networkElementId" : "ne4Id", + "operator" : "operator1", + "instant" : "outage", + "contingencyId" : "contingency1Id", + "optimized" : true, + "monitored" : false, + "reliabilityMargin" : 0.0, + "iMax" : [ NaN ], + "nominalV" : [ 220.0 ], + "thresholds" : [ { + "unit" : "ampere", + "min" : -800.0, + "side" : "right" + } ] + }, { + "id" : "cnec1prevId", + "name" : "cnec1prevId", + "networkElementId" : "ne4Id", + "operator" : "operator1", + "instant" : "preventive", + "optimized" : true, + "monitored" : false, + "reliabilityMargin" : 0.0, + "iMax" : [ NaN, 1000.0 ], + "nominalV" : [ 220.0 ], + "thresholds" : [ { + "unit" : "ampere", + "min" : -500.0, + "side" : "right" + } ] + }, { + "id" : "cnec2prevId", + "name" : "cnec2prevId", + "networkElementId" : "ne5Id", + "operator" : "operator2", + "instant" : "preventive", + "optimized" : true, + "monitored" : false, + "reliabilityMargin" : 0.0, + "iMax" : [ 2000.0 ], + "nominalV" : [ 380.0, 220.0 ], + "thresholds" : [ { + "unit" : "ampere", + "min" : -800.0, + "side" : "left" + }, { + "unit" : "ampere", + "min" : -800.0, + "side" : "right" + }, { + "unit" : "ampere", + "max" : 1200.0, + "side" : "right" + }, { + "unit" : "percent_imax", + "min" : -0.3, + "side" : "left" + } ] + }, { + "id" : "cnec3autoId", + "name" : "cnec3autoName", + "networkElementId" : "ne2Id", + "operator" : "operator3", + "instant" : "auto", + "contingencyId" : "contingency2Id", + "optimized" : false, + "monitored" : true, + "reliabilityMargin" : 20.0, + "iMax" : [ NaN ], + "nominalV" : [ NaN ], + "thresholds" : [ { + "unit" : "megawatt", + "max" : 500.0, + "side" : "left" + }, { + "unit" : "megawatt", + "max" : 500.0, + "side" : "right" + } ] + }, { + "id" : "cnec3curId", + "name" : "cnec3curId", + "networkElementId" : "ne2Id", + "operator" : "operator3", + "instant" : "curative", + "contingencyId" : "contingency2Id", + "optimized" : false, + "monitored" : true, + "reliabilityMargin" : 20.0, + "iMax" : [ NaN ], + "nominalV" : [ NaN ], + "thresholds" : [ { + "unit" : "megawatt", + "max" : 500.0, + "side" : "left" + }, { + "unit" : "megawatt", + "max" : 500.0, + "side" : "right" + } ] + }, { + "id" : "cnec3prevId", + "name" : "cnec3prevName", + "networkElementId" : "ne2Id", + "operator" : "operator3", + "instant" : "preventive", + "optimized" : false, + "monitored" : true, + "reliabilityMargin" : 20.0, + "iMax" : [ NaN ], + "nominalV" : [ NaN ], + "thresholds" : [ { + "unit" : "megawatt", + "max" : 500.0, + "side" : "left" + }, { + "unit" : "megawatt", + "max" : 500.0, + "side" : "right" + } ] + }, { + "id" : "cnec4prevId", + "name" : "cnec4prevName", + "networkElementId" : "ne3Id", + "operator" : "operator4", + "instant" : "preventive", + "optimized" : true, + "monitored" : true, + "reliabilityMargin" : 0.0, + "iMax" : [ NaN ], + "nominalV" : [ NaN ], + "thresholds" : [ { + "unit" : "megawatt", + "max" : 500.0, + "side" : "left" + } ] + } ], + "angleCnecs" : [ { + "id" : "angleCnecId", + "name" : "angleCnecName", + "exportingNetworkElementId" : "eneId", + "importingNetworkElementId" : "ineId", + "operator" : "operator1", + "instant" : "curative", + "contingencyId" : "contingency1Id", + "optimized" : false, + "monitored" : true, + "reliabilityMargin" : 10.0, + "thresholds" : [ { + "unit" : "degree", + "min" : -100.0, + "max" : 100.0 + } ] + } ], + "voltageCnecs" : [ { + "id" : "voltageCnecId", + "name" : "voltageCnecName", + "networkElementId" : "voltageCnecNeId", + "operator" : "operator1", + "instant" : "curative", + "contingencyId" : "contingency1Id", + "optimized" : false, + "monitored" : true, + "reliabilityMargin" : 1.0, + "thresholds" : [ { + "unit" : "kilovolt", + "min" : 380.0 + } ] + } ], + "pstRangeActions" : [ { + "id" : "pstRange1Id", + "name" : "pstRange1Name", + "operator" : "RTE", + "freeToUseUsageRules" : [ { + "instant" : "preventive", + "usageMethod" : "available" + } ], + "networkElementId" : "pst", + "initialTap" : 2, + "tapToAngleConversionMap" : { + "-3" : 0.0, + "-2" : 0.5, + "-1" : 1.0, + "0" : 1.5, + "1" : 2.0, + "2" : 2.5, + "3" : 3.0 + }, + "ranges" : [ { + "min" : 1, + "max" : 7, + "rangeType" : "absolute" + }, { + "min" : -3, + "max" : 3, + "rangeType" : "relativeToInitialNetwork" + } ] + }, { + "id" : "pstRange2Id", + "name" : "pstRange2Name", + "operator" : "RTE", + "onFlowConstraintUsageRules" : [ { + "instant" : "preventive", + "flowCnecId" : "cnec3prevId" + } ], + "networkElementId" : "pst2", + "groupId" : "group-1-pst", + "initialTap" : 1, + "tapToAngleConversionMap" : { + "-3" : 0.0, + "-2" : 0.5, + "-1" : 1.0, + "0" : 1.5, + "1" : 2.0, + "2" : 2.5, + "3" : 3.0 + }, + "ranges" : [ { + "min" : 1, + "max" : 7, + "rangeType" : "absolute" + }, { + "min" : -3, + "max" : 3, + "rangeType" : "relativeToInitialNetwork" + } ] + }, { + "id" : "pstRange3Id", + "name" : "pstRange3Name", + "operator" : "RTE", + "onAngleConstraintUsageRules" : [ { + "instant" : "curative", + "angleCnecId" : "angleCnecId" + } ], + "networkElementId" : "pst3", + "groupId" : "group-3-pst", + "initialTap" : 1, + "tapToAngleConversionMap" : { + "-3" : 0.0, + "-2" : 0.5, + "-1" : 1.0, + "0" : 1.5, + "1" : 2.0, + "2" : 2.5, + "3" : 3.0 + }, + "ranges" : [ { + "min" : 1, + "max" : 7, + "rangeType" : "absolute" + }, { + "min" : -3, + "max" : 3, + "rangeType" : "relativeToInitialNetwork" + } ] + } ], + "hvdcRangeActions" : [ { + "id" : "hvdcRange1Id", + "name" : "hvdcRange1Name", + "operator" : "RTE", + "onFlowConstraintInCountryUsageRules" : [ { + "instant" : "preventive", + "country" : "FR" + } ], + "networkElementId" : "hvdc", + "initialSetpoint" : 0.0, + "ranges" : [ { + "min" : -1000.0, + "max" : 1000.0 + } ] + }, { + "id" : "hvdcRange2Id", + "name" : "hvdcRange2Name", + "operator" : "RTE", + "onStateUsageRules" : [ { + "instant" : "curative", + "contingencyId" : "contingency1Id", + "usageMethod" : "available" + }, { + "instant" : "curative", + "contingencyId" : "contingency2Id", + "usageMethod" : "available" + } ], + "onFlowConstraintUsageRules" : [ { + "instant" : "preventive", + "flowCnecId" : "cnec3curId" + } ], + "networkElementId" : "hvdc2", + "groupId" : "group-1-hvdc", + "initialSetpoint" : 0.0, + "ranges" : [ { + "min" : -1000.0, + "max" : 1000.0 + } ] + } ], + "injectionRangeActions" : [ { + "id" : "injectionRange1Id", + "name" : "injectionRange1Name", + "operator" : null, + "onStateUsageRules" : [ { + "instant" : "curative", + "contingencyId" : "contingency1Id", + "usageMethod" : "available" + } ], + "onFlowConstraintInCountryUsageRules" : [ { + "instant" : "curative", + "country" : "ES" + } ], + "networkElementIdsAndKeys" : { + "generator1Id" : 1.0, + "generator2Id" : -1.0 + }, + "initialSetpoint" : 0.0, + "ranges" : [ { + "min" : -500.0, + "max" : 500.0 + }, { + "min" : -1000.0, + "max" : 1000.0 + } ] + } ], + "networkActions" : [ { + "id" : "complexNetworkActionId", + "name" : "complexNetworkActionName", + "operator" : "RTE", + "freeToUseUsageRules" : [ { + "instant" : "preventive", + "usageMethod" : "available" + }, { + "instant" : "preventive", + "usageMethod" : "forced" + } ], + "topologicalActions" : [ { + "networkElementId" : "ne1Id", + "actionType" : "close" + } ], + "pstSetpoints" : [ { + "networkElementId" : "pst", + "setpoint" : 5 + } ] + }, { + "id" : "injectionSetpointRaId", + "name" : "injectionSetpointRaName", + "operator" : "RTE", + "onFlowConstraintUsageRules" : [ { + "instant" : "auto", + "flowCnecId" : "cnec3autoId" + } ], + "injectionSetpoints" : [ { + "networkElementId" : "injection", + "setpoint" : 260.0 + } ] + }, { + "id" : "pstSetpointRaId", + "name" : "pstSetpointRaName", + "operator" : "RTE", + "freeToUseUsageRules" : [ { + "instant" : "preventive", + "usageMethod" : "available" + } ], + "onStateUsageRules" : [ { + "instant" : "curative", + "contingencyId" : "contingency1Id", + "usageMethod" : "forced" + } ], + "pstSetpoints" : [ { + "networkElementId" : "pst", + "setpoint" : 15 + } ] + }, { + "id" : "switchPairRaId", + "name" : "switchPairRaName", + "operator" : "RTE", + "onStateUsageRules" : [ { + "instant" : "curative", + "contingencyId" : "contingency2Id", + "usageMethod" : "available" + } ], + "switchPairs" : [ { + "open" : "to-open", + "close" : "to-close" + } ] + } ] +} \ No newline at end of file diff --git a/data/rao-result/rao-result-io/rao-result-json/src/test/resources/retrocompatibility/v1.7/rao-result-v1.7.json b/data/rao-result/rao-result-io/rao-result-json/src/test/resources/retrocompatibility/v1.7/rao-result-v1.7.json new file mode 100644 index 0000000000..5cd394af2e --- /dev/null +++ b/data/rao-result/rao-result-io/rao-result-json/src/test/resources/retrocompatibility/v1.7/rao-result-v1.7.json @@ -0,0 +1,556 @@ +{ + "type" : "RAO_RESULT", + "version" : "1.7", + "info" : "Generated by FARAO http://farao-community.github.io", + "computationStatus" : "default", + "executionDetails" : "Custom execution details", + "costResults" : { + "initial" : { + "functionalCost" : 100.0, + "virtualCost" : { + "loopFlow" : 0.0, + "MNEC" : 0.0 + } + }, + "preventive" : { + "functionalCost" : 80.0, + "virtualCost" : { + "loopFlow" : 0.0, + "MNEC" : 0.0 + } + }, + "auto" : { + "functionalCost" : -20.0, + "virtualCost" : { + "loopFlow" : 15.0, + "MNEC" : 20.0 + } + }, + "curative" : { + "functionalCost" : -50.0, + "virtualCost" : { + "loopFlow" : 10.0, + "MNEC" : 2.0 + } + } + }, + "computationStatusMap" : [ { + "computationStatus" : "FAILURE", + "instant" : "curative", + "contingency" : "contingency1Id" + } ], + "flowCnecResults" : [ { + "flowCnecId" : "cnec1outageId", + "initial" : { + "ampere" : { + "margin" : 1121.0, + "relativeMargin" : 1122.0, + "side2" : { + "flow" : 1120.5, + "loopFlow" : 1123.5, + "commercialFlow" : 1124.5 + } + }, + "megawatt" : { + "margin" : 1111.0, + "relativeMargin" : 1112.0, + "side2" : { + "flow" : 1110.5, + "loopFlow" : 1113.5, + "commercialFlow" : 1114.5, + "zonalPtdfSum" : 0.6 + } + } + }, + "preventive" : { + "ampere" : { + "margin" : 1221.0, + "relativeMargin" : 1222.0, + "side2" : { + "flow" : 1220.5, + "loopFlow" : 1223.5, + "commercialFlow" : 1224.5 + } + }, + "megawatt" : { + "margin" : 1211.0, + "relativeMargin" : 1212.0, + "side2" : { + "flow" : 1210.5, + "loopFlow" : 1213.5, + "commercialFlow" : 1214.5, + "zonalPtdfSum" : 0.6 + } + } + } + }, { + "flowCnecId" : "cnec1prevId", + "initial" : { + "ampere" : { + "margin" : 1121.0, + "relativeMargin" : 1122.0, + "side2" : { + "flow" : 1120.5, + "loopFlow" : 1123.5, + "commercialFlow" : 1124.5 + } + }, + "megawatt" : { + "margin" : 1111.0, + "relativeMargin" : 1112.0, + "side2" : { + "flow" : 1110.5, + "loopFlow" : 1113.5, + "commercialFlow" : 1114.5, + "zonalPtdfSum" : 0.6 + } + } + }, + "preventive" : { + "ampere" : { + "margin" : 1221.0, + "relativeMargin" : 1222.0, + "side2" : { + "flow" : 1220.5, + "loopFlow" : 1223.5, + "commercialFlow" : 1224.5 + } + }, + "megawatt" : { + "margin" : 1211.0, + "relativeMargin" : 1212.0, + "side2" : { + "flow" : 1210.5, + "loopFlow" : 1213.5, + "commercialFlow" : 1214.5, + "zonalPtdfSum" : 0.6 + } + } + } + }, { + "flowCnecId" : "cnec2prevId", + "initial" : { + "ampere" : { + "margin" : 2121.0, + "relativeMargin" : 2122.0, + "side1" : { + "flow" : 2120.0, + "loopFlow" : 2123.0, + "commercialFlow" : 2124.0 + }, + "side2" : { + "flow" : 2120.5, + "loopFlow" : 2123.5, + "commercialFlow" : 2124.5 + } + }, + "megawatt" : { + "margin" : 2111.0, + "relativeMargin" : 2112.0, + "side1" : { + "flow" : 2110.0, + "loopFlow" : 2113.0, + "commercialFlow" : 2114.0, + "zonalPtdfSum" : 0.2 + }, + "side2" : { + "flow" : 2110.5, + "loopFlow" : 2113.5, + "commercialFlow" : 2114.5, + "zonalPtdfSum" : 0.7 + } + } + }, + "preventive" : { + "ampere" : { + "margin" : 2221.0, + "relativeMargin" : 2222.0, + "side1" : { + "flow" : 2220.0, + "loopFlow" : 2223.0, + "commercialFlow" : 2224.0 + }, + "side2" : { + "flow" : 2220.5, + "loopFlow" : 2223.5, + "commercialFlow" : 2224.5 + } + }, + "megawatt" : { + "margin" : 2211.0, + "relativeMargin" : 2212.0, + "side1" : { + "flow" : 2210.0, + "loopFlow" : 2213.0, + "commercialFlow" : 2214.0, + "zonalPtdfSum" : 0.2 + }, + "side2" : { + "flow" : 2210.5, + "loopFlow" : 2213.5, + "commercialFlow" : 2214.5, + "zonalPtdfSum" : 0.7 + } + } + } + }, { + "flowCnecId" : "cnec3autoId", + "initial" : { + "ampere" : { + "margin" : 3121.0, + "side1" : { + "flow" : 3120.0 + }, + "side2" : { + "flow" : 3120.5 + } + }, + "megawatt" : { + "margin" : 3111.0, + "side1" : { + "flow" : 3110.0 + }, + "side2" : { + "flow" : 3110.5 + } + } + }, + "preventive" : { + "ampere" : { + "margin" : 3221.0, + "side1" : { + "flow" : 3220.0 + }, + "side2" : { + "flow" : 3220.5 + } + }, + "megawatt" : { + "margin" : 3211.0, + "side1" : { + "flow" : 3210.0 + }, + "side2" : { + "flow" : 3210.5 + } + } + }, + "auto" : { + "ampere" : { + "margin" : 3321.0, + "side1" : { + "flow" : 3320.0 + }, + "side2" : { + "flow" : 3320.5 + } + }, + "megawatt" : { + "margin" : 3311.0, + "side1" : { + "flow" : 3310.0 + }, + "side2" : { + "flow" : 3310.5 + } + } + }, + "curative" : { + "ampere" : { + "margin" : 3321.0, + "side1" : { + "flow" : 3320.0 + }, + "side2" : { + "flow" : 3320.5 + } + }, + "megawatt" : { + "margin" : 3311.0, + "side1" : { + "flow" : 3310.0 + }, + "side2" : { + "flow" : 3310.5 + } + } + } + }, { + "flowCnecId" : "cnec3curId", + "initial" : { + "ampere" : { + "margin" : 3121.0, + "side1" : { + "flow" : 3120.0 + }, + "side2" : { + "flow" : 3120.5 + } + }, + "megawatt" : { + "margin" : 3111.0, + "side1" : { + "flow" : 3110.0 + }, + "side2" : { + "flow" : 3110.5 + } + } + }, + "preventive" : { + "ampere" : { + "margin" : 3221.0, + "side1" : { + "flow" : 3220.0 + }, + "side2" : { + "flow" : 3220.5 + } + }, + "megawatt" : { + "margin" : 3211.0, + "side1" : { + "flow" : 3210.0 + }, + "side2" : { + "flow" : 3210.5 + } + } + }, + "auto" : { + "ampere" : { + "margin" : 3321.0, + "side1" : { + "flow" : 3320.0 + }, + "side2" : { + "flow" : 3320.5 + } + }, + "megawatt" : { + "margin" : 3311.0, + "side1" : { + "flow" : 3310.0 + }, + "side2" : { + "flow" : 3310.5 + } + } + }, + "curative" : { + "ampere" : { + "margin" : 3421.0, + "side1" : { + "flow" : 3420.0 + }, + "side2" : { + "flow" : 3420.5 + } + }, + "megawatt" : { + "margin" : 3411.0, + "side1" : { + "flow" : 3410.0 + }, + "side2" : { + "flow" : 3410.5 + } + } + } + }, { + "flowCnecId" : "cnec3prevId", + "initial" : { + "ampere" : { + "margin" : 3121.0, + "side1" : { + "flow" : 3120.0 + }, + "side2" : { + "flow" : 3120.5 + } + }, + "megawatt" : { + "margin" : 3111.0, + "side1" : { + "flow" : 3110.0 + }, + "side2" : { + "flow" : 3110.5 + } + } + }, + "preventive" : { + "ampere" : { + "margin" : 3221.0, + "side1" : { + "flow" : 3220.0 + }, + "side2" : { + "flow" : 3220.5 + } + }, + "megawatt" : { + "margin" : 3211.0, + "side1" : { + "flow" : 3210.0 + }, + "side2" : { + "flow" : 3210.5 + } + } + } + }, { + "flowCnecId" : "cnec4prevId", + "initial" : { + "ampere" : { + "margin" : 4121.0, + "relativeMargin" : 4122.0, + "side1" : { + "flow" : 4120.0 + } + }, + "megawatt" : { + "margin" : 4111.0, + "relativeMargin" : 4112.0, + "side1" : { + "flow" : 4110.0, + "zonalPtdfSum" : 0.4 + } + } + }, + "preventive" : { + "ampere" : { + "margin" : 4221.0, + "relativeMargin" : 4222.0, + "side1" : { + "flow" : 4220.0 + } + }, + "megawatt" : { + "margin" : 4211.0, + "relativeMargin" : 4212.0, + "side1" : { + "flow" : 4210.0, + "zonalPtdfSum" : 0.4 + } + } + } + } ], + "angleCnecResults" : [ { + "angleCnecId" : "angleCnecId", + "initial" : { + "degree" : { + "angle" : 3135.0, + "margin" : 3131.0 + } + }, + "preventive" : { + "degree" : { + "angle" : 3235.0, + "margin" : 3231.0 + } + }, + "auto" : { + "degree" : { + "angle" : 3335.0, + "margin" : 3331.0 + } + }, + "curative" : { + "degree" : { + "angle" : 3435.0, + "margin" : 3431.0 + } + } + } ], + "voltageCnecResults" : [ { + "voltageCnecId" : "voltageCnecId", + "initial" : { + "kilovolt" : { + "minVoltage" : 4146.0, + "maxVoltage" : 4156.0, + "margin" : 4141.0 + } + }, + "preventive" : { + "kilovolt" : { + "minVoltage" : 4246.0, + "maxVoltage" : 4256.0, + "margin" : 4241.0 + } + }, + "auto" : { + "kilovolt" : { + "minVoltage" : 4346.0, + "maxVoltage" : 4356.0, + "margin" : 4341.0 + } + }, + "curative" : { + "kilovolt" : { + "minVoltage" : 4446.0, + "maxVoltage" : 4456.0, + "margin" : 4441.0 + } + } + } ], + "networkActionResults" : [ { + "networkActionId" : "complexNetworkActionId", + "activatedStates" : [ { + "instant" : "preventive" + } ] + }, { + "networkActionId" : "injectionSetpointRaId", + "activatedStates" : [ { + "instant" : "auto", + "contingency" : "contingency2Id" + } ] + }, { + "networkActionId" : "pstSetpointRaId", + "activatedStates" : [ { + "instant" : "curative", + "contingency" : "contingency1Id" + } ] + } ], + "rangeActionResults" : [ { + "rangeActionId" : "hvdcRange1Id", + "initialSetpoint" : 0.0, + "activatedStates" : [ { + "instant" : "preventive", + "setpoint" : -1000.0 + } ] + }, { + "rangeActionId" : "hvdcRange2Id", + "initialSetpoint" : -100.0, + "activatedStates" : [ { + "instant" : "curative", + "contingency" : "contingency2Id", + "setpoint" : 400.0 + }, { + "instant" : "curative", + "contingency" : "contingency1Id", + "setpoint" : 100.0 + } ] + }, { + "rangeActionId" : "injectionRange1Id", + "initialSetpoint" : 100.0, + "activatedStates" : [ { + "instant" : "curative", + "contingency" : "contingency1Id", + "setpoint" : -300.0 + } ] + }, { + "rangeActionId" : "pstRange1Id", + "initialSetpoint" : 0.0, + "activatedStates" : [ { + "instant" : "preventive", + "setpoint" : 3.0 + } ] + }, { + "rangeActionId" : "pstRange2Id", + "initialSetpoint" : 1.5 + }, { + "rangeActionId" : "pstRange3Id", + "initialSetpoint" : 1.0 + } ] +} \ No newline at end of file diff --git a/docs/output-data/rao-result.md b/docs/output-data/rao-result.md index 4f4ebc7fdf..8633553afe 100644 --- a/docs/output-data/rao-result.md +++ b/docs/output-data/rao-result.md @@ -82,9 +82,9 @@ _See also: [RAO steps](/castor/rao-steps.md)_ :parser: markdown ``` -### Executed optimisation steps +### Execution details -```{include} rao-result/steps.md +```{include} rao-result/execution-details.md :parser: markdown ``` diff --git a/docs/output-data/rao-result/execution-details.md b/docs/output-data/rao-result/execution-details.md new file mode 100644 index 0000000000..240d17e6ae --- /dev/null +++ b/docs/output-data/rao-result/execution-details.md @@ -0,0 +1,26 @@ +This field can either contain information about the failure when the RAO fails, or macro information about which steps the [CASTOR RAO](/castor.md#algorithm) executed when it did not fail. +(See also: [Forbidding cost increase](/parameters.md#forbid-cost-increase), [Second preventive RAO parameters](/parameters.md#second-preventive-rao-parameters)) + +Note: This field replaced the optimizationStepsExecuted field. + +::::{tabs} +:::{group-tab} JAVA API + +~~~java +String getExecutionDetails(); +~~~ + +::: +:::{group-tab} JSON File + +Example: + +~~~json +{ + "executionDetails": "Second preventive improved first preventive results", + ... +} +~~~ + +::: +:::: diff --git a/docs/output-data/rao-result/steps.md b/docs/output-data/rao-result/steps.md deleted file mode 100644 index b5f521cf5d..0000000000 --- a/docs/output-data/rao-result/steps.md +++ /dev/null @@ -1,32 +0,0 @@ -This field contains macro information about which steps the [CASTOR RAO](/castor.md#algorithm) executed. -(See also: [Forbidding cost increase](/parameters.md#forbid-cost-increase), [Second preventive RAO parameters](/parameters.md#second-preventive-rao-parameters)) - -| Value | Did CASTOR run a 1st preventive RAO? | Did CASTOR run a 2nd preventive RAO? | Did the RAO fall back to initial situation? | Did the RAO fall back to 1st preventive RAO result even though a 2nd was run? | -|----------------------------------------------------------|--------------------------------------|--------------------------------------|---------------------------------------------|-------------------------------------------------------------------------------| -| FIRST_PREVENTIVE_ONLY | ✔️ | | | | -| FIRST_PREVENTIVE_FELLBACK_TO_INITIAL_SITUATION | ✔️ | | ✔️ | | -| SECOND_PREVENTIVE_IMPROVED_FIRST | ✔️ | ✔️ | | | -| SECOND_PREVENTIVE_FELLBACK_TO_INITIAL_SITUATION | ✔️ | ✔️ | ✔️ | | -| SECOND_PREVENTIVE_FELLBACK_TO_FIRST_PREVENTIVE_SITUATION | ✔️ | ✔️ | | ✔️ | - -::::{tabs} -:::{group-tab} JAVA API - -~~~java -OptimizationStepsExecuted getOptimizationStepsExecuted(); -~~~ - -::: -:::{group-tab} JSON File - -Example: - -~~~json -{ - "optimizationStepsExecuted": "Second preventive improved first preventive results", - ... -} -~~~ - -::: -:::: diff --git a/ra-optimisation/search-tree-rao/src/main/java/com/powsybl/openrao/searchtreerao/castor/algorithm/CastorFullOptimization.java b/ra-optimisation/search-tree-rao/src/main/java/com/powsybl/openrao/searchtreerao/castor/algorithm/CastorFullOptimization.java index 10ec51e312..cf3dea9bec 100644 --- a/ra-optimisation/search-tree-rao/src/main/java/com/powsybl/openrao/searchtreerao/castor/algorithm/CastorFullOptimization.java +++ b/ra-optimisation/search-tree-rao/src/main/java/com/powsybl/openrao/searchtreerao/castor/algorithm/CastorFullOptimization.java @@ -29,6 +29,7 @@ import com.powsybl.openrao.searchtreerao.searchtree.parameters.SearchTreeParameters; import com.powsybl.openrao.sensitivityanalysis.AppliedRemedialActions; import com.powsybl.iidm.network.Network; +import org.apache.commons.lang3.exception.ExceptionUtils; import java.time.temporal.ChronoUnit; import java.util.*; @@ -67,118 +68,129 @@ public CastorFullOptimization(RaoInput raoInput, RaoParameters raoParameters, ja } public CompletableFuture run() { + String currentStep = "data initialization"; + + try { + RaoUtil.initData(raoInput, raoParameters); + StateTree stateTree = new StateTree(crac); + ToolProvider toolProvider = ToolProvider.buildFromRaoInputAndParameters(raoInput, raoParameters); + + currentStep = "initial sensitivity analysis"; + // ----- INITIAL SENSI ----- + // compute initial sensitivity on all CNECs + // (this is necessary to have initial flows for MNEC and loopflow constraints on CNECs, in preventive and curative perimeters) + PrePerimeterSensitivityAnalysis prePerimeterSensitivityAnalysis = new PrePerimeterSensitivityAnalysis( + crac.getFlowCnecs(), + crac.getRangeActions(), + raoParameters, + toolProvider); + + PrePerimeterResult initialOutput; + initialOutput = prePerimeterSensitivityAnalysis.runInitialSensitivityAnalysis(network, crac); + if (initialOutput.getSensitivityStatus() == ComputationStatus.FAILURE) { + BUSINESS_LOGS.error("Initial sensitivity analysis failed"); + return CompletableFuture.completedFuture(new FailedRaoResultImpl("Initial sensitivity analysis failed")); + } + RaoLogger.logSensitivityAnalysisResults("Initial sensitivity analysis: ", + prePerimeterSensitivityAnalysis.getObjectiveFunction(), + initialOutput, + raoParameters, + NUMBER_LOGGED_ELEMENTS_DURING_RAO); + + // ----- PREVENTIVE PERIMETER OPTIMIZATION ----- + // run search tree on preventive perimeter + currentStep = "first preventive"; + java.time.Instant preventiveRaoStartInstant = java.time.Instant.now(); + BUSINESS_LOGS.info("----- Preventive perimeter optimization [start]"); + + network.getVariantManager().cloneVariant(network.getVariantManager().getWorkingVariantId(), INITIAL_SCENARIO); + network.getVariantManager().cloneVariant(network.getVariantManager().getWorkingVariantId(), PREVENTIVE_SCENARIO); + network.getVariantManager().cloneVariant(network.getVariantManager().getWorkingVariantId(), SECOND_PREVENTIVE_SCENARIO_BEFORE_OPT); + network.getVariantManager().setWorkingVariant(PREVENTIVE_SCENARIO); + + if (stateTree.getContingencyScenarios().isEmpty()) { + CompletableFuture result = CompletableFuture.completedFuture(optimizePreventivePerimeter(stateTree, toolProvider, initialOutput)); + BUSINESS_LOGS.info("----- Preventive perimeter optimization [end]"); + return result; + } - RaoUtil.initData(raoInput, raoParameters); - StateTree stateTree = new StateTree(crac); - ToolProvider toolProvider = ToolProvider.buildFromRaoInputAndParameters(raoInput, raoParameters); - - // ----- INITIAL SENSI ----- - // compute initial sensitivity on all CNECs - // (this is necessary to have initial flows for MNEC and loopflow constraints on CNECs, in preventive and curative perimeters) - PrePerimeterSensitivityAnalysis prePerimeterSensitivityAnalysis = new PrePerimeterSensitivityAnalysis( - crac.getFlowCnecs(), - crac.getRangeActions(), - raoParameters, - toolProvider); - - PrePerimeterResult initialOutput; - initialOutput = prePerimeterSensitivityAnalysis.runInitialSensitivityAnalysis(network, crac); - if (initialOutput.getSensitivityStatus() == ComputationStatus.FAILURE) { - BUSINESS_LOGS.error("Initial sensitivity analysis failed"); - return CompletableFuture.completedFuture(new FailedRaoResultImpl("Initial sensitivity analysis failed")); - } - RaoLogger.logSensitivityAnalysisResults("Initial sensitivity analysis: ", - prePerimeterSensitivityAnalysis.getObjectiveFunction(), - initialOutput, - raoParameters, - NUMBER_LOGGED_ELEMENTS_DURING_RAO); - - // ----- PREVENTIVE PERIMETER OPTIMIZATION ----- - // run search tree on preventive perimeter - java.time.Instant preventiveRaoStartInstant = java.time.Instant.now(); - BUSINESS_LOGS.info("----- Preventive perimeter optimization [start]"); - - network.getVariantManager().cloneVariant(network.getVariantManager().getWorkingVariantId(), INITIAL_SCENARIO); - network.getVariantManager().cloneVariant(network.getVariantManager().getWorkingVariantId(), PREVENTIVE_SCENARIO); - network.getVariantManager().cloneVariant(network.getVariantManager().getWorkingVariantId(), SECOND_PREVENTIVE_SCENARIO_BEFORE_OPT); - network.getVariantManager().setWorkingVariant(PREVENTIVE_SCENARIO); - - if (stateTree.getContingencyScenarios().isEmpty()) { - CompletableFuture result = CompletableFuture.completedFuture(optimizePreventivePerimeter(stateTree, toolProvider, initialOutput)); + OptimizationResult preventiveResult = optimizePreventivePerimeter(stateTree, toolProvider, initialOutput).getOptimizationResult(crac.getPreventiveState()); BUSINESS_LOGS.info("----- Preventive perimeter optimization [end]"); - return result; - } + java.time.Instant preventiveRaoEndInstant = java.time.Instant.now(); + long preventiveRaoTime = ChronoUnit.SECONDS.between(preventiveRaoStartInstant, preventiveRaoEndInstant); + + // ----- SENSI POST-PRA ----- + currentStep = "post-PRA sensitivity analysis"; + // mutualise the pre-perimeter sensi analysis for all contingency scenario + get after-PRA result over all CNECs + + double preventiveOptimalCost = preventiveResult.getCost(); + TreeParameters automatonTreeParameters = TreeParameters.buildForAutomatonPerimeter(raoParameters); + TreeParameters curativeTreeParameters = TreeParameters.buildForCurativePerimeter(raoParameters, preventiveOptimalCost); + network.getVariantManager().setWorkingVariant(INITIAL_SCENARIO); + network.getVariantManager().cloneVariant(network.getVariantManager().getWorkingVariantId(), PREVENTIVE_SCENARIO, true); + network.getVariantManager().setWorkingVariant(PREVENTIVE_SCENARIO); + applyRemedialActions(network, preventiveResult, crac.getPreventiveState()); + + PrePerimeterResult preCurativeSensitivityAnalysisOutput = prePerimeterSensitivityAnalysis.runBasedOnInitialResults(network, crac, initialOutput, Collections.emptySet(), null); + if (preCurativeSensitivityAnalysisOutput.getSensitivityStatus() == ComputationStatus.FAILURE) { + BUSINESS_LOGS.error("Systematic sensitivity analysis after preventive remedial actions failed"); + return CompletableFuture.completedFuture(new FailedRaoResultImpl("Systematic sensitivity analysis after preventive remedial actions failed")); + } + RaoLogger.logSensitivityAnalysisResults("Systematic sensitivity analysis after preventive remedial actions: ", + prePerimeterSensitivityAnalysis.getObjectiveFunction(), + preCurativeSensitivityAnalysisOutput, + raoParameters, + NUMBER_LOGGED_ELEMENTS_DURING_RAO); + + RaoResult mergedRaoResults; + + // ----- CURATIVE PERIMETERS OPTIMIZATION ----- + currentStep = "contingency scenarios"; + // optimize contingency scenarios (auto + curative instants) + + // If stop criterion is SECURE and preventive perimeter was not secure, do not run post-contingency RAOs + // (however RAO could continue depending on parameter optimize-curative-if-basecase-unsecure) + if (shouldStopOptimisationIfPreventiveUnsecure(preventiveOptimalCost)) { + BUSINESS_LOGS.info("Preventive perimeter could not be secured; there is no point in optimizing post-contingency perimeters. The RAO will be interrupted here."); + mergedRaoResults = new PreventiveAndCurativesRaoResultImpl(crac.getPreventiveState(), initialOutput, preventiveResult, preCurativeSensitivityAnalysisOutput, crac); + // log results + RaoLogger.logMostLimitingElementsResults(BUSINESS_LOGS, preCurativeSensitivityAnalysisOutput, raoParameters.getObjectiveFunctionParameters().getType(), NUMBER_LOGGED_ELEMENTS_END_RAO); + + return postCheckResults(mergedRaoResults, initialOutput, raoParameters.getObjectiveFunctionParameters()); + } - OptimizationResult preventiveResult = optimizePreventivePerimeter(stateTree, toolProvider, initialOutput).getOptimizationResult(crac.getPreventiveState()); - BUSINESS_LOGS.info("----- Preventive perimeter optimization [end]"); - java.time.Instant preventiveRaoEndInstant = java.time.Instant.now(); - long preventiveRaoTime = ChronoUnit.SECONDS.between(preventiveRaoStartInstant, preventiveRaoEndInstant); - - // ----- SENSI POST-PRA ----- - // mutualise the pre-perimeter sensi analysis for all contingency scenario + get after-PRA result over all CNECs - - double preventiveOptimalCost = preventiveResult.getCost(); - TreeParameters automatonTreeParameters = TreeParameters.buildForAutomatonPerimeter(raoParameters); - TreeParameters curativeTreeParameters = TreeParameters.buildForCurativePerimeter(raoParameters, preventiveOptimalCost); - network.getVariantManager().setWorkingVariant(INITIAL_SCENARIO); - network.getVariantManager().cloneVariant(network.getVariantManager().getWorkingVariantId(), PREVENTIVE_SCENARIO, true); - network.getVariantManager().setWorkingVariant(PREVENTIVE_SCENARIO); - applyRemedialActions(network, preventiveResult, crac.getPreventiveState()); - - PrePerimeterResult preCurativeSensitivityAnalysisOutput = prePerimeterSensitivityAnalysis.runBasedOnInitialResults(network, crac, initialOutput, Collections.emptySet(), null); - if (preCurativeSensitivityAnalysisOutput.getSensitivityStatus() == ComputationStatus.FAILURE) { - BUSINESS_LOGS.error("Systematic sensitivity analysis after preventive remedial actions failed"); - return CompletableFuture.completedFuture(new FailedRaoResultImpl("Systematic sensitivity analysis after preventive remedial actions failed")); - } - RaoLogger.logSensitivityAnalysisResults("Systematic sensitivity analysis after preventive remedial actions: ", - prePerimeterSensitivityAnalysis.getObjectiveFunction(), - preCurativeSensitivityAnalysisOutput, - raoParameters, - NUMBER_LOGGED_ELEMENTS_DURING_RAO); - - RaoResult mergedRaoResults; - - // ----- CURATIVE PERIMETERS OPTIMIZATION ----- - // optimize contingency scenarios (auto + curative instants) - - // If stop criterion is SECURE and preventive perimeter was not secure, do not run post-contingency RAOs - // (however RAO could continue depending on parameter optimize-curative-if-basecase-unsecure) - if (shouldStopOptimisationIfPreventiveUnsecure(preventiveOptimalCost)) { - BUSINESS_LOGS.info("Preventive perimeter could not be secured; there is no point in optimizing post-contingency perimeters. The RAO will be interrupted here."); - mergedRaoResults = new PreventiveAndCurativesRaoResultImpl(crac.getPreventiveState(), initialOutput, preventiveResult, preCurativeSensitivityAnalysisOutput, crac); - // log results - RaoLogger.logMostLimitingElementsResults(BUSINESS_LOGS, preCurativeSensitivityAnalysisOutput, raoParameters.getObjectiveFunctionParameters().getType(), NUMBER_LOGGED_ELEMENTS_END_RAO); + BUSINESS_LOGS.info("----- Post-contingency perimeters optimization [start]"); + CastorContingencyScenarios castorContingencyScenarios = new CastorContingencyScenarios(crac, raoParameters, toolProvider, stateTree, automatonTreeParameters, curativeTreeParameters, initialOutput); + Map postContingencyResults = castorContingencyScenarios.optimizeContingencyScenarios(network, preCurativeSensitivityAnalysisOutput, false); + BUSINESS_LOGS.info("----- Post-contingency perimeters optimization [end]"); + + // ----- SECOND PREVENTIVE PERIMETER OPTIMIZATION ----- + currentStep = "second preventive optimization"; + mergedRaoResults = new PreventiveAndCurativesRaoResultImpl(stateTree, initialOutput, preventiveResult, preCurativeSensitivityAnalysisOutput, postContingencyResults, crac); + boolean logFinalResultsOutsideOfSecondPreventive = true; + // Run second preventive when necessary + CastorSecondPreventive castorSecondPreventive = new CastorSecondPreventive(crac, raoParameters, network, stateTree, toolProvider, targetEndInstant); + if (castorSecondPreventive.shouldRunSecondPreventiveRao(preventiveResult, postContingencyResults.values(), mergedRaoResults, preventiveRaoTime)) { + RaoResult secondPreventiveRaoResults = castorSecondPreventive.runSecondPreventiveAndAutoRao(castorContingencyScenarios, prePerimeterSensitivityAnalysis, initialOutput, preventiveResult, postContingencyResults); + if (secondPreventiveImprovesResults(secondPreventiveRaoResults, mergedRaoResults)) { + mergedRaoResults = secondPreventiveRaoResults; + mergedRaoResults.setExecutionDetails(OptimizationStepsExecuted.SECOND_PREVENTIVE_IMPROVED_FIRST); + logFinalResultsOutsideOfSecondPreventive = false; + } else { + mergedRaoResults.setExecutionDetails(OptimizationStepsExecuted.SECOND_PREVENTIVE_FELLBACK_TO_FIRST_PREVENTIVE_SITUATION); + } + } + // Log final results + if (logFinalResultsOutsideOfSecondPreventive) { + BUSINESS_LOGS.info("Merging preventive and post-contingency RAO results:"); + RaoLogger.logMostLimitingElementsResults(BUSINESS_LOGS, stateTree.getBasecaseScenario(), preventiveResult, stateTree.getContingencyScenarios(), postContingencyResults, raoParameters.getObjectiveFunctionParameters().getType(), NUMBER_LOGGED_ELEMENTS_END_RAO); + } return postCheckResults(mergedRaoResults, initialOutput, raoParameters.getObjectiveFunctionParameters()); + } catch (RuntimeException e) { + BUSINESS_LOGS.error("{} \n {}", e.getMessage(), ExceptionUtils.getStackTrace(e)); + return CompletableFuture.completedFuture(new FailedRaoResultImpl(String.format("RAO failed during %s : %s", currentStep, e.getMessage()))); } - - BUSINESS_LOGS.info("----- Post-contingency perimeters optimization [start]"); - CastorContingencyScenarios castorContingencyScenarios = new CastorContingencyScenarios(crac, raoParameters, toolProvider, stateTree, automatonTreeParameters, curativeTreeParameters, initialOutput); - Map postContingencyResults = castorContingencyScenarios.optimizeContingencyScenarios(network, preCurativeSensitivityAnalysisOutput, false); - BUSINESS_LOGS.info("----- Post-contingency perimeters optimization [end]"); - - // ----- SECOND PREVENTIVE PERIMETER OPTIMIZATION ----- - mergedRaoResults = new PreventiveAndCurativesRaoResultImpl(stateTree, initialOutput, preventiveResult, preCurativeSensitivityAnalysisOutput, postContingencyResults, crac); - boolean logFinalResultsOutsideOfSecondPreventive = true; - // Run second preventive when necessary - CastorSecondPreventive castorSecondPreventive = new CastorSecondPreventive(crac, raoParameters, network, stateTree, toolProvider, targetEndInstant); - if (castorSecondPreventive.shouldRunSecondPreventiveRao(preventiveResult, postContingencyResults.values(), mergedRaoResults, preventiveRaoTime)) { - RaoResult secondPreventiveRaoResults = castorSecondPreventive.runSecondPreventiveAndAutoRao(castorContingencyScenarios, prePerimeterSensitivityAnalysis, initialOutput, preventiveResult, postContingencyResults); - if (secondPreventiveImprovesResults(secondPreventiveRaoResults, mergedRaoResults)) { - mergedRaoResults = secondPreventiveRaoResults; - mergedRaoResults.setOptimizationStepsExecuted(OptimizationStepsExecuted.SECOND_PREVENTIVE_IMPROVED_FIRST); - logFinalResultsOutsideOfSecondPreventive = false; - } else { - mergedRaoResults.setOptimizationStepsExecuted(OptimizationStepsExecuted.SECOND_PREVENTIVE_FELLBACK_TO_FIRST_PREVENTIVE_SITUATION); - } - } - // Log final results - if (logFinalResultsOutsideOfSecondPreventive) { - BUSINESS_LOGS.info("Merging preventive and post-contingency RAO results:"); - RaoLogger.logMostLimitingElementsResults(BUSINESS_LOGS, stateTree.getBasecaseScenario(), preventiveResult, stateTree.getContingencyScenarios(), postContingencyResults, raoParameters.getObjectiveFunctionParameters().getType(), NUMBER_LOGGED_ELEMENTS_END_RAO); - } - - return postCheckResults(mergedRaoResults, initialOutput, raoParameters.getObjectiveFunctionParameters()); } private boolean shouldStopOptimisationIfPreventiveUnsecure(double preventiveOptimalCost) { @@ -235,10 +247,10 @@ private CompletableFuture postCheckResults(RaoResult raoResult, PrePe finalCost = initialCost; finalFunctionalCost = initialFunctionalCost; finalVirtualCost = initialVirtualCost; - if (raoResult.getOptimizationStepsExecuted().equals(OptimizationStepsExecuted.FIRST_PREVENTIVE_ONLY)) { - finalRaoResult.setOptimizationStepsExecuted(OptimizationStepsExecuted.FIRST_PREVENTIVE_FELLBACK_TO_INITIAL_SITUATION); + if (raoResult.getExecutionDetails().equals(OptimizationStepsExecuted.FIRST_PREVENTIVE_ONLY)) { + finalRaoResult.setExecutionDetails(OptimizationStepsExecuted.FIRST_PREVENTIVE_FELLBACK_TO_INITIAL_SITUATION); } else { - finalRaoResult.setOptimizationStepsExecuted(OptimizationStepsExecuted.SECOND_PREVENTIVE_FELLBACK_TO_INITIAL_SITUATION); + finalRaoResult.setExecutionDetails(OptimizationStepsExecuted.SECOND_PREVENTIVE_FELLBACK_TO_INITIAL_SITUATION); } } diff --git a/ra-optimisation/search-tree-rao/src/main/java/com/powsybl/openrao/searchtreerao/castor/algorithm/CastorSecondPreventive.java b/ra-optimisation/search-tree-rao/src/main/java/com/powsybl/openrao/searchtreerao/castor/algorithm/CastorSecondPreventive.java index d469204edd..553edabb9f 100644 --- a/ra-optimisation/search-tree-rao/src/main/java/com/powsybl/openrao/searchtreerao/castor/algorithm/CastorSecondPreventive.java +++ b/ra-optimisation/search-tree-rao/src/main/java/com/powsybl/openrao/searchtreerao/castor/algorithm/CastorSecondPreventive.java @@ -155,7 +155,7 @@ RaoResult runSecondPreventiveAndAutoRao(CastorContingencyScenarios castorConting } } catch (OpenRaoException e) { BUSINESS_LOGS.error(e.getMessage()); - return new FailedRaoResultImpl(e.getMessage()); + return new FailedRaoResultImpl(String.format("RAO failed during second preventive : %s", e.getMessage())); } // Run 2nd automaton simulation and update results diff --git a/ra-optimisation/search-tree-rao/src/main/java/com/powsybl/openrao/searchtreerao/result/impl/FailedRaoResultImpl.java b/ra-optimisation/search-tree-rao/src/main/java/com/powsybl/openrao/searchtreerao/result/impl/FailedRaoResultImpl.java index 8843202c47..6e663849b5 100644 --- a/ra-optimisation/search-tree-rao/src/main/java/com/powsybl/openrao/searchtreerao/result/impl/FailedRaoResultImpl.java +++ b/ra-optimisation/search-tree-rao/src/main/java/com/powsybl/openrao/searchtreerao/result/impl/FailedRaoResultImpl.java @@ -19,7 +19,6 @@ import com.powsybl.openrao.data.crac.api.rangeaction.PstRangeAction; import com.powsybl.openrao.data.crac.api.rangeaction.RangeAction; import com.powsybl.openrao.data.raoresult.api.ComputationStatus; -import com.powsybl.openrao.data.raoresult.api.OptimizationStepsExecuted; import com.powsybl.openrao.data.raoresult.api.RaoResult; import java.util.Map; @@ -29,7 +28,7 @@ * @author Joris Mancini {@literal } */ public class FailedRaoResultImpl implements RaoResult { - private final String failureReason; + private String failureReason; private final String exceptionMessage; public FailedRaoResultImpl(String failureReason) { @@ -37,10 +36,6 @@ public FailedRaoResultImpl(String failureReason) { this.exceptionMessage = "This method should not be used, because the RAO failed: " + failureReason; } - public String getFailureReason() { - return failureReason; - } - @Override public ComputationStatus getComputationStatus() { return ComputationStatus.FAILURE; @@ -162,13 +157,13 @@ public Map, Double> getOptimizedSetPointsOnState(State state) { } @Override - public void setOptimizationStepsExecuted(OptimizationStepsExecuted optimizationStepsExecuted) { - throw new OpenRaoException(exceptionMessage); + public void setExecutionDetails(String executionDetails) { + this.failureReason = executionDetails; } @Override - public OptimizationStepsExecuted getOptimizationStepsExecuted() { - throw new OpenRaoException(exceptionMessage); + public String getExecutionDetails() { + return this.failureReason; } @Override diff --git a/ra-optimisation/search-tree-rao/src/main/java/com/powsybl/openrao/searchtreerao/result/impl/OneStateOnlyRaoResultImpl.java b/ra-optimisation/search-tree-rao/src/main/java/com/powsybl/openrao/searchtreerao/result/impl/OneStateOnlyRaoResultImpl.java index 40a888c723..45d44e74ca 100644 --- a/ra-optimisation/search-tree-rao/src/main/java/com/powsybl/openrao/searchtreerao/result/impl/OneStateOnlyRaoResultImpl.java +++ b/ra-optimisation/search-tree-rao/src/main/java/com/powsybl/openrao/searchtreerao/result/impl/OneStateOnlyRaoResultImpl.java @@ -34,7 +34,7 @@ public class OneStateOnlyRaoResultImpl extends AbstractFlowRaoResult { private final PrePerimeterResult initialResult; private final OptimizationResult postOptimizationResult; private final Set optimizedFlowCnecs; - private OptimizationStepsExecuted optimizationStepsExecuted = OptimizationStepsExecuted.FIRST_PREVENTIVE_ONLY; + private String executionDetails = OptimizationStepsExecuted.FIRST_PREVENTIVE_ONLY; public OneStateOnlyRaoResultImpl(State optimizedState, PrePerimeterResult initialResult, OptimizationResult postOptimizationResult, Set optimizedFlowCnecs) { this.optimizedState = optimizedState; @@ -270,12 +270,8 @@ public Map, Double> getOptimizedSetPointsOnState(State state) { } @Override - public void setOptimizationStepsExecuted(OptimizationStepsExecuted optimizationStepsExecuted) { - if (this.optimizationStepsExecuted.isOverwritePossible(optimizationStepsExecuted)) { - this.optimizationStepsExecuted = optimizationStepsExecuted; - } else { - throw new OpenRaoException("The RaoResult object should not be modified outside of its usual routine"); - } + public void setExecutionDetails(String executionDetails) { + this.executionDetails = executionDetails; } @Override @@ -284,7 +280,7 @@ public boolean isSecure(PhysicalParameter... u) { } @Override - public OptimizationStepsExecuted getOptimizationStepsExecuted() { - return optimizationStepsExecuted; + public String getExecutionDetails() { + return executionDetails; } } diff --git a/ra-optimisation/search-tree-rao/src/main/java/com/powsybl/openrao/searchtreerao/result/impl/PreventiveAndCurativesRaoResultImpl.java b/ra-optimisation/search-tree-rao/src/main/java/com/powsybl/openrao/searchtreerao/result/impl/PreventiveAndCurativesRaoResultImpl.java index c644f27815..dcc0dc3df0 100644 --- a/ra-optimisation/search-tree-rao/src/main/java/com/powsybl/openrao/searchtreerao/result/impl/PreventiveAndCurativesRaoResultImpl.java +++ b/ra-optimisation/search-tree-rao/src/main/java/com/powsybl/openrao/searchtreerao/result/impl/PreventiveAndCurativesRaoResultImpl.java @@ -43,7 +43,7 @@ public class PreventiveAndCurativesRaoResultImpl extends AbstractFlowRaoResult { private final Map postContingencyResults; private final ObjectiveFunctionResult finalCostEvaluator; private final Crac crac; - private OptimizationStepsExecuted optimizationStepsExecuted = OptimizationStepsExecuted.FIRST_PREVENTIVE_ONLY; + private String executionDetails = OptimizationStepsExecuted.FIRST_PREVENTIVE_ONLY; private final Map> optimizedStateForInstantAndState = new HashMap<>(); @@ -601,12 +601,8 @@ private State getStateOptimizedBefore(State state) { } @Override - public void setOptimizationStepsExecuted(OptimizationStepsExecuted optimizationStepsExecuted) { - if (this.optimizationStepsExecuted.isOverwritePossible(optimizationStepsExecuted)) { - this.optimizationStepsExecuted = optimizationStepsExecuted; - } else { - throw new OpenRaoException("The RaoResult object should not be modified outside of its usual routine"); - } + public void setExecutionDetails(String executionDetails) { + this.executionDetails = executionDetails; } @Override @@ -615,7 +611,7 @@ public boolean isSecure(PhysicalParameter... u) { } @Override - public OptimizationStepsExecuted getOptimizationStepsExecuted() { - return optimizationStepsExecuted; + public String getExecutionDetails() { + return executionDetails; } } diff --git a/ra-optimisation/search-tree-rao/src/main/java/com/powsybl/openrao/searchtreerao/result/impl/UnoptimizedRaoResultImpl.java b/ra-optimisation/search-tree-rao/src/main/java/com/powsybl/openrao/searchtreerao/result/impl/UnoptimizedRaoResultImpl.java index 2cd5d43c2f..b4d753cf67 100644 --- a/ra-optimisation/search-tree-rao/src/main/java/com/powsybl/openrao/searchtreerao/result/impl/UnoptimizedRaoResultImpl.java +++ b/ra-optimisation/search-tree-rao/src/main/java/com/powsybl/openrao/searchtreerao/result/impl/UnoptimizedRaoResultImpl.java @@ -34,7 +34,7 @@ */ public class UnoptimizedRaoResultImpl implements RaoResult { private final PrePerimeterResult initialResult; - private OptimizationStepsExecuted optimizationStepsExecuted = OptimizationStepsExecuted.FIRST_PREVENTIVE_ONLY; + private String executionDetails = OptimizationStepsExecuted.FIRST_PREVENTIVE_ONLY; public UnoptimizedRaoResultImpl(PrePerimeterResult initialResult) { this.initialResult = initialResult; @@ -171,12 +171,8 @@ public Map, Double> getOptimizedSetPointsOnState(State state) { } @Override - public void setOptimizationStepsExecuted(OptimizationStepsExecuted optimizationStepsExecuted) { - if (this.optimizationStepsExecuted.isOverwritePossible(optimizationStepsExecuted)) { - this.optimizationStepsExecuted = optimizationStepsExecuted; - } else { - throw new OpenRaoException("The RaoResult object should not be modified outside of its usual routine"); - } + public void setExecutionDetails(String executionDetails) { + this.executionDetails = executionDetails; } @Override @@ -190,7 +186,7 @@ public boolean isSecure(PhysicalParameter... u) { } @Override - public OptimizationStepsExecuted getOptimizationStepsExecuted() { - return optimizationStepsExecuted; + public String getExecutionDetails() { + return executionDetails; } } diff --git a/ra-optimisation/search-tree-rao/src/test/java/com/powsybl/openrao/searchtreerao/castor/algorithm/CastorFullOptimizationTest.java b/ra-optimisation/search-tree-rao/src/test/java/com/powsybl/openrao/searchtreerao/castor/algorithm/CastorFullOptimizationTest.java index ad25badbaa..a8cdb540a8 100644 --- a/ra-optimisation/search-tree-rao/src/test/java/com/powsybl/openrao/searchtreerao/castor/algorithm/CastorFullOptimizationTest.java +++ b/ra-optimisation/search-tree-rao/src/test/java/com/powsybl/openrao/searchtreerao/castor/algorithm/CastorFullOptimizationTest.java @@ -18,7 +18,6 @@ import com.powsybl.openrao.commons.logs.RaoBusinessLogs; import com.powsybl.openrao.data.crac.api.Crac; import com.powsybl.openrao.data.crac.api.CracFactory; -import com.powsybl.openrao.data.crac.api.Instant; import com.powsybl.openrao.data.crac.api.InstantKind; import com.powsybl.openrao.data.crac.api.State; import com.powsybl.openrao.data.crac.api.cnec.FlowCnec; @@ -31,11 +30,11 @@ import com.powsybl.openrao.data.raoresult.api.OptimizationStepsExecuted; import com.powsybl.openrao.raoapi.RaoInput; import com.powsybl.openrao.raoapi.json.JsonRaoParameters; +import com.powsybl.openrao.raoapi.parameters.MultithreadingParameters; import com.powsybl.openrao.raoapi.parameters.ObjectiveFunctionParameters; import com.powsybl.openrao.raoapi.parameters.RaoParameters; import com.powsybl.openrao.raoapi.parameters.SecondPreventiveRaoParameters; import com.powsybl.openrao.searchtreerao.result.impl.FailedRaoResultImpl; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.mockito.Mockito; import org.slf4j.LoggerFactory; @@ -52,34 +51,21 @@ * @author Peter Mitri {@literal } */ class CastorFullOptimizationTest { - private static final String PREVENTIVE_INSTANT_ID = "preventive"; - private static final String CURATIVE_INSTANT_ID = "curative"; - private Crac crac; private Network network; - private Instant preventiveInstant; - private Instant curativeInstant; - - @BeforeEach - public void setup() throws IOException { - network = Network.read("network_with_alegro_hub.xiidm", getClass().getResourceAsStream("/network/network_with_alegro_hub.xiidm")); - crac = Crac.read("small-crac.json", getClass().getResourceAsStream("/crac/small-crac.json"), network); - preventiveInstant = crac.getInstant(PREVENTIVE_INSTANT_ID); - curativeInstant = crac.getInstant(CURATIVE_INSTANT_ID); - RaoInput inputs = Mockito.mock(RaoInput.class); - when(inputs.getNetwork()).thenReturn(network); - when(inputs.getNetworkVariantId()).thenReturn(network.getVariantManager().getWorkingVariantId()); - when(inputs.getCrac()).thenReturn(crac); + private RaoInput raoInput; + + public void setup(String networkFile, String cracFile) throws IOException { + network = Network.read(networkFile, getClass().getResourceAsStream("/network/" + networkFile)); + crac = Crac.read(cracFile, getClass().getResourceAsStream("/crac/" + cracFile), network); + raoInput = RaoInput.build(network, crac).build(); } @Test void smallRaoWithDivergingInitialSensi() throws IOException { // Small RAO with diverging initial sensi // Cannot optimize range actions in unit tests (needs OR-Tools installed) - - network = Network.read("small-network-2P.uct", getClass().getResourceAsStream("/network/small-network-2P.uct")); - crac = Crac.read("small-crac-2P.json", getClass().getResourceAsStream("/crac/small-crac-2P.json"), network); - RaoInput raoInput = RaoInput.build(network, crac).build(); + setup("small-network-2P.uct", "small-crac-2P.json"); RaoParameters raoParameters = JsonRaoParameters.read(getClass().getResourceAsStream("/parameters/RaoParameters_oneIteration_v2.json")); // Run RAO @@ -91,29 +77,23 @@ void smallRaoWithDivergingInitialSensi() throws IOException { void smallRaoWithout2P() throws IOException { // Small RAO without second preventive optimization and only topological actions // Cannot optimize range actions in unit tests (needs OR-Tools installed) - - network = Network.read("small-network-2P.uct", getClass().getResourceAsStream("/network/small-network-2P.uct")); - crac = Crac.read("small-crac-2P.json", getClass().getResourceAsStream("/crac/small-crac-2P.json"), network); - RaoInput raoInput = RaoInput.build(network, crac).build(); + setup("small-network-2P.uct", "small-crac-2P.json"); RaoParameters raoParameters = JsonRaoParameters.read(getClass().getResourceAsStream("/parameters/RaoParameters_2P_v2.json")); // Run RAO RaoResult raoResult = new CastorFullOptimization(raoInput, raoParameters, null).run().join(); assertEquals(371.88, raoResult.getFunctionalCost(null), 1.); - assertEquals(493.56, raoResult.getFunctionalCost(preventiveInstant), 1.); - assertEquals(256.78, raoResult.getFunctionalCost(curativeInstant), 1.); + assertEquals(493.56, raoResult.getFunctionalCost(crac.getPreventiveInstant()), 1.); + assertEquals(256.78, raoResult.getFunctionalCost(crac.getLastInstant()), 1.); assertEquals(Set.of(crac.getNetworkAction("close_de3_de4"), crac.getNetworkAction("close_fr1_fr5")), raoResult.getActivatedNetworkActionsDuringState(crac.getPreventiveState())); - assertEquals(Set.of(crac.getNetworkAction("open_fr1_fr3")), raoResult.getActivatedNetworkActionsDuringState(crac.getState(crac.getContingency("co1_fr2_fr3_1"), curativeInstant))); - assertEquals(FIRST_PREVENTIVE_ONLY, raoResult.getOptimizationStepsExecuted()); + assertEquals(Set.of(crac.getNetworkAction("open_fr1_fr3")), raoResult.getActivatedNetworkActionsDuringState(crac.getState(crac.getContingency("co1_fr2_fr3_1"), crac.getLastInstant()))); + assertEquals(FIRST_PREVENTIVE_ONLY, raoResult.getExecutionDetails()); } @Test void smallRaoWith2P() throws IOException { // Same RAO as before but activating 2P => results should be better - - network = Network.read("small-network-2P.uct", getClass().getResourceAsStream("/network/small-network-2P.uct")); - crac = Crac.read("small-crac-2P.json", getClass().getResourceAsStream("/crac/small-crac-2P.json"), network); - RaoInput raoInput = RaoInput.build(network, crac).build(); + setup("small-network-2P.uct", "small-crac-2P.json"); RaoParameters raoParameters = JsonRaoParameters.read(getClass().getResourceAsStream("/parameters/RaoParameters_2P_v2.json")); // Activate 2P @@ -122,22 +102,17 @@ void smallRaoWith2P() throws IOException { // Run RAO RaoResult raoResult = new CastorFullOptimization(raoInput, raoParameters, null).run().join(); assertEquals(371.88, raoResult.getFunctionalCost(null), 1.); - assertEquals(674.6, raoResult.getFunctionalCost(preventiveInstant), 1.); - assertEquals(-555.91, raoResult.getFunctionalCost(curativeInstant), 1.); + assertEquals(674.6, raoResult.getFunctionalCost(crac.getPreventiveInstant()), 1.); + assertEquals(-555.91, raoResult.getFunctionalCost(crac.getLastInstant()), 1.); assertEquals(Set.of(crac.getNetworkAction("close_de3_de4"), crac.getNetworkAction("open_fr1_fr2")), raoResult.getActivatedNetworkActionsDuringState(crac.getPreventiveState())); - assertEquals(Set.of(crac.getNetworkAction("open_fr1_fr3")), raoResult.getActivatedNetworkActionsDuringState(crac.getState(crac.getContingency("co1_fr2_fr3_1"), curativeInstant))); - assertEquals(OptimizationStepsExecuted.SECOND_PREVENTIVE_IMPROVED_FIRST, raoResult.getOptimizationStepsExecuted()); - OpenRaoException exception = assertThrows(OpenRaoException.class, () -> raoResult.setOptimizationStepsExecuted(FIRST_PREVENTIVE_ONLY)); - assertEquals("The RaoResult object should not be modified outside of its usual routine", exception.getMessage()); + assertEquals(Set.of(crac.getNetworkAction("open_fr1_fr3")), raoResult.getActivatedNetworkActionsDuringState(crac.getState(crac.getContingency("co1_fr2_fr3_1"), crac.getLastInstant()))); + assertEquals(OptimizationStepsExecuted.SECOND_PREVENTIVE_IMPROVED_FIRST, raoResult.getExecutionDetails()); } @Test void smallRaoWithGlobal2P() throws IOException { // Same RAO as before but activating Global 2P => results should be the same (there are no range actions) - - network = Network.read("small-network-2P.uct", getClass().getResourceAsStream("/network/small-network-2P.uct")); - crac = Crac.read("small-crac-2P.json", getClass().getResourceAsStream("/crac/small-crac-2P.json"), network); - RaoInput raoInput = RaoInput.build(network, crac).build(); + setup("small-network-2P.uct", "small-crac-2P.json"); RaoParameters raoParameters = JsonRaoParameters.read(getClass().getResourceAsStream("/parameters/RaoParameters_2P_v2.json")); // Activate global 2P @@ -147,13 +122,11 @@ void smallRaoWithGlobal2P() throws IOException { // Run RAO RaoResult raoResult = new CastorFullOptimization(raoInput, raoParameters, null).run().join(); assertEquals(371.88, raoResult.getFunctionalCost(null), 1.); - assertEquals(674.6, raoResult.getFunctionalCost(preventiveInstant), 1.); - assertEquals(-555.91, raoResult.getFunctionalCost(curativeInstant), 1.); + assertEquals(674.6, raoResult.getFunctionalCost(crac.getPreventiveInstant()), 1.); + assertEquals(-555.91, raoResult.getFunctionalCost(crac.getLastInstant()), 1.); assertEquals(Set.of(crac.getNetworkAction("close_de3_de4"), crac.getNetworkAction("open_fr1_fr2")), raoResult.getActivatedNetworkActionsDuringState(crac.getPreventiveState())); - assertEquals(Set.of(crac.getNetworkAction("open_fr1_fr3")), raoResult.getActivatedNetworkActionsDuringState(crac.getState(crac.getContingency("co1_fr2_fr3_1"), curativeInstant))); - assertEquals(OptimizationStepsExecuted.SECOND_PREVENTIVE_IMPROVED_FIRST, raoResult.getOptimizationStepsExecuted()); - OpenRaoException exception = assertThrows(OpenRaoException.class, () -> raoResult.setOptimizationStepsExecuted(OptimizationStepsExecuted.FIRST_PREVENTIVE_FELLBACK_TO_INITIAL_SITUATION)); - assertEquals("The RaoResult object should not be modified outside of its usual routine", exception.getMessage()); + assertEquals(Set.of(crac.getNetworkAction("open_fr1_fr3")), raoResult.getActivatedNetworkActionsDuringState(crac.getState(crac.getContingency("co1_fr2_fr3_1"), crac.getLastInstant()))); + assertEquals(OptimizationStepsExecuted.SECOND_PREVENTIVE_IMPROVED_FIRST, raoResult.getExecutionDetails()); } @Test @@ -165,17 +138,13 @@ void testOptimizationStepsExecutedAndLogsWhenFallbackOnFirstPrev() throws IOExce logger.addAppender(listAppender); // Set up RAO and run - network = Network.read("small-network-2P.uct", getClass().getResourceAsStream("/network/small-network-2P.uct")); - crac = Crac.read("small-crac-2P_cost_increase.json", getClass().getResourceAsStream("/crac/small-crac-2P_cost_increase.json"), network); - RaoInput raoInput = RaoInput.build(network, crac).build(); + setup("small-network-2P.uct", "small-crac-2P_cost_increase.json"); RaoParameters raoParameters = JsonRaoParameters.read(getClass().getResourceAsStream("/parameters/RaoParameters_2P_v2.json")); raoParameters.getObjectiveFunctionParameters().setForbidCostIncrease(true); RaoResult raoResult = new CastorFullOptimization(raoInput, raoParameters, null).run().join(); // Test Optimization steps executed - assertEquals(OptimizationStepsExecuted.FIRST_PREVENTIVE_FELLBACK_TO_INITIAL_SITUATION, raoResult.getOptimizationStepsExecuted()); - OpenRaoException exception = assertThrows(OpenRaoException.class, () -> raoResult.setOptimizationStepsExecuted(FIRST_PREVENTIVE_ONLY)); - assertEquals("The RaoResult object should not be modified outside of its usual routine", exception.getMessage()); + assertEquals(OptimizationStepsExecuted.FIRST_PREVENTIVE_FELLBACK_TO_INITIAL_SITUATION, raoResult.getExecutionDetails()); // Test final log after RAO fallbacks listAppender.stop(); @@ -223,7 +192,7 @@ void testThreeCurativeInstantsWithSecondCurativeHavingNoCnecAndNoRa() { .newOnInstantUsageRule().withInstant("curative3").withUsageMethod(UsageMethod.AVAILABLE).add() .add(); - RaoInput raoInput = RaoInput.build(network, crac).build(); + raoInput = RaoInput.build(network, crac).build(); RaoParameters raoParameters = JsonRaoParameters.read(getClass().getResourceAsStream("/parameters/RaoParameters_2P_v2.json")); raoParameters.getObjectiveFunctionParameters().setType(ObjectiveFunctionParameters.ObjectiveFunctionType.MAX_MIN_MARGIN_IN_AMPERE); @@ -317,7 +286,7 @@ void testThreeCurativeInstants() { .newOnInstantUsageRule().withInstant("curative3").withUsageMethod(UsageMethod.AVAILABLE).add() .add(); - RaoInput raoInput = RaoInput.build(network, crac).build(); + raoInput = RaoInput.build(network, crac).build(); RaoParameters raoParameters = JsonRaoParameters.read(getClass().getResourceAsStream("/parameters/RaoParameters_2P_v2.json")); raoParameters.getObjectiveFunctionParameters().setType(ObjectiveFunctionParameters.ObjectiveFunctionType.MAX_MIN_MARGIN_IN_AMPERE); @@ -380,10 +349,7 @@ void testThreeCurativeInstants() { @Test void optimizationWithAutoSearchTree() throws IOException { - network = Network.read("12Nodes_2_twin_lines.uct", getClass().getResourceAsStream("/network/12Nodes_2_twin_lines.uct")); - crac = Crac.read("small-crac-available-aras.json", getClass().getResourceAsStream("/crac/small-crac-available-aras.json"), network); - - RaoInput raoInput = RaoInput.build(network, crac).build(); + setup("12Nodes_2_twin_lines.uct", "small-crac-available-aras.json"); RaoParameters raoParameters = JsonRaoParameters.read(getClass().getResourceAsStream("/parameters/RaoParameters_DC.json")); RaoResult raoResult = new CastorFullOptimization(raoInput, raoParameters, null).run().join(); @@ -406,10 +372,7 @@ void optimizationWithAutoSearchTree() throws IOException { @Test void optimizationWithAutoSearchTreeAndAutoPsts() throws IOException { - network = Network.read("12Nodes_2_twin_lines.uct", getClass().getResourceAsStream("/network/12Nodes_2_twin_lines.uct")); - crac = Crac.read("small-crac-available-aras-low-limits-thresholds.json", getClass().getResourceAsStream("/crac/small-crac-available-aras-low-limits-thresholds.json"), network); - - RaoInput raoInput = RaoInput.build(network, crac).build(); + setup("12Nodes_2_twin_lines.uct", "small-crac-available-aras-low-limits-thresholds.json"); RaoParameters raoParameters = JsonRaoParameters.read(getClass().getResourceAsStream("/parameters/RaoParameters_DC.json")); RaoResult raoResult = new CastorFullOptimization(raoInput, raoParameters, null).run().join(); @@ -433,13 +396,7 @@ void optimizationWithAutoSearchTreeAndAutoPsts() throws IOException { @Test void threeCurativeInstantsWithCumulativeMaximumNumberOfApplicableRemedialActions() throws IOException { - network = Network.read("12Nodes_4ParallelLines.uct", getClass().getResourceAsStream("/network/12Nodes_4ParallelLines.uct")); - crac = Crac.read( - "small-crac-ra-limits-per-instant.json", CastorFullOptimizationTest.class.getResourceAsStream("/crac/small-crac-ra-limits-per-instant.json"), - network - ); - - RaoInput raoInput = RaoInput.build(network, crac).build(); + setup("12Nodes_4ParallelLines.uct", "small-crac-ra-limits-per-instant.json"); RaoParameters raoParameters = JsonRaoParameters.read(getClass().getResourceAsStream("/parameters/RaoParameters_DC.json")); RaoResult raoResult = new CastorFullOptimization(raoInput, raoParameters, null).run().join(); @@ -452,13 +409,7 @@ void threeCurativeInstantsWithCumulativeMaximumNumberOfApplicableRemedialActions @Test void threeCurativeInstantsWithCumulativeMaximumNumberOfTsos() throws IOException { - network = Network.read("12Nodes_4ParallelLines.uct", getClass().getResourceAsStream("/network/12Nodes_4ParallelLines.uct")); - crac = Crac.read( - "small-crac-ra-limits-per-instant-3-tsos.json", CastorFullOptimizationTest.class.getResourceAsStream("/crac/small-crac-ra-limits-per-instant-3-tsos.json"), - network - ); - - RaoInput raoInput = RaoInput.build(network, crac).build(); + setup("12Nodes_4ParallelLines.uct", "small-crac-ra-limits-per-instant-3-tsos.json"); RaoParameters raoParameters = JsonRaoParameters.read(getClass().getResourceAsStream("/parameters/RaoParameters_DC.json")); RaoResult raoResult = new CastorFullOptimization(raoInput, raoParameters, null).run().join(); @@ -472,9 +423,7 @@ void threeCurativeInstantsWithCumulativeMaximumNumberOfTsos() throws IOException @Test void curativeOptimizationShouldNotBeDoneIfPreventiveUnsecure() throws IOException { - network = Network.read("small-network-2P.uct", getClass().getResourceAsStream("/network/small-network-2P.uct")); - crac = Crac.read("small-crac-to-check-curative-optimization-if-preventive-unsecure.json", getClass().getResourceAsStream("/crac/small-crac-to-check-curative-optimization-if-preventive-unsecure.json"), network); - RaoInput raoInput = RaoInput.build(network, crac).build(); + setup("small-network-2P.uct", "small-crac-to-check-curative-optimization-if-preventive-unsecure.json"); RaoParameters raoParameters = JsonRaoParameters.read(getClass().getResourceAsStream("/parameters/RaoParameters_2P_v2.json")); raoParameters.getObjectiveFunctionParameters().setPreventiveStopCriterion(ObjectiveFunctionParameters.PreventiveStopCriterion.SECURE); @@ -487,9 +436,7 @@ void curativeOptimizationShouldNotBeDoneIfPreventiveUnsecure() throws IOExceptio @Test void curativeOptimizationShouldBeDoneIfPreventiveSecure() throws IOException { - network = Network.read("small-network-2P.uct", getClass().getResourceAsStream("/network/small-network-2P.uct")); - crac = Crac.read("small-crac-to-check-curative-optimization-if-preventive-secure.json", getClass().getResourceAsStream("/crac/small-crac-to-check-curative-optimization-if-preventive-secure.json"), network); - RaoInput raoInput = RaoInput.build(network, crac).build(); + setup("small-network-2P.uct", "small-crac-to-check-curative-optimization-if-preventive-secure.json"); RaoParameters raoParameters = JsonRaoParameters.read(getClass().getResourceAsStream("/parameters/RaoParameters_2P_v2.json")); raoParameters.getObjectiveFunctionParameters().setPreventiveStopCriterion(ObjectiveFunctionParameters.PreventiveStopCriterion.SECURE); @@ -502,9 +449,7 @@ void curativeOptimizationShouldBeDoneIfPreventiveSecure() throws IOException { @Test void curativeOptimizationShouldBeDoneIfPreventiveMinMarginNegative() throws IOException { - network = Network.read("small-network-2P.uct", getClass().getResourceAsStream("/network/small-network-2P.uct")); - crac = Crac.read("small-crac-to-check-curative-optimization-if-preventive-unsecure.json", getClass().getResourceAsStream("/crac/small-crac-to-check-curative-optimization-if-preventive-unsecure.json"), network); - RaoInput raoInput = RaoInput.build(network, crac).build(); + setup("small-network-2P.uct", "small-crac-to-check-curative-optimization-if-preventive-secure.json"); RaoParameters raoParameters = JsonRaoParameters.read(getClass().getResourceAsStream("/parameters/RaoParameters_2P_v2.json")); raoParameters.getObjectiveFunctionParameters().setOptimizeCurativeIfPreventiveUnsecure(false); @@ -516,9 +461,7 @@ void curativeOptimizationShouldBeDoneIfPreventiveMinMarginNegative() throws IOEx @Test void curativeOptimizationShouldBeDoneIfPreventiveUnsecureAndAssociatedParameterSet() throws IOException { - network = Network.read("small-network-2P.uct", getClass().getResourceAsStream("/network/small-network-2P.uct")); - crac = Crac.read("small-crac-to-check-curative-optimization-if-preventive-unsecure.json", getClass().getResourceAsStream("/crac/small-crac-to-check-curative-optimization-if-preventive-unsecure.json"), network); - RaoInput raoInput = RaoInput.build(network, crac).build(); + setup("small-network-2P.uct", "small-crac-to-check-curative-optimization-if-preventive-secure.json"); RaoParameters raoParameters = JsonRaoParameters.read(getClass().getResourceAsStream("/parameters/RaoParameters_2P_v2.json")); raoParameters.getObjectiveFunctionParameters().setPreventiveStopCriterion(ObjectiveFunctionParameters.PreventiveStopCriterion.SECURE); @@ -531,9 +474,7 @@ void curativeOptimizationShouldBeDoneIfPreventiveUnsecureAndAssociatedParameterS @Test void curativeOptimizationShouldBeDoneIfPreventiveSecureAndAssociatedParameterSet() throws IOException { - network = Network.read("small-network-2P.uct", getClass().getResourceAsStream("/network/small-network-2P.uct")); - crac = Crac.read("small-crac-to-check-curative-optimization-if-preventive-secure.json", getClass().getResourceAsStream("/crac/small-crac-to-check-curative-optimization-if-preventive-secure.json"), network); - RaoInput raoInput = RaoInput.build(network, crac).build(); + setup("small-network-2P.uct", "small-crac-to-check-curative-optimization-if-preventive-secure.json"); RaoParameters raoParameters = JsonRaoParameters.read(getClass().getResourceAsStream("/parameters/RaoParameters_2P_v2.json")); raoParameters.getObjectiveFunctionParameters().setPreventiveStopCriterion(ObjectiveFunctionParameters.PreventiveStopCriterion.SECURE); @@ -546,9 +487,7 @@ void curativeOptimizationShouldBeDoneIfPreventiveSecureAndAssociatedParameterSet @Test void curativeOptimizationShouldBeDoneIfPreventiveMinMarginNegativeAndAssociatedParameterSet() throws IOException { - network = Network.read("small-network-2P.uct", getClass().getResourceAsStream("/network/small-network-2P.uct")); - crac = Crac.read("small-crac-to-check-curative-optimization-if-preventive-unsecure.json", getClass().getResourceAsStream("/crac/small-crac-to-check-curative-optimization-if-preventive-unsecure.json"), network); - RaoInput raoInput = RaoInput.build(network, crac).build(); + setup("small-network-2P.uct", "small-crac-to-check-curative-optimization-if-preventive-secure.json"); RaoParameters raoParameters = JsonRaoParameters.read(getClass().getResourceAsStream("/parameters/RaoParameters_2P_v2.json")); raoParameters.getObjectiveFunctionParameters().setOptimizeCurativeIfPreventiveUnsecure(true); @@ -560,9 +499,7 @@ void curativeOptimizationShouldBeDoneIfPreventiveMinMarginNegativeAndAssociatedP @Test void curativeStopCriterionReachedSkipsPerimeterBuilding() throws IOException { - network = Network.read("small-network-2P.uct", getClass().getResourceAsStream("/network/small-network-2P.uct")); - crac = Crac.read("small-crac-purely-virtual-curative.json", getClass().getResourceAsStream("/crac/small-crac-purely-virtual-curative.json"), network); - RaoInput raoInput = RaoInput.build(network, crac).build(); + setup("small-network-2P.uct", "small-crac-purely-virtual-curative.json"); RaoParameters raoParameters = JsonRaoParameters.read(getClass().getResourceAsStream("/parameters/RaoParameters_secure.json")); raoParameters.getObjectiveFunctionParameters().setOptimizeCurativeIfPreventiveUnsecure(true); @@ -571,4 +508,55 @@ void curativeStopCriterionReachedSkipsPerimeterBuilding() throws IOException { RaoResult raoResult = new CastorFullOptimization(raoInput, raoParameters, null).run().join(); assertEquals(-12, raoResult.getOptimizedTapOnState(crac.getState("N-1 NL1-NL3", crac.getLastInstant()), crac.getPstRangeAction("CRA_PST_BE"))); } + + @Test + void catchDuringDataInitialization() throws IOException { + setup("small-network-2P.uct", "small-crac-2P.json"); + RaoParameters raoParameters = null; + RaoResult raoResult = new CastorFullOptimization(raoInput, raoParameters, null).run().join(); + assertInstanceOf(FailedRaoResultImpl.class, raoResult); + assertEquals("RAO failed during data initialization : Cannot invoke \"com.powsybl.openrao.raoapi.parameters.RaoParameters.getObjectiveFunctionParameters()\" because \"raoParameters\" is null", raoResult.getExecutionDetails()); + } + + @Test + void catchDuringInitialSensitivity() throws IOException { + setup("small-network-2P.uct", "small-crac-2P.json"); + RaoParameters raoParameters = Mockito.spy(new RaoParameters()); + when(raoParameters.getLoadFlowAndSensitivityParameters()).thenThrow(new OpenRaoException("Testing exception handling")); + RaoResult raoResult = new CastorFullOptimization(raoInput, raoParameters, null).run().join(); + assertInstanceOf(FailedRaoResultImpl.class, raoResult); + assertEquals("RAO failed during initial sensitivity analysis : Testing exception handling", raoResult.getExecutionDetails()); + } + + @Test + void catchDuringFirstPreventive() throws IOException { + setup("small-network-2P.uct", "small-crac-2P.json"); + RaoParameters raoParameters = Mockito.spy(JsonRaoParameters.read(getClass().getResourceAsStream("/parameters/RaoParameters_2P_v2.json"))); + when(raoParameters.getTopoOptimizationParameters()).thenThrow(new OpenRaoException("Testing exception handling")); + + RaoResult raoResult = new CastorFullOptimization(raoInput, raoParameters, null).run().join(); + assertEquals("RAO failed during first preventive : Testing exception handling", raoResult.getExecutionDetails()); + } + + @Test + void catchDuringContingencyScenarios() throws IOException { + setup("small-network-2P.uct", "small-crac-2P.json"); + RaoParameters raoParameters = JsonRaoParameters.read(getClass().getResourceAsStream("/parameters/RaoParameters_2P_v2.json")); + MultithreadingParameters multithreadingParameters = Mockito.spy(raoParameters.getMultithreadingParameters()); + when(multithreadingParameters.getContingencyScenariosInParallel()).thenThrow(new OpenRaoException("Testing exception handling")); + raoParameters.setMultithreadingParameters(multithreadingParameters); + + RaoResult raoResult = new CastorFullOptimization(raoInput, raoParameters, null).run().join(); + assertEquals("RAO failed during contingency scenarios : Testing exception handling", raoResult.getExecutionDetails()); + } + + @Test + void catchDuringSecondPreventive() throws IOException { + setup("small-network-2P.uct", "small-crac-2P.json"); + RaoParameters raoParameters = Mockito.spy(JsonRaoParameters.read(getClass().getResourceAsStream("/parameters/RaoParameters_2P_v2.json"))); + when(raoParameters.getSecondPreventiveRaoParameters()).thenThrow(new OpenRaoException("Testing exception handling")); + + RaoResult raoResult = new CastorFullOptimization(raoInput, raoParameters, null).run().join(); + assertEquals("RAO failed during second preventive optimization : Testing exception handling", raoResult.getExecutionDetails()); + } } diff --git a/ra-optimisation/search-tree-rao/src/test/java/com/powsybl/openrao/searchtreerao/result/impl/FailedRaoResultImplTest.java b/ra-optimisation/search-tree-rao/src/test/java/com/powsybl/openrao/searchtreerao/result/impl/FailedRaoResultImplTest.java index 05c3e5e4fc..79206cb6df 100644 --- a/ra-optimisation/search-tree-rao/src/test/java/com/powsybl/openrao/searchtreerao/result/impl/FailedRaoResultImplTest.java +++ b/ra-optimisation/search-tree-rao/src/test/java/com/powsybl/openrao/searchtreerao/result/impl/FailedRaoResultImplTest.java @@ -21,7 +21,6 @@ import com.powsybl.openrao.data.crac.api.rangeaction.RangeAction; import com.powsybl.openrao.data.crac.api.State; import com.powsybl.openrao.data.raoresult.api.ComputationStatus; -import com.powsybl.openrao.data.raoresult.api.OptimizationStepsExecuted; import org.junit.jupiter.api.Test; import static com.powsybl.openrao.commons.Unit.MEGAWATT; @@ -63,12 +62,10 @@ void testBasicReturns() { assertThrows(OpenRaoException.class, () -> failedRaoResultImpl.getActivatedRangeActionsDuringState(state)); assertThrows(OpenRaoException.class, () -> failedRaoResultImpl.getOptimizedTapsOnState(state)); assertThrows(OpenRaoException.class, () -> failedRaoResultImpl.getOptimizedSetPointsOnState(state)); - assertThrows(OpenRaoException.class, failedRaoResultImpl::getOptimizationStepsExecuted); - assertThrows(OpenRaoException.class, () -> failedRaoResultImpl.setOptimizationStepsExecuted(OptimizationStepsExecuted.FIRST_PREVENTIVE_ONLY)); assertThrows(OpenRaoException.class, failedRaoResultImpl::isSecure); Exception e = assertThrows(OpenRaoException.class, () -> failedRaoResultImpl.isSecure(optInstant, PhysicalParameter.FLOW)); assertEquals("This method should not be used, because the RAO failed: mocked error message 1", e.getMessage()); - assertEquals("mocked error message 1", failedRaoResultImpl.getFailureReason()); + assertEquals("mocked error message 1", failedRaoResultImpl.getExecutionDetails()); } @Test @@ -82,7 +79,7 @@ void testAngleAndVoltageCnec() { assertThrows(OpenRaoException.class, () -> failedRaoResultImpl.getVoltage(optInstant, voltageCnec, MinOrMax.MAX, MEGAWATT)); Exception e = assertThrows(OpenRaoException.class, () -> failedRaoResultImpl.getAngle(optInstant, angleCnec, MEGAWATT)); assertEquals("Angle cnecs are not computed in the rao", e.getMessage()); - assertEquals("mocked error message 2", failedRaoResultImpl.getFailureReason()); + assertEquals("mocked error message 2", failedRaoResultImpl.getExecutionDetails()); } @Test @@ -98,6 +95,6 @@ void testgetFlowAndMargin() { assertThrows(OpenRaoException.class, () -> failedRaoResultImpl.getMargin(optInstant, flowCnec, MEGAWATT)); Exception e = assertThrows(OpenRaoException.class, () -> failedRaoResultImpl.getRelativeMargin(optInstant, flowCnec, MEGAWATT)); assertEquals("This method should not be used, because the RAO failed: mocked error message 3", e.getMessage()); - assertEquals("mocked error message 3", failedRaoResultImpl.getFailureReason()); + assertEquals("mocked error message 3", failedRaoResultImpl.getExecutionDetails()); } } diff --git a/ra-optimisation/search-tree-rao/src/test/java/com/powsybl/openrao/searchtreerao/result/impl/OneStateOnlyRaoResultImplTest.java b/ra-optimisation/search-tree-rao/src/test/java/com/powsybl/openrao/searchtreerao/result/impl/OneStateOnlyRaoResultImplTest.java index 1d4014dc7f..84a759ccf0 100644 --- a/ra-optimisation/search-tree-rao/src/test/java/com/powsybl/openrao/searchtreerao/result/impl/OneStateOnlyRaoResultImplTest.java +++ b/ra-optimisation/search-tree-rao/src/test/java/com/powsybl/openrao/searchtreerao/result/impl/OneStateOnlyRaoResultImplTest.java @@ -426,15 +426,9 @@ void testCurativeCase2() { @Test void testOptimizedStepsExecuted() { - assertFalse(output.getOptimizationStepsExecuted().hasRunSecondPreventive()); - output.setOptimizationStepsExecuted(OptimizationStepsExecuted.SECOND_PREVENTIVE_IMPROVED_FIRST); - assertTrue(output.getOptimizationStepsExecuted().hasRunSecondPreventive()); - OpenRaoException exception = assertThrows(OpenRaoException.class, () -> output.setOptimizationStepsExecuted(OptimizationStepsExecuted.FIRST_PREVENTIVE_ONLY)); - assertEquals("The RaoResult object should not be modified outside of its usual routine", exception.getMessage()); - exception = assertThrows(OpenRaoException.class, () -> output.setOptimizationStepsExecuted(OptimizationStepsExecuted.SECOND_PREVENTIVE_FELLBACK_TO_FIRST_PREVENTIVE_SITUATION)); - assertEquals("The RaoResult object should not be modified outside of its usual routine", exception.getMessage()); - exception = assertThrows(OpenRaoException.class, () -> output.setOptimizationStepsExecuted(OptimizationStepsExecuted.FIRST_PREVENTIVE_FELLBACK_TO_INITIAL_SITUATION)); - assertEquals("The RaoResult object should not be modified outside of its usual routine", exception.getMessage()); + assertEquals(OptimizationStepsExecuted.FIRST_PREVENTIVE_ONLY, output.getExecutionDetails()); + output.setExecutionDetails(OptimizationStepsExecuted.SECOND_PREVENTIVE_IMPROVED_FIRST); + assertEquals(OptimizationStepsExecuted.SECOND_PREVENTIVE_IMPROVED_FIRST, output.getExecutionDetails()); } @Test diff --git a/ra-optimisation/search-tree-rao/src/test/java/com/powsybl/openrao/searchtreerao/result/impl/PreventiveAndCurativesRaoResultImplTest.java b/ra-optimisation/search-tree-rao/src/test/java/com/powsybl/openrao/searchtreerao/result/impl/PreventiveAndCurativesRaoResultImplTest.java index 66d081bf45..61283677c3 100644 --- a/ra-optimisation/search-tree-rao/src/test/java/com/powsybl/openrao/searchtreerao/result/impl/PreventiveAndCurativesRaoResultImplTest.java +++ b/ra-optimisation/search-tree-rao/src/test/java/com/powsybl/openrao/searchtreerao/result/impl/PreventiveAndCurativesRaoResultImplTest.java @@ -1035,15 +1035,9 @@ void testWithFinalCostEvaluator() { @Test void testOptimizedStepsExecuted() { setUp(); - assertFalse(output.getOptimizationStepsExecuted().hasRunSecondPreventive()); - output.setOptimizationStepsExecuted(OptimizationStepsExecuted.SECOND_PREVENTIVE_IMPROVED_FIRST); - assertTrue(output.getOptimizationStepsExecuted().hasRunSecondPreventive()); - OpenRaoException exception = assertThrows(OpenRaoException.class, () -> output.setOptimizationStepsExecuted(OptimizationStepsExecuted.FIRST_PREVENTIVE_ONLY)); - assertEquals("The RaoResult object should not be modified outside of its usual routine", exception.getMessage()); - exception = assertThrows(OpenRaoException.class, () -> output.setOptimizationStepsExecuted(OptimizationStepsExecuted.SECOND_PREVENTIVE_FELLBACK_TO_FIRST_PREVENTIVE_SITUATION)); - assertEquals("The RaoResult object should not be modified outside of its usual routine", exception.getMessage()); - exception = assertThrows(OpenRaoException.class, () -> output.setOptimizationStepsExecuted(OptimizationStepsExecuted.FIRST_PREVENTIVE_FELLBACK_TO_INITIAL_SITUATION)); - assertEquals("The RaoResult object should not be modified outside of its usual routine", exception.getMessage()); + assertEquals(OptimizationStepsExecuted.FIRST_PREVENTIVE_ONLY, output.getExecutionDetails()); + output.setExecutionDetails(OptimizationStepsExecuted.SECOND_PREVENTIVE_IMPROVED_FIRST); + assertEquals(OptimizationStepsExecuted.SECOND_PREVENTIVE_IMPROVED_FIRST, output.getExecutionDetails()); } @Test diff --git a/ra-optimisation/search-tree-rao/src/test/java/com/powsybl/openrao/searchtreerao/result/impl/UnoptimizedRaoResultImplTest.java b/ra-optimisation/search-tree-rao/src/test/java/com/powsybl/openrao/searchtreerao/result/impl/UnoptimizedRaoResultImplTest.java index 723a0ab7e3..e02509e666 100644 --- a/ra-optimisation/search-tree-rao/src/test/java/com/powsybl/openrao/searchtreerao/result/impl/UnoptimizedRaoResultImplTest.java +++ b/ra-optimisation/search-tree-rao/src/test/java/com/powsybl/openrao/searchtreerao/result/impl/UnoptimizedRaoResultImplTest.java @@ -273,15 +273,9 @@ void testGetActivatedRangeActionsDuringState() { @Test void testOptimizedStepsExecuted() { setUp(); - assertFalse(output.getOptimizationStepsExecuted().hasRunSecondPreventive()); - output.setOptimizationStepsExecuted(OptimizationStepsExecuted.SECOND_PREVENTIVE_FELLBACK_TO_FIRST_PREVENTIVE_SITUATION); - assertTrue(output.getOptimizationStepsExecuted().hasRunSecondPreventive()); - OpenRaoException exception = assertThrows(OpenRaoException.class, () -> output.setOptimizationStepsExecuted(OptimizationStepsExecuted.FIRST_PREVENTIVE_ONLY)); - assertEquals("The RaoResult object should not be modified outside of its usual routine", exception.getMessage()); - exception = assertThrows(OpenRaoException.class, () -> output.setOptimizationStepsExecuted(OptimizationStepsExecuted.SECOND_PREVENTIVE_FELLBACK_TO_FIRST_PREVENTIVE_SITUATION)); - assertEquals("The RaoResult object should not be modified outside of its usual routine", exception.getMessage()); - exception = assertThrows(OpenRaoException.class, () -> output.setOptimizationStepsExecuted(OptimizationStepsExecuted.FIRST_PREVENTIVE_FELLBACK_TO_INITIAL_SITUATION)); - assertEquals("The RaoResult object should not be modified outside of its usual routine", exception.getMessage()); + assertEquals(OptimizationStepsExecuted.FIRST_PREVENTIVE_ONLY, output.getExecutionDetails()); + output.setExecutionDetails(OptimizationStepsExecuted.SECOND_PREVENTIVE_FELLBACK_TO_FIRST_PREVENTIVE_SITUATION); + assertEquals(OptimizationStepsExecuted.SECOND_PREVENTIVE_FELLBACK_TO_FIRST_PREVENTIVE_SITUATION, output.getExecutionDetails()); } @Test diff --git a/tests/src/test/java/com/powsybl/openrao/tests/steps/SearchTreeRaoSteps.java b/tests/src/test/java/com/powsybl/openrao/tests/steps/SearchTreeRaoSteps.java index b725694923..a2d2af8bec 100644 --- a/tests/src/test/java/com/powsybl/openrao/tests/steps/SearchTreeRaoSteps.java +++ b/tests/src/test/java/com/powsybl/openrao/tests/steps/SearchTreeRaoSteps.java @@ -701,8 +701,8 @@ private Pair getWorstCnec(Unit unit, boolean relative) { RaoResult infos */ - @Then("the optimization steps executed by the RAO should be {string}") + @Then("the execution details should be {string}") public void getOptimizationSteps(String string) { - assertEquals(string, raoResult.getOptimizationStepsExecuted().toString()); + assertEquals(string, raoResult.getExecutionDetails()); } } diff --git a/tests/src/test/resources/com/powsybl/openrao/tests/features/epic13_curative/US13_5.feature b/tests/src/test/resources/com/powsybl/openrao/tests/features/epic13_curative/US13_5.feature index 062a5b05bc..a3a09e5fbc 100644 --- a/tests/src/test/resources/com/powsybl/openrao/tests/features/epic13_curative/US13_5.feature +++ b/tests/src/test/resources/com/powsybl/openrao/tests/features/epic13_curative/US13_5.feature @@ -179,7 +179,7 @@ Feature: US 13.5: dynamic of range actions available in several instants And the remedial action "cra_pst_fr" is not used after "CO1_fr2_fr3_1" at "curative" And the remedial action "cra_pst_be" is used after "CO1_fr2_fr3_1" at "curative" And the worst margin is 996 A - Then the optimization steps executed by the RAO should be "SECOND_PREVENTIVE_IMPROVED_FIRST" + Then the execution details should be "Second preventive improved first preventive results" @fast @rao @mock @ac @second-preventive Scenario: US 13.5.11.bis: CBCORA, CRA and PRA on same PSTs, with global 2P optimisation @@ -202,4 +202,4 @@ Feature: US 13.5: dynamic of range actions available in several instants # And the tap of PstRangeAction "pra_pst_be" should be 15 after "CO1_fr2_fr3_1" at "curative" # does not work currently: expected behaviour not clear yet in that case And the worst margin is 995 A - Then the optimization steps executed by the RAO should be "SECOND_PREVENTIVE_IMPROVED_FIRST" \ No newline at end of file + Then the execution details should be "Second preventive improved first preventive results" \ No newline at end of file diff --git a/tests/src/test/resources/com/powsybl/openrao/tests/features/epic15_specific_network_elements/epic15_11/US15_11_4.feature b/tests/src/test/resources/com/powsybl/openrao/tests/features/epic15_specific_network_elements/epic15_11/US15_11_4.feature index 07d6db6b12..2b502eec6e 100644 --- a/tests/src/test/resources/com/powsybl/openrao/tests/features/epic15_specific_network_elements/epic15_11/US15_11_4.feature +++ b/tests/src/test/resources/com/powsybl/openrao/tests/features/epic15_specific_network_elements/epic15_11/US15_11_4.feature @@ -23,7 +23,7 @@ Feature: US 15.11.4: ARAO with 2P And the value of the objective function after CRA should be 140 And the margin on cnec "FR2-FR3-O - preventive" after PRA should be -140 MW And the margin on cnec "NL2-BE3-O - curative" after CRA should be 0 MW - Then the optimization steps executed by the RAO should be "SECOND_PREVENTIVE_IMPROVED_FIRST" + Then the execution details should be "Second preventive improved first preventive results" @fast @rao @mock @ac @second-preventive @mnec Scenario: US 15.11.4.2: ARAO2 @@ -41,4 +41,4 @@ Feature: US 15.11.4: ARAO with 2P And the worst margin is -141 MW And the value of the objective function after CRA should be 141 And the margin on cnec "NL2-BE3-O - curative" after CRA should be 224 MW - Then the optimization steps executed by the RAO should be "SECOND_PREVENTIVE_IMPROVED_FIRST" \ No newline at end of file + Then the execution details should be "Second preventive improved first preventive results" \ No newline at end of file diff --git a/tests/src/test/resources/com/powsybl/openrao/tests/features/epic15_specific_network_elements/epic15_11/US15_11_5.feature b/tests/src/test/resources/com/powsybl/openrao/tests/features/epic15_specific_network_elements/epic15_11/US15_11_5.feature index ed1bb8b3c2..7c20e56974 100644 --- a/tests/src/test/resources/com/powsybl/openrao/tests/features/epic15_specific_network_elements/epic15_11/US15_11_5.feature +++ b/tests/src/test/resources/com/powsybl/openrao/tests/features/epic15_specific_network_elements/epic15_11/US15_11_5.feature @@ -23,7 +23,7 @@ Feature: US 15.11.5: Additional tests to check various fixes concerning automato Given configuration file is "epic15/RaoParameters_ep15us11-5-2.json" When I launch search_tree_rao And the margin on cnec "de2_nl3_co1 - DDE2AA11->NNL3AA11 - co1_de2_nl3 - curative" after PRA should be -2519.05 MW - And the optimization steps executed by the RAO should be "FIRST_PREVENTIVE_ONLY" + And the execution details should be "The RAO only went through first preventive" @fast @rao @mock @dc @contingency-scenarios Scenario: US 15.11.5.3.1: test get highest functional cost worst cnec is a curative after 1PRAO @@ -62,7 +62,7 @@ Feature: US 15.11.5: Additional tests to check various fixes concerning automato And the margin on cnec "be1_be3_co1 - BBE1AA11->BBE3AA11 - co1_fr2_de3 - curative" after PRA should be -293.5 MW And the margin on cnec "be1_be3_co1 - BBE1AA11->BBE3AA11 - co1_fr2_de3 - auto" after ARA should be -360.65 MW And the margin on cnec "be1_be3_co1 - BBE1AA11->BBE3AA11 - co1_fr2_de3 - curative" after CRA should be 112.7 MW - And the optimization steps executed by the RAO should be "SECOND_PREVENTIVE_IMPROVED_FIRST" + And the execution details should be "Second preventive improved first preventive results" @fast @rao @mock @dc @contingency-scenarios Scenario: US 15.11.5.5: RaoResult AFTER PRA fixed for curative cnecs, without 2P @@ -77,7 +77,7 @@ Feature: US 15.11.5: Additional tests to check various fixes concerning automato And the margin on cnec "be1_be3_co1 - BBE1AA11->BBE3AA11 - co1_fr2_de3 - curative" after PRA should be -302.38 MW And the margin on cnec "be1_be3_co1 - BBE1AA11->BBE3AA11 - co1_fr2_de3 - auto" after ARA should be -223.44 MW And the margin on cnec "be1_be3_co1 - BBE1AA11->BBE3AA11 - co1_fr2_de3 - curative" after CRA should be 240.61 MW - And the optimization steps executed by the RAO should be "FIRST_PREVENTIVE_ONLY" + And the execution details should be "The RAO only went through first preventive" @fast @rao @mock @dc @second-preventive Scenario: US 15.11.5.6: Considering ARA in 2P improves 2P optimization @@ -90,4 +90,4 @@ Feature: US 15.11.5: Additional tests to check various fixes concerning automato And the margin on cnec "BE1-BE3 - preventive" after PRA should be 1500 MW And the margin on cnec "NL3-DE2 - curative" after PRA should be -1444 MW And the margin on cnec "NL3-DE2 - curative" after CRA should be 1385 MW - And the optimization steps executed by the RAO should be "SECOND_PREVENTIVE_IMPROVED_FIRST" + And the execution details should be "Second preventive improved first preventive results" diff --git a/tests/src/test/resources/com/powsybl/openrao/tests/features/epic20_advanced_search_tree/US20_1.feature b/tests/src/test/resources/com/powsybl/openrao/tests/features/epic20_advanced_search_tree/US20_1.feature index a736c18133..af73128a32 100644 --- a/tests/src/test/resources/com/powsybl/openrao/tests/features/epic20_advanced_search_tree/US20_1.feature +++ b/tests/src/test/resources/com/powsybl/openrao/tests/features/epic20_advanced_search_tree/US20_1.feature @@ -18,7 +18,7 @@ Feature: US 20.1: enable second optimization of the preventive perimeter And the tap of PstRangeAction "pst_be" should be -16 in preventive And the margin on cnec "FFR1AA1 FFR4AA1 1 - co1_fr2_fr3_1 - curative" after CRA should be 321 A And the margin on cnec "FFR3AA1 FFR5AA1 1 - co1_fr2_fr3_1 - curative" after CRA should be 501 A - Then the optimization steps executed by the RAO should be "SECOND_PREVENTIVE_IMPROVED_FIRST" + Then the execution details should be "Second preventive improved first preventive results" @fast @rao @mock @ac @second-preventive Scenario: US 20.1.1.2: Same case as US 20.1.1 with a limitation of 2 RAs in preventive @@ -145,7 +145,7 @@ Feature: US 20.1: enable second optimization of the preventive perimeter And the worst margin is 638 A And the margin on cnec "FFR4AA1 DDE1AA1 1 - preventive" after PRA should be 638 A And the margin on cnec "FFR1AA1 FFR4AA1 1 - co1_fr2_fr3_1 - curative" after CRA should be 645 A - Then the optimization steps executed by the RAO should be "SECOND_PREVENTIVE_IMPROVED_FIRST" + Then the execution details should be "Second preventive improved first preventive results" @fast @rao @mock @ac @second-preventive Scenario: US 20.1.3: Preventive and curative network actions 2/3 @@ -164,7 +164,7 @@ Feature: US 20.1: enable second optimization of the preventive perimeter And the margin on cnec "FFR4AA1 DDE1AA1 1 - co1_fr2_fr3_1 - curative" after CRA should be -291 A And the margin on cnec "FFR2AA1 DDE3AA1 1 - preventive" after PRA should be -277 A And the margin on cnec "FFR2AA1 DDE3AA1 1 - co1_fr2_fr3_1 - outage" after PRA should be 36 A - Then the optimization steps executed by the RAO should be "SECOND_PREVENTIVE_IMPROVED_FIRST" + Then the execution details should be "Second preventive improved first preventive results" @fast @rao @mock @ac @second-preventive Scenario: US 20.1.4: Preventive and curative network actions 3/3 @@ -183,7 +183,7 @@ Feature: US 20.1: enable second optimization of the preventive perimeter And the margin on cnec "FFR4AA1 DDE1AA1 1 - co1_fr2_fr3_1 - curative" after CRA should be -291 A And the margin on cnec "FFR2AA1 DDE3AA1 1 - preventive" after PRA should be -277 A And the margin on cnec "FFR2AA1 DDE3AA1 1 - co1_fr2_fr3_1 - outage" after PRA should be 36 A - Then the optimization steps executed by the RAO should be "SECOND_PREVENTIVE_IMPROVED_FIRST" + Then the execution details should be "Second preventive improved first preventive results" @fast @rao @mock @ac @second-preventive Scenario: US 20.1.5: Duplicated RA on the same PST, one being a PRA and the other one being a CRA @@ -205,7 +205,7 @@ Feature: US 20.1: enable second optimization of the preventive perimeter And the margin on cnec "FFR2AA1 FFR3AA1 2 - co1_fr2_fr3_1 - curative" after CRA should be 535 A And the margin on cnec "FFR3AA1 FFR5AA1 1 - co1_fr2_fr3_1 - curative" after CRA should be 963 A And the margin on cnec "FFR3AA1 FFR5AA1 1 - co1_fr2_fr3_1 - outage" after PRA should be 1148 A - Then the optimization steps executed by the RAO should be "SECOND_PREVENTIVE_IMPROVED_FIRST" + Then the execution details should be "Second preventive improved first preventive results" @fast @rao @mock @ac @second-preventive Scenario: US 20.1.6: Same test as 20.1.5 but the CRA has a relative to previous instant range @@ -223,7 +223,7 @@ Feature: US 20.1: enable second optimization of the preventive perimeter And the tap of PstRangeAction "pst_be" should be -16 after "co1_fr2_fr3_1" at "curative" # The margin is way worse as we cannot re-optimize the preventive PST Then the worst margin is -184 A - Then the optimization steps executed by the RAO should be "SECOND_PREVENTIVE_IMPROVED_FIRST" + Then the execution details should be "Second preventive improved first preventive results" @fast @rao @mock @ac @second-preventive @@ -244,4 +244,4 @@ Feature: US 20.1: enable second optimization of the preventive perimeter And the margin on cnec "fr4_de1_CO1 - curative" after CRA should be 738 A And the margin on cnec "fr4_de1_CO1 - outage" after PRA should be 848 A And the margin on cnec "fr3_fr5_CO1 - DIR - curative" after CRA should be 861 A - Then the optimization steps executed by the RAO should be "SECOND_PREVENTIVE_IMPROVED_FIRST" \ No newline at end of file + Then the execution details should be "Second preventive improved first preventive results" \ No newline at end of file diff --git a/tests/src/test/resources/com/powsybl/openrao/tests/features/epic20_advanced_search_tree/US20_2.feature b/tests/src/test/resources/com/powsybl/openrao/tests/features/epic20_advanced_search_tree/US20_2.feature index 6f52d4be95..abe0999693 100644 --- a/tests/src/test/resources/com/powsybl/openrao/tests/features/epic20_advanced_search_tree/US20_2.feature +++ b/tests/src/test/resources/com/powsybl/openrao/tests/features/epic20_advanced_search_tree/US20_2.feature @@ -19,7 +19,7 @@ Feature: US 20.2: Handle loopflows in second preventive optimization And the loopflow threshold on cnec "003_FR-DE - curative" should be 250 MW And the initial loopflow on cnec "003_FR-DE - curative" should be -342 MW And the loopflow on cnec "003_FR-DE - curative" after CRA should be -341 MW - Then the optimization steps executed by the RAO should be "SECOND_PREVENTIVE_IMPROVED_FIRST" + Then the execution details should be "Second preventive improved first preventive results" @fast @rao @mock @dc @second-preventive @loopflow Scenario: US 20.2.2: LF constraint in curative is solved by CRA + 2P @@ -37,7 +37,7 @@ Feature: US 20.2: Handle loopflows in second preventive optimization And the loopflow threshold on cnec "003_FR-DE - curative" should be 250 MW And the initial loopflow on cnec "003_FR-DE - curative" should be -342 MW And the loopflow on cnec "003_FR-DE - curative" after CRA should be -323 MW - Then the optimization steps executed by the RAO should be "SECOND_PREVENTIVE_IMPROVED_FIRST" + Then the execution details should be "Second preventive improved first preventive results" @fast @rao @mock @dc @second-preventive @loopflow Scenario: US 20.2.3: LF constraint avoided on preventive CNEC in 2P @@ -56,4 +56,4 @@ Feature: US 20.2: Handle loopflows in second preventive optimization And the initial loopflow on cnec "001_FR-DE - preventive" should be -124 MW And the loopflow on cnec "001_FR-DE - preventive" after PRA should be -297 MW # Doesn't run 2P because LF constraint is already seen in 1P as the CNEC is preventive - Then the optimization steps executed by the RAO should be "FIRST_PREVENTIVE_ONLY" \ No newline at end of file + Then the execution details should be "The RAO only went through first preventive" \ No newline at end of file diff --git a/tests/src/test/resources/com/powsybl/openrao/tests/features/epic20_advanced_search_tree/US20_4.feature b/tests/src/test/resources/com/powsybl/openrao/tests/features/epic20_advanced_search_tree/US20_4.feature index 85143e2d0d..0cca6809ba 100644 --- a/tests/src/test/resources/com/powsybl/openrao/tests/features/epic20_advanced_search_tree/US20_4.feature +++ b/tests/src/test/resources/com/powsybl/openrao/tests/features/epic20_advanced_search_tree/US20_4.feature @@ -19,7 +19,7 @@ Feature: US 20.4: Handle MNECs in second preventive optimization And the value of the objective function after CRA should be 168 And the margin on cnec "FR2-FR3-O - preventive" after PRA should be -168 MW And the margin on cnec "NL2-BE3-O - curative" after CRA should be 7 MW - Then the optimization steps executed by the RAO should be "SECOND_PREVENTIVE_IMPROVED_FIRST" + Then the execution details should be "Second preventive improved first preventive results" @fast @rao @mock @ac @second-preventive @mnec Scenario: US 20.4.2: MNEC constraint in curative is solved by CRA + 2P @@ -36,7 +36,7 @@ Feature: US 20.4: Handle MNECs in second preventive optimization And the value of the objective function after CRA should be 161 And the margin on cnec "FR2-FR3-O - preventive" after PRA should be -161 MW And the margin on cnec "NL2-BE3-O - curative" after CRA should be 7 MW - Then the optimization steps executed by the RAO should be "SECOND_PREVENTIVE_IMPROVED_FIRST" + Then the execution details should be "Second preventive improved first preventive results" @fast @rao @mock @ac @second-preventive @mnec Scenario: US 20.4.3: MNEC constraint avoided on preventive MNEC in 2P @@ -51,4 +51,4 @@ Feature: US 20.4: Handle MNECs in second preventive optimization And the margin on cnec "NL1-NL3-D - curative" after CRA should be -182 MW And the margin on cnec "NL2-BE3-O - curative" after CRA should be -145 MW And the margin on cnec "FR2-FR3-O - preventive" after PRA should be -96 MW - Then the optimization steps executed by the RAO should be "SECOND_PREVENTIVE_IMPROVED_FIRST" \ No newline at end of file + Then the execution details should be "Second preventive improved first preventive results" \ No newline at end of file diff --git a/tests/src/test/resources/com/powsybl/openrao/tests/features/epic20_advanced_search_tree/US20_5.feature b/tests/src/test/resources/com/powsybl/openrao/tests/features/epic20_advanced_search_tree/US20_5.feature index c4abc8fed1..9af6e415fa 100644 --- a/tests/src/test/resources/com/powsybl/openrao/tests/features/epic20_advanced_search_tree/US20_5.feature +++ b/tests/src/test/resources/com/powsybl/openrao/tests/features/epic20_advanced_search_tree/US20_5.feature @@ -13,7 +13,7 @@ Feature: US 20.5: Advanced 2nd preventive run conditions When I launch search_tree_rao Then the worst margin is -144 A And the value of the objective function after CRA should be 144 - Then the optimization steps executed by the RAO should be "FIRST_PREVENTIVE_ONLY" + Then the execution details should be "The RAO only went through first preventive" @fast @rao @mock @ac @second-preventive Scenario: US 20.5.2: Cost has increased during RAO, fall back to initial solution (copy of 20.1.2) @@ -26,7 +26,7 @@ Feature: US 20.5: Advanced 2nd preventive run conditions And the tap of PstRangeAction "pst_be" should be 0 after "co1_fr2_fr3_1" at "curative" And the worst margin is 113 A And the value of the objective function after CRA should be -113 - Then the optimization steps executed by the RAO should be "FIRST_PREVENTIVE_FELLBACK_TO_INITIAL_SITUATION" + Then the execution details should be "First preventive fell back to initial situation" @fast @rao @mock @ac @second-preventive Scenario: US 20.5.3: Cost has not increased during RAO, do not run 2P (copy of 20.1.1) @@ -36,7 +36,7 @@ Feature: US 20.5: Advanced 2nd preventive run conditions When I launch search_tree_rao Then the worst margin is -144 A And the value of the objective function after CRA should be 144 - Then the optimization steps executed by the RAO should be "FIRST_PREVENTIVE_ONLY" + Then the execution details should be "The RAO only went through first preventive" @fast @rao @mock @ac @second-preventive Scenario: US 20.5.4: Cost has increased during RAO, run 2P (copy of 20.1.2) @@ -53,7 +53,7 @@ Feature: US 20.5: Advanced 2nd preventive run conditions And the worst margin is 638 A And the margin on cnec "FFR4AA1 DDE1AA1 1 - preventive" after PRA should be 638 A And the margin on cnec "FFR1AA1 FFR4AA1 1 - co1_fr2_fr3_1 - curative" after CRA should be 645 A - Then the optimization steps executed by the RAO should be "SECOND_PREVENTIVE_IMPROVED_FIRST" + Then the execution details should be "Second preventive improved first preventive results" @fast @rao @mock @ac @second-preventive Scenario: US 20.5.5: Not enough time to run 2P (copy of 20.1.1) @@ -63,7 +63,7 @@ Feature: US 20.5: Advanced 2nd preventive run conditions When I launch search_tree_rao with a time limit of -1 seconds Then the worst margin is -144 A And the value of the objective function after CRA should be 144 - Then the optimization steps executed by the RAO should be "FIRST_PREVENTIVE_ONLY" + Then the execution details should be "The RAO only went through first preventive" @fast @rao @mock @ac @second-preventive Scenario: US 20.5.6: Enough time to run 2P (copy of 20.1.1) @@ -74,4 +74,4 @@ Feature: US 20.5: Advanced 2nd preventive run conditions Then the worst margin is 321 A And the margin on cnec "FFR1AA1 FFR4AA1 1 - co1_fr2_fr3_1 - curative" after CRA should be 321 A And the margin on cnec "FFR3AA1 FFR5AA1 1 - co1_fr2_fr3_1 - curative" after CRA should be 501 A - Then the optimization steps executed by the RAO should be "SECOND_PREVENTIVE_IMPROVED_FIRST" \ No newline at end of file + Then the execution details should be "Second preventive improved first preventive results" \ No newline at end of file diff --git a/tests/src/test/resources/com/powsybl/openrao/tests/features/epic20_advanced_search_tree/US20_6.feature b/tests/src/test/resources/com/powsybl/openrao/tests/features/epic20_advanced_search_tree/US20_6.feature index 9a2e1c42b9..f5848b8d85 100644 --- a/tests/src/test/resources/com/powsybl/openrao/tests/features/epic20_advanced_search_tree/US20_6.feature +++ b/tests/src/test/resources/com/powsybl/openrao/tests/features/epic20_advanced_search_tree/US20_6.feature @@ -13,7 +13,7 @@ Feature: US 20.6: Second Preventive improvements When I launch search_tree_rao Then the worst margin is -40.5 MW And the tap of PstRangeAction "CRA_PST_DE" should be 0 after "Contingency NL3 BE1 2" at "curative" - Then the optimization steps executed by the RAO should be "SECOND_PREVENTIVE_IMPROVED_FIRST" + Then the execution details should be "Second preventive improved first preventive results" @fast @rao @mock @dc @second-preventive Scenario: US 20.6.2: Fallback to first preventive after 2nd preventive @@ -22,4 +22,4 @@ Feature: US 20.6: Second Preventive improvements Given configuration file is "epic20/RaoParameters_20_6_2.json" When I launch search_tree_rao Then the worst margin is 100.0 MW - And the optimization steps executed by the RAO should be "SECOND_PREVENTIVE_FELLBACK_TO_FIRST_PREVENTIVE_SITUATION" \ No newline at end of file + And the execution details should be "Second preventive fell back to first preventive results" \ No newline at end of file diff --git a/tests/src/test/resources/com/powsybl/openrao/tests/features/epic2_pst_range_actions/US2_3.feature b/tests/src/test/resources/com/powsybl/openrao/tests/features/epic2_pst_range_actions/US2_3.feature index c80fbb98e5..7686348d2d 100644 --- a/tests/src/test/resources/com/powsybl/openrao/tests/features/epic2_pst_range_actions/US2_3.feature +++ b/tests/src/test/resources/com/powsybl/openrao/tests/features/epic2_pst_range_actions/US2_3.feature @@ -51,4 +51,5 @@ Feature: US 2.3: Combine range PST and NetworkAction optimization Given crac file is "epic2/SL_ep2us3case4.json" Given configuration file is "common/RaoParameters_posMargin_ampere.json" When I launch search_tree_rao - Then the calculation fails \ No newline at end of file + Then the calculation fails + And the execution details should be "Initial sensitivity analysis failed" \ No newline at end of file diff --git a/tests/src/test/resources/com/powsybl/openrao/tests/features/epic4_dc_mw/US4_3.feature b/tests/src/test/resources/com/powsybl/openrao/tests/features/epic4_dc_mw/US4_3.feature index 24ea985a1b..58956e60c8 100644 --- a/tests/src/test/resources/com/powsybl/openrao/tests/features/epic4_dc_mw/US4_3.feature +++ b/tests/src/test/resources/com/powsybl/openrao/tests/features/epic4_dc_mw/US4_3.feature @@ -23,6 +23,7 @@ Feature: US 4.3: manage AC/DC modes from configuration Given configuration file is "epic4/RaoParameters_posMargin_ampere_ac_divergence.json" When I launch search_tree_rao Then the calculation fails + And the execution details should be "Initial sensitivity analysis failed" @fast @rao @mock @dc @preventive-only Scenario: US 4.3.3: no failure with DC config diff --git a/tests/src/test/resources/com/powsybl/openrao/tests/features/epic91_rao_enhancements/US91_12.feature b/tests/src/test/resources/com/powsybl/openrao/tests/features/epic91_rao_enhancements/US91_12.feature index 4d5e546382..ad975c2241 100644 --- a/tests/src/test/resources/com/powsybl/openrao/tests/features/epic91_rao_enhancements/US91_12.feature +++ b/tests/src/test/resources/com/powsybl/openrao/tests/features/epic91_rao_enhancements/US91_12.feature @@ -554,7 +554,7 @@ Feature: US 91.12: Multi-curative Given crac file is "epic91/crac_91_12_16.json" Given configuration file is "epic91/RaoParameters_case_91_12_secure.json" When I launch search_tree_rao - Then the optimization steps executed by the RAO should be "FIRST_PREVENTIVE_ONLY" + Then the execution details should be "The RAO only went through first preventive" And 3 remedial actions are used in preventive And the remedial action "PRA_PST_BE" is used in preventive And the tap of PstRangeAction "PRA_PST_BE" should be -11 in preventive @@ -573,7 +573,7 @@ Feature: US 91.12: Multi-curative Given crac file is "epic91/crac_91_12_17.json" Given configuration file is "epic91/RaoParameters_case_91_12_secure_2PRAO.json" When I launch search_tree_rao - Then the optimization steps executed by the RAO should be "SECOND_PREVENTIVE_IMPROVED_FIRST" + Then the execution details should be "Second preventive improved first preventive results" And 3 remedial actions are used in preventive And the remedial action "PRA_PST_BE" is used in preventive And the tap of PstRangeAction "PRA_PST_BE" should be -11 in preventive @@ -593,7 +593,7 @@ Feature: US 91.12: Multi-curative Given crac file is "epic91/crac_91_12_18.json" Given configuration file is "epic91/RaoParameters_case_91_12_secure_2PRAO.json" When I launch search_tree_rao - Then the optimization steps executed by the RAO should be "SECOND_PREVENTIVE_IMPROVED_FIRST" + Then the execution details should be "Second preventive improved first preventive results" # Initial And the initial flow on cnec "NNL2AA1 BBE3AA1 1 - preventive" should be 500.0 MW And the initial flow on cnec "NNL2AA1 BBE3AA1 1 - Contingency DE2 DE3 1 - outage" should be 583.33 MW @@ -633,7 +633,7 @@ Feature: US 91.12: Multi-curative Given crac file is "epic91/crac_91_12_19.json" Given configuration file is "epic91/RaoParameters_case_91_12_secure_2PRAO.json" When I launch search_tree_rao - Then the optimization steps executed by the RAO should be "SECOND_PREVENTIVE_IMPROVED_FIRST" + Then the execution details should be "Second preventive improved first preventive results" # Preventive And 1 remedial actions are used in preventive And the remedial action "PRA_CLOSE_NL2_BE3_2" is used in preventive @@ -667,7 +667,7 @@ Feature: US 91.12: Multi-curative Given crac file is "epic91/crac_91_12_20.json" Given configuration file is "epic91/RaoParameters_case_91_12_secure_2PRAO.json" When I launch search_tree_rao - Then the optimization steps executed by the RAO should be "SECOND_PREVENTIVE_IMPROVED_FIRST" + Then the execution details should be "Second preventive improved first preventive results" # Preventive And 1 remedial actions are used in preventive And the remedial action "PRA_CLOSE_NL2_BE3_3" is used in preventive