Faster ModificationsContext - #1469
Open
PoulpoGaz wants to merge 4 commits into
Open
Conversation
Signed-off-by: Valentin Carrez <valentin.carrez@rte-france.com>
Signed-off-by: Valentin Carrez <valentin.carrez@rte-france.com>
Signed-off-by: Valentin Carrez <valentin.carrez@rte-france.com>
|
PoulpoGaz
marked this pull request as ready for review
July 22, 2026 14:02
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Please check if the PR fulfills these requirements
Does this PR already have an issue describing the problem?
What kind of change does this PR introduce?
Feature
What is the current behavior?
This PR reduces the work performed by
ModificationsContextin two ways.First, it changes how vertices removed from or added to the main component are computed to avoid an unnecessary copy and uses
THashSetinstead ofHashSet.Second,
AbstractGraphConnectivity#startTemporaryChangescurrently copies all vertices outside the main component so that callers can later invokeget(Vertices|Edges)(AddedTo|RemovedFrom)MainComponent. But, sometimes users don't call these methods, making this coy unnecessary.For example: in
LfActionUtils#updateConnectivity, the impact of a set of actions on the network connectivity after a contingency is simulated. Because the connectivity is in its initial state, that is before the contingency, it is necessary tostartTemporaryChangesand apply the contingencystartTemporaryChangesagain (otherwise, topological comparisons would be performed against the pre-contingency state instead of the post-contingency state) and apply the actionsget(Vertices|Edges)(AddedTo|removedFrom)MainComponent.Notice that the first
startTemporaryChangesisn't associated with any topological comparisons. So in this case, copying the vertices outside the main component is unnecessary.What is the new behavior (if this is a feature change)?
This PR introduces a new method in GraphConnectivity:
startTemporaryChanges(boolean computeComparisons). Users can now explicitly disable the computation of topological comparisons by passingfalse. If they use one of the following methods:get(Vertices|Edges)(AddedTo|removedFrom)MainComponent, an exception is thrown.startTemporaryChangesis kept and his behavior isn't changed.When running a security analysis with ~5000 contingencies, ~5000 operator strategies with one action and
NaiveGraphConnectivity, the total time spent on connectivity is reduced from 72 s to 60 s. When using DTree, the total time is reduced from 8.7 s to 5.6 s.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: