-
Notifications
You must be signed in to change notification settings - Fork 8
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
Replace "Usage Rules" by "Trigger Conditions" #1050
Conversation
Signed-off-by: Thomas Bouquet <[email protected]>
Signed-off-by: Thomas Bouquet <[email protected]>
Signed-off-by: Thomas Bouquet <[email protected]>
Signed-off-by: Thomas Bouquet <[email protected]>
Signed-off-by: Thomas Bouquet <[email protected]>
Signed-off-by: Thomas Bouquet <[email protected]>
Signed-off-by: Thomas Bouquet <[email protected]>
Signed-off-by: Thomas Bouquet <[email protected]>
Signed-off-by: Thomas Bouquet <[email protected]>
Signed-off-by: Thomas Bouquet <[email protected]>
Signed-off-by: Thomas Bouquet <[email protected]>
# Conflicts: # data/crac-creation/crac-creator-csa-profiles/src/main/java/com/powsybl/openrao/data/craccreation/creator/csaprofile/craccreator/remedialaction/CsaProfileRemedialActionsCreator.java # ra-optimisation/search-tree-rao/src/main/java/com/powsybl/openrao/searchtreerao/commons/parameters/UnoptimizedCnecParameters.java # ra-optimisation/search-tree-rao/src/test/java/com/powsybl/openrao/searchtreerao/commons/RaoUtilTest.java # ra-optimisation/search-tree-rao/src/test/java/com/powsybl/openrao/searchtreerao/commons/parameters/UnoptimizedCnecParametersTest.java # ra-optimisation/search-tree-rao/src/test/java/com/powsybl/openrao/searchtreerao/linearoptimisation/algorithms/fillers/UnoptimizedCnecFillerPstLimitationRuleTest.java
Signed-off-by: Thomas Bouquet <[email protected]>
Signed-off-by: Thomas Bouquet <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should discuss the design more
&& ur.getUsageMethod().equals(instant.isAuto() ? UsageMethod.FORCED : UsageMethod.AVAILABLE) | ||
)); | ||
ra.getTriggerConditions().stream() | ||
.filter(tc -> tc.getContingency().isEmpty() && tc.getCnec().isPresent() && tc.getCountry().isEmpty()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about we add a TriggerCondition.getType() method, that returns an enum, to retrieve the business type of the trigger condition? (equivalent to the types we had before)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes this could work
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that may make the code a few less flexible than it was first intended but for readability's sake it might be better indeed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added the TriggerConditionType
enum.
cnecStatusMap.forEach((cnecId, cnecStatus) -> { | ||
if (cnecStatus.isValid()) { | ||
Cnec<?> cnec = crac.getCnec(cnecId); | ||
UsageMethod usageMethod = getUsageMethod(cnecStatus.elementCombinationConstraintKind(), isSchemeRemedialAction, instant, remedialActionType); | ||
if (isOnConstraintInstantCoherent(cnec.getState().getInstant(), instant)) { | ||
remedialActionAdder.newOnConstraintUsageRule() | ||
remedialActionAdder.newTriggerCondition() | ||
.withInstant(instant.getId()) | ||
.withCnec(cnecId) | ||
.withUsageMethod(usageMethod) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we might as well rename UsageMethod, it doesn't make sense anymore
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, we discussed about this with @phiedw and agreed a new name may be better
the question is: how should we rename it?
...n/java/com/powsybl/openrao/data/craciojson/deserializers/NetworkActionArrayDeserializer.java
Outdated
Show resolved
Hide resolved
data/crac/crac-impl/src/main/java/com/powsybl/openrao/data/cracimpl/CracImpl.java
Outdated
Show resolved
Hide resolved
data/crac/crac-impl/src/main/java/com/powsybl/openrao/data/cracimpl/CracImpl.java
Outdated
Show resolved
Hide resolved
@@ -368,11 +368,11 @@ Set<FlowCnec> gatherFlowCnecsForAutoRangeAction(RangeAction<?> availableRa, | |||
Network network) { | |||
// UsageMethod should be FORCED | |||
if (availableRa.getUsageMethod(automatonState).equals(UsageMethod.FORCED)) { | |||
if (availableRa.getUsageRules().stream().filter(usageRule -> usageRule instanceof OnInstant || usageRule instanceof OnContingencyState) | |||
.anyMatch(usageRule -> usageRule.getUsageMethod(automatonState).equals(UsageMethod.FORCED))) { | |||
if (availableRa.getTriggerConditions().stream().filter(triggerCondition -> triggerCondition.getCnec().isEmpty() && triggerCondition.getCountry().isEmpty()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not a fan of checking emptiness of attributes to know if an RA is applicable... we should discuss how to improve this design
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, I just did this as a temporary solution for the behavior to be the same before and after the new code
But this is not elegant at all and I think there are some design discussions needed here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed this by checking the type of TriggerCondition. If you think this is a better way to do, we could generalize the usage elsewhere in the code (mainly in tests).
Signed-off-by: Thomas Bouquet <[email protected]>
Signed-off-by: Thomas Bouquet <[email protected]>
Signed-off-by: Thomas Bouquet <[email protected]>
# Conflicts: # data/crac-io/crac-io-json/src/test/java/com/powsybl/openrao/data/craciojson/CracImportExportTest.java # data/rao-result/rao-result-json/src/test/java/com/powsybl/openrao/data/raoresultjson/RaoResultRoundTripTest.java
Signed-off-by: Thomas Bouquet <[email protected]>
Signed-off-by: Thomas Bouquet <[email protected]>
# Conflicts: # data/crac-creation/crac-creator-csa-profiles/src/test/java/com/powsybl/openrao/data/craccreation/creator/csaprofile/craccreator/cnec/FlowCnecCreationTest.java # data/crac-creation/crac-creator-csa-profiles/src/test/java/com/powsybl/openrao/data/craccreation/creator/csaprofile/craccreator/remedialaction/GroupRemedialActionTest.java # data/crac-creation/crac-creator-csa-profiles/src/test/java/com/powsybl/openrao/data/craccreation/creator/csaprofile/craccreator/remedialaction/PstRangeActionCreationTest.java # data/crac-creation/crac-creator-csa-profiles/src/test/java/com/powsybl/openrao/data/craccreation/creator/csaprofile/craccreator/remedialaction/RemedialActionCreationTest.java # data/crac-io/crac-io-json/src/main/java/com/powsybl/openrao/data/craciojson/JsonSerializationConstants.java # data/crac/crac-impl/src/test/java/com/powsybl/openrao/data/cracimpl/OnConstraintAdderImplTest.java # data/crac/crac-impl/src/test/java/com/powsybl/openrao/data/cracimpl/OnFlowConstraintInCountryAdderImplTest.java
Signed-off-by: Thomas Bouquet <[email protected]>
Since the code must be made common with PowSyBl (cf. #1067) I suggest to close this PR for the moment |
Please check if the PR fulfills these requirements
Does this PR already have an issue describing the problem?
Fixes #992
What kind of change does this PR introduce?
Usage Rules have been discarded and replaced by Trigger Conditions that carry a sort of logical gates on four conditions: instant, contingency, cnec and country.
Does this PR introduce a breaking change or deprecate an API?
If yes, please check if the following requirements are fulfilled
What changes might users need to make in their application due to this PR? (migration steps)
TODO
Other information: