-
Notifications
You must be signed in to change notification settings - Fork 8
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
Improve equation system indexing performance #252
Conversation
Signed-off-by: Geoffroy Jamgotchian <geoffroy.jamgotchian@rte-france.com>
# Conflicts: # src/main/java/com/powsybl/openloadflow/equations/EquationSystem.java
# Conflicts: # src/main/java/com/powsybl/openloadflow/equations/EquationSystem.java
Signed-off-by: Geoffroy Jamgotchian <geoffroy.jamgotchian@rte-france.com>
Kudos, SonarCloud Quality Gate passed! |
case EQUATION_DEACTIVATED: | ||
invalidate(); | ||
if (!sortedEquationsToSolve.isEmpty()) { // not need to remove if not already indexed |
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.
You could add it to the equations to remove anyway and test instead only once before the remove loop if the equations map is empty.
@@ -118,7 +130,10 @@ public void onEquationTermChange(EquationTerm term, EquationTermEventType eventT | |||
case EQUATION_TERM_ADDED: | |||
case EQUATION_TERM_ACTIVATED: | |||
case EQUATION_TERM_DEACTIVATED: | |||
invalidate(); | |||
if (!sortedEquationsToSolve.isEmpty()) { // not need to remove if not already indexed |
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.
as above, you could add it to equationsToRemove
anyway
if (equation.isActive() && EquationUpdateType.DEFAULT == equation.getUpdateType()) { | ||
// do not use equations that would be updated only after NR |
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.
maybe keep that comment? and/or anticipate this by not adding the equation to the list
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.
Done
for (EquationTerm equationTerm : equation.getTerms()) { | ||
if (equationTerm.isActive()) { |
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.
Just wondering if we shouldn't add a getActiveTerms()
or getActiveTermsStream()
as it's often what we're looking for.
|
||
private void update() { | ||
if (reIndex()) { | ||
int columnCount = 0; |
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.
Outside that PR, but just realized that we don't check here that the number of equations equals the number of variables. That could be done here instead of waiting until the matrix creation.
@@ -118,7 +130,10 @@ public void onEquationTermChange(EquationTerm term, EquationTermEventType eventT | |||
case EQUATION_TERM_ADDED: | |||
case EQUATION_TERM_ACTIVATED: | |||
case EQUATION_TERM_DEACTIVATED: |
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.
couldn't you add a termsToRemove list and a termsToAdd list to avoid removing the whole equation and adding it again? well, maybe that's becoming too complex for the possible gain, it's sure easier like it is now - what do you think?
} | ||
} | ||
} | ||
if (!atLeastOneTermIsValid) { | ||
throw new IllegalStateException("Equation " + equation + " is active but all of its terms are inactive"); |
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.
Oh I forgot about that, I didn't get why you removed that check, it could not happen anymore?
Kudos, SonarCloud Quality Gate passed! |
# Conflicts: # src/main/java/com/powsybl/openloadflow/ac/equations/ClosedBranchSide1CurrentMagnitudeEquationTerm.java # src/main/java/com/powsybl/openloadflow/ac/equations/ClosedBranchSide2CurrentMagnitudeEquationTerm.java # src/main/java/com/powsybl/openloadflow/ac/equations/OpenBranchSide1CurrentMagnitudeEquationTerm.java # src/main/java/com/powsybl/openloadflow/ac/equations/OpenBranchSide2CurrentMagnitudeEquationTerm.java # src/test/java/com/powsybl/openloadflow/sa/OpenSecurityAnalysisTest.java
Signed-off-by: Geoffroy Jamgotchian <geoffroy.jamgotchian@rte-france.com>
Kudos, SonarCloud Quality Gate passed! |
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 or deprecate an API? If yes, check the following:
Other information:
(if any of the questions/checkboxes don't apply, please delete them entirely)