Skip to content

Commit 4bb5d46

Browse files
authored
Merge branch 'main' into dynamic-rounding-on-results
2 parents d9081a6 + 67078bb commit 4bb5d46

File tree

4 files changed

+39
-29
lines changed

4 files changed

+39
-29
lines changed

pom.xml

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,10 @@
4343

4444
<properties>
4545
<jib.from.image>powsybl/java-dynawo:2.1.0</jib.from.image>
46-
<gridsuite-dependencies.version>34</gridsuite-dependencies.version>
46+
<gridsuite-dependencies.version>35</gridsuite-dependencies.version>
4747
<liquibase-hibernate-package>org.gridsuite.securityanalysis.server</liquibase-hibernate-package>
4848
<db-util.version>1.0.5</db-util.version>
4949
<mockwebserver3.version>5.0.0-alpha.14</mockwebserver3.version>
50-
<!-- FIXME: powsybl-network-store modules'version is overloaded in the dependencies section.The overloads and this property below have to be removed at next powsybl-ws-dependencies.version upgrade -->
51-
<powsybl-network-store.version>1.18.2</powsybl-network-store.version>
5250
</properties>
5351

5452
<build>
@@ -95,24 +93,6 @@
9593
<type>pom</type>
9694
<scope>import</scope>
9795
</dependency>
98-
<!-- FIXME: to be removed at next powsybl-ws-dependencies upgrade -->
99-
<dependency>
100-
<groupId>com.powsybl</groupId>
101-
<artifactId>powsybl-network-store-iidm-impl</artifactId>
102-
<version>${powsybl-network-store.version}</version>
103-
</dependency>
104-
<!-- FIXME: to be removed at next powsybl-ws-dependencies upgrade -->
105-
<dependency>
106-
<groupId>com.powsybl</groupId>
107-
<artifactId>powsybl-network-store-client</artifactId>
108-
<version>${powsybl-network-store.version}</version>
109-
</dependency>
110-
<!-- FIXME: to be removed at next powsybl-ws-dependencies upgrade -->
111-
<dependency>
112-
<groupId>com.powsybl</groupId>
113-
<artifactId>powsybl-network-store-model</artifactId>
114-
<version>${powsybl-network-store.version}</version>
115-
</dependency>
11696

11797
<!-- imports -->
11898
<dependency>
@@ -227,6 +207,12 @@
227207
<artifactId>micrometer-registry-prometheus</artifactId>
228208
<scope>runtime</scope>
229209
</dependency>
210+
<!-- FIXME: Remove this runtime dependency when variant multithread access is implemented in the network-store -->
211+
<dependency>
212+
<groupId>com.powsybl</groupId>
213+
<artifactId>powsybl-iidm-impl</artifactId>
214+
<scope>runtime</scope>
215+
</dependency>
230216

231217
<!-- Test dependencies -->
232218
<dependency>

src/main/java/org/gridsuite/securityanalysis/server/service/SecurityAnalysisParametersService.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,13 @@ public SecurityAnalysisRunContext createRunContext(UUID networkUuid, String vari
7777
}
7878

7979
public SecurityAnalysisParametersDTO toSecurityAnalysisParameters(SecurityAnalysisParametersEntity entity) {
80-
SecurityAnalysisParameters securityAnalysisParameters;
80+
SecurityAnalysisParameters securityAnalysisParameters = SecurityAnalysisParameters.load();
8181
List<List<Double>> limitReductions = new ArrayList<>();
8282
if (entity == null) {
83-
securityAnalysisParameters = SecurityAnalysisParameters.load()
84-
// the default values are overloaded
85-
.setIncreasedViolationsParameters(getIncreasedViolationsParameters(DEFAULT_FLOW_PROPORTIONAL_THRESHOLD, DEFAULT_LOW_VOLTAGE_PROPORTIONAL_THRESHOLD, DEFAULT_LOW_VOLTAGE_ABSOLUTE_THRESHOLD, DEFAULT_HIGH_VOLTAGE_PROPORTIONAL_THRESHOLD, DEFAULT_HIGH_VOLTAGE_ABSOLUTE_THRESHOLD));
83+
// the default values are overloaded
84+
securityAnalysisParameters.setIncreasedViolationsParameters(getIncreasedViolationsParameters(DEFAULT_FLOW_PROPORTIONAL_THRESHOLD, DEFAULT_LOW_VOLTAGE_PROPORTIONAL_THRESHOLD, DEFAULT_LOW_VOLTAGE_ABSOLUTE_THRESHOLD, DEFAULT_HIGH_VOLTAGE_PROPORTIONAL_THRESHOLD, DEFAULT_HIGH_VOLTAGE_ABSOLUTE_THRESHOLD));
8685
} else {
87-
securityAnalysisParameters = new SecurityAnalysisParameters().setIncreasedViolationsParameters(getIncreasedViolationsParameters(entity.getFlowProportionalThreshold(), entity.getLowVoltageProportionalThreshold(), entity.getLowVoltageAbsoluteThreshold(), entity.getHighVoltageProportionalThreshold(), entity.getHighVoltageAbsoluteThreshold()));
86+
securityAnalysisParameters.setIncreasedViolationsParameters(getIncreasedViolationsParameters(entity.getFlowProportionalThreshold(), entity.getLowVoltageProportionalThreshold(), entity.getLowVoltageAbsoluteThreshold(), entity.getHighVoltageProportionalThreshold(), entity.getHighVoltageAbsoluteThreshold()));
8887
limitReductions = entity.toLimitReductionsValues();
8988
}
9089

src/main/java/org/gridsuite/securityanalysis/server/service/SecurityAnalysisWorkerService.java

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,12 @@
1818
import com.powsybl.iidm.criteria.duration.PermanentDurationCriterion;
1919
import com.powsybl.iidm.network.LimitType;
2020
import com.powsybl.iidm.network.Network;
21+
import com.powsybl.iidm.network.NetworkFactory;
2122
import com.powsybl.iidm.network.VariantManagerConstants;
23+
import com.powsybl.iidm.serde.NetworkSerDe;
2224
import com.powsybl.loadflow.LoadFlowResult;
2325
import com.powsybl.network.store.client.NetworkStoreService;
26+
import com.powsybl.network.store.client.PreloadingStrategy;
2427
import com.powsybl.security.*;
2528
import com.powsybl.security.limitreduction.LimitReduction;
2629
import com.powsybl.ws.commons.LogUtils;
@@ -42,6 +45,7 @@
4245
import java.util.Objects;
4346
import java.util.UUID;
4447
import java.util.concurrent.CompletableFuture;
48+
import java.util.concurrent.TimeUnit;
4549
import java.util.concurrent.atomic.AtomicReference;
4650
import java.util.function.Consumer;
4751
import java.util.function.Function;
@@ -92,6 +96,11 @@ public SecurityAnalysisResult run(SecurityAnalysisRunContext runContext) {
9296
}
9397
}
9498

99+
@Override
100+
protected PreloadingStrategy getNetworkPreloadingStrategy() {
101+
return PreloadingStrategy.ALL_COLLECTIONS_NEEDED_FOR_BUS_VIEW;
102+
}
103+
95104
@Override
96105
protected String getComputationType() {
97106
return COMPUTATION_TYPE;
@@ -108,6 +117,22 @@ protected CompletableFuture<SecurityAnalysisResult> getCompletableFuture(Securit
108117
.toList();
109118
List<LimitReduction> limitReductions = createLimitReductions(runContext);
110119

120+
Network network = runContext.getNetwork();
121+
// FIXME: Remove this part when multithread variant access is implemented in the network-store
122+
if (runContext.getProvider().equals("OpenLoadFlow")) {
123+
long startTime = System.nanoTime();
124+
Network originalNetwork = runContext.getNetwork();
125+
String originalVariant = originalNetwork.getVariantManager().getWorkingVariantId();
126+
originalNetwork.getVariantManager().setWorkingVariant(variantId);
127+
128+
network = NetworkSerDe.copy(originalNetwork, NetworkFactory.find("Default"));
129+
if (!variantId.equals(VariantManagerConstants.INITIAL_VARIANT_ID)) {
130+
network.getVariantManager().cloneVariant(VariantManagerConstants.INITIAL_VARIANT_ID, variantId);
131+
}
132+
LOGGER.info("Network copied to iidm-impl in {} ms", TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startTime));
133+
originalNetwork.getVariantManager().setWorkingVariant(originalVariant);
134+
}
135+
111136
SecurityAnalysisRunParameters runParameters = new SecurityAnalysisRunParameters()
112137
.setSecurityAnalysisParameters(runContext.getParameters().securityAnalysisParameters())
113138
.setComputationManager(executionService.getComputationManager())
@@ -116,7 +141,7 @@ protected CompletableFuture<SecurityAnalysisResult> getCompletableFuture(Securit
116141
.setReportNode(runContext.getReportNode());
117142

118143
return securityAnalysisRunner.runAsync(
119-
runContext.getNetwork(),
144+
network,
120145
variantId,
121146
n -> contingencies,
122147
runParameters)

src/test/java/org/gridsuite/securityanalysis/server/SecurityAnalysisControllerTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,9 @@ void setUp() throws Exception {
166166
network.getVariantManager().cloneVariant(VariantManagerConstants.INITIAL_VARIANT_ID, VARIANT_2_ID);
167167
network.getVariantManager().cloneVariant(VariantManagerConstants.INITIAL_VARIANT_ID, VARIANT_3_ID);
168168

169-
given(networkStoreService.getNetwork(NETWORK_UUID, PreloadingStrategy.COLLECTION)).willReturn(network);
169+
given(networkStoreService.getNetwork(NETWORK_UUID, PreloadingStrategy.ALL_COLLECTIONS_NEEDED_FOR_BUS_VIEW)).willReturn(network);
170170

171-
when(networkStoreService.getNetwork(NETWORK_STOP_UUID, PreloadingStrategy.COLLECTION)).thenAnswer(invocation -> {
171+
when(networkStoreService.getNetwork(NETWORK_STOP_UUID, PreloadingStrategy.ALL_COLLECTIONS_NEEDED_FOR_BUS_VIEW)).thenAnswer(invocation -> {
172172
//Needed so the stop call doesn't arrive too late
173173
Network network1 = new NetworkFactoryImpl().createNetwork("other", "test");
174174
network1.getVariantManager().cloneVariant(VariantManagerConstants.INITIAL_VARIANT_ID, VARIANT_TO_STOP_ID);

0 commit comments

Comments
 (0)