Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotfix initial shift d2cc #186

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cse-cc-export-runner-app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>gridcapa-cse</artifactId>
<groupId>com.farao-community.farao</groupId>
<version>1.25.0</version>
<version>1.25.3-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion cse-cc-import-runner-app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>gridcapa-cse</artifactId>
<groupId>com.farao-community.farao</groupId>
<version>1.25.0</version>
<version>1.25.3-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ private static double getZoneSumOfActiveLoads(Network network, CseCountry cseCou
return network.getLoadStream()
.filter(load -> isLoadCorrespondingToTheCountry(load, cseCountry))
.map(Load::getP0)
.map(Math::abs)
.reduce(0., Double::sum);
}

Expand All @@ -79,7 +80,7 @@ private static Scalable getStackedScalable(CseCountry cseCountry, Scalable scala
network.getLoadStream()
.filter(load -> isLoadCorrespondingToTheCountry(load, cseCountry))
.forEach(load -> {
percentageList.add((load.getP0() / sum) * 100);
percentageList.add(Math.abs(load.getP0() / sum) * 100);
scalableList.add(Scalable.onLoad(load.getId()));
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.farao_community.farao.cse.import_runner.app.services;

import com.farao_community.farao.cse.import_runner.app.dichotomy.ZonalScalableProvider;
import com.farao_community.farao.cse.runner.api.resource.ProcessType;
import com.powsybl.openrao.commons.EICode;
import com.farao_community.farao.cse.computation.BorderExchanges;
import com.farao_community.farao.cse.import_runner.app.CseData;
Expand All @@ -17,6 +19,7 @@
import org.slf4j.Logger;
import org.springframework.stereotype.Service;

import java.io.IOException;
import java.security.SecureRandom;
import java.util.HashMap;
import java.util.Map;
Expand All @@ -29,16 +32,18 @@ public class InitialShiftService {
private final FileExporter fileExporter;
private final FileImporter fileImporter;
private final ProcessConfiguration processConfiguration;
private final ZonalScalableProvider zonalScalableProvider;
private static final Set<String> BORDER_COUNTRIES = Set.of(CseCountry.FR.getEiCode(), CseCountry.CH.getEiCode(), CseCountry.AT.getEiCode(), CseCountry.SI.getEiCode());

public InitialShiftService(Logger businessLogger, FileExporter fileExporter, FileImporter fileImporter, ProcessConfiguration processConfiguration) {
public InitialShiftService(ZonalScalableProvider zonalScalableProvider, Logger businessLogger, FileExporter fileExporter, FileImporter fileImporter, ProcessConfiguration processConfiguration) {
this.businessLogger = businessLogger;
this.fileExporter = fileExporter;
this.fileImporter = fileImporter;
this.processConfiguration = processConfiguration;
this.zonalScalableProvider = zonalScalableProvider;
}

void performInitialShiftFromVulcanusLevelToNtcLevel(Network network, CseData cseData, CseRequest cseRequest, Map<String, Double> referenceExchanges, Map<String, Double> ntcsByEic) {
void performInitialShiftFromVulcanusLevelToNtcLevel(Network network, CseData cseData, CseRequest cseRequest, Map<String, Double> referenceExchanges, Map<String, Double> ntcsByEic) throws IOException {
Map<String, Double> preprocessedNetworkNps = BorderExchanges.computeCseCountriesBalances(network);
for (Map.Entry<String, Double> entry : preprocessedNetworkNps.entrySet()) {
businessLogger.info("Summary : Net positions on preprocessed network : for area {} : net position is {}.", entry.getKey(), entry.getValue());
Expand Down Expand Up @@ -81,8 +86,8 @@ public Map<String, Double> getInitialShiftValues(CseData cseData, Map<String, Do
return initialShifts;
}

private void shiftNetwork(Map<String, Double> scalingValuesByCountry, CseRequest cseRequest, Network network) {
ZonalData<Scalable> zonalScalable = GlskDocumentImporters.importGlsk(fileImporter.openUrlStream(cseRequest.getMergedGlskUrl())).getZonalScalable(network);
private void shiftNetwork(Map<String, Double> scalingValuesByCountry, CseRequest cseRequest, Network network) throws IOException {
ZonalData<Scalable> zonalScalable = getZonalScalableForProcess(cseRequest, network);
String initialVariantId = network.getVariantManager().getWorkingVariantId();
// SecureRandom used to be compliant with sonar
String newVariant = "temporary-working-variant" + new SecureRandom().nextInt(100) + initialVariantId;
Expand Down Expand Up @@ -112,4 +117,10 @@ private void shiftNetwork(Map<String, Double> scalingValuesByCountry, CseRequest
}

}

private ZonalData<Scalable> getZonalScalableForProcess(CseRequest cseRequest, Network network) throws IOException {
return cseRequest.getProcessType().equals(ProcessType.D2CC) ?
zonalScalableProvider.get(cseRequest.getMergedGlskUrl(), network, ProcessType.D2CC) :
GlskDocumentImporters.importGlsk(fileImporter.openUrlStream(cseRequest.getMergedGlskUrl())).getZonalScalable(network);
}
}
4 changes: 2 additions & 2 deletions cse-lib/computation/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
<parent>
<artifactId>gridcapa-cse-lib</artifactId>
<groupId>com.farao-community.farao</groupId>
<version>1.25.0</version>
<version>1.25.3-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>gridcapa-cse-computation</artifactId>
<version>1.25.0</version>
<version>1.25.3-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Common CSE computation utilities</name>
<description>Module that manages common computation for CSE processes</description>
Expand Down
4 changes: 2 additions & 2 deletions cse-lib/data/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
<parent>
<artifactId>gridcapa-cse-lib</artifactId>
<groupId>com.farao-community.farao</groupId>
<version>1.25.0</version>
<version>1.25.3-SNAPSHOT</version>
</parent>

<artifactId>gridcapa-cse-data</artifactId>
<version>1.25.0</version>
<version>1.25.3-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Common CSE data management</name>
<description>Module that manages specific data format for CSE processes</description>
Expand Down
2 changes: 1 addition & 1 deletion cse-lib/network-processing/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<artifactId>gridcapa-cse-lib</artifactId>
<groupId>com.farao-community.farao</groupId>
<version>1.25.0</version>
<version>1.25.3-SNAPSHOT</version>
</parent>

<artifactId>gridcapa-cse-network-processing</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion cse-lib/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>gridcapa-cse</artifactId>
<groupId>com.farao-community.farao</groupId>
<version>1.25.0</version>
<version>1.25.3-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion cse-runner-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.farao-community.farao</groupId>
<artifactId>gridcapa-cse</artifactId>
<version>1.25.0</version>
<version>1.25.3-SNAPSHOT</version>
</parent>

<artifactId>gridcapa-cse-runner-api</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion cse-runner-spring-boot-starter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>gridcapa-cse</artifactId>
<groupId>com.farao-community.farao</groupId>
<version>1.25.0</version>
<version>1.25.3-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
10 changes: 5 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</parent>

<artifactId>gridcapa-cse</artifactId>
<version>1.25.0</version>
<version>1.25.3-SNAPSHOT</version>
<packaging>pom</packaging>

<name>GridCapa CSE</name>
Expand Down Expand Up @@ -50,10 +50,10 @@
<awaitility.version>3.0.0</awaitility.version>

<!-- BUSINESS DEPENDENCIES -->
<farao.dependencies.version>1.27.0</farao.dependencies.version>
<farao.dichotomy.version>4.15.0</farao.dichotomy.version>
<gridcapa.rao.runner.version>1.21.0</gridcapa.rao.runner.version>
<gridcapa.task-manager.version>1.21.0</gridcapa.task-manager.version>
<farao.dependencies.version>1.27.2</farao.dependencies.version>
<farao.dichotomy.version>4.15.2</farao.dichotomy.version>
<gridcapa.rao.runner.version>1.21.1</gridcapa.rao.runner.version>
<gridcapa.task-manager.version>1.26.0</gridcapa.task-manager.version>
<gridcapa.starter.minio.adapter.version>1.1.0</gridcapa.starter.minio.adapter.version>
</properties>

Expand Down
Loading