diff --git a/ra-optimisation/search-tree-rao/src/main/java/com/powsybl/openrao/searchtreerao/commons/RaoUtil.java b/ra-optimisation/search-tree-rao/src/main/java/com/powsybl/openrao/searchtreerao/commons/RaoUtil.java index f22a302c77..1a15167a1e 100644 --- a/ra-optimisation/search-tree-rao/src/main/java/com/powsybl/openrao/searchtreerao/commons/RaoUtil.java +++ b/ra-optimisation/search-tree-rao/src/main/java/com/powsybl/openrao/searchtreerao/commons/RaoUtil.java @@ -136,14 +136,14 @@ public static boolean isAnyMarginNegative(FlowResult flowResult, Set 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 flowCnecs, Network network, RaoParameters raoParameters) { + public static boolean isRemedialActionAvailable(RemedialAction remedialAction, State state, FlowResult flowResult, Set flowCnecs, Network network, RaoParameters raoParameters) { Set 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 usageMethods = getAllUsageMethods(usageRules, remedialAction, state, prePerimeterResult, flowCnecs, network, raoParameters); + Set usageMethods = getAllUsageMethods(usageRules, remedialAction, state, flowResult, flowCnecs, network, raoParameters); UsageMethod finalUsageMethod = UsageMethod.getStrongestUsageMethod(usageMethods); if (state.getInstant().isAuto()) { @@ -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 getAllUsageMethods(Set usageRules, RemedialAction remedialAction, State state, PrePerimeterResult prePerimeterResult, Set flowCnecs, Network network, RaoParameters raoParameters) { + private static Set getAllUsageMethods(Set usageRules, RemedialAction remedialAction, State state, FlowResult flowResult, Set 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()); }