Skip to content
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

add affected terminals to traverse in TrippingTopologyTraverser to trace which terminals have been traversed #2040

Merged
merged 8 commits into from
Mar 30, 2022

Conversation

JacquesBorsenberger
Copy link
Contributor

…ace which terminals have been traversed.

Please check if the PR fulfills these requirements (please use '[x]' to check the checkboxes, or submit the PR and then click the checkboxes)

  • 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)

Does this PR already have an issue describing the problem ? If so, link to this issue using '#XXX' and skip the rest

What 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:

  • The Breaking Change or Deprecated label has been added
  • The migration guide has been updated in the github wiki (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)

assertEquals(switchIds, switchesToOpen.stream().map(Switch::getId).collect(Collectors.toSet()));
Set<Terminal> affectedTerminals = new HashSet<>();
tripping.traverse(network, switchesToOpen, terminalsToDisconnect, affectedTerminals);
assertEquals(affectedTerminals.stream().map(Terminal::getConnectable).map(Connectable::getId).collect(Collectors.toSet()),
Copy link
Contributor

Choose a reason for hiding this comment

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

Why having removed this assertion ? :
assertEquals(switchIds, switchesToOpen.stream().map(Switch::getId).collect(Collectors.toSet()));

Copy link
Contributor Author

@JacquesBorsenberger JacquesBorsenberger Mar 25, 2022

Choose a reason for hiding this comment

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

should not have been removed, fixed

Signed-off-by: jacques borsenberger <jacques.borsenberger@rte-france.com>
@@ -26,10 +26,10 @@ protected AbstractInjectionTripping(String id) {
}

@Override
public void traverse(Network network, Set<Switch> switchesToOpen, Set<Terminal> terminalsToDisconnect) {
public void traverse(Network network, Set<Switch> switchesToOpen, Set<Terminal> terminalsToDisconnect, Set<Terminal> affectedTerminals) {
Copy link
Member

Choose a reason for hiding this comment

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

"affected" is not the correct word: traversedTerminal?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -41,6 +41,8 @@ public TraverseResult traverse(Terminal terminal, boolean connected) {
terminalsToDisconnect.add(terminal);
}
return TraverseResult.TERMINATE_PATH;
} else if (affectedTerminals != null) {
affectedTerminals.add(terminal);
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we should only fill traversed terminal in case of bus/breaker topo. Even if in that case we will have the same list of terminal than in terminalsToDisconnect, but that would more consistent.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@geofjamg geofjamg requested a review from flo-dup March 29, 2022 08:56
Signed-off-by: jacques borsenberger <jacques.borsenberger@rte-france.com>
Signed-off-by: jacques borsenberger <jacques.borsenberger@rte-france.com>
Copy link
Contributor

@flo-dup flo-dup left a comment

Choose a reason for hiding this comment

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

I don't see why we couldn't have reused terminalsToDisconnect instead of adding a new set traversedTerminals. And then simply adding it in the TopologyKind.NODE_BREAKER case. It seems to lead to the same result as what's done here. You probably already tried that, could you tell me what I'm missing?

@geofjamg
Copy link
Member

terminalsToDisconnect

I don't see why we couldn't have reused terminalsToDisconnect instead of adding a new set traversedTerminals. And then simply adding it in the TopologyKind.NODE_BREAKER case. It seems to lead to the same result as what's done here. You probably already tried that, could you tell me what I'm missing?

I think the initial use of terminalsToDisconnect only for bus/breaker topo?

@geofjamg
Copy link
Member

terminalsToDisconnect

I don't see why we couldn't have reused terminalsToDisconnect instead of adding a new set traversedTerminals. And then simply adding it in the TopologyKind.NODE_BREAKER case. It seems to lead to the same result as what's done here. You probably already tried that, could you tell me what I'm missing?

I think the initial use of terminalsToDisconnect only for bus/breaker topo?

But maybe you are right we can change its meaning to simplify the API but in that case, it is a serious breaking change.

@flo-dup
Copy link
Contributor

flo-dup commented Mar 29, 2022

Yes it was only bus/breaker topology. Reusing it for node/breaker topology (and renaming it to traversedTerminals?) would do the same as what's done here... but then we change the behaviour of the traverser for that topology, so indeed a serious breaking change.

@geofjamg
Copy link
Member

But maybe it is not a so serious breaking change because people that we using this utillity class for a bus/breaker topo were not using terminalsToDisconnect, but just switches

@JacquesBorsenberger
Copy link
Contributor Author

actually, after calling traverse, operation are called on each elements of terminalsToDisconnect
AbstractTripping.java: disconnect
Hades2ADNConverter.java: disconnect then connect

this may change some behavior, so I'll need to add guard depending on network type,

@flo-dup
Copy link
Contributor

flo-dup commented Mar 29, 2022

this may change some behavior, so I'll need to add guard depending on network type,

Thanks for pointing that out... Indeed that would lead to some extra care afterwards which makes it heavier to use.

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

91.3% 91.3% Coverage
0.0% 0.0% Duplication

@miovd miovd changed the title add affected terminals to traverse in TrippingTopologyTraverser to tr… add affected terminals to traverse in TrippingTopologyTraverser to trace which terminals have been traversed Mar 30, 2022
@miovd miovd merged commit 409e636 into main Mar 30, 2022
@miovd miovd deleted the add_affected_terminals_to_TrippingTopologyTraverser branch March 30, 2022 09:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants