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

Fix divergence case #870

Merged
merged 6 commits into from
Jan 24, 2024
Merged

Fix divergence case #870

merged 6 commits into from
Jan 24, 2024

Conversation

MartinBelthle
Copy link
Collaborator

@MartinBelthle MartinBelthle commented Jan 17, 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?

AlgoLeague ticket 129.

What kind of change does this PR introduce?

Bug fixes

What is the current behavior?

Part 1 : If the RAO does a second preventive and fallbacks to the initial situation in the end, it encounters this error :
The RaoResult object should not be modified outside of its usual routine.
It's because its variable optimizationStepsExecuted went from FIRST_PREVENTIVE_ONLY to SECOND_PREVENTIVE_FELLBACK_TO_INITIAL_SITUATION which was not allowed.

Part 2 :

  1. The method getVirtualCost() of the class SkippedOptimizationResultImpl returns 0.
  2. The method getVirtualCost("sensitivity-failure-cost") returns 0.
  3. When merging preventive and curative perimeter, we filter out contingencies with a load flow divergence.

Example:

CASTOR applies PRAs. These actions make a contingency perimeter "Co-1 curative" diverge.
So, it skips this perimeter and marks it as a SkippedOptimizationResultImpl.
When merging preventive and curative perimeters, it filters out this perimeter from the cost evaluation.
This means even though CASTOR made a perimeter diverge, in the end it does not see it.
To correct this behavior, we also have to change the value returned by the 2 methods getVirtualCost as even if CASTOR considered this perimeter it would still not see the virtual cost associated.

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

Part 1 : The exception no longer occurs as this change is allowed.

Part 2 :

  1. The class SkippedOptimizationResultImpl now has a variable sensitivityFailureOvercost which corresponds to the one filled in the RAO Parameters. The method getVirtualCost() now returns this cost. The same goes for getVirtualCost(virtualCostName) which returns sensitivityFailureOvercost if called with "sensitivity-failure-cost" and 0 otherwise.
  2. When merging preventive and curative perimeter, we do not longer filter out contingencies with a load flow divergence.

So, if the same example occurs, the RAO will go through every contingency perimeter and for the ones with loadflow divergence, it will add the sensitivityFailureOvercost to the virtual cost.

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

  • Yes
  • No

Other information:

The farao-cucumber-branch swe-divergence contains a test case and every test passed on Jenkins.

@MartinBelthle MartinBelthle self-assigned this Jan 18, 2024
@MartinBelthle MartinBelthle added PR: waiting-for-review This PR is waiting to be reviewed and removed PR: WIP labels Jan 19, 2024
@@ -58,7 +59,10 @@ public double getSensitivityFailureOvercost() {
}

public void setSensitivityFailureOvercost(double sensitivityFailureOvercost) {
this.sensitivityFailureOvercost = sensitivityFailureOvercost;
if (sensitivityFailureOvercost < 0) {
BUSINESS_WARNS.warn("The value {} for `sensitivity-failure-overcost` is smaller than 0. This would encourage the optimizer to make the loadflow diverge. Thus, it will be set to + {}", sensitivityFailureOvercost, -sensitivityFailureOvercost);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

throw exception instead (we do it elsewhere when the parameter is wrong, for example in setPstSensitivityThreshold)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I talked about it with Philippe and we copied the logic of the method setCurativeMinObjImprovement in class ObjectiveFunctionParameters. I can modify the code but I prefer that you discuss it with him before.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok then, for now. but i think we should harmonize the parameters more, and see what is done in other powsybl projects

Signed-off-by: belthlemar <martin.belthle@rte-france.com>
Signed-off-by: belthlemar <martin.belthle@rte-france.com>
Signed-off-by: belthlemar <martin.belthle@rte-france.com>
Signed-off-by: belthlemar <martin.belthle@rte-france.com>
Signed-off-by: belthlemar <martin.belthle@rte-france.com>
Signed-off-by: belthlemar <martin.belthle@rte-france.com>
@pet-mit pet-mit merged commit ccfa2f4 into main Jan 24, 2024
5 of 6 checks passed
@pet-mit pet-mit deleted the fix-divergence-case branch January 24, 2024 07:45
MartinBelthle added a commit that referenced this pull request May 28, 2024
Fix divergence cases, and 2nd PRAO falling back to initial situation

Signed-off-by: belthlemar <martin.belthle@rte-france.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: waiting-for-review This PR is waiting to be reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants