Skip to content

Commit

Permalink
Remove feature "do not optimize cnecs in series with a pst" (#1015)
Browse files Browse the repository at this point in the history
  • Loading branch information
phiedw authored Jun 20, 2024
1 parent d52a2b2 commit 0840be9
Show file tree
Hide file tree
Showing 141 changed files with 144 additions and 1,930 deletions.
1 change: 0 additions & 1 deletion docs/castor/linear-problem.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ linear-problem/continuous-range-action-group-filler.md
linear-problem/discrete-pst-tap-filler.md
linear-problem/discrete-pst-group-filler.md
linear-problem/unoptimized-cnec-filler-cra.md
linear-problem/unoptimized-cnec-filler-pst.md
linear-problem/ra-usage-limits-filler.md
```

Expand Down
5 changes: 0 additions & 5 deletions docs/castor/linear-problem/unoptimized-cnec-filler-cra.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
# Modelling un-optimised CNECs (CRAs)

> ⚠️ **NOTE**
> These constraints are not compatible with [Modelling un-optimised CNECs (PSTs)](unoptimized-cnec-filler-pst.md).
> Only one of both features can be activated
> through [RAO parameters](/parameters/parameters.md#cnecs-that-should-not-be-optimised).
## Used input data

| Name | Symbol | Details |
Expand Down
110 changes: 0 additions & 110 deletions docs/castor/linear-problem/unoptimized-cnec-filler-pst.md

This file was deleted.

16 changes: 4 additions & 12 deletions docs/castor/special-features/do-not-optimize-specific-cnecs.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,19 @@

## Definition

Some FlowCnecs $\mathcal{C} ^{specific}$ can be omitted from the optimization for two reasons:
Some FlowCnecs $\mathcal{C} ^{specific}$ can be omitted from the optimization for the following reason:
- Curative CNECs from TSOs not sharing any CRAs are not taken into account when looking for the minimum margin in the
objective function (only during CRA optimization), as long as the applied CRAs do not decrease these CNECs' margins
(compared to their margins before applying any CRA).
In other words, other TSOs' CRAs shall not be used to relieve CNECs from TSOs not sharing any CRA (unless if the former
TSOs' CRAs actually have a negative impact on the latter TSOs' CNECs).
This feature is needed in the CORE region capacity calculation process.
(see [do-not-optimize-curative-cnecs-for-tsos-without-cras](/parameters/parameters.md#do-not-optimize-curative-cnecs-for-tsos-without-cras))
- CNECs configured as in series with a PST (see [do-not-optimize-cnec-secured-by-its-pst](/parameters/parameters.md#do-not-optimize-cnec-secured-by-its-pst))
are not taken into account when looking for the minimum margin in the objective function, as long as these CNECs have a
positive margin or an overload that can be fully relieved by the action of this PST. In other words, they will only be
taken into account if the PST has too few tap positions left (before hitting its limit) to relieve their overload.
This feature is needed for specific network elements in the SWE region (for both capacity calculation and coordinated security analysis).
(see [do-not-optimize-curative-cnecs-for-tsos-without-cras](/parameters/parameters.md#do-not-optimize-curative-cnecs-for-tsos-without-cras))

## Implementation

Both these situations can be modelled with constraints activating a binary variable when it becomes necessary to loosen the following constraint:
This situation can be modelled with constraints activating a binary variable when it becomes necessary to loosen the following constraint:
- Cnecs in $\mathcal{C} ^{specific}$ must not see their margins worsened
- Cnecs in $\mathcal{C} ^{specific}$ are secure or can be secured if their associated PST is shifted

This binary variable forces cnecs in $\mathcal{C} ^{specific}$ to be taken into account in the minimum margin objective.
These constraints are modelled in the RAO under the linear problem as:
- [Modelling un-optimized CNECs (CRAs)](/castor/linear-problem/unoptimized-cnec-filler-cra.md)
- [Modelling un-optimized CNECs (PSTs)](/castor/linear-problem/unoptimized-cnec-filler-pst.md)
These constraints are modelled in the RAO under the linear problem as described [here](/castor/linear-problem/unoptimized-cnec-filler-cra.md).
21 changes: 1 addition & 20 deletions docs/parameters.md
Original file line number Diff line number Diff line change
Expand Up @@ -362,21 +362,6 @@ optimisation of specific CNECs in specific conditions.
If it is set to false, all CNECs are treated equally in the curative RAO.
This parameter has no effect on the preventive RAO.
This parameter should be set to true for CORE CC.
This parameter is not compatible with [do-not-optimize-cnec-secured-by-its-pst](#do-not-optimize-cnec-secured-by-its-pst)
for technical reasons.

#### do-not-optimize-cnec-secured-by-its-pst
- **Expected value**: a map with string keys and values. The keys should represent critical network element IDs, and the
values should represent PST network element IDs.
- **Default value**: empty map
- **Usage**: when a critical network element (identified by its PowSyBl ID) is associated to a PST (identified by its
PowSyBl ID) in this parameter, CNECs defined on the critical element will not be taken into account in the minimum
margin objective function, as long as they can be secured by the associated PST. In other words, they will only be
taken into account if the PST has too few tap positions left to reduce the flow constraints on these CNECs.
This parameter affects both preventive and curative RAOs.
It is actually used for the SWE CC process.
This parameter is not compatible with [do-not-optimize-curative-cnecs-for-tsos-without-cras](#do-not-optimize-curative-cnecs-for-tsos-without-cras)
for technical reasons.

### Load-flow and sensitivity computation parameters
These parameters (load-flow-and-sensitivity-computation) configure the load-flow and sensitivity computations providers
Expand Down Expand Up @@ -641,11 +626,7 @@ Zones are seperated by + or -.
"hint-from-first-preventive-rao" : true
},
"not-optimized-cnecs" : {
"do-not-optimize-curative-cnecs-for-tsos-without-cras" : false,
"do-not-optimize-cnec-secured-by-its-pst" : {
"NE1" : "PST1",
"NE2" : "PST2"
}
"do-not-optimize-curative-cnecs-for-tsos-without-cras" : false
},
"load-flow-and-sensitivity-computation" : {
"load-flow-provider" : "OpenLoadFlow",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ private RaoParametersCommons() {
public static final String NOT_OPTIMIZED_CNECS = "not-optimized-cnecs";
public static final String NOT_OPTIMIZED_CNECS_SECTION = "rao-not-optimized-cnecs";
public static final String DO_NOT_OPTIMIZE_CURATIVE_CNECS = "do-not-optimize-curative-cnecs-for-tsos-without-cras";
public static final String DO_NOT_OPTIMIZE_CNECS_SECURED_BY_ITS_PST = "do-not-optimize-cnec-secured-by-its-pst";

// Not optimized cnecs parameters
public static final String LOAD_FLOW_AND_SENSITIVITY_COMPUTATION = "load-flow-and-sensitivity-computation";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
import com.fasterxml.jackson.core.JsonParser;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.TreeMap;

import static com.powsybl.openrao.raoapi.RaoParametersCommons.*;

Expand All @@ -29,7 +26,6 @@ private JsonNotOptimizedCnecsParameters() {
static void serialize(RaoParameters parameters, JsonGenerator jsonGenerator) throws IOException {
jsonGenerator.writeObjectFieldStart(NOT_OPTIMIZED_CNECS);
jsonGenerator.writeBooleanField(DO_NOT_OPTIMIZE_CURATIVE_CNECS, parameters.getNotOptimizedCnecsParameters().getDoNotOptimizeCurativeCnecsForTsosWithoutCras());
jsonGenerator.writeObjectField(DO_NOT_OPTIMIZE_CNECS_SECURED_BY_ITS_PST, new TreeMap<>(parameters.getNotOptimizedCnecsParameters().getDoNotOptimizeCnecsSecuredByTheirPst()));
jsonGenerator.writeEndObject();
}

Expand All @@ -40,24 +36,9 @@ static void deserialize(JsonParser jsonParser, RaoParameters raoParameters) thro
jsonParser.nextToken();
raoParameters.getNotOptimizedCnecsParameters().setDoNotOptimizeCurativeCnecsForTsosWithoutCras(jsonParser.getBooleanValue());
break;
case DO_NOT_OPTIMIZE_CNECS_SECURED_BY_ITS_PST:
jsonParser.nextToken();
raoParameters.getNotOptimizedCnecsParameters().setDoNotOptimizeCnecsSecuredByTheirPst(readStringToStringMap(jsonParser));
break;
default:
throw new OpenRaoException(String.format("Cannot deserialize not optimized cnecs parameters: unexpected field in %s (%s)", NOT_OPTIMIZED_CNECS, jsonParser.getCurrentName()));
}
}
}

private static Map<String, String> readStringToStringMap(JsonParser jsonParser) throws IOException {
HashMap<String, String> map = jsonParser.readValueAs(HashMap.class);
// Check types
map.forEach((Object o, Object o2) -> {
if (!(o instanceof String) || !(o2 instanceof String)) {
throw new OpenRaoException("Unexpected key or value type in a Map<String, String> parameter!");
}
});
return map;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

package com.powsybl.openrao.raoapi.parameters;

import com.powsybl.openrao.commons.OpenRaoException;
import com.powsybl.commons.config.PlatformConfig;

import java.util.*;
Expand All @@ -20,13 +19,7 @@
public class NotOptimizedCnecsParameters {

private static final boolean DEFAULT_DO_NOT_OPTIMIZE_CURATIVE_CNECS_FOR_TSOS_WITHOUT_CRAS = false;
private static final Map<String, String> DEFAULT_DO_NOT_OPTIMIZE_CNECS_SECURED_BY_THEIR_PST = new HashMap<>();
private boolean doNotOptimizeCurativeCnecsForTsosWithoutCras = DEFAULT_DO_NOT_OPTIMIZE_CURATIVE_CNECS_FOR_TSOS_WITHOUT_CRAS;
private Map<String, String> doNotOptimizeCnecsSecuredByTheirPst = DEFAULT_DO_NOT_OPTIMIZE_CNECS_SECURED_BY_THEIR_PST;

public Map<String, String> getDoNotOptimizeCnecsSecuredByTheirPst() {
return doNotOptimizeCnecsSecuredByTheirPst;
}

public boolean getDoNotOptimizeCurativeCnecsForTsosWithoutCras() {
return doNotOptimizeCurativeCnecsForTsosWithoutCras;
Expand All @@ -38,22 +31,11 @@ public static NotOptimizedCnecsParameters load(PlatformConfig platformConfig) {
platformConfig.getOptionalModuleConfig(NOT_OPTIMIZED_CNECS_SECTION)
.ifPresent(config -> {
parameters.setDoNotOptimizeCurativeCnecsForTsosWithoutCras(config.getBooleanProperty(DO_NOT_OPTIMIZE_CURATIVE_CNECS, DEFAULT_DO_NOT_OPTIMIZE_CURATIVE_CNECS_FOR_TSOS_WITHOUT_CRAS));
parameters.setDoNotOptimizeCnecsSecuredByTheirPst(ParametersUtil.convertListToStringStringMap(config.getStringListProperty(DO_NOT_OPTIMIZE_CNECS_SECURED_BY_ITS_PST, ParametersUtil.convertStringStringMapToList(DEFAULT_DO_NOT_OPTIMIZE_CNECS_SECURED_BY_THEIR_PST))));
});
return parameters;
}

public void setDoNotOptimizeCurativeCnecsForTsosWithoutCras(boolean doNotOptimizeCurativeCnecsForTsosWithoutCras) {
if (doNotOptimizeCurativeCnecsForTsosWithoutCras && !getDoNotOptimizeCnecsSecuredByTheirPst().isEmpty()) {
throw new OpenRaoException(String.format("%s and %s are incompatible", DO_NOT_OPTIMIZE_CNECS_SECURED_BY_ITS_PST, DO_NOT_OPTIMIZE_CURATIVE_CNECS));
}
this.doNotOptimizeCurativeCnecsForTsosWithoutCras = doNotOptimizeCurativeCnecsForTsosWithoutCras;
}

public void setDoNotOptimizeCnecsSecuredByTheirPst(Map<String, String> doNotOptimizeCnecsSecuredByTheirPstEntry) {
if (doNotOptimizeCnecsSecuredByTheirPstEntry != null && !doNotOptimizeCnecsSecuredByTheirPstEntry.isEmpty() && getDoNotOptimizeCurativeCnecsForTsosWithoutCras()) {
throw new OpenRaoException(String.format("%s and %s are incompatible", DO_NOT_OPTIMIZE_CNECS_SECURED_BY_ITS_PST, DO_NOT_OPTIMIZE_CURATIVE_CNECS));
}
this.doNotOptimizeCnecsSecuredByTheirPst = Objects.requireNonNullElseGet(doNotOptimizeCnecsSecuredByTheirPstEntry, HashMap::new);
}
}
Loading

0 comments on commit 0840be9

Please sign in to comment.