-
Notifications
You must be signed in to change notification settings - Fork 7
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
Conversation
// ---- 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)) { |
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.
can this work?
if (!(optResult instanceof SkippedOptimizationResultImpl)) { | |
if (!optResult.getSensitivityStatus().equals(FAILURE)) { |
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.
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) -> { |
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.
can you use stream / filter ?
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; | ||
} |
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.
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)) { |
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.
can you create a recursive method instead? something like:
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)); | |
} | |
Please check if the PR fulfills these requirements (please use
'[x]'
to check the checkboxes, or submit the PR and then click the checkboxes)Does this PR already have an issue describing the problem ? If so, link to this issue using
'#XXX'
and skip the restWhat 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)