Skip to content

Conversation

@SylvestreSakti
Copy link
Member

@SylvestreSakti SylvestreSakti commented Feb 3, 2026

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)
  • A PR or issue has been opened in all impacted repositories (if any)

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

What kind of change does this PR introduce?
Performance issue is observed when using getFictitiousP0() and getFictitiousQ0() even when there are no fictitious injection. This PR optimizes this behavior.

What is the current behavior?
getFictitiousP0() and getFictitiousQ0() always search all nodes of the bus to compute fictitious injection.

What is the new behavior (if this is a feature change)?
The search is done only if there is at least one non-zero fictitious injection in the voltage level.

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

  • Yes
  • No

@SylvestreSakti SylvestreSakti changed the title Add hasFictitiousP0() and hasFictitiousQ0() to NodeBreakerView Add hasFictitiousP0() and hasFictitiousQ0() to NodeBreakerTopologyModel Feb 3, 2026
if (Double.isNaN(p0)) {
throw new ValidationException(voltageLevel, "undefined value cannot be set as fictitious p0");
}
hasFictitiousP0.setTrue();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Only true for current variant (and if p0 != 0). And you need to handle the setFalse also, if we switch back the value to 0 (and all others are).


@Override
public boolean hasFictitiousP0() {
return hasFictitiousP0.get();
Copy link
Collaborator

Choose a reason for hiding this comment

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

to avoid this parameter we could check that fictitiousP0ByNode is empty, and if not sum the (abs?) values of current variant for each node

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, this would be cleaner and without any parameter

Copy link
Member Author

Choose a reason for hiding this comment

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

Done, currently, it is considered that any non zero value in any node of the current variant leads to hasFictitiousP0=true. I don't know if there would be the need to be more accurate (sum of the nodes ?)

Signed-off-by: PRABAKARAN Sylvestre <[email protected]>
Signed-off-by: PRABAKARAN Sylvestre <[email protected]>
@SylvestreSakti SylvestreSakti changed the title Add hasFictitiousP0() and hasFictitiousQ0() to NodeBreakerTopologyModel Optimize getFictitiousP0() and getFictitiousQ0() to compute over every nodes only when needed Feb 3, 2026
Comment on lines 650 to 660
if (fictitiousP0ByNode.isEmpty()) {
return false;
}
int variantIndex = getNetwork().getVariantIndex();
for (int node : fictitiousP0ByNode.keys()) {
TDoubleArrayList p0ByVariant = fictitiousP0ByNode.get(node);
if (p0ByVariant != null && p0ByVariant.get(variantIndex) != 0.0) {
return true;
}
}
return false;
Copy link
Member

Choose a reason for hiding this comment

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

you can avoid duplication by creating a small private method with the map (fictitiousP0ByNode or fictitiousQ0ByNode) as argument

Copy link
Member Author

Choose a reason for hiding this comment

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

Done 👍

Signed-off-by: PRABAKARAN Sylvestre <[email protected]>
Signed-off-by: PRABAKARAN Sylvestre <[email protected]>
Signed-off-by: PRABAKARAN Sylvestre <[email protected]>
@SylvestreSakti SylvestreSakti marked this pull request as ready for review February 3, 2026 17:33
Signed-off-by: PRABAKARAN Sylvestre <[email protected]>
Signed-off-by: PRABAKARAN Sylvestre <[email protected]>
@sonarqubecloud
Copy link

sonarqubecloud bot commented Feb 4, 2026

Quality Gate Failed Quality Gate failed

Failed conditions
78.6% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

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