power-grid-model icon indicating copy to clipboard operation
power-grid-model copied to clipboard

[FEATURE] More efficient iterations over components

Open mgovers opened this issue 1 year ago • 1 comments

Describe the feature request

The enumerated_zip_sequence function iterates over all groups/buses, regardless of whether the input was a DenseGroupedIdxVector or a SparseGroupedIdxVector.

Especially for DenseGroupedIdxVector, for which it is expected to have few groups/buses, the iteration is over a lot of empty groups (potentially orders of magnitude larger than the amount of actually occupied non-empty groups). This results in a lot of useless calculations.

Proposed solution

  • Create a function enumerate_occupied that takes in only one grouped_idx_vector and enumerates over the occupied groupes only
  • Do not support zipped iterations to prevent difficult occupied group matching
  • Keep the current enumerated_zip_sequence to allow for zip-like features

mgovers avatar Oct 24 '23 06:10 mgovers

Most of this was resolved in #426 . Only determining a better decision criterion is left:

https://github.com/PowerGridModel/power-grid-model/blame/main/power_grid_model_c/power_grid_model/include/power_grid_model/index_mapping.hpp#L134C23-L134C53

mgovers avatar Feb 14 '24 08:02 mgovers