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 2P ARA skipped opt #777

Merged
merged 7 commits into from
Aug 31, 2023
Merged

Fix 2P ARA skipped opt #777

merged 7 commits into from
Aug 31, 2023

Conversation

Godelaine
Copy link
Collaborator

Please check if the PR fulfills these requirements (please use '[x]' to check the checkboxes, or submit the PR and then click the checkboxes)

  • 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 ? If so, link to this issue using '#XXX' and skip the rest

What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)

What is the current behavior? (You can also link to an open issue here)

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

Does this PR introduce a breaking change? (What changes might users need to make in their application due to this PR?)

Other information:

(if any of the questions/checkboxes don't apply, please delete them entirely)

// ---- only RAs from perimeters that haven't failed are included in appliedArasAndCras
// ---- this check is only performed here because SkippedOptimizationResultImpl with appliedRas can only be generated for AUTO instant
newPostContingencyResults.forEach((state, optResult) -> {
if (!(optResult instanceof SkippedOptimizationResultImpl)) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

can this work?

Suggested change
if (!(optResult instanceof SkippedOptimizationResultImpl)) {
if (!optResult.getSensitivityStatus().equals(FAILURE)) {

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

normalement c'est bien la même chose oui. mais un SkippedOpt n'a pas forcément un computationStatus failed (à sa création c'set bien le cas, et donc ici aussi). Je trouve ça plus clair en tout cas d'avoir la même écriture que plus loin (l518)

addAppliedRangeActionsPostContingency(com.farao_community.farao.data.crac_api.Instant.AUTO, appliedArasAndCras, newPostContingencyResults);
// ---- only RAs from perimeters that haven't failed are included in appliedArasAndCras
// ---- this check is only performed here because SkippedOptimizationResultImpl with appliedRas can only be generated for AUTO instant
newPostContingencyResults.forEach((state, optResult) -> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

can you use stream / filter ?

Comment on lines 116 to 125
public AppliedRemedialActions copyNetworkActionsAndAutomaticRangeActions() {
AppliedRemedialActions ara = new AppliedRemedialActions();
appliedRa.forEach((state, appliedRaOnState) -> ara.addAppliedNetworkActions(state, appliedRaOnState.networkActions));
appliedRa.forEach((state, appliedRaOnState) -> {
if (state.getInstant().equals(Instant.AUTO)) {
ara.addAppliedRangeActions(state, appliedRaOnState.rangeActions);
}
});
return ara;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

add a unit test for this

// if an elementary result is defined for the network element and state, return it
// else find a previous state with an elementary result
// if none are found, return reference setpoint
if (setPointPerState.containsKey(state)) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

can you create a recursive method instead? something like:

Suggested change
if (setPointPerState.containsKey(state)) {
Double lastSetpoint = getLastSetpoint(setPointPerState, state);
if (lastSetPoint != null) {
return lastSetPoint;
}
...
Double getLastSetpoint(Map setPointPerState, State state) {
if (state == null) {
return null;
}
if (setPointPerState.containsKey(state)) {
return setPointPerState.get(state);
}
return getLastSetpoint(setPointPerState, getPreviousState(state).orElse(null));
}

@pet-mit pet-mit merged commit e83bb3f into master Aug 31, 2023
@pet-mit pet-mit deleted the fix2PAraSkippedOpt branch August 31, 2023 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants