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

Incremental Y-Bus admittance matrix update #444

Conversation

Jerry-Jinfeng-Guo
Copy link
Contributor

Incremental updates with decrement functionality, draft implementation not using std::views for now.

: add test case / benchmark the perf diff; add implementation using std::views.

… using `std::views` for now. ToDo: add test case / benchmark the perf diff; add implementation using `std::views`.

Signed-off-by: Jerry Guo <[email protected]>
…revent decrement more than once

Signed-off-by: Jerry Guo <[email protected]>
… based `affected_entries`.

Signed-off-by: Jerry Guo <[email protected]>
Signed-off-by: Jerry Guo <[email protected]>
Copy link
Member

@mgovers mgovers left a comment

Choose a reason for hiding this comment

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

i won't review everything but i just happened to find this 😬

@TonyXiang8787
Copy link
Member

@Jerry-Jinfeng-Guo is this PR now out of draft and ready for review?

@Jerry-Jinfeng-Guo
Copy link
Contributor Author

Jerry-Jinfeng-Guo commented Dec 22, 2023

@TonyXiang8787 To the comment : it's ready for review in its current usage. Some major discussions need to happen as to how users would typically use it, but I think those are mostly wrapper stuff on top of what's already implemented.

@TonyXiang8787 TonyXiang8787 marked this pull request as ready for review December 22, 2023 09:06
Signed-off-by: Martijn Govers <[email protected]>
@TonyXiang8787
Copy link
Member

@mgovers @Jerry-Jinfeng-Guo before you guys merge, please change the name of the PR. The name of the PR will be in the release note, so make a more understandable and meaningful name.

@mgovers mgovers changed the title Incremental updates with decrement functionality, draft implementation Incremental parameter updates to Ybus to prevent fully reconstructing Feb 5, 2024
@Jerry-Jinfeng-Guo Jerry-Jinfeng-Guo changed the title Incremental parameter updates to Ybus to prevent fully reconstructing Incremental Y-Bus admittance matrix update Feb 5, 2024
Signed-off-by: Martijn Govers <[email protected]>
@Jerry-Jinfeng-Guo Jerry-Jinfeng-Guo added the improvement Improvement on internal implementation label Feb 5, 2024
@mgovers
Copy link
Member

mgovers commented Feb 5, 2024

@mgovers @Jerry-Jinfeng-Guo

The iterative current pf solver uses the address of the YBus parameter to check if there is a change on the parameter or not. If we change the way YBus stores the parameter, we need to modify that logic too.

if (y_data_ptr_ != &y_bus.admittance()) {
ComplexTensorVector<sym> mat_data(y_bus.nnz_lu());
detail::copy_y_bus<sym>(y_bus, mat_data);
for (auto const& [bus_number, sources] : enumerated_zip_sequence(sources_per_bus)) {
Idx const data_sequence = bus_entry[bus_number];
for (auto source_number : sources) {
// YBus_diag += Y_source
mat_data[data_sequence] += y_bus.math_model_param().source_param[source_number];
}
}
// prefactorize
BlockPermArray perm(this->n_bus_);
sparse_solver_.prefactorize(mat_data, perm);
// move pre-factorized version into shared ptr
mat_data_ = std::make_shared<ComplexTensorVector<sym> const>(std::move(mat_data));
perm_ = std::make_shared<BlockPermArray const>(std::move(perm));
// cache pointer
y_data_ptr_ = &y_bus.admittance();
}
}

solved by making a callback if parameters changed that is registered for the solver to respective ybus

Signed-off-by: Jerry Guo <[email protected]>
@TonyXiang8787
Copy link
Member

@Jerry-Jinfeng-Guo @mgovers is this ready for final review?

@Jerry-Jinfeng-Guo
Copy link
Contributor Author

@Jerry-Jinfeng-Guo @mgovers is this ready for final review?

Apart from a few code smells, yes

Signed-off-by: Martijn Govers <[email protected]>
@mgovers
Copy link
Member

mgovers commented Feb 5, 2024

remaining code smells are the same as those on main

Signed-off-by: Martijn Govers <[email protected]>
@mgovers
Copy link
Member

mgovers commented Feb 5, 2024

This is ready for review again

Copy link

sonarqubecloud bot commented Feb 5, 2024

Quality Gate Passed Quality Gate passed

The SonarCloud Quality Gate passed, but some issues were introduced.

6 New issues
0 Security Hotspots
94.7% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarCloud

@Jerry-Jinfeng-Guo Jerry-Jinfeng-Guo merged commit 6de0638 into main Feb 5, 2024
27 checks passed
@Jerry-Jinfeng-Guo Jerry-Jinfeng-Guo deleted the feature/DGC-1950-Incrementally-update-topology-parameters branch February 5, 2024 14:58
@Jerry-Jinfeng-Guo Jerry-Jinfeng-Guo added the feature New feature or request label Feb 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request improvement Improvement on internal implementation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants