diff --git a/pom.xml b/pom.xml
index 16120b9a75..0795050f1e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -48,7 +48,7 @@
5.5.2
1.6.2
- 4.2.0
+ 4.3.0-alpha-1
diff --git a/src/main/java/com/powsybl/openloadflow/sa/OpenSecurityAnalysis.java b/src/main/java/com/powsybl/openloadflow/sa/OpenSecurityAnalysis.java
index 5aa2155450..c1b8be480e 100644
--- a/src/main/java/com/powsybl/openloadflow/sa/OpenSecurityAnalysis.java
+++ b/src/main/java/com/powsybl/openloadflow/sa/OpenSecurityAnalysis.java
@@ -11,9 +11,13 @@
import com.powsybl.commons.reporter.Reporter;
import com.powsybl.contingency.ContingenciesProvider;
import com.powsybl.contingency.Contingency;
-import com.powsybl.iidm.network.*;
+import com.powsybl.iidm.network.Branch;
+import com.powsybl.iidm.network.Network;
+import com.powsybl.iidm.network.Switch;
+import com.powsybl.iidm.network.TopologyKind;
import com.powsybl.loadflow.LoadFlowParameters;
import com.powsybl.math.matrix.MatrixFactory;
+import com.powsybl.math.matrix.SparseMatrixFactory;
import com.powsybl.openloadflow.OpenLoadFlowParameters;
import com.powsybl.openloadflow.OpenLoadFlowProvider;
import com.powsybl.openloadflow.ac.nr.NewtonRaphsonStatus;
@@ -23,6 +27,7 @@
import com.powsybl.openloadflow.equations.Equation;
import com.powsybl.openloadflow.equations.EquationTerm;
import com.powsybl.openloadflow.equations.PreviousValueVoltageInitializer;
+import com.powsybl.openloadflow.graph.EvenShiloachGraphDecrementalConnectivity;
import com.powsybl.openloadflow.graph.GraphDecrementalConnectivity;
import com.powsybl.openloadflow.network.*;
import com.powsybl.openloadflow.network.util.ActivePowerDistribution;
@@ -30,7 +35,9 @@
import com.powsybl.openloadflow.util.LfContingency;
import com.powsybl.openloadflow.util.PropagatedContingency;
import com.powsybl.security.*;
+import com.powsybl.security.detectors.DefaultLimitViolationDetector;
import com.powsybl.security.interceptors.SecurityAnalysisInterceptor;
+import com.powsybl.security.results.PostContingencyResult;
import org.apache.commons.lang3.tuple.Pair;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -44,7 +51,7 @@
/**
* @author Geoffroy Jamgotchian
*/
-public class OpenSecurityAnalysis implements SecurityAnalysis {
+public class OpenSecurityAnalysis {
private static final Logger LOGGER = LoggerFactory.getLogger(OpenSecurityAnalysis.class);
@@ -62,6 +69,14 @@ public class OpenSecurityAnalysis implements SecurityAnalysis {
private static final double POST_CONTINGENCY_INCREASING_FACTOR = 1.1;
+ public OpenSecurityAnalysis(Network network) {
+ this(network, new DefaultLimitViolationDetector(), new LimitViolationFilter());
+ }
+
+ public OpenSecurityAnalysis(Network network, LimitViolationDetector detector, LimitViolationFilter filter) {
+ this(network, detector, filter, new SparseMatrixFactory(), EvenShiloachGraphDecrementalConnectivity::new);
+ }
+
public OpenSecurityAnalysis(Network network, LimitViolationDetector detector, LimitViolationFilter filter,
MatrixFactory matrixFactory, Supplier> connectivityProvider) {
this.network = Objects.requireNonNull(network);
@@ -71,31 +86,29 @@ public OpenSecurityAnalysis(Network network, LimitViolationDetector detector, Li
this.connectivityProvider = Objects.requireNonNull(connectivityProvider);
}
- @Override
public void addInterceptor(SecurityAnalysisInterceptor interceptor) {
interceptors.add(Objects.requireNonNull(interceptor));
}
- @Override
public boolean removeInterceptor(SecurityAnalysisInterceptor interceptor) {
return interceptors.remove(Objects.requireNonNull(interceptor));
}
- @Override
- public CompletableFuture run(String workingVariantId, SecurityAnalysisParameters securityAnalysisParameters, ContingenciesProvider contingenciesProvider) {
+ public CompletableFuture run(String workingVariantId, SecurityAnalysisParameters securityAnalysisParameters,
+ ContingenciesProvider contingenciesProvider) {
Objects.requireNonNull(workingVariantId);
Objects.requireNonNull(securityAnalysisParameters);
Objects.requireNonNull(contingenciesProvider);
return CompletableFuture.supplyAsync(() -> {
String oldWorkingVariantId = network.getVariantManager().getWorkingVariantId();
network.getVariantManager().setWorkingVariant(workingVariantId);
- SecurityAnalysisResult result = runSync(securityAnalysisParameters, contingenciesProvider);
+ SecurityAnalysisReport result = runSync(securityAnalysisParameters, contingenciesProvider);
network.getVariantManager().setWorkingVariant(oldWorkingVariantId);
return result;
});
}
- SecurityAnalysisResult runSync(SecurityAnalysisParameters securityAnalysisParameters, ContingenciesProvider contingenciesProvider) {
+ SecurityAnalysisReport runSync(SecurityAnalysisParameters securityAnalysisParameters, ContingenciesProvider contingenciesProvider) {
Stopwatch stopwatch = Stopwatch.createStarted();
LoadFlowParameters lfParameters = securityAnalysisParameters.getLoadFlowParameters();
@@ -129,7 +142,7 @@ SecurityAnalysisResult runSync(SecurityAnalysisParameters securityAnalysisParame
stopwatch.stop();
LOGGER.info("Security analysis done in {} ms", stopwatch.elapsed(TimeUnit.MILLISECONDS));
- return result;
+ return new SecurityAnalysisReport(result);
}
List createNetworks(Set allSwitchesToOpen, AcLoadFlowParameters acParameters) {
diff --git a/src/main/java/com/powsybl/openloadflow/sa/OpenSecurityAnalysisFactory.java b/src/main/java/com/powsybl/openloadflow/sa/OpenSecurityAnalysisFactory.java
deleted file mode 100644
index f5f0fdb2ee..0000000000
--- a/src/main/java/com/powsybl/openloadflow/sa/OpenSecurityAnalysisFactory.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/**
- * Copyright (c) 2020, 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.openloadflow.sa;
-
-import com.powsybl.computation.ComputationManager;
-import com.powsybl.iidm.network.Network;
-import com.powsybl.math.matrix.MatrixFactory;
-import com.powsybl.math.matrix.SparseMatrixFactory;
-import com.powsybl.openloadflow.graph.EvenShiloachGraphDecrementalConnectivity;
-import com.powsybl.openloadflow.graph.GraphDecrementalConnectivity;
-import com.powsybl.openloadflow.network.LfBus;
-import com.powsybl.security.LimitViolationDetector;
-import com.powsybl.security.LimitViolationFilter;
-import com.powsybl.security.SecurityAnalysisFactory;
-import com.powsybl.security.detectors.DefaultLimitViolationDetector;
-
-import java.util.Objects;
-import java.util.function.Supplier;
-
-/**
- * @author Geoffroy Jamgotchian
- */
-public class OpenSecurityAnalysisFactory implements SecurityAnalysisFactory {
-
- private final MatrixFactory matrixFactory;
-
- private final Supplier> connectivityProvider;
-
- public OpenSecurityAnalysisFactory() {
- this(new SparseMatrixFactory(), EvenShiloachGraphDecrementalConnectivity::new);
- }
-
- public OpenSecurityAnalysisFactory(MatrixFactory matrixFactory, Supplier> connectivityProvider) {
- this.matrixFactory = Objects.requireNonNull(matrixFactory);
- this.connectivityProvider = Objects.requireNonNull(connectivityProvider);
- }
-
- @Override
- public OpenSecurityAnalysis create(Network network, ComputationManager computationManager, int priority) {
- return new OpenSecurityAnalysis(network, new DefaultLimitViolationDetector(), new LimitViolationFilter(), matrixFactory, connectivityProvider);
- }
-
- @Override
- public OpenSecurityAnalysis create(Network network, LimitViolationFilter filter, ComputationManager computationManager, int priority) {
- return new OpenSecurityAnalysis(network, new DefaultLimitViolationDetector(), filter, matrixFactory, connectivityProvider);
- }
-
- @Override
- public OpenSecurityAnalysis create(Network network, LimitViolationDetector detector, LimitViolationFilter filter, ComputationManager computationManager, int priority) {
- return new OpenSecurityAnalysis(network, detector, filter, matrixFactory, connectivityProvider);
- }
-}
diff --git a/src/main/java/com/powsybl/openloadflow/sa/OpenSecurityAnalysisProvider.java b/src/main/java/com/powsybl/openloadflow/sa/OpenSecurityAnalysisProvider.java
new file mode 100644
index 0000000000..002334a05e
--- /dev/null
+++ b/src/main/java/com/powsybl/openloadflow/sa/OpenSecurityAnalysisProvider.java
@@ -0,0 +1,64 @@
+/**
+ * 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.openloadflow.sa;
+
+import com.google.auto.service.AutoService;
+import com.powsybl.computation.ComputationManager;
+import com.powsybl.contingency.ContingenciesProvider;
+import com.powsybl.iidm.network.Network;
+import com.powsybl.math.matrix.MatrixFactory;
+import com.powsybl.math.matrix.SparseMatrixFactory;
+import com.powsybl.openloadflow.graph.EvenShiloachGraphDecrementalConnectivity;
+import com.powsybl.openloadflow.graph.GraphDecrementalConnectivity;
+import com.powsybl.openloadflow.network.LfBus;
+import com.powsybl.openloadflow.util.PowsyblOpenLoadFlowVersion;
+import com.powsybl.security.*;
+import com.powsybl.security.interceptors.SecurityAnalysisInterceptor;
+
+import java.util.List;
+import java.util.concurrent.CompletableFuture;
+import java.util.function.Supplier;
+
+/**
+ * @author Florian Dupuy
+ */
+@AutoService(SecurityAnalysisProvider.class)
+public class OpenSecurityAnalysisProvider implements SecurityAnalysisProvider {
+
+ private final MatrixFactory matrixFactory;
+
+ private final Supplier> connectivityProvider;
+
+ public OpenSecurityAnalysisProvider(MatrixFactory matrixFactory, Supplier> connectivityProvider) {
+ this.matrixFactory = matrixFactory;
+ this.connectivityProvider = connectivityProvider;
+ }
+
+ public OpenSecurityAnalysisProvider() {
+ this(new SparseMatrixFactory(), EvenShiloachGraphDecrementalConnectivity::new);
+ }
+
+ @Override
+ public CompletableFuture run(Network network, String workingVariantId, LimitViolationDetector limitViolationDetector,
+ LimitViolationFilter limitViolationFilter, ComputationManager computationManager,
+ SecurityAnalysisParameters securityAnalysisParameters, ContingenciesProvider contingenciesProvider,
+ List interceptors) {
+ OpenSecurityAnalysis osa = new OpenSecurityAnalysis(network, limitViolationDetector, limitViolationFilter, matrixFactory, connectivityProvider);
+ interceptors.forEach(osa::addInterceptor);
+ return osa.run(workingVariantId, securityAnalysisParameters, contingenciesProvider);
+ }
+
+ @Override
+ public String getName() {
+ return "OpenSecurityAnalysis";
+ }
+
+ @Override
+ public String getVersion() {
+ return new PowsyblOpenLoadFlowVersion().toString();
+ }
+}
diff --git a/src/test/java/com/powsybl/openloadflow/sa/LfContingencyTest.java b/src/test/java/com/powsybl/openloadflow/sa/LfContingencyTest.java
index da608faa26..499b129130 100644
--- a/src/test/java/com/powsybl/openloadflow/sa/LfContingencyTest.java
+++ b/src/test/java/com/powsybl/openloadflow/sa/LfContingencyTest.java
@@ -11,10 +11,14 @@
import com.powsybl.contingency.Contingency;
import com.powsybl.iidm.network.Network;
import com.powsybl.iidm.network.test.FourSubstationsNodeBreakerFactory;
+import com.powsybl.math.matrix.DenseMatrixFactory;
+import com.powsybl.openloadflow.graph.EvenShiloachGraphDecrementalConnectivity;
import com.powsybl.openloadflow.network.LfNetwork;
import com.powsybl.openloadflow.network.MostMeshedSlackBusSelector;
import com.powsybl.openloadflow.util.LfContingency;
import com.powsybl.openloadflow.util.PropagatedContingency;
+import com.powsybl.security.LimitViolationFilter;
+import com.powsybl.security.detectors.DefaultLimitViolationDetector;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -55,7 +59,8 @@ void test() throws IOException {
LfNetwork mainNetwork = lfNetworks.get(0);
assertEquals(2, lfNetworks.size());
- OpenSecurityAnalysis sa = new OpenSecurityAnalysisFactory().create(network, null, 0);
+ OpenSecurityAnalysis sa = new OpenSecurityAnalysis(network, new DefaultLimitViolationDetector(),
+ new LimitViolationFilter(), new DenseMatrixFactory(), EvenShiloachGraphDecrementalConnectivity::new);
String branchId = "LINE_S3S4";
Contingency contingency = new Contingency(branchId, new BranchContingency(branchId));
diff --git a/src/test/java/com/powsybl/openloadflow/sa/OpenSecurityAnalysisTest.java b/src/test/java/com/powsybl/openloadflow/sa/OpenSecurityAnalysisTest.java
index c2c47d92c5..961b88e0cb 100644
--- a/src/test/java/com/powsybl/openloadflow/sa/OpenSecurityAnalysisTest.java
+++ b/src/test/java/com/powsybl/openloadflow/sa/OpenSecurityAnalysisTest.java
@@ -20,7 +20,10 @@
import com.powsybl.openloadflow.OpenLoadFlowParameters;
import com.powsybl.openloadflow.graph.EvenShiloachGraphDecrementalConnectivity;
import com.powsybl.openloadflow.graph.NaiveGraphDecrementalConnectivity;
-import com.powsybl.openloadflow.network.*;
+import com.powsybl.openloadflow.network.ConnectedComponentNetworkFactory;
+import com.powsybl.openloadflow.network.LfBus;
+import com.powsybl.openloadflow.network.NodeBreakerNetworkFactory;
+import com.powsybl.openloadflow.network.SlackBusSelectionMode;
import com.powsybl.security.*;
import com.powsybl.security.detectors.DefaultLimitViolationDetector;
import org.junit.jupiter.api.BeforeEach;
@@ -28,10 +31,10 @@
import java.io.StringWriter;
import java.util.Collections;
-import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.CompletionException;
import java.util.List;
import java.util.Optional;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.CompletionException;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@@ -92,13 +95,15 @@ void testCurrentLimitViolations() {
.map(id -> new Contingency(id, new BranchContingency(id)))
.collect(Collectors.toList());
- OpenSecurityAnalysisFactory osaFactory = new OpenSecurityAnalysisFactory(new DenseMatrixFactory(),
+ OpenSecurityAnalysisProvider osaProvider = new OpenSecurityAnalysisProvider(new DenseMatrixFactory(),
() -> new NaiveGraphDecrementalConnectivity<>(LfBus::getNum));
- OpenSecurityAnalysis securityAnalysis = osaFactory.create(network, null, 0);
+ CompletableFuture futureResult = osaProvider.run(network, network.getVariantManager().getWorkingVariantId(),
+ new DefaultLimitViolationDetector(), new LimitViolationFilter(), null, saParameters,
+ contingenciesProvider, Collections.emptyList());
- SecurityAnalysisResult result = securityAnalysis.runSync(saParameters, contingenciesProvider);
- assertTrue(result.getPreContingencyResult().isComputationOk());
- assertEquals(0, result.getPreContingencyResult().getLimitViolations().size());
+ SecurityAnalysisResult result = futureResult.join().getResult();
+ assertTrue(result.getPreContingencyResult().getLimitViolationsResult().isComputationOk());
+ assertEquals(0, result.getPreContingencyResult().getLimitViolationsResult().getLimitViolations().size());
assertEquals(2, result.getPostContingencyResults().size());
assertTrue(result.getPostContingencyResults().get(0).getLimitViolationsResult().isComputationOk());
assertEquals(2, result.getPostContingencyResults().get(0).getLimitViolationsResult().getLimitViolations().size());
@@ -118,13 +123,14 @@ void testCurrentLimitViolations2() {
.map(id -> new Contingency(id, new BranchContingency(id)))
.collect(Collectors.toList());
network.getLine("L1").getCurrentLimits1().setPermanentLimit(200);
- OpenSecurityAnalysisFactory osaFactory = new OpenSecurityAnalysisFactory(new DenseMatrixFactory(),
- () -> new NaiveGraphDecrementalConnectivity<>(LfBus::getNum));
- OpenSecurityAnalysis securityAnalysis = osaFactory.create(network, null, 0);
- SecurityAnalysisResult result = securityAnalysis.runSync(saParameters, contingenciesProvider);
- assertTrue(result.getPreContingencyResult().isComputationOk());
- assertEquals(1, result.getPreContingencyResult().getLimitViolations().size());
+ OpenSecurityAnalysis securityAnalysis = new OpenSecurityAnalysis(network, new DefaultLimitViolationDetector(),
+ new LimitViolationFilter(), new DenseMatrixFactory(), () -> new NaiveGraphDecrementalConnectivity<>(LfBus::getNum));
+
+ SecurityAnalysisReport report = securityAnalysis.runSync(saParameters, contingenciesProvider);
+ SecurityAnalysisResult result = report.getResult();
+ assertTrue(result.getPreContingencyResult().getLimitViolationsResult().isComputationOk());
+ assertEquals(1, result.getPreContingencyResult().getLimitViolationsResult().getLimitViolations().size());
assertEquals(1, result.getPostContingencyResults().size());
assertTrue(result.getPostContingencyResults().get(0).getLimitViolationsResult().isComputationOk());
assertEquals(2, result.getPostContingencyResults().get(0).getLimitViolationsResult().getLimitViolations().size());
@@ -146,12 +152,14 @@ void testLowVoltageLimitViolations() {
.map(id -> new Contingency(id, new BranchContingency(id)))
.collect(Collectors.toList());
- OpenSecurityAnalysisFactory osaFactory = new OpenSecurityAnalysisFactory();
- OpenSecurityAnalysis securityAnalysis = osaFactory.create(network, new LimitViolationFilter(), null, 0);
+ OpenSecurityAnalysisProvider osaProvider = new OpenSecurityAnalysisProvider();
+ CompletableFuture futureResult = osaProvider.run(network, network.getVariantManager().getWorkingVariantId(),
+ new DefaultLimitViolationDetector(), new LimitViolationFilter(), null, saParameters,
+ contingenciesProvider, Collections.emptyList());
- SecurityAnalysisResult result = securityAnalysis.runSync(saParameters, contingenciesProvider);
- assertTrue(result.getPreContingencyResult().isComputationOk());
- assertEquals(0, result.getPreContingencyResult().getLimitViolations().size());
+ SecurityAnalysisResult result = futureResult.join().getResult();
+ assertTrue(result.getPreContingencyResult().getLimitViolationsResult().isComputationOk());
+ assertEquals(0, result.getPreContingencyResult().getLimitViolationsResult().getLimitViolations().size());
assertEquals(2, result.getPostContingencyResults().size());
assertTrue(result.getPostContingencyResults().get(0).getLimitViolationsResult().isComputationOk());
assertEquals(3, result.getPostContingencyResults().get(0).getLimitViolationsResult().getLimitViolations().size());
@@ -190,12 +198,12 @@ void testHighVoltageLimitViolations() {
.map(id -> new Contingency(id, new BranchContingency(id)))
.collect(Collectors.toList());
- OpenSecurityAnalysisFactory osaFactory = new OpenSecurityAnalysisFactory();
- OpenSecurityAnalysis securityAnalysis = osaFactory.create(network, new LimitViolationFilter(), null, 0);
+ OpenSecurityAnalysis securityAnalysis = new OpenSecurityAnalysis(network);
- SecurityAnalysisResult result = securityAnalysis.runSync(saParameters, contingenciesProvider);
- assertTrue(result.getPreContingencyResult().isComputationOk());
- assertEquals(1, result.getPreContingencyResult().getLimitViolations().size());
+ SecurityAnalysisReport report = securityAnalysis.runSync(saParameters, contingenciesProvider);
+ SecurityAnalysisResult result = report.getResult();
+ assertTrue(result.getPreContingencyResult().getLimitViolationsResult().isComputationOk());
+ assertEquals(1, result.getPreContingencyResult().getLimitViolationsResult().getLimitViolations().size());
assertEquals(2, result.getPostContingencyResults().size());
assertTrue(result.getPostContingencyResults().get(0).getLimitViolationsResult().isComputationOk());
@@ -225,16 +233,15 @@ void testFourSubstations() {
.map(b -> new Contingency(b.getId(), new BranchContingency(b.getId())))
.collect(Collectors.toList());
- OpenSecurityAnalysisFactory osaFactory = new OpenSecurityAnalysisFactory(new DenseMatrixFactory(), EvenShiloachGraphDecrementalConnectivity::new);
- OpenSecurityAnalysis securityAnalysis = osaFactory.create(network, new DefaultLimitViolationDetector(),
- new LimitViolationFilter(), null, 0);
+ OpenSecurityAnalysis securityAnalysis = new OpenSecurityAnalysis(network, new DefaultLimitViolationDetector(),
+ new LimitViolationFilter(), new DenseMatrixFactory(), EvenShiloachGraphDecrementalConnectivity::new);
- SecurityAnalysisResult result = securityAnalysis.run(network.getVariantManager().getWorkingVariantId(), saParameters, contingenciesProvider).join();
- assertTrue(result.getPreContingencyResult().isComputationOk());
+ SecurityAnalysisReport report = securityAnalysis.run(network.getVariantManager().getWorkingVariantId(), saParameters, contingenciesProvider).join();
+ assertTrue(report.getResult().getPreContingencyResult().getLimitViolationsResult().isComputationOk());
saParameters.getLoadFlowParameters().setBalanceType(LoadFlowParameters.BalanceType.PROPORTIONAL_TO_LOAD);
- SecurityAnalysisResult result2 = securityAnalysis.runSync(saParameters, contingenciesProvider);
- assertTrue(result2.getPreContingencyResult().isComputationOk());
+ SecurityAnalysisReport report2 = securityAnalysis.runSync(saParameters, contingenciesProvider);
+ assertTrue(report2.getResult().getPreContingencyResult().getLimitViolationsResult().isComputationOk());
}
@Test
@@ -247,11 +254,11 @@ void testNoGenerator() {
ContingenciesProvider contingenciesProvider = n -> Collections.emptyList();
- CompletableFuture result = new OpenSecurityAnalysisFactory(new DenseMatrixFactory(), EvenShiloachGraphDecrementalConnectivity::new)
- .create(network, new DefaultLimitViolationDetector(), new LimitViolationFilter(), null, 0)
- .run(network.getVariantManager().getWorkingVariantId(), saParameters, contingenciesProvider);
+ CompletableFuture report = new OpenSecurityAnalysis(network, new DefaultLimitViolationDetector(),
+ new LimitViolationFilter(), new DenseMatrixFactory(), EvenShiloachGraphDecrementalConnectivity::new)
+ .run(network.getVariantManager().getWorkingVariantId(), saParameters, contingenciesProvider);
- CompletionException exception = assertThrows(CompletionException.class, result::join);
+ CompletionException exception = assertThrows(CompletionException.class, report::join);
assertEquals("Largest network is invalid", exception.getCause().getMessage());
}
@@ -271,11 +278,12 @@ void testNoRemainingGenerator() {
.map(id -> new Contingency(id, new BranchContingency(id)))
.collect(Collectors.toList());
- OpenSecurityAnalysisFactory osaFactory = new OpenSecurityAnalysisFactory(new DenseMatrixFactory(), EvenShiloachGraphDecrementalConnectivity::new);
- OpenSecurityAnalysis securityAnalysis = osaFactory.create(network, new DefaultLimitViolationDetector(),
- new LimitViolationFilter(), null, 0);
- SecurityAnalysisResult result = securityAnalysis.run(network.getVariantManager().getWorkingVariantId(), saParameters, contingenciesProvider).join();
- assertTrue(result.getPostContingencyResults().get(0).getLimitViolationsResult().isComputationOk());
+ SecurityAnalysisReport report = new OpenSecurityAnalysis(network, new DefaultLimitViolationDetector(),
+ new LimitViolationFilter(), new DenseMatrixFactory(), EvenShiloachGraphDecrementalConnectivity::new)
+ .run(network.getVariantManager().getWorkingVariantId(), saParameters, contingenciesProvider)
+ .join();
+
+ assertTrue(report.getResult().getPostContingencyResults().get(0).getLimitViolationsResult().isComputationOk());
}
@Test
@@ -295,11 +303,12 @@ void testNoRemainingLoad() {
.map(id -> new Contingency(id, new BranchContingency(id)))
.collect(Collectors.toList());
- OpenSecurityAnalysisFactory osaFactory = new OpenSecurityAnalysisFactory(new DenseMatrixFactory(), EvenShiloachGraphDecrementalConnectivity::new);
- OpenSecurityAnalysis securityAnalysis = osaFactory.create(network, new DefaultLimitViolationDetector(),
- new LimitViolationFilter(), null, 0);
- SecurityAnalysisResult result = securityAnalysis.run(network.getVariantManager().getWorkingVariantId(), saParameters, contingenciesProvider).join();
- assertTrue(result.getPostContingencyResults().get(0).getLimitViolationsResult().isComputationOk());
+ SecurityAnalysisReport report = new OpenSecurityAnalysis(network, new DefaultLimitViolationDetector(),
+ new LimitViolationFilter(), new DenseMatrixFactory(), EvenShiloachGraphDecrementalConnectivity::new)
+ .run(network.getVariantManager().getWorkingVariantId(), saParameters, contingenciesProvider)
+ .join();
+
+ assertTrue(report.getResult().getPostContingencyResults().get(0).getLimitViolationsResult().isComputationOk());
}
@Test
@@ -319,11 +328,10 @@ void testSAWithSeveralConnectedComponents() {
.map(b -> new Contingency(b.getId(), new BranchContingency(b.getId())))
.collect(Collectors.toList());
- OpenSecurityAnalysisFactory osaFactory = new OpenSecurityAnalysisFactory(new DenseMatrixFactory(), EvenShiloachGraphDecrementalConnectivity::new);
- OpenSecurityAnalysis securityAnalysis = osaFactory.create(network, new DefaultLimitViolationDetector(),
- new LimitViolationFilter(), null, 0);
+ OpenSecurityAnalysis securityAnalysis = new OpenSecurityAnalysis(network, new DefaultLimitViolationDetector(),
+ new LimitViolationFilter(), new DenseMatrixFactory(), EvenShiloachGraphDecrementalConnectivity::new);
- SecurityAnalysisResult result = securityAnalysis.run(network.getVariantManager().getWorkingVariantId(), saParameters, contingenciesProvider).join();
- assertTrue(result.getPreContingencyResult().isComputationOk());
+ SecurityAnalysisReport report = securityAnalysis.run(network.getVariantManager().getWorkingVariantId(), saParameters, contingenciesProvider).join();
+ assertTrue(report.getResult().getPreContingencyResult().getLimitViolationsResult().isComputationOk());
}
}
diff --git a/src/test/java/com/powsybl/openloadflow/sensi/ac/AcSensitivityAnalysisContingenciesTest.java b/src/test/java/com/powsybl/openloadflow/sensi/ac/AcSensitivityAnalysisContingenciesTest.java
index 20da0649ef..e02cbee8d1 100644
--- a/src/test/java/com/powsybl/openloadflow/sensi/ac/AcSensitivityAnalysisContingenciesTest.java
+++ b/src/test/java/com/powsybl/openloadflow/sensi/ac/AcSensitivityAnalysisContingenciesTest.java
@@ -18,6 +18,7 @@
import com.powsybl.openloadflow.OpenLoadFlowParameters;
import com.powsybl.openloadflow.network.*;
import com.powsybl.openloadflow.sensi.*;
+import com.powsybl.openloadflow.sensi.ContingencyContext;
import com.powsybl.openloadflow.util.LoadFlowAssert;
import com.powsybl.sensitivity.*;
import com.powsybl.sensitivity.factors.BranchFlowPerInjectionIncrease;