4
4
5
5
#pragma once
6
6
7
+ #include " core_utils.hpp"
7
8
#include " state.hpp"
8
- #include " utils.hpp"
9
9
10
10
#include " ../all_components.hpp"
11
11
#include " ../common/iterator_like_concepts.hpp"
@@ -100,7 +100,8 @@ template <typename CompType> void process_buffer_span(auto const& all_spans, Upd
100
100
// check the ids
101
101
auto const first_span = all_spans[0 ];
102
102
// check the subsequent scenarios
103
- // only return true if all scenarios match the ids of the first batch
103
+ // only return true if ids of all scenarios match the ids of the first batch
104
+
104
105
properties.update_ids_match =
105
106
std::ranges::all_of (all_spans.cbegin () + 1 , all_spans.cend (), [&first_span](auto const & current_span) {
106
107
return std::ranges::equal (current_span, first_span,
@@ -198,9 +199,9 @@ inline void get_component_sequence_impl(MainModelState<ComponentContainer> const
198
199
template <component_c Component, class ComponentContainer ,
199
200
forward_iterator_like<typename Component::UpdateType> ForwardIterator>
200
201
requires model_component_state_c<MainModelState, ComponentContainer, Component>
201
- inline std::vector<Idx2D> get_component_sequence_by_it (MainModelState<ComponentContainer> const & state,
202
- ForwardIterator begin, ForwardIterator end,
203
- Idx n_comp_elements = na_Idx) {
202
+ inline std::vector<Idx2D> get_component_sequence_by_iter (MainModelState<ComponentContainer> const & state,
203
+ ForwardIterator begin, ForwardIterator end,
204
+ Idx n_comp_elements = na_Idx) {
204
205
std::vector<Idx2D> result;
205
206
result.reserve (std::distance (begin, end));
206
207
get_component_sequence_impl<Component>(state, begin, end, std::back_inserter (result), n_comp_elements);
@@ -213,7 +214,7 @@ std::vector<Idx2D> get_component_sequence(MainModelState<ComponentContainer> con
213
214
ConstDataset const & update_data, Idx scenario_idx,
214
215
independence::UpdateCompProperties const & comp_independence = {}) {
215
216
auto const get_sequence = [&state, n_comp_elements = comp_independence.get_n_elements ()](auto const & span) {
216
- return get_component_sequence_by_it <CompType>(state, std::begin (span), std::end (span), n_comp_elements);
217
+ return get_component_sequence_by_iter <CompType>(state, std::begin (span), std::end (span), n_comp_elements);
217
218
};
218
219
if (update_data.is_columnar (CompType::name)) {
219
220
auto const buffer_span =
@@ -246,6 +247,8 @@ SequenceIdx<ComponentTypes...> get_all_sequence_idx_map(MainModelState<Component
246
247
template <class ... ComponentTypes, class ComponentContainer >
247
248
SequenceIdx<ComponentTypes...> get_all_sequence_idx_map (MainModelState<ComponentContainer> const & state,
248
249
ConstDataset const & update_data) {
250
+ // Independence for all components is set to true as permanent updates involve only one scenario.
251
+ // Flags for all components (not only the ones present in update_data) are set to avoid more expensive checks.
249
252
constexpr ComponentFlags<ComponentTypes...> all_true = [] {
250
253
ComponentFlags<ComponentTypes...> result{};
251
254
std::ranges::fill (result, true );
@@ -291,7 +294,7 @@ template <component_c Component, class ComponentContainer,
291
294
inline UpdateChange update_component (MainModelState<ComponentContainer>& state, ForwardIterator begin,
292
295
ForwardIterator end, OutputIterator changed_it) {
293
296
return update_component<Component>(state, begin, end, changed_it,
294
- detail::get_component_sequence_by_it <Component>(state, begin, end));
297
+ detail::get_component_sequence_by_iter <Component>(state, begin, end));
295
298
}
296
299
297
300
// template to get the inverse update for components
@@ -320,7 +323,7 @@ template <component_c Component, class ComponentContainer,
320
323
inline void update_inverse (MainModelState<ComponentContainer> const & state, ForwardIterator begin, ForwardIterator end,
321
324
OutputIterator destination) {
322
325
return update_inverse<Component>(state, begin, end, destination,
323
- detail::get_component_sequence_by_it <Component>(state, begin, end));
326
+ detail::get_component_sequence_by_iter <Component>(state, begin, end));
324
327
}
325
328
326
329
} // namespace power_grid_model::main_core::update
0 commit comments