From 386a4a28d9c7d31fa187752306071d9cf8dea714 Mon Sep 17 00:00:00 2001 From: Thomas Bouquet Date: Mon, 25 Mar 2024 16:37:58 +0100 Subject: [PATCH] Change compatibility rule for switch pairs Signed-off-by: Thomas Bouquet --- .../com/powsybl/openrao/data/cracimpl/SwitchPairImpl.java | 3 +-- .../openrao/data/cracimpl/NetworkActionImplTest.java | 2 +- .../powsybl/openrao/data/cracimpl/SwitchPairImplTest.java | 8 ++++---- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/data/crac/crac-impl/src/main/java/com/powsybl/openrao/data/cracimpl/SwitchPairImpl.java b/data/crac/crac-impl/src/main/java/com/powsybl/openrao/data/cracimpl/SwitchPairImpl.java index 5626bf65da..91f996f671 100644 --- a/data/crac/crac-impl/src/main/java/com/powsybl/openrao/data/cracimpl/SwitchPairImpl.java +++ b/data/crac/crac-impl/src/main/java/com/powsybl/openrao/data/cracimpl/SwitchPairImpl.java @@ -61,8 +61,7 @@ public NetworkElement getSwitchToClose() { @Override public boolean isCompatibleWith(ElementaryAction otherElementaryAction) { if (otherElementaryAction instanceof SwitchPair switchPair) { - return !switchToOpen.equals(switchPair.getSwitchToOpen()) && !switchToOpen.equals(switchPair.getSwitchToClose()) && !switchToClose.equals(switchPair.getSwitchToClose()) && !switchToClose.equals(switchPair.getSwitchToOpen()) - || switchToOpen.equals(switchPair.getSwitchToOpen()) || switchToClose.equals(switchPair.getSwitchToClose()); + return !switchToOpen.equals(switchPair.getSwitchToOpen()) && !switchToOpen.equals(switchPair.getSwitchToClose()) && !switchToClose.equals(switchPair.getSwitchToClose()) && !switchToClose.equals(switchPair.getSwitchToOpen()); } return true; } diff --git a/data/crac/crac-impl/src/test/java/com/powsybl/openrao/data/cracimpl/NetworkActionImplTest.java b/data/crac/crac-impl/src/test/java/com/powsybl/openrao/data/cracimpl/NetworkActionImplTest.java index c7e5584d9e..8a612c4666 100644 --- a/data/crac/crac-impl/src/test/java/com/powsybl/openrao/data/cracimpl/NetworkActionImplTest.java +++ b/data/crac/crac-impl/src/test/java/com/powsybl/openrao/data/cracimpl/NetworkActionImplTest.java @@ -137,6 +137,6 @@ void compatibility() { assertTrue(crac.getNetworkAction("hvdc-es-fr-200-mw").isCompatibleWith(crac.getNetworkAction("switch-pair-and-pst"))); assertTrue(crac.getNetworkAction("aligned-psts").isCompatibleWith(crac.getNetworkAction("aligned-psts"))); assertFalse(crac.getNetworkAction("aligned-psts").isCompatibleWith(crac.getNetworkAction("switch-pair-and-pst"))); - assertTrue(crac.getNetworkAction("switch-pair-and-pst").isCompatibleWith(crac.getNetworkAction("switch-pair-and-pst"))); + assertFalse(crac.getNetworkAction("switch-pair-and-pst").isCompatibleWith(crac.getNetworkAction("switch-pair-and-pst"))); } } diff --git a/data/crac/crac-impl/src/test/java/com/powsybl/openrao/data/cracimpl/SwitchPairImplTest.java b/data/crac/crac-impl/src/test/java/com/powsybl/openrao/data/cracimpl/SwitchPairImplTest.java index 79005cb521..d8104f688b 100644 --- a/data/crac/crac-impl/src/test/java/com/powsybl/openrao/data/cracimpl/SwitchPairImplTest.java +++ b/data/crac/crac-impl/src/test/java/com/powsybl/openrao/data/cracimpl/SwitchPairImplTest.java @@ -119,7 +119,7 @@ void compatibility() { Crac crac = createCracWithRemedialActions(); SwitchPair switchPair = (SwitchPair) crac.getNetworkAction("open-switch-1-close-switch-2").getElementaryActions().iterator().next(); - assertTrue(switchPair.isCompatibleWith(switchPair)); + assertFalse(switchPair.isCompatibleWith(switchPair)); assertTrue(switchPair.isCompatibleWith(crac.getNetworkAction("open-switch-2").getElementaryActions().iterator().next())); assertTrue(switchPair.isCompatibleWith(crac.getNetworkAction("close-switch-1").getElementaryActions().iterator().next())); assertTrue(switchPair.isCompatibleWith(crac.getNetworkAction("close-switch-2").getElementaryActions().iterator().next())); @@ -134,10 +134,10 @@ void compatibility() { assertTrue(switchPair.isCompatibleWith(crac.getNetworkAction("pst-2-tap-3").getElementaryActions().iterator().next())); assertTrue(switchPair.isCompatibleWith(crac.getNetworkAction("pst-2-tap-8").getElementaryActions().iterator().next())); - assertTrue(switchPair.isCompatibleWith(crac.getNetworkAction("open-switch-1-close-switch-2").getElementaryActions().iterator().next())); + assertFalse(switchPair.isCompatibleWith(crac.getNetworkAction("open-switch-1-close-switch-2").getElementaryActions().iterator().next())); assertFalse(switchPair.isCompatibleWith(crac.getNetworkAction("open-switch-2-close-switch-1").getElementaryActions().iterator().next())); assertTrue(switchPair.isCompatibleWith(crac.getNetworkAction("open-switch-3-close-switch-4").getElementaryActions().iterator().next())); - assertTrue(switchPair.isCompatibleWith(crac.getNetworkAction("open-switch-1-close-switch-3").getElementaryActions().iterator().next())); - assertTrue(switchPair.isCompatibleWith(crac.getNetworkAction("open-switch-3-close-switch-2").getElementaryActions().iterator().next())); + assertFalse(switchPair.isCompatibleWith(crac.getNetworkAction("open-switch-1-close-switch-3").getElementaryActions().iterator().next())); + assertFalse(switchPair.isCompatibleWith(crac.getNetworkAction("open-switch-3-close-switch-2").getElementaryActions().iterator().next())); } }