power-grid-model
power-grid-model copied to clipboard
[FEATURE] More efficient iterations over components
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 onegrouped_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
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