diff --git a/src/core/algorithms/dd/split/split.cpp b/src/core/algorithms/dd/split/split.cpp index 92d27dad9..9ee8d578a 100644 --- a/src/core/algorithms/dd/split/split.cpp +++ b/src/core/algorithms/dd/split/split.cpp @@ -175,6 +175,14 @@ unsigned Split::ReduceDDs(auto const& start_time) { std::vector search, dfs_y; std::list
reduced; + std::vector tuple_pair_indices; + if (reduce_method_ == +Reduce::IEHybrid) { + tuple_pair_indices = std::vector(tuple_pair_num_); + for (std::size_t i = 0; i < tuple_pair_num_; i++) { + tuple_pair_indices[i] = i; + } + } + for (model::ColumnIndex index = 0; index < num_columns_; index++) { std::vector indices; for (model::ColumnIndex j = 0; j < num_columns_; j++) { @@ -203,7 +211,7 @@ unsigned Split::ReduceDDs(auto const& start_time) { reduced = HybridPruningReduce(df_y, search, cnt); break; case +Reduce::IEHybrid: - reduced = InstanceExclusionReduce(tuple_pairs_, search, df_y, cnt); + reduced = InstanceExclusionReduce(tuple_pair_indices, search, df_y, cnt); break; default: break; @@ -327,6 +335,7 @@ void Split::CalculateTuplePairs() { } } } + tuple_pair_num_ = tuple_pairs_.size(); } double Split::CalculateDistance(model::ColumnIndex column_index, @@ -659,26 +668,26 @@ std::list
Split::HybridPruningReduce(DF const& rhs, std::vector const& s return dds; } -std::list
Split::InstanceExclusionReduce( - std::vector> const& tuple_pairs, - std::vector const& search, DF const& rhs, unsigned& cnt) { +std::list
Split::InstanceExclusionReduce(std::vector const& tuple_pair_indices, + std::vector const& search, DF const& rhs, + unsigned& cnt) { if (!search.size()) return {}; std::list
dds; DF const first_df = search.front(); DF const last_df = search.back(); - std::vector> remaining_tuple_pairs; + std::vector remaining_tuple_pair_indices; cnt++; bool last_dd_holds = true; bool no_pairs_left = true; - for (auto pair : tuple_pairs) { - if (!CheckDF(rhs, pair)) { - if (CheckDF(first_df, pair)) { - remaining_tuple_pairs.push_back(pair); + for (auto index : tuple_pair_indices) { + if (!CheckDF(rhs, tuple_pairs_[index])) { + if (CheckDF(first_df, tuple_pairs_[index])) { + remaining_tuple_pair_indices.push_back(index); no_pairs_left = false; } - if (last_dd_holds && CheckDF(last_df, pair)) last_dd_holds = false; + if (last_dd_holds && CheckDF(last_df, tuple_pairs_[index])) last_dd_holds = false; if (!no_pairs_left && !last_dd_holds) break; } } @@ -686,7 +695,8 @@ std::list
Split::InstanceExclusionReduce( if (no_pairs_left) { if (IsFeasible(first_df)) dds.emplace_back(first_df, rhs); std::vector remainder = DoPositivePruning(search, first_df); - std::list
remaining_dds = InstanceExclusionReduce(tuple_pairs, remainder, rhs, cnt); + std::list
remaining_dds = + InstanceExclusionReduce(tuple_pair_indices, remainder, rhs, cnt); dds.splice(dds.end(), remaining_dds); return dds; } @@ -695,14 +705,14 @@ std::list
Split::InstanceExclusionReduce( if (!last_dd_holds) { std::vector remainder = DoNegativePruning(search, last_df); - return InstanceExclusionReduce(tuple_pairs, remainder, rhs, cnt); + return InstanceExclusionReduce(tuple_pair_indices, remainder, rhs, cnt); } auto const [prune, remainder] = PositiveSplit(search, first_df); - dds = InstanceExclusionReduce(tuple_pairs, remainder, rhs, cnt); + dds = InstanceExclusionReduce(tuple_pair_indices, remainder, rhs, cnt); std::list
const pruning_dds = - InstanceExclusionReduce(remaining_tuple_pairs, prune, rhs, cnt); + InstanceExclusionReduce(remaining_tuple_pair_indices, prune, rhs, cnt); std::list
merged_dds = MergeReducedResults(dds, pruning_dds); dds.splice(dds.end(), merged_dds); diff --git a/src/core/algorithms/dd/split/split.h b/src/core/algorithms/dd/split/split.h index 4d4933256..3a8697600 100644 --- a/src/core/algorithms/dd/split/split.h +++ b/src/core/algorithms/dd/split/split.h @@ -31,6 +31,7 @@ class Split : public Algorithm { unsigned num_rows_; model::ColumnIndex num_columns_; std::vector non_empty_cols_; + std::size_t tuple_pair_num_; std::vector type_ids_; @@ -87,9 +88,9 @@ class Split : public Algorithm { std::list
NegativePruningReduce(DF const& rhs, std::vector const& search, unsigned& cnt); std::list
HybridPruningReduce(DF const& rhs, std::vector const& search, unsigned& cnt); - std::list
InstanceExclusionReduce( - std::vector> const& tuple_pairs, - std::vector const& search, DF const& rhs, unsigned& cnt); + std::list
InstanceExclusionReduce(std::vector const& tuple_pair_indices, + std::vector const& search, DF const& rhs, + unsigned& cnt); unsigned ReduceDDs(auto const& start_time); unsigned RemoveRedundantDDs(); unsigned RemoveTransitiveDDs();