Skip to content

Merge links into nodes: hook link algorithm - #1536

Merged
mgovers merged 33 commits into
mainfrom
pgm/feature/link-supernode-output
Aug 26, 2026
Merged

Merge links into nodes: hook link algorithm#1536
mgovers merged 33 commits into
mainfrom
pgm/feature/link-supernode-output

Conversation

@figueroa1395

@figueroa1395 figueroa1395 commented Aug 14, 2026

Copy link
Copy Markdown
Member

Part of #35

Follow up of #1520

This PR activates the link solver but it doesn't hook up the output yet.

Signed-off-by: Santiago Figueroa Manrique <santiago.figueroa.manrique@alliander.com>
Signed-off-by: Santiago Figueroa Manrique <santiago.figueroa.manrique@alliander.com>
@figueroa1395 figueroa1395 self-assigned this Aug 14, 2026
@figueroa1395 figueroa1395 added feature New feature or request do-not-merge This should not be merged labels Aug 14, 2026
figueroa1395 and others added 4 commits August 19, 2026 13:18
Signed-off-by: Santiago Figueroa Manrique <santiago.figueroa.manrique@alliander.com>
Signed-off-by: Santiago Figueroa Manrique <santiago.figueroa.manrique@alliander.com>
Signed-off-by: Santiago Figueroa Manrique <santiago.figueroa.manrique@alliander.com>
mgovers and others added 7 commits August 20, 2026 09:20
Signed-off-by: Martijn Govers <Martijn.Govers@Alliander.com>
Signed-off-by: Martijn Govers <Martijn.Govers@Alliander.com>
Signed-off-by: Santiago Figueroa Manrique <santiago.figueroa.manrique@alliander.com>
Signed-off-by: Santiago Figueroa Manrique <santiago.figueroa.manrique@alliander.com>
Signed-off-by: Martijn Govers <Martijn.Govers@Alliander.com>
Signed-off-by: Santiago Figueroa Manrique <santiago.figueroa.manrique@alliander.com>
@figueroa1395 figueroa1395 removed the do-not-merge This should not be merged label Aug 21, 2026
@figueroa1395
figueroa1395 marked this pull request as ready for review August 21, 2026 09:32
@mgovers mgovers added the do-not-merge This should not be merged label Aug 21, 2026
@mgovers

mgovers commented Aug 21, 2026

Copy link
Copy Markdown
Member

reviewed. after open comments are resolved can be merged on monday.

@figueroa1395 figueroa1395 changed the title Merge links into nodes: Create link output from link solver algorithm Merge links into nodes: hook link algorithm Aug 21, 2026
Signed-off-by: Martijn Govers <Martijn.Govers@Alliander.com>
Signed-off-by: Martijn Govers <Martijn.Govers@Alliander.com>
Signed-off-by: Martijn Govers <Martijn.Govers@Alliander.com>
Signed-off-by: Martijn Govers <Martijn.Govers@Alliander.com>
Signed-off-by: Martijn Govers <Martijn.Govers@Alliander.com>
Signed-off-by: Martijn Govers <Martijn.Govers@Alliander.com>
Signed-off-by: Martijn Govers <Martijn.Govers@Alliander.com>

@Jerry-Jinfeng-Guo Jerry-Jinfeng-Guo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@mgovers
mgovers added this pull request to the merge queue Aug 25, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Aug 25, 2026
@mgovers

mgovers commented Aug 25, 2026

Copy link
Copy Markdown
Member

merge conflict. i will now resolve them

Signed-off-by: Martijn Govers <Martijn.Govers@Alliander.com>
@mgovers

mgovers commented Aug 25, 2026

Copy link
Copy Markdown
Member

merge conflict should be fixed. please re-review

mgovers and others added 2 commits August 26, 2026 08:26
Signed-off-by: Martijn Govers <Martijn.Govers@Alliander.com>
Signed-off-by: Martijn Govers <martijn.govers@alliander.com>
@sonarqubecloud

Copy link
Copy Markdown

@Jerry-Jinfeng-Guo

Copy link
Copy Markdown
Member

What do we want to do with the first sonar cloud issue? Otherwise lgtm.

@mgovers

mgovers commented Aug 26, 2026

Copy link
Copy Markdown
Member

What do we want to do with the first sonar cloud issue? Otherwise lgtm.

it's an instance of #1401

The subtype is of type for (auto&& a : std::views::zip(x, y)) { /*...*/ }, which sonar since recently has started to understand. However, because it's now using std::ranges::for_each(std::views::zip(x, y), [](auto&& a) { /*...*/ }), which sonar doesn't understand yet.

I don't think we need to dive into this now.

@Jerry-Jinfeng-Guo Jerry-Jinfeng-Guo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sonar cloud issues are either introduced somewhere else or intentional TODO's. Approve.

@mgovers
mgovers added this pull request to the merge queue Aug 26, 2026
Merged via the queue into main with commit e3a8308 Aug 26, 2026
34 checks passed
@mgovers
mgovers deleted the pgm/feature/link-supernode-output branch August 26, 2026 14:29
marhofmann added a commit to marhofmann/power-grid-model that referenced this pull request Aug 26, 2026
Each topological node holds one value per user node, and only link-merged
supernodes have more than one -- in a grid without links every topological
node has exactly one. Three of these vectors are rebuilt on every scenario
(node_injection, node_flow_from_branch and bus_injection), so each node asks
the allocator for room to store a single complex number three times per
scenario.

Give them inline room for one element, so the ordinary node does not
allocate. Link-merged nodes still work, they just allocate as before. The
indexing interface is unchanged. As a side effect the copy from
node_injection into bus_injection stops being a heap copy, because both
sides are now the same inline type.

Expose the container generically rather than at the point of use: a new
common/small_vector.hpp holds a single using declaration for SmallVector,
alongside the other type aliases in common/. Other call sites can then reach
for it without pulling in boost directly, and the underlying container can
be swapped in one place. boost::container::small_vector is header-only and
Boost::headers is already an INTERFACE dependency of the power_grid_model
target, so this adds nothing to the build. The inline capacity stays a
per-use-site decision; here it is 1 because that is exactly what an ordinary
topological node holds.

Measured on tests/benchmark_cpp (radial grid, 2605 nodes, 1000-scenario
symmetric Newton-Raphson batch), MSVC /O2, against the parent commit, 10
interleaved rounds per arm on an otherwise idle machine, medians:

  produce output    2.4487 s -> 2.2470 s   1.09x
  math calculation  2.0757 s -> 2.1361 s   control, unchanged within noise
  whole batch run   4.9217 s -> 4.7514 s   1.04x

The change won 9 of the 10 paired rounds, so the effect is real, but the
0.20 s median gain sits inside main's own 0.69 s run-to-run spread, so treat
it as modest rather than decisive.

The gain is smaller than it would have been before PowerGridModel#1536, because most of
the per-node allocation cost now sits in compute_link_solver, which this
does not touch. See the linked issue.

All ten C++ test suites pass, 176999 assertions, built with warnings as
errors, including the handling-of-links cases that exercise supernodes
holding more than one user node.

Signed-off-by: Martin Hofmann <martin.hofmann-3@ei.thm.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants