Skip to content

Commit

Permalink
Modify isRemedialActionAvailable to use a FlowResult (#875)
Browse files Browse the repository at this point in the history
* modified isRemedialActionAvailable to take a FlowResult instead of a PerimeterResult to make it less restrictive

---------

Signed-off-by: Philippe Edwards <philippe.edwards@rte-france.com>
  • Loading branch information
phiedw authored Jan 29, 2024
1 parent 3775f52 commit 8779169
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,14 @@ public static boolean isAnyMarginNegative(FlowResult flowResult, Set<FlowCnec> f
* For automatonState, the remedial action is available if and only if the usage method is "FORCED".
* For other states, the remedial action is available if and only if the usage method is "AVAILABLE".
*/
public static boolean isRemedialActionAvailable(RemedialAction<?> remedialAction, State state, PrePerimeterResult prePerimeterResult, Set<FlowCnec> flowCnecs, Network network, RaoParameters raoParameters) {
public static boolean isRemedialActionAvailable(RemedialAction<?> remedialAction, State state, FlowResult flowResult, Set<FlowCnec> flowCnecs, Network network, RaoParameters raoParameters) {
Set<UsageRule> usageRules = remedialAction.getUsageRules();
if (usageRules.isEmpty()) {
OpenRaoLoggerProvider.BUSINESS_WARNS.warn(format("The remedial action %s has no usage rule and therefore will not be available.", remedialAction.getName()));
return false;
}

Set<UsageMethod> usageMethods = getAllUsageMethods(usageRules, remedialAction, state, prePerimeterResult, flowCnecs, network, raoParameters);
Set<UsageMethod> usageMethods = getAllUsageMethods(usageRules, remedialAction, state, flowResult, flowCnecs, network, raoParameters);
UsageMethod finalUsageMethod = UsageMethod.getStrongestUsageMethod(usageMethods);

if (state.getInstant().isAuto()) {
Expand All @@ -165,11 +165,11 @@ public static boolean isRemedialActionAvailable(RemedialAction<?> remedialAction
* Returns a set of usageMethods corresponding to a remedialAction.
* It filters out every OnFlowConstraint(InCountry) that is not applicable due to positive margins.
*/
private static Set<UsageMethod> getAllUsageMethods(Set<UsageRule> usageRules, RemedialAction<?> remedialAction, State state, PrePerimeterResult prePerimeterResult, Set<FlowCnec> flowCnecs, Network network, RaoParameters raoParameters) {
private static Set<UsageMethod> getAllUsageMethods(Set<UsageRule> usageRules, RemedialAction<?> remedialAction, State state, FlowResult flowResult, Set<FlowCnec> flowCnecs, Network network, RaoParameters raoParameters) {
return usageRules.stream()
.filter(ur -> ur instanceof OnContingencyState || ur instanceof OnInstant
|| (ur instanceof OnFlowConstraint || ur instanceof OnFlowConstraintInCountry)
&& isAnyMarginNegative(prePerimeterResult, remedialAction.getFlowCnecsConstrainingForOneUsageRule(ur, flowCnecs, network), raoParameters.getObjectiveFunctionParameters().getType().getUnit()))
&& isAnyMarginNegative(flowResult, remedialAction.getFlowCnecsConstrainingForOneUsageRule(ur, flowCnecs, network), raoParameters.getObjectiveFunctionParameters().getType().getUnit()))
.map(ur -> ur.getUsageMethod(state))
.collect(Collectors.toSet());
}
Expand Down

0 comments on commit 8779169

Please sign in to comment.