Skip to content
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

Allow to use checkLimits methods with LimitReductions #3056

Merged
merged 14 commits into from
Jun 19, 2024

Conversation

EtienneLt
Copy link
Contributor

@EtienneLt EtienneLt commented Jun 4, 2024

Please check if the PR fulfills these requirements

  • The commit message follows our guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

Does this PR already have an issue describing the problem?
No

What kind of change does this PR introduce?
Feature

What is the new behavior (if this is a feature change)?

Add several methods in LimitViolationUtils and Security taking a LimitsComputer as parameter. This allows to use them with the LimitReduction API:

  • LimitViolationUtils.checkTemporaryLimits(…);
  • LimitViolationUtils.checkPermanentLimit(…);
  • Security.checkLimits(…);
  • Security.checkLimitsDc(…).

Does this PR introduce a breaking change or deprecate an API?

  • Yes
  • No

If yes, please check if the following requirements are fulfilled

  • The Breaking Change or Deprecated label has been added
  • The migration steps are described in the following section

What changes might users need to make in their application due to this PR? (migration steps)

Other information:
To detect limit violations using some LimitReductions, you need to call one of these methods with an instace of DefaultLimitReductionsApplier, which is a LimitsComputer handling the LimitReductions.

For instance, if you want to call Security.checkLimits(…) with the 2 LimitReductions, limitReduction1 and limitReduction2, you can use the following code:

DefaultLimitReductionsApplier computer = new DefaultLimitReductionsApplier(List.of(reduction1, reduction2));
List<LimitViolation> violations = Security.checkLimits(network, computer);

By default, the reductions which will be applied are the ones defined for the pre-contingency state.
If you want to compute the violations for the state after a specific contingency, you will have to indicate it

For instance, if after the pre-contingency state, you want to compute the post-contingency state for contingency1, you can use the following code:

computer.setWorkingContingency("contingency1");
violations = Security.checkLimits(network, computer);

Note that you don't have to recreate a new DefaultLimitReductionsApplier. I fact, it is more performant to reuse the same object. This LimitsComputer's implementation manages an internal cache and it won't recompute reduced limits if it detects that the reductions applicable for a network element are the same as for the previously studied contingency.

@EtienneLt EtienneLt force-pushed the compute-limit-reductions branch 4 times, most recently from dd8d4bf to e5fcd63 Compare June 5, 2024 06:52
@EtienneLt EtienneLt self-assigned this Jun 7, 2024
flo-dup and others added 9 commits June 12, 2024 08:32
Signed-off-by: Florian Dupuy <florian.dupuy@rte-france.com>
Signed-off-by: Olivier Perrin <olivier.perrin@rte-france.com>
Signed-off-by: Etienne LESOT <etienne.lesot@rte-france.com>
Signed-off-by: Etienne LESOT <etienne.lesot@rte-france.com>
Signed-off-by: Etienne LESOT <etienne.lesot@rte-france.com>
Signed-off-by: Etienne LESOT <etienne.lesot@rte-france.com>
Signed-off-by: Etienne LESOT <etienne.lesot@rte-france.com>
Signed-off-by: Etienne LESOT <etienne.lesot@rte-france.com>
Signed-off-by: Etienne LESOT <etienne.lesot@rte-france.com>
@olperr1 olperr1 changed the title Compute limit reductions Allow to use checkLimits methods with LimitReductions Jun 12, 2024
Copy link

sonarcloud bot commented Jun 19, 2024

@olperr1 olperr1 merged commit 676fe31 into main Jun 19, 2024
7 checks passed
@olperr1 olperr1 deleted the compute-limit-reductions branch June 19, 2024 12:32
geofjamg pushed a commit that referenced this pull request Sep 18, 2024
* Move LimitViolationDetector interface in detectors dedicated package
* Replace limitReductionValue by limitsComputer to detect violations
* Restore old methods to prevent breaking changes
* Optimize SimpleLimitsComputer + add a convenient method in Security

Signed-off-by: Etienne LESOT <etienne.lesot@rte-france.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants