Skip to content

Partition parallel branches deterministically - #341

Closed
acostarelli wants to merge 1 commit into
psy6from
ac/deterministic-partition
Closed

Partition parallel branches deterministically#341
acostarelli wants to merge 1 commit into
psy6from
ac/deterministic-partition

Conversation

@acostarelli

Copy link
Copy Markdown
Member

It seems that binning branches by their impedance angle is affected by the order in which you read branches / create bins. This approach updates the "representative" bin angle with the bin median. This is probably not the most efficient approach, but I don't know if this is a hot-spot.

I also don't know if this would've ever caused an error. I would imagine if anything this results in fewer bins, but maybe also solves issues that might stem from reading the same vector of branches but in a different order (not sure if that would ever happen though).

It seems that binning branches by their impedance angle is affected by
the order in which you read branches / create bins. This approach
updates the "representative" bin angle with the bin median. This is
probably not the most efficient approach, but I don't know if this is a
hot-spot.

I also don't know if this would've ever caused an error. I would imagine
if anything this results in fewer bins, but maybe also solves issues
that might stem from reading the same vector of branches but in a
different order (not sure if that would ever happen though).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to make partitioning of parallel branches by impedance angle deterministic (i.e., independent of iteration order) by updating each bin’s representative angle using a median-based approach.

Changes:

  • Adds Statistics.median as the intended mechanism for stabilizing the representative impedance angle per bucket.
  • Updates _partition_members_by_impedance_angle to adjust bucket angles during binning.
  • Updates Project.toml to include Statistics and reorganizes the [sources] block.

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/PowerNetworkMatrices.jl Imports median from Statistics for use in impedance-angle bucketing logic.
src/common.jl Updates parallel-branch impedance-angle partitioning logic to revise bucket representative angles.
Project.toml Adds Statistics dependency and adjusts metadata layout (including [sources]).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/common.jl
Comment on lines 606 to 610
push!(buckets, PSY.ACTransmission[br])
else
push!(buckets[ix], br)
angles[ix] = median(angles[ix])
end
@acostarelli

Copy link
Copy Markdown
Member Author

Closed because I messed up, but it didn't throw me an error so I'll look into why.

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.

2 participants