fix: bugfix three winding transformers in graphs#198
Conversation
…into fix/three-winding-with-cycle-representation
DCO Remediation Commit for Vincent Koppen <vincent.koppen@alliander.com> I, Vincent Koppen <vincent.koppen@alliander.com>, hereby add my Signed-off-by to this commit: b305453 I, Vincent Koppen <vincent.koppen@alliander.com>, hereby add my Signed-off-by to this commit: 9701f0c I, Vincent Koppen <vincent.koppen@alliander.com>, hereby add my Signed-off-by to this commit: affb900 I, Vincent Koppen <vincent.koppen@alliander.com>, hereby add my Signed-off-by to this commit: ed61f71 Signed-off-by: Vincent Koppen <vincent.koppen@alliander.com>
Signed-off-by: Vincent Koppen <vincent.koppen@alliander.com>
Signed-off-by: Vincent Koppen <vincent.koppen@alliander.com>
|
jaapschoutenalliander
left a comment
There was a problem hiding this comment.
Happy with the suggested solution for now. Some input on the implementation but mainly looks good
| source=self.external_to_internal(ext_start_node_id), | ||
| target=self.external_to_internal(ext_end_node_id), | ||
| ) | ||
| branches_to_remove = self._branches_to_remove_from_three_winding_transformers() |
There was a problem hiding this comment.
I suggest putting the boiler plate to remove the three winding transformers and re-add them in a re-usable wrapper. If there are more algorithms that need it they can easily do that:
something like
def _run_with_three_winding_correction(
self,
algorithm: Callable[[], list[list[int]]],
) -> list[list[int]]:
branches_to_remove = self._branches_to_remove_from_three_winding_transformers()
with self.tmp_remove_branches(branches_to_remove):
result = algorithm()
if branches_to_remove:
return self._squash_paths_inside_three_winding_transformers(result)
return resultThere was a problem hiding this comment.
Seems like a good idea. I guess for readability we could even make a contextmanager.
with self._three_winding_correction():
...There was a problem hiding this comment.
I will experiment with this, for the current functionality this works. But only since the two algorithms that we need to "fix" happen to have the same output (list[list[int]]). If we have a third algorithm later on that needs fixing with a different output type, we might have to revisit.
--> Think I can also solve this by also applying a "post-processs" function that we can now set as default to the current one
There was a problem hiding this comment.
I don't think a context manager can work, unless we do not include the _squash_paths_inside_three_winding_transformers part in it.
We do not get access to the result of the function that is called within the context manager, which is needed for that function.
There was a problem hiding this comment.
@Thijss and @jaapschoutenalliander I have simplified the setup I think, let me know what you think! :)
There was a problem hiding this comment.
Nice, happy with this approach
Co-authored-by: Jaap Schouten <58551444+jaapschoutenalliander@users.noreply.github.com> Signed-off-by: Vincent Koppen <53343926+vincentkoppen@users.noreply.github.com>
Signed-off-by: Vincent Koppen <vincent.koppen@alliander.com>
…h-cycle-representation Signed-off-by: Vincent Koppen <vincent.koppen@alliander.com>
Signed-off-by: Vincent Koppen <vincent.koppen@alliander.com>
|



Depends on #267 to be merged first
Fixes #167
There were multiple ways to solve this problem:
Disadvantage on memory
Disadvantage: a lot of current algorithms/queries become harder, since you always need to hop / remove the node.
Neither option is perfect, but for now keeping it mostly as is and fixing the two algorithms that were incorrect seems like the easiest/cleanest option.
For these algorithms we:
This way we do not return additional paths that are not there, nor do we see cycles that are not there (since we removed the cycles introduced by the three winding trafo's).
Later if we add even more algorithm we can always revisit again en see whether one of the other option becomes a better solution.