Skip to content

Commit

Permalink
Merge branch 'master' into eurostag_maincc
Browse files Browse the repository at this point in the history
  • Loading branch information
sylvlecl committed Jan 25, 2018
2 parents e861844 + ff3e2df commit 6ad9e95
Show file tree
Hide file tree
Showing 5 changed files with 188 additions and 141 deletions.
34 changes: 17 additions & 17 deletions wca-integration/src/main/java/eu/itesla_project/wca/WCAImpl.java
@@ -1,6 +1,6 @@
/**
* Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium)
* Copyright (c) 2016-2017, RTE (http://www.rte-france.com)
* Copyright (c) 2016-2018, 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/.
Expand Down Expand Up @@ -174,7 +174,7 @@ public WCAImpl(Network network, ComputationManager computationManager, HistoDbCl
.setMinBaseVoltage(config.getVoltageLevelConstraintFilter())
.setCountries(config.getCountryConstraintFilter().isEmpty() ? null : config.getCountryConstraintFilter());

this.wcaReport = new WCAReportImpl(network.getId());
this.wcaReport = new WCAReportImpl(network);

env = ImmutableMap.of("XPRESS", config.getXpressHome().resolve("bin").toString(),
"LD_LIBRARY_PATH", config.getXpressHome().resolve("lib").toString());
Expand Down Expand Up @@ -491,10 +491,10 @@ private CompletableFuture<WCAClusterNum> createClustersWorkflowTask(Contingency

WCAPostContingencyStatus postContingencyStatus = new WCAPostContingencyStatus(contingency.getId(), new WCALoadflowResult(true, null));

List<LimitViolation> contingencyStateLimitViolations = violationsFilter.apply(Security.checkLimits(network));
List<LimitViolation> contingencyStateLimitViolations = violationsFilter.apply(Security.checkLimits(network), network);
if (contingencyStateLimitViolations.size() > 0) {
LOGGER.warn("Network {}, contingency {}: constraint violantions found in post contingency state:\n{}",
network.getId(), contingency.getId(), Security.printLimitsViolations(contingencyStateLimitViolations, violationsFilter));
network.getId(), contingency.getId(), Security.printLimitsViolations(contingencyStateLimitViolations, network, violationsFilter));
postContingencyStatus.setPostContingencyViolationsWithoutUncertainties(contingencyStateLimitViolations);
filteredClusters.removeClusters(contingency.getId(),
EnumSet.of(WCAClusterNum.ONE),
Expand Down Expand Up @@ -551,7 +551,7 @@ private CompletableFuture<WCAClusterNum> createClustersWorkflowTask(Contingency
boolean violationsRemoved = false;
boolean actionApplied = false;
String comment = null;
List<LimitViolation> curativeStateLimitViolations = violationsFilter.apply(Security.checkLimits(network));
List<LimitViolation> curativeStateLimitViolations = violationsFilter.apply(Security.checkLimits(network), network);
if (curativeStateLimitViolations.isEmpty()) {
LOGGER.info("Network {}, contingency {}, curative action {} solves violations: adding curative action to list for 'clusters' task",
network.getId(), contingency.getId(), curativeActionId);
Expand All @@ -562,7 +562,7 @@ private CompletableFuture<WCAClusterNum> createClustersWorkflowTask(Contingency
previousState = curativeStateId;
} else {
LOGGER.warn("Network {}, contingency {}, curative action {}: violantions found in post curative action state:\n{}",
network.getId(), contingency.getId(), curativeActionId, Security.printLimitsViolations(curativeStateLimitViolations, violationsFilter));
network.getId(), contingency.getId(), curativeActionId, Security.printLimitsViolations(curativeStateLimitViolations, network, violationsFilter));
comment = "violantions found in post curative action state";
if (!filterCurativeActions) {
LOGGER.info("Network {}, contingency {}, curative action {}: adding anyway curative action to list for 'clusters' task (config filterCurativeActions = false)",
Expand Down Expand Up @@ -640,10 +640,10 @@ private CompletableFuture<WCAClusterNum> createClustersWorkflowTask(Contingency
);
} else {
postContingencyStatus.setPostContingencyWithUncertaintiesLoadflowResult(new WCALoadflowResult(true, null));
List<LimitViolation> clustersLimitViolations = violationsFilter.apply(Security.checkLimits(network));
List<LimitViolation> clustersLimitViolations = violationsFilter.apply(Security.checkLimits(network), network);
if (clustersLimitViolations.size() > 0) {
LOGGER.warn("Network {}, contingency {}: constraint violantions found in state with 'clusters' uncertainties:\n{}",
network.getId(), contingency.getId(), Security.printLimitsViolations(clustersLimitViolations, violationsFilter));
network.getId(), contingency.getId(), Security.printLimitsViolations(clustersLimitViolations, network, violationsFilter));
postContingencyStatus.setPostContingencyViolationsWithUncertainties(clustersLimitViolations);
} else {
LOGGER.warn("Network {}, contingency {}: no violations found in state with 'clusters' uncertainties",
Expand Down Expand Up @@ -713,10 +713,10 @@ private CompletableFuture<List<CompletableFuture<WCACluster>>> createWcaTask(Str
});
} else {
wcaReport.setBaseStateLoadflowResult(new WCALoadflowResult(true, null));
List<LimitViolation> baseStateLimitViolations = violationsFilter.apply(Security.checkLimits(network));
List<LimitViolation> baseStateLimitViolations = violationsFilter.apply(Security.checkLimits(network), network);
if (baseStateLimitViolations.size() > 0) {
LOGGER.warn("Network {}: constraint violantions found in base state:\n{}",
network.getId(), Security.printLimitsViolations(baseStateLimitViolations, violationsFilter));
network.getId(), Security.printLimitsViolations(baseStateLimitViolations, network, violationsFilter));
wcaReport.setPreContingencyViolationsWithoutUncertainties(baseStateLimitViolations);
contingencies.forEach(contingency -> filteredClusters.removeClusters(contingency.getId(),
EnumSet.of(WCAClusterNum.ONE, WCAClusterNum.TWO),
Expand Down Expand Up @@ -776,10 +776,10 @@ private CompletableFuture<List<CompletableFuture<WCACluster>>> createWcaTask(Str
wcaReport.setBaseStateWithUncertaintiesLoadflowResult(new WCALoadflowResult(false, "load flow on state with 'domains' uncertainties diverged: metrics = " + loadFlowResult.getMetrics()));
return CompletableFuture.completedFuture(baseStateLimitViolations);
} else {
List<LimitViolation> domainsLimitViolations = violationsFilter.apply(Security.checkLimits(network));
List<LimitViolation> domainsLimitViolations = violationsFilter.apply(Security.checkLimits(network), network);
if (domainsLimitViolations.size() > 0) {
LOGGER.warn("Network {}: constraint violantions found in state with 'domains' uncertainties:\n{}",
network.getId(), Security.printLimitsViolations(domainsLimitViolations, violationsFilter));
network.getId(), Security.printLimitsViolations(domainsLimitViolations, network, violationsFilter));
wcaReport.setPreContingencyViolationsWithUncertainties(domainsLimitViolations);
contingencies.forEach(contingency -> filteredClusters.removeClusters(contingency.getId(),
EnumSet.of(WCAClusterNum.ONE, WCAClusterNum.TWO),
Expand All @@ -798,7 +798,7 @@ private CompletableFuture<List<CompletableFuture<WCACluster>>> createWcaTask(Str
network.getStateManager().setWorkingState(baseStateId);
}
LOGGER.info("Network {}: {} violations to be prevented:\n{}",
network.getId(), violationsToBePrevented.size(), Security.printLimitsViolations(violationsToBePrevented, violationsFilter));
network.getId(), violationsToBePrevented.size(), Security.printLimitsViolations(violationsToBePrevented, network, violationsFilter));
List<String> preventiveStateIdsForDomains = Collections.synchronizedList(new ArrayList<>());
List<String> preventiveActionIdsForDomains = Collections.synchronizedList(new ArrayList<>());
Map<String, List<Action>> possibleActionsToApply = Collections.synchronizedMap(new HashMap<String, List<Action>>());
Expand Down Expand Up @@ -838,7 +838,7 @@ private CompletableFuture<List<CompletableFuture<WCACluster>>> createWcaTask(Str
try {
loadFlowResult1 = loadFlow.run(LOAD_FLOW_PARAMETERS);
if (loadFlowResult1.isOk()) {
List<LimitViolation> preventiveStateLimitViolations = violationsFilter.apply(Security.checkLimits(network));
List<LimitViolation> preventiveStateLimitViolations = violationsFilter.apply(Security.checkLimits(network), network);
Optional<LimitViolation> notSolvedLimitViolation = preventiveStateLimitViolations
.stream()
.filter(preventiveStateLimitViolation -> preventiveStateLimitViolation.getSubjectId().equals(violationToBePrevented.getSubjectId()))
Expand All @@ -862,7 +862,7 @@ private CompletableFuture<List<CompletableFuture<WCACluster>>> createWcaTask(Str
message = "post preventive action state contains new violations";
}
LOGGER.warn("Network {}, preventive action {}: {}:\n{}",
network.getId(), preventiveActionId, message, Security.printLimitsViolations(preventiveStateLimitViolations, violationsFilter));
network.getId(), preventiveActionId, message, Security.printLimitsViolations(preventiveStateLimitViolations, network, violationsFilter));
if (!config.filterPreventiveActions()) {
LOGGER.info("Network {}, preventive action {}: adding anyway preventive action to list (config filterPreventiveActions = false)",
network.getId(), preventiveActionId);
Expand Down Expand Up @@ -970,7 +970,7 @@ private CompletableFuture<List<CompletableFuture<WCACluster>>> createWcaTask(Str
.thenAccept(ignored -> {
// check that the violations have disappeared? this check has already been done previously
// update basecase remaining violations
wcaReport.setBaseStateRemainingViolations(violationsFilter.apply(Security.checkLimits(network)));
wcaReport.setBaseStateRemainingViolations(violationsFilter.apply(Security.checkLimits(network), network));
})
.exceptionally(throwable -> {
if (throwable != null) {
Expand All @@ -987,7 +987,7 @@ private CompletableFuture<List<CompletableFuture<WCACluster>>> createWcaTask(Str
wcaReport.setPostPreventiveActionsViolationsWithUncertainties(wcaReport.getBaseStateRemainingViolations());
if (!wcaReport.getBaseStateRemainingViolations().isEmpty()) {
LOGGER.warn("Network {}: loosening the basecase constraints for remaining violations:\n{}",
network.getId(), Security.printLimitsViolations(new ArrayList<>(wcaReport.getBaseStateRemainingViolations()), violationsFilter));
network.getId(), Security.printLimitsViolations(new ArrayList<>(wcaReport.getBaseStateRemainingViolations()), network, violationsFilter));
ConstraintsModifierConfig constraintsModifierConfig = new ConstraintsModifierConfig(
config.getCountryConstraintFilter(),
config.ignoreVoltageConstraints() ? EnumSet.of(LimitViolationType.CURRENT) : EnumSet.allOf(LimitViolationType.class)
Expand Down

0 comments on commit 6ad9e95

Please sign in to comment.