Conversation
|
Address current limitations of the sensitivity analysis result writer: - No support for multi-component computation (could not report when a base simulation succeeded on one component but failed on another) - No indication of the cause of a failure to compute a contingency, unlike what is reported for a load flow run - No indication whether a result is complete or only partial when the computation has been canceled or interrupted Implement multi-component support and partial-result reporting in the DC and AC sensitivity analyses, propagating the new SensitivityResultWriter contract introduced in powsybl-core (writeStateStatus with loadflow status and component indices, computationComplete lifecycle hook). Signed-off-by: Fabrice Buscaylet <fabrice.buscaylet@artelys.com>
7b737ef to
43ae945
Compare
|
I rebased the The rebases were really not trivial (an automatic merge was impossible). While my branches were under review, Geoffroy’s PR #3670 (operator strategies in the sensitivity API) was merged into core, along with its OLF counterpart #1326. These two PRs touched the same Rather than keeping the two APIs side by side, I merged my additions into the interface redesigned by Geoffroy. His design is centered around the new My additions — per‑component load‑flow status and partial result reporting in case of interruption — are a cross‑cutting concern that integrates naturally into this state. So concretely, for the writer interface:
The final proposed contract is therefore: /**
* @author Geoffroy Jamgotchian {@literal <geoffroy.jamgotchian at rte-france.com>}
* @author Fabrice Buscaylet {@literal <fabrice.buscaylet at artelys.com}
*/
public interface SensitivityResultWriter {
/**
* In the case of multi-component computation, a factor has a variable
* that is linked to an equipment that belongs to a single component.
* Called once per factor and contingency in the factor context that
* belongs to the same component as the factor equipment.
* NaN for invalid factors whose equipment does not belong to a component
* that has been run.
*
* @param factorIndex the factor index
* @param contingencyIndex the contingency index, -1 for pre-contingency state
* @param operatorStrategyIndex the operator strategy index, -1 if none
* @param value the sensitivity value
* @param functionReference the function reference
*/
void writeSensitivityValue(int factorIndex, int contingencyIndex,
int operatorStrategyIndex, double value,
double functionReference);
/**
* Reports the status for a given state (contingency + optional operator strategy)
* and a given component (numCC/numCS).
* <p>
* Called for every state and every numCC/numCS where the state has an impact.
* For pre-contingency reporting, both {@code contingencyIndex} and
* {@code operatorStrategyIndex} are -1.
* For contingencies that are never run, called once in the end with NO_IMPACT
* and numCC and numCS set to -1.
*
* @param contingencyIndex the contingency index, -1 for pre-contingency state
* @param operatorStrategyIndex the operator strategy index, -1 if none
* @param status the sensitivity analysis status
* @param loadFlowStatus the load flow status for this component
* @param numCC index of connected component, -1 if not applicable
* @param numCS index of synchronous component, -1 if not applicable
*/
void writeStateStatus(int contingencyIndex, int operatorStrategyIndex,
SensitivityAnalysisResult.Status status,
SensitivityAnalysisResult.LoadFlowStatus loadFlowStatus,
int numCC, int numCS);
/**
* Called at the end of the computation if the computation has not been interrupted.
*/
void computationComplete();
}On the result model side:
On the OLF side:
The tests pass: 61/61 on core, 284/284 on the OLF sensi package. Two unrelated failures appeared, which look like upstream issues related to the core bump 7.2.0 → 7.3.0‑SNAPSHOT:
Practically speaking, since the commits were squashed and the branches had already been pushed to GitHub, the remote history no longer matched what I had locally. I therefore force‑pushed on the same branch. |


Please check if the PR fulfills these requirements
Does this PR already have an issue describing the problem?
powsybl/powsybl-core#3626
What kind of change does this PR introduce?
Implement features:
What is the current behavior?
powsybl/powsybl-core#3626
What is the new behavior (if this is a feature change)?
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)
Other information: