From 1dc086dffba99ca494f6de9245a9879c820a13a5 Mon Sep 17 00:00:00 2001 From: Thomas <purcell@fhi-berlin.mpg.de> Date: Wed, 7 Apr 2021 15:05:55 +0200 Subject: [PATCH] Bug fixes from the previous merge Cleaning some errors up that occured after the merge --- .../feature_space/FeatureSpace.cpp | 12 +++------- .../abs_diff/absolute_difference.cpp | 1 + .../value_storage/nodes_value_containers.hpp | 2 +- src/mpi_interface/MPI_ops.cpp | 8 +++---- src/utils/compare_features.cpp | 24 +++++++++---------- src/utils/compare_features.hpp | 16 ++++++------- src/utils/project.cpp | 4 ++-- src/utils/project.hpp | 4 ++-- .../googletest/utils/test_compare_features.cc | 12 +++++----- 9 files changed, 39 insertions(+), 44 deletions(-) diff --git a/src/feature_creation/feature_space/FeatureSpace.cpp b/src/feature_creation/feature_space/FeatureSpace.cpp index f75ae553..c3991840 100644 --- a/src/feature_creation/feature_space/FeatureSpace.cpp +++ b/src/feature_creation/feature_space/FeatureSpace.cpp @@ -107,20 +107,14 @@ void FeatureSpace::initialize_fs() int n_max_ops = 0; for(int rr = 0; rr < _max_phi - _n_rung_store; ++rr) n_max_ops += std::pow(2, rr); - if((n_max_ops > _phi_0.size()) && (_n_rung_store == 0)) - { - std::cerr << "WARNING: Setting _n_rung_store to 1 to prevent possible overwrite issues" << std::endl; - ++_n_rung_store; - _n_rung_generate -= (_n_rung_generate == 1) && (_n_rung_store + _n_rung_generate > _max_phi); - } initialize_fs_output_files(); - project_funcs::set_project_fxn(project_type, _task_sizes.size(), _project, _project_no_omp); - comp_feats::set_is_valid_fxn(project_type, _cross_cor_max, _n_samp, _is_valid, _is_valid_feat_list); + project_funcs::set_project_fxn(_project_type, _task_sizes.size(), _project, _project_no_omp); + comp_feats::set_is_valid_fxn(_project_type, _cross_cor_max, _n_samp, _is_valid, _is_valid_feat_list); set_op_lists(); double start = omp_get_wtime(); - generate_feature_space(prop); + generate_feature_space(); _mpi_comm->barrier(); double duration = omp_get_wtime() - start; if(_mpi_comm->rank() == 0) diff --git a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/abs_diff/absolute_difference.cpp b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/abs_diff/absolute_difference.cpp index 7422e108..e5da83a0 100644 --- a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/abs_diff/absolute_difference.cpp +++ b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/abs_diff/absolute_difference.cpp @@ -1,4 +1,5 @@ #include <feature_creation/node/operator_nodes/allowed_operator_nodes/abs_diff/absolute_difference.hpp> +#include <feature_creation/node/operator_nodes/allowed_operator_nodes/sub/subtract.hpp> void generateAbsDiffNode(std::vector<node_ptr>& feat_list, node_ptr feat_1, node_ptr feat_2, unsigned long int& feat_ind, double l_bound, double u_bound) { diff --git a/src/feature_creation/node/value_storage/nodes_value_containers.hpp b/src/feature_creation/node/value_storage/nodes_value_containers.hpp index 1e73ab5f..5bc3930b 100644 --- a/src/feature_creation/node/value_storage/nodes_value_containers.hpp +++ b/src/feature_creation/node/value_storage/nodes_value_containers.hpp @@ -81,7 +81,7 @@ namespace node_value_arrs * @param n_feat number of features to store * @param use_temp If true keep the temporary_storage */ - void resize_values_arr(int n_dims, unsigned long int n_feat, bool use_temp); + void resize_values_arr(int n_dims, int n_feat, bool use_temp); /** * @brief Initialize the descriptor matrix diff --git a/src/mpi_interface/MPI_ops.cpp b/src/mpi_interface/MPI_ops.cpp index 00c3cbf3..4adc7290 100644 --- a/src/mpi_interface/MPI_ops.cpp +++ b/src/mpi_interface/MPI_ops.cpp @@ -13,16 +13,16 @@ void mpi_reduce_op::set_op(std::string project_type, double cross_cor_max, int n if(project_type.compare("classification") == 0) { if(CROSS_COR_MAX < 0.99999) - IS_VALID = comp_feats::valid_feature_against_spearman_selected_feat; + IS_VALID = comp_feats::valid_feature_against_selected_spearman_mpi_op; else - IS_VALID = comp_feats::valid_feature_against_spearman_selected_max_corr_1; + IS_VALID = comp_feats::valid_feature_against_selected_spearman_max_corr_1_mpi_op; } else { if(CROSS_COR_MAX < 0.99999) - IS_VALID = comp_feats::valid_feature_against_pearson_selected_feat; + IS_VALID = comp_feats::valid_feature_against_selected_pearson_mpi_op; else - IS_VALID = comp_feats::valid_feature_against_pearson_selected_max_corr_1; + IS_VALID = comp_feats::valid_feature_against_selected_pearson_max_corr_1_mpi_op; } } diff --git a/src/utils/compare_features.cpp b/src/utils/compare_features.cpp index 1475bc2a..7e87475e 100644 --- a/src/utils/compare_features.cpp +++ b/src/utils/compare_features.cpp @@ -17,12 +17,12 @@ void comp_feats::set_is_valid_fxn( if(max_corr < 0.99999) { is_valid = valid_feature_against_selected_pearson; - is_valid_feat_list = valid_feature_against_selected_pearson; + is_valid_feat_list = valid_feature_against_selected_pearson_feat_list; } else { is_valid = valid_feature_against_selected_pearson_max_corr_1; - is_valid_feat_list = valid_feature_against_selected_pearson_max_corr_1; + is_valid_feat_list = valid_feature_against_selected_pearson_max_corr_1_feat_list; } } else @@ -33,12 +33,12 @@ void comp_feats::set_is_valid_fxn( if(max_corr < 0.99999) { is_valid = valid_feature_against_selected_spearman; - is_valid_feat_list = valid_feature_against_selected_spearman; + is_valid_feat_list = valid_feature_against_selected_spearman_feat_list; } else { is_valid = valid_feature_against_selected_spearman_max_corr_1; - is_valid_feat_list = valid_feature_against_selected_spearman_max_corr_1; + is_valid_feat_list = valid_feature_against_selected_spearman_max_corr_1_feat_list; } } } @@ -59,7 +59,7 @@ bool comp_feats::valid_feature_against_selected_pearson_max_corr_1(double* val_p return true; } -bool comp_feats::valid_feature_against_selected_pearson_max_corr_1(double* val_ptr, int n_samp, double cross_cor_max, std::vector<node_ptr>& selected, std::vector<double>& scores_sel, double cur_score) +bool comp_feats::valid_feature_against_selected_pearson_max_corr_1_feat_list(double* val_ptr, int n_samp, double cross_cor_max, std::vector<node_ptr>& selected, std::vector<double>& scores_sel, double cur_score) { double base_val = util_funcs::r(val_ptr, val_ptr, n_samp); @@ -74,7 +74,7 @@ bool comp_feats::valid_feature_against_selected_pearson_max_corr_1(double* val_p return true; } -bool comp_feats::valid_feature_against_selected_pearson_max_corr_1(double* val_ptr, int n_samp, double cross_cor_max, std::vector<node_sc_pair>& out_vec, double cur_score) +bool comp_feats::valid_feature_against_selected_pearson_max_corr_1_mpi_op(double* val_ptr, int n_samp, double cross_cor_max, std::vector<node_sc_pair>& out_vec, double cur_score) { double base_val = util_funcs::r(val_ptr, val_ptr, n_samp); @@ -107,7 +107,7 @@ bool comp_feats::valid_feature_against_selected_pearson(double* val_ptr, int n_s return is_valid; } -bool comp_feats::valid_feature_against_selected_pearson(double* val_ptr, int n_samp, double cross_cor_max, std::vector<node_ptr>& selected, std::vector<double>& scores_sel, double cur_score) +bool comp_feats::valid_feature_against_selected_pearson_feat_list(double* val_ptr, int n_samp, double cross_cor_max, std::vector<node_ptr>& selected, std::vector<double>& scores_sel, double cur_score) { double base_val = util_funcs::r(val_ptr, val_ptr, n_samp); @@ -119,7 +119,7 @@ bool comp_feats::valid_feature_against_selected_pearson(double* val_ptr, int n_s return true; } -bool comp_feats::valid_feature_against_selected_pearson(double* val_ptr, int n_samp, double cross_cor_max, std::vector<node_sc_pair>& out_vec, double cur_score) +bool comp_feats::valid_feature_against_selected_pearson_mpi_op(double* val_ptr, int n_samp, double cross_cor_max, std::vector<node_sc_pair>& out_vec, double cur_score) { double base_val = util_funcs::r(val_ptr, val_ptr, n_samp); @@ -149,7 +149,7 @@ bool comp_feats::valid_feature_against_selected_spearman_max_corr_1(double* val_ return true; } -bool comp_feats::valid_feature_against_selected_spearman_max_corr_1(double* val_ptr, int n_samp, double cross_cor_max, std::vector<node_ptr>& selected, std::vector<double>& scores_sel, double cur_score) +bool comp_feats::valid_feature_against_selected_spearman_max_corr_1_feat_list(double* val_ptr, int n_samp, double cross_cor_max, std::vector<node_ptr>& selected, std::vector<double>& scores_sel, double cur_score) { double base_val = std::abs(util_funcs::spearman_r(val_ptr, val_ptr, &RANK[omp_get_thread_num() * 4 * n_samp], &RANK[(omp_get_thread_num() * 4 + 2) * n_samp], &INDEX[omp_get_thread_num() * 2 * n_samp], n_samp)); @@ -166,7 +166,7 @@ bool comp_feats::valid_feature_against_selected_spearman_max_corr_1(double* val_ return true; } -bool comp_feats::valid_feature_against_selected_spearman_max_corr_1(double* val_ptr, int n_samp, double cross_cor_max, std::vector<node_sc_pair>& out_vec, double cur_score) +bool comp_feats::valid_feature_against_selected_spearman_max_corr_1_mpi_op(double* val_ptr, int n_samp, double cross_cor_max, std::vector<node_sc_pair>& out_vec, double cur_score) { double base_val = std::abs(util_funcs::spearman_r(val_ptr, val_ptr, &RANK[omp_get_thread_num() * 4 * n_samp], &RANK[(omp_get_thread_num() * 4 + 2) * n_samp], &INDEX[omp_get_thread_num() * 2 * n_samp], n_samp)); @@ -201,7 +201,7 @@ bool comp_feats::valid_feature_against_selected_spearman(double* val_ptr, int n_ return is_valid; } -bool comp_feats::valid_feature_against_selected_spearman(double* val_ptr, int n_samp, double cross_cor_max, std::vector<node_ptr>& selected, std::vector<double>& scores_sel, double cur_score) +bool comp_feats::valid_feature_against_selected_spearman_feat_list(double* val_ptr, int n_samp, double cross_cor_max, std::vector<node_ptr>& selected, std::vector<double>& scores_sel, double cur_score) { double base_val = std::abs(util_funcs::spearman_r(val_ptr, val_ptr, &RANK[omp_get_thread_num() * 4 * n_samp], &RANK[(omp_get_thread_num() * 4 + 2) * n_samp], &INDEX[omp_get_thread_num() * 2 * n_samp], n_samp)); @@ -215,7 +215,7 @@ bool comp_feats::valid_feature_against_selected_spearman(double* val_ptr, int n_ return true; } -bool comp_feats::valid_feature_against_selected_spearman(double* val_ptr, int n_samp, double cross_cor_max, std::vector<node_sc_pair>& out_vec, double cur_score) +bool comp_feats::valid_feature_against_selected_spearman_mpi_op(double* val_ptr, int n_samp, double cross_cor_max, std::vector<node_sc_pair>& out_vec, double cur_score) { double base_val = std::abs(util_funcs::spearman_r(val_ptr, val_ptr, &RANK[omp_get_thread_num() * 4 * n_samp], &RANK[(omp_get_thread_num() * 4 + 2) * n_samp], &INDEX[omp_get_thread_num() * 2 * n_samp], n_samp)); diff --git a/src/utils/compare_features.hpp b/src/utils/compare_features.hpp index 0badade6..0cd67b52 100644 --- a/src/utils/compare_features.hpp +++ b/src/utils/compare_features.hpp @@ -59,7 +59,7 @@ namespace comp_feats * * @return True if the feature is still valid */ - bool valid_feature_against_selected_pearson_max_corr_1(double* val_ptr, int n_samp, double cross_cor_max, std::vector<node_ptr>& selected, std::vector<double>& scores_sel, double cur_score); + bool valid_feature_against_selected_pearson_max_corr_1_feat_list(double* val_ptr, int n_samp, double cross_cor_max, std::vector<node_ptr>& selected, std::vector<double>& scores_sel, double cur_score); /** * @brief Checks the feature to see if it is still valid against previously selected features (using the Pearson correlation coefficient with a maximum cross-correlation of 1.0) @@ -73,7 +73,7 @@ namespace comp_feats * * @return True if the feature is still valid */ - bool valid_feature_against_selected_pearson_max_corr_1(double* val_ptr, int n_samp, double cross_cor_max, std::vector<node_sc_pair>& out_vec, double cur_score); + bool valid_feature_against_selected_pearson_max_corr_1_mpi_op(double* val_ptr, int n_samp, double cross_cor_max, std::vector<node_sc_pair>& out_vec, double cur_score); /** * @brief Checks the feature to see if it is still valid against previously selected features (using the Pearson correlation coefficient) @@ -98,7 +98,7 @@ namespace comp_feats * * @return True if the feature is still valid */ - bool valid_feature_against_selected_pearson(double* val_ptr, int n_samp, double cross_cor_max, std::vector<node_ptr>& selected, std::vector<double>& scores_sel, double cur_score); + bool valid_feature_against_selected_pearson_feat_list(double* val_ptr, int n_samp, double cross_cor_max, std::vector<node_ptr>& selected, std::vector<double>& scores_sel, double cur_score); /** * @brief Checks the feature to see if it is still valid against previously selected features (using the Pearson correlation coefficient) @@ -112,7 +112,7 @@ namespace comp_feats * * @return True if the feature is still valid */ - bool valid_feature_against_selected_pearson(double* val_ptr, int n_samp, double cross_cor_max, std::vector<node_sc_pair>& out_vec, double cur_score); + bool valid_feature_against_selected_pearson_mpi_op(double* val_ptr, int n_samp, double cross_cor_max, std::vector<node_sc_pair>& out_vec, double cur_score); /** * @brief Checks the feature to see if it is still valid against previously selected features (using the rank correlation coefficient with a maximum cross-correlation of 1.0) @@ -137,7 +137,7 @@ namespace comp_feats * * @return True if the feature is still valid */ - bool valid_feature_against_selected_spearman_max_corr_1(double* val_ptr, int n_samp, double cross_cor_max, std::vector<node_ptr>& selected, std::vector<double>& scores_sel, double cur_score); + bool valid_feature_against_selected_spearman_max_corr_1_feat_list(double* val_ptr, int n_samp, double cross_cor_max, std::vector<node_ptr>& selected, std::vector<double>& scores_sel, double cur_score); /** * @brief Checks the feature to see if it is still valid against previously selected features (using the rank correlation coefficient with a maximum cross-correlation of 1.0) @@ -151,7 +151,7 @@ namespace comp_feats * * @return True if the feature is still valid */ - bool valid_feature_against_selected_spearman_max_corr_1(double* val_ptr, int n_samp, double cross_cor_max, std::vector<node_sc_pair>& out_vec, double cur_score); + bool valid_feature_against_selected_spearman_max_corr_1_mpi_op(double* val_ptr, int n_samp, double cross_cor_max, std::vector<node_sc_pair>& out_vec, double cur_score); /** * @brief Checks the feature to see if it is still valid against previously selected features (using the rank correlation coefficient) @@ -176,7 +176,7 @@ namespace comp_feats * * @return True if the feature is still valid */ - bool valid_feature_against_selected_spearman(double* val_ptr, int n_samp, double cross_cor_max, std::vector<node_ptr>& selected, std::vector<double>& scores_sel, double cur_score); + bool valid_feature_against_selected_spearman_feat_list(double* val_ptr, int n_samp, double cross_cor_max, std::vector<node_ptr>& selected, std::vector<double>& scores_sel, double cur_score); /** * @brief Checks the feature to see if it is still valid against previously selected features (using the rank correlation coefficient) @@ -190,7 +190,7 @@ namespace comp_feats * * @return True if the feature is still valid */ - bool valid_feature_against_selected_spearman(double* val_ptr, int n_samp, double cross_cor_max, std::vector<node_sc_pair>& out_vec, double cur_score); + bool valid_feature_against_selected_spearman_mpi_op(double* val_ptr, int n_samp, double cross_cor_max, std::vector<node_sc_pair>& out_vec, double cur_score); } #endif diff --git a/src/utils/project.cpp b/src/utils/project.cpp index 8efa8739..bcae3d99 100644 --- a/src/utils/project.cpp +++ b/src/utils/project.cpp @@ -3,8 +3,8 @@ void project_funcs::set_project_fxn( const std::string project_type, const int n_task, - std::function<void(double*, double*, std::vector<node_ptr>&, std::vector<int>&, int)>& project, - std::function<void(double*, double*, std::vector<node_ptr>&, std::vector<int>&, int)>& project_no_omp + std::function<void(double*, double*, std::vector<node_ptr>&, const std::vector<int>&, int)>& project, + std::function<void(double*, double*, std::vector<node_ptr>&, const std::vector<int>&, int)>& project_no_omp ) { if(project_type.compare("regression") == 0) diff --git a/src/utils/project.hpp b/src/utils/project.hpp index 24f7afc9..d5741287 100644 --- a/src/utils/project.hpp +++ b/src/utils/project.hpp @@ -27,8 +27,8 @@ namespace project_funcs void set_project_fxn( const std::string project_type, const int n_task, - std::function<void(double*, double*, std::vector<node_ptr>&, std::vector<int>&, int)>& project, - std::function<void(double*, double*, std::vector<node_ptr>&, std::vector<int>&, int)>& project_no_omp + std::function<void(double*, double*, std::vector<node_ptr>&, const std::vector<int>&, int)>& project, + std::function<void(double*, double*, std::vector<node_ptr>&, const std::vector<int>&, int)>& project_no_omp ); /** diff --git a/tests/googletest/utils/test_compare_features.cc b/tests/googletest/utils/test_compare_features.cc index 831c4a15..75903be6 100644 --- a/tests/googletest/utils/test_compare_features.cc +++ b/tests/googletest/utils/test_compare_features.cc @@ -21,14 +21,14 @@ namespace { std::copy_n(val_3.data(), val_3.size(), node_value_arrs::get_d_matrix_ptr(0)); - EXPECT_FALSE(comp_feats::valid_feature_against_selected_max_corr_1_pearson(val_1.data(), 4, 1.0, scores, 0.9897782665572893, 1, 0)); - EXPECT_FALSE(comp_feats::valid_feature_against_selected_max_corr_1_feat_list_pearson(val_1.data(), 4, 1.0, selected, scores, 0.9897782665572893)); + EXPECT_FALSE(comp_feats::valid_feature_against_selected_pearson_max_corr_1(val_1.data(), 4, 1.0, scores, 0.9897782665572893, 1, 0)); + EXPECT_FALSE(comp_feats::valid_feature_against_selected_pearson_max_corr_1_feat_list(val_1.data(), 4, 1.0, selected, scores, 0.9897782665572893)); EXPECT_FALSE(comp_feats::valid_feature_against_selected_pearson(val_1.data(), 4, 1.0, scores, 0.9897782665572893, 1, 0)); - EXPECT_FALSE(comp_feats::valid_feature_against_selected_feat_list_pearson(val_1.data(), 4, 1.0, selected, scores, 0.9897782665572893)); + EXPECT_FALSE(comp_feats::valid_feature_against_selected_pearson_feat_list(val_1.data(), 4, 1.0, selected, scores, 0.9897782665572893)); - EXPECT_TRUE(comp_feats::valid_feature_against_selected_max_corr_1_pearson(val_2.data(), 4, 1.0, scores, 0.9028289727756884, 1, 0)); - EXPECT_TRUE(comp_feats::valid_feature_against_selected_max_corr_1_feat_list_pearson(val_2.data(), 4, 1.0, selected, scores, 0.9028289727756884)); + EXPECT_TRUE(comp_feats::valid_feature_against_selected_pearson_max_corr_1(val_2.data(), 4, 1.0, scores, 0.9028289727756884, 1, 0)); + EXPECT_TRUE(comp_feats::valid_feature_against_selected_pearson_max_corr_1_feat_list(val_2.data(), 4, 1.0, selected, scores, 0.9028289727756884)); EXPECT_TRUE(comp_feats::valid_feature_against_selected_pearson(val_2.data(), 4, 1.0, scores, 0.9028289727756884, 1, 0)); - EXPECT_TRUE(comp_feats::valid_feature_against_selected_feat_list_pearson(val_2.data(), 4, 1.0, selected, scores, 0.9028289727756884)); + EXPECT_TRUE(comp_feats::valid_feature_against_selected_pearson_feat_list(val_2.data(), 4, 1.0, selected, scores, 0.9028289727756884)); } } -- GitLab