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

[FEATURE] Incrementally update topology parameters when there is a parameter change #337

Closed
TonyXiang8787 opened this issue Aug 8, 2023 · 7 comments
Labels
improvement Improvement on internal implementation

Comments

@TonyXiang8787
Copy link
Member

TonyXiang8787 commented Aug 8, 2023

Background

When the PGM get updated, we check if the topology is changed and/or the parameters are changed. For topology change we need to rebuild the whole topology. For parameter change we need to update the parameters in the math model.

Currently, we recalculate all the parameters in the math model. This is significant work. Mathematically, we just need to update the parameters which are impacted by the change.

Improvement

We propose to only update the math parameters incrementally when there are some changes.

  1. Remove the single boolean status topology_param_up_to_date. Make a track of all the changed components which have impact on math parameter.
  2. In the update parameter function, only calculate the math parameter of those components. And update them incrementally in the math model, mainly YBus class.

Consideration

Currently the mathematical parameters are stored as std:shared_ptr<const T> in the YBus. This makes sharing between the threads easy. But if we want to update the value, we have to re-allocate the whole struct and copy the old values. We need to think the trade-off of using std:shared_ptr<const T> or just by value.

@TonyXiang8787 TonyXiang8787 added the improvement Improvement on internal implementation label Aug 8, 2023
@TonyXiang8787 TonyXiang8787 moved this to Q3 2023 in Power Grid Model Aug 8, 2023
@TonyXiang8787 TonyXiang8787 moved this from Q3 2023 to Q4 2023 in Power Grid Model Sep 19, 2023
@mgovers
Copy link
Member

mgovers commented Feb 14, 2024

Most of this was resolved in #444 . Only removal of construction of all math parameters in main_model.hpp is left

@TonyXiang8787
Copy link
Member Author

This has been implemented in #444

@mgovers
Copy link
Member

mgovers commented Sep 20, 2024

Most of this was resolved in #444 . Only removal of construction of all math parameters in main_model.hpp is left

So we're not going to go all the way.

@TonyXiang8787
Copy link
Member Author

Most of this was resolved in #444 . Only removal of construction of all math parameters in main_model.hpp is left

So we're not going to go all the way.

What do you mean removal of construction of all math parameters in main_model.hpp?

@mgovers
Copy link
Member

mgovers commented Oct 7, 2024

Most of this was resolved in #444 . Only removal of construction of all math parameters in main_model.hpp is left

So we're not going to go all the way.

What do you mean removal of construction of all math parameters in main_model.hpp?

https://github.com/PowerGridModel/power-grid-model/blob/main/power_grid_model_c/power_grid_model/include/power_grid_model/main_model_impl.hpp#L1180-L1307

in this code section, we always calculate the calculation_parameters for all components, even if only one of them is updated. We can cache that and only calculate the calculation parameters for the components that have changed.

@TonyXiang8787
Copy link
Member Author

Most of this was resolved in #444 . Only removal of construction of all math parameters in main_model.hpp is left

So we're not going to go all the way.

What do you mean removal of construction of all math parameters in main_model.hpp?

https://github.com/PowerGridModel/power-grid-model/blob/main/power_grid_model_c/power_grid_model/include/power_grid_model/main_model_impl.hpp#L1180-L1307

in this code section, we always calculate the calculation_parameters for all components, even if only one of them is updated. We can cache that and only calculate the calculation parameters for the components that have changed.

So we always calculate all the parameters, and for incremental update, we only use some of them to update the YBus?

If that's the case, we can indeed further optimize. Please create a separate ticket to explain the issue.

@mgovers
Copy link
Member

mgovers commented Oct 7, 2024

Most of this was resolved in #444 . Only removal of construction of all math parameters in main_model.hpp is left

So we're not going to go all the way.

What do you mean removal of construction of all math parameters in main_model.hpp?

https://github.com/PowerGridModel/power-grid-model/blob/main/power_grid_model_c/power_grid_model/include/power_grid_model/main_model_impl.hpp#L1180-L1307
in this code section, we always calculate the calculation_parameters for all components, even if only one of them is updated. We can cache that and only calculate the calculation parameters for the components that have changed.

So we always calculate all the parameters, and for incremental update, we only use some of them to update the YBus?

If that's the case, we can indeed further optimize. Please create a separate ticket to explain the issue.

done in #766

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement Improvement on internal implementation
Projects
Status: Q3 2024
Development

No branches or pull requests

2 participants