diff --git a/src/descriptor_identifier/SISSORegressor.cpp b/src/descriptor_identifier/SISSORegressor.cpp index c4cde777339cace3f60f2242b6b8edcb8c2962bd..2fb93748a8f823ce97262cff7683d3e7ab27adca 100644 --- a/src/descriptor_identifier/SISSORegressor.cpp +++ b/src/descriptor_identifier/SISSORegressor.cpp @@ -56,7 +56,7 @@ void SISSORegressor::least_squares(std::vector<int>& inds, double* coeffs, int s std::copy_n(_b.get(), n_dim, coeffs); else { - std::string err_msg = "least_squares failed, " + std::to_string(info); + std::string err_msg = "least_squares failed, " + std::to_string(info) + ", on rank: " + std::to_string(_mpi_comm->rank()); for(auto& ind : inds) err_msg += ", " + std::to_string(ind) + ": " + std::to_string(node_value_arrs::get_d_matrix_ptr(ind)[0]); throw std::logic_error(err_msg); diff --git a/src/feature_creation/feature_space/FeatureSpace.cpp b/src/feature_creation/feature_space/FeatureSpace.cpp index a4d5f340bad053c9fb7abd8a433363f8839f5853..c5a3ab37d146adc8bb015bfc6393a885a1bac8b1 100644 --- a/src/feature_creation/feature_space/FeatureSpace.cpp +++ b/src/feature_creation/feature_space/FeatureSpace.cpp @@ -146,12 +146,12 @@ void FeatureSpace::generate_feature_space(std::vector<double>& prop) _n_feat = _phi.size(); int feat_ind = _phi.size(); - for(auto feat_1 = _phi.begin() + _mpi_comm->rank(); feat_1 < _phi.end(); feat_1 += _mpi_comm->size()) + for(auto feat_1 = _phi.begin() + _mpi_comm->rank() + _start_gen.back(); feat_1 < _phi.end(); feat_1 += _mpi_comm->size()) generate_new_feats(feat_1, next_phi, feat_ind, l_bound, u_bound); - _mpi_comm->barrier(); _start_gen.push_back(_phi.size()); - if((nn < _max_phi) || (_mpi_comm->size() == 1)) + + if((nn < _max_phi) || (nn <= _n_rung_store) || (_mpi_comm->size() == 1)) { std::vector<std::vector<node_ptr>> next_phi_gathered; mpi::all_gather(*_mpi_comm, next_phi, next_phi_gathered); @@ -168,9 +168,10 @@ void FeatureSpace::generate_feature_space(std::vector<double>& prop) } } + node_value_arrs::clear_temp_reg(); if(nn < _max_phi) { - std::fill_n(node_value_arrs::TEMP_STORAGE_REG.data(), node_value_arrs::TEMP_STORAGE_REG.size(), -1); + // std::fill_n(node_value_arrs::TEMP_STORAGE_REG.data(), node_value_arrs::TEMP_STORAGE_REG.size(), -1); // Remove identical features _scores.resize(_phi.size()); @@ -181,14 +182,13 @@ void FeatureSpace::generate_feature_space(std::vector<double>& prop) std::vector<int> del_inds; + _mpi_comm->barrier(); + + for(int sc = 0; sc < _scores.size() - 1; ++sc) - { - if(_scores[inds[sc]] - _scores[inds[sc + 1]] < 1e-10) - { - if(1.0 - std::abs(util_funcs::r(_phi[_start_gen.back() + inds[sc]]->value_ptr(), _phi[_start_gen.back() + inds[sc + 1]]->value_ptr(), _n_samp)) < 1e-13) + if(_scores[inds[sc + 1]] - _scores[inds[sc]] < 1e-10) + if(std::abs(util_funcs::r(_phi[_start_gen.back() + inds[sc]]->value_ptr(), _phi[_start_gen.back() + inds[sc]]->value_ptr(), _n_samp) - util_funcs::r(_phi[_start_gen.back() + inds[sc]]->value_ptr(), _phi[_start_gen.back() + inds[sc + 1]]->value_ptr(), _n_samp)) < 1e-13) del_inds.push_back(-1 * (inds[sc] + _start_gen.back())); - } - } inds = util_funcs::argsort(del_inds); for(int ii = 0; ii < inds.size(); ++ii) @@ -327,6 +327,7 @@ void FeatureSpace::generate_feature_space(std::vector<double>& prop) } } } + _n_feat = _phi.size(); } @@ -344,8 +345,8 @@ void FeatureSpace::project_generated(double* prop, int size, std::vector<node_pt for(auto feat = _phi.begin() + _start_gen.back() + _mpi_comm->rank(); feat < _phi.end(); feat += _mpi_comm->size()) { - std::fill_n(node_value_arrs::TEMP_STORAGE_REG.data(), node_value_arrs::TEMP_STORAGE_REG.size(), -1); - std::fill_n(node_value_arrs::TEMP_STORAGE_TEST_REG.data(), node_value_arrs::TEMP_STORAGE_TEST_REG.size(), -1); + node_value_arrs::clear_temp_reg(); + node_value_arrs::clear_temp_test_reg(); int feat_ind = _phi.size(); std::vector<node_ptr> generated_phi; @@ -407,7 +408,7 @@ bool FeatureSpace::valid_score_against_past(double* val_ptr, double cur_score, s if(*std::min_element(scores_comp.begin(), scores_comp.end()) < 1e-10) { int dd = std::min_element(scores_comp.begin(), scores_comp.end()) - scores_comp.begin(); - if(1.0 - std::abs(util_funcs::r(node_value_arrs::get_d_matrix_ptr(dd), val_ptr, _n_samp)) < 1e-13) + if(std::abs(util_funcs::r(val_ptr, val_ptr, _n_samp) - util_funcs::r(node_value_arrs::get_d_matrix_ptr(dd), val_ptr, _n_samp)) < 1e-10) return false; } return true; @@ -420,14 +421,25 @@ bool FeatureSpace::valid_score_against_current(int end_check, double* val_ptr, d if(*std::min_element(scores_comp.begin(), scores_comp.begin() + end_check) < 1e-10) { int dd = std::min_element(scores_comp.begin(), scores_comp.begin() + end_check) - scores_comp.begin(); - if(1.0 - std::abs(util_funcs::r(node_value_arrs::get_d_matrix_ptr(node_value_arrs::N_SELECTED - _n_sis_select + dd), val_ptr, _n_samp)) < 1e-13) + if(std::abs(util_funcs::r(val_ptr, val_ptr, _n_samp) - util_funcs::r(node_value_arrs::get_d_matrix_ptr(node_value_arrs::N_SELECTED - _n_sis_select + dd), val_ptr, _n_samp)) < 1e-10) return false; + else + { + std::vector<double> test(_n_samp); + std::transform(val_ptr, val_ptr + _n_samp, node_value_arrs::get_d_matrix_ptr(node_value_arrs::N_SELECTED - _n_sis_select + dd), test.data(), std::minus<double>()); + std::cout << std::setw(24) << std::setprecision(20) << *std::min_element(test.begin(), test.end()) << '\t' << *std::max_element(test.begin(), test.end()) << std::endl; + std::cout << std::setw(24) << std::setprecision(20) << *val_ptr << *node_value_arrs::get_d_matrix_ptr(node_value_arrs::N_SELECTED - _n_sis_select + dd) << std::endl; + std::cout << std::setw(24) << std::setprecision(20) << std::abs(util_funcs::r(val_ptr, val_ptr, _n_samp) - util_funcs::r(node_value_arrs::get_d_matrix_ptr(node_value_arrs::N_SELECTED - _n_sis_select + dd), val_ptr, _n_samp)) << std::endl; + } } return true; } void FeatureSpace::sis(std::vector<double>& prop) { + // std::fill_n(node_value_arrs::TEMP_STORAGE_REG.data(), node_value_arrs::TEMP_STORAGE_REG.size(), -1); + // std::fill_n(node_value_arrs::TEMP_STORAGE_TEST_REG.data(), node_value_arrs::TEMP_STORAGE_TEST_REG.size(), -1); + std::vector<double> scores_comp(std::max(node_value_arrs::N_SELECTED, _n_sis_select), 1.0); std::vector<double> scores_sel(_n_sis_select, 0.0); @@ -481,7 +493,7 @@ void FeatureSpace::sis(std::vector<double>& prop) phi_sel.resize(cur_feat_local); scores_sel.resize(cur_feat_local); project_generated(prop.data(), prop.size(), phi_sel, scores_sel, scores_comp); - std::fill_n(node_value_arrs::TEMP_STORAGE_TEST_REG.data(), node_value_arrs::TEMP_STORAGE_TEST_REG.size(), -1); + // std::fill_n(node_value_arrs::TEMP_STORAGE_TEST_REG.data(), node_value_arrs::TEMP_STORAGE_TEST_REG.size(), -1); } @@ -534,10 +546,15 @@ void FeatureSpace::sis(std::vector<double>& prop) if(std::none_of(inds.begin(), inds.end(), [&compare_ind](int i1){return i1 == compare_ind;})) { scores_sel.erase(scores_sel.begin() + ii); - phi_sel.back()->selected() = false; - phi_sel.back()->set_dmat_ind(-1); + phi_sel[ii]->selected() = false; + phi_sel[ii]->set_dmat_ind(-1); phi_sel.erase(phi_sel.begin() + ii); } + else + { + phi_sel[ii]->selected() = false; + phi_sel[ii]->set_dmat_ind(-1); + } } for(auto& feat : phi_sel) feat->selected() = false; @@ -560,6 +577,7 @@ void FeatureSpace::sis(std::vector<double>& prop) _mpi_comm->recv(rr, _mpi_comm->cantorTagGen(rr, 0, 2, 1), &sent_phi[rr * _n_sis_select], _n_sis_select); } + // std::fill_n(node_value_arrs::TEMP_STORAGE_REG.data(), node_value_arrs::TEMP_STORAGE_REG.size(), -1); if(inds.size() == unique_scores) { inds = util_funcs::argsort(sent_scores); @@ -600,20 +618,6 @@ void FeatureSpace::sis(std::vector<double>& prop) ++cur_feat_local; ++cur_feat; } - else - { - sent_phi[inds[ii]]->selected() = false; - sent_phi[inds[ii]]->set_dmat_ind(-1); - } - ++ii; - } - while(ii < sent_phi.size()) - { - if(sent_phi[inds[ii]]) - { - sent_phi[inds[ii]]->selected() = false; - sent_phi[inds[ii]]->set_dmat_ind(-1); - } ++ii; } } @@ -626,19 +630,14 @@ void FeatureSpace::sis(std::vector<double>& prop) _mpi_comm->send(0, _mpi_comm->cantorTagGen(_mpi_comm->rank(), 0, 2, 0), scores_sel.data(), _n_sis_select); _mpi_comm->send(0, _mpi_comm->cantorTagGen(_mpi_comm->rank(), 0, 2, 1), phi_sel.data(), _n_sis_select); _phi_selected.resize(node_value_arrs::N_SELECTED); - for(auto& feat : phi_sel) - { - if(feat) - { - feat->selected() = false; - feat->set_dmat_ind(-1); - } - } } mpi::broadcast(*_mpi_comm, &_phi_selected[_phi_selected.size() - _n_sis_select], _n_sis_select, 0); - for(int ii = _phi_selected.size() - _n_sis_select; ii < _phi_selected.size(); ++ii) + std::vector<int> rungs(_n_sis_select, 0); + std::transform(_phi_selected.end() - _n_sis_select, _phi_selected.end(), rungs.begin(), [](node_ptr feat){return feat->rung();}); + inds = util_funcs::argsort(rungs); + for(int ii = 0; ii < inds.size(); ++ii) { - _phi_selected[ii]->set_value(); + _phi_selected[inds[ii] + node_value_arrs::N_SELECTED - _n_sis_select]->set_value(); ++cur_feat; } } diff --git a/src/feature_creation/node/FeatureNode.hpp b/src/feature_creation/node/FeatureNode.hpp index 5c55766d9398d07147acf7c1420903d13db915d7..4f7bef882d28daa0e63cf3fed89c18d60e8842b9 100644 --- a/src/feature_creation/node/FeatureNode.hpp +++ b/src/feature_creation/node/FeatureNode.hpp @@ -117,7 +117,7 @@ public: /** * @brief Accessor function to the value of the feature */ - inline double* value_ptr(int offset = 0){return _selected ? node_value_arrs::get_d_matrix_ptr(_d_mat_ind) : node_value_arrs::get_value_ptr(_arr_ind, offset);} + inline double* value_ptr(int offset = 0){return _selected ? node_value_arrs::get_d_matrix_ptr(_d_mat_ind) : node_value_arrs::get_value_ptr(_arr_ind, _feat_ind, offset);} /** * @brief Accessor function to the value of the feature's test set diff --git a/src/feature_creation/node/Node.hpp b/src/feature_creation/node/Node.hpp index 4062d52fa52f116466e59faf86f1b77a17d3f736..5e28fa08703402e476dde69884751419b3c39e10 100644 --- a/src/feature_creation/node/Node.hpp +++ b/src/feature_creation/node/Node.hpp @@ -151,7 +151,7 @@ public: /** * @brief Accessor function to the test value of the feature */ - virtual double* test_value_ptr(int offset = 0) = 0; + virtual double* test_value_ptr(int offset = -1) = 0; /** * @brief Check if the feature contains NaN diff --git a/src/feature_creation/node/operator_nodes/OperatorNode.hpp b/src/feature_creation/node/operator_nodes/OperatorNode.hpp index 368ee56229f08c781dee7bcb04a8a6ef2369869f..6e358ceae62c49bd0d6dfcb69cdb2be602aaa867 100644 --- a/src/feature_creation/node/operator_nodes/OperatorNode.hpp +++ b/src/feature_creation/node/operator_nodes/OperatorNode.hpp @@ -98,12 +98,12 @@ public: return node_value_arrs::get_d_matrix_ptr(_d_mat_ind); offset = (offset == -1) ? rung() : offset; - if((rung() > node_value_arrs::N_RUNGS_STORED) && (node_value_arrs::temp_storage_reg(_arr_ind, offset) != _arr_ind)) + if((rung() > node_value_arrs::N_RUNGS_STORED) && (node_value_arrs::temp_storage_reg(_arr_ind, offset) != _feat_ind)) { set_value(offset); - node_value_arrs::temp_storage_reg(_arr_ind, offset) = _arr_ind; + node_value_arrs::temp_storage_reg(_arr_ind, offset) = _feat_ind; } - return node_value_arrs::get_value_ptr(_arr_ind, offset); + return node_value_arrs::get_value_ptr(_arr_ind, _feat_ind, offset); } /** @@ -117,10 +117,10 @@ public: double* test_value_ptr(int offset=-1) { offset = (offset == -1) ? rung() : offset; - if((rung() > node_value_arrs::N_RUNGS_STORED) && (node_value_arrs::temp_storage_test_reg(_arr_ind, offset) != _arr_ind)) + if((rung() > node_value_arrs::N_RUNGS_STORED) && (node_value_arrs::temp_storage_test_reg(_arr_ind, offset) != _feat_ind)) { set_test_value(offset); - node_value_arrs::temp_storage_test_reg(_arr_ind, offset) = _arr_ind; + // node_value_arrs::temp_storage_test_reg(_arr_ind, offset) = _feat_ind; } return node_value_arrs::get_test_value_ptr(_arr_ind, offset); diff --git a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/absolute_difference.hpp b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/absolute_difference.hpp index 2cd40b6635b73b3fba799b28d8126b47ab7223a4..994e80298d9d422f37c8ff3d53aee2b6d1087f80 100644 --- a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/absolute_difference.hpp +++ b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/absolute_difference.hpp @@ -30,7 +30,7 @@ public: allowed_op_funcs::abs_diff(_n_samp, _feats[0]->value_ptr(offset + 2), _feats[1]->value_ptr(offset + 1), node_value_arrs::get_d_matrix_ptr(_d_mat_ind)); offset = (offset == -1) ? rung() : offset; - allowed_op_funcs::abs_diff(_n_samp, _feats[0]->value_ptr(offset + 2), _feats[1]->value_ptr(offset + 1), node_value_arrs::get_value_ptr(_arr_ind, offset)); + allowed_op_funcs::abs_diff(_n_samp, _feats[0]->value_ptr(offset + 2), _feats[1]->value_ptr(offset + 1), node_value_arrs::get_value_ptr(_arr_ind, _feat_ind, offset)); } inline void set_test_value(int offset = -1) diff --git a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/absolute_value.hpp b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/absolute_value.hpp index dcbeb7bf21660db42c5bd5f7887f825b4e46b0f7..44d7fc2a189ddcb4126acb7118e0e9ff8fcf71f2 100644 --- a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/absolute_value.hpp +++ b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/absolute_value.hpp @@ -29,7 +29,7 @@ public: allowed_op_funcs::abs(_n_samp, _feats[0]->value_ptr(offset + 2), node_value_arrs::get_d_matrix_ptr(_d_mat_ind)); offset = (offset == -1) ? rung() : offset; - allowed_op_funcs::abs(_n_samp, _feats[0]->value_ptr(offset + 2), node_value_arrs::get_value_ptr(_arr_ind, offset)); + allowed_op_funcs::abs(_n_samp, _feats[0]->value_ptr(offset + 2), node_value_arrs::get_value_ptr(_arr_ind, _feat_ind, offset)); } inline void set_test_value(int offset = -1) diff --git a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/add.hpp b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/add.hpp index a36acfac1c60073472456842d9c11c3bf85dce3b..f00fe1c4f127a37fd3d92c69f81e31b113dacd90 100644 --- a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/add.hpp +++ b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/add.hpp @@ -29,7 +29,7 @@ public: allowed_op_funcs::add(_n_samp, _feats[0]->value_ptr(offset + 2), _feats[1]->value_ptr(offset + 1), node_value_arrs::get_d_matrix_ptr(_d_mat_ind)); offset = (offset == -1) ? rung() : offset; - allowed_op_funcs::add(_n_samp, _feats[0]->value_ptr(offset + 2), _feats[1]->value_ptr(offset + 1), node_value_arrs::get_value_ptr(_arr_ind, offset)); + allowed_op_funcs::add(_n_samp, _feats[0]->value_ptr(offset + 2), _feats[1]->value_ptr(offset + 1), node_value_arrs::get_value_ptr(_arr_ind, _feat_ind, offset)); } inline void set_test_value(int offset = -1) diff --git a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/cos.hpp b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/cos.hpp index d822778466514dc4d3148167339dc1131b79bf92..b40670a9f2b0487fb5a7ae832f77245e8dbba397 100644 --- a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/cos.hpp +++ b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/cos.hpp @@ -29,7 +29,7 @@ public: allowed_op_funcs::cos(_n_samp, _feats[0]->value_ptr(offset + 2), node_value_arrs::get_d_matrix_ptr(_d_mat_ind)); offset = (offset == -1) ? rung() : offset; - allowed_op_funcs::cos(_n_samp, _feats[0]->value_ptr(offset + 2), node_value_arrs::get_value_ptr(_arr_ind, offset)); + allowed_op_funcs::cos(_n_samp, _feats[0]->value_ptr(offset + 2), node_value_arrs::get_value_ptr(_arr_ind, _feat_ind, offset)); } inline void set_test_value(int offset = -1) diff --git a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/cube.hpp b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/cube.hpp index 10e5057bd8db1e77237a2fb0f6767a0f6af6f075..5dd0071b6ec93e3135ea89a636023c252d501543 100644 --- a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/cube.hpp +++ b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/cube.hpp @@ -29,7 +29,7 @@ public: allowed_op_funcs::cb(_n_samp, _feats[0]->value_ptr(offset + 2), node_value_arrs::get_d_matrix_ptr(_d_mat_ind)); offset = (offset == -1) ? rung() : offset; - allowed_op_funcs::cb(_n_samp, _feats[0]->value_ptr(offset + 2), node_value_arrs::get_value_ptr(_arr_ind, offset)); + allowed_op_funcs::cb(_n_samp, _feats[0]->value_ptr(offset + 2), node_value_arrs::get_value_ptr(_arr_ind, _feat_ind, offset)); } inline void set_test_value(int offset = -1) diff --git a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/cube_root.cpp b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/cube_root.cpp index 7cf21d646817a82e5d33dfa071b1763fa4b167f6..47f4daff556b126c7fd163a0ed2b42ca5a1cdcdd 100644 --- a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/cube_root.cpp +++ b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/cube_root.cpp @@ -6,7 +6,7 @@ CbrtNode::CbrtNode() CbrtNode::CbrtNode(std::array<node_ptr, 1> feats, int feat_ind, double l_bound, double u_bound): OperatorNode(feats, feat_ind) { - if((feats[0]->type() == NODE_TYPE::CB) || (feats[0]->type() == NODE_TYPE::SQ) || (feats[0]->type() == NODE_TYPE::INV)) + if((feats[0]->type() == NODE_TYPE::CB) || (feats[0]->type() == NODE_TYPE::SQ) || (feats[0]->type() == NODE_TYPE::SIX_POW) || (feats[0]->type() == NODE_TYPE::INV)) throw InvalidFeatureException(); set_value(); @@ -19,7 +19,7 @@ CbrtNode::CbrtNode(std::array<node_ptr, 1> feats, int feat_ind, double l_bound, CbrtNode::CbrtNode(node_ptr feat, int feat_ind, double l_bound, double u_bound): OperatorNode({feat}, feat_ind) { - if((feat->type() == NODE_TYPE::CB) || (feat->type() == NODE_TYPE::SQ) || (feat->type() == NODE_TYPE::INV)) + if((feat->type() == NODE_TYPE::CB) || (feat->type() == NODE_TYPE::SQ) || (feat->type() == NODE_TYPE::SIX_POW) || (feat->type() == NODE_TYPE::INV)) throw InvalidFeatureException(); set_value(); diff --git a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/cube_root.hpp b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/cube_root.hpp index 56cdf525f7bd51a3d7a902d8bd8089bd0d9f8f08..5c2c636e942f0c25dc2b5abccf59a9679b6a1f11 100644 --- a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/cube_root.hpp +++ b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/cube_root.hpp @@ -29,7 +29,7 @@ public: allowed_op_funcs::cbrt(_n_samp, _feats[0]->value_ptr(offset + 2), node_value_arrs::get_d_matrix_ptr(_d_mat_ind)); offset = (offset == -1) ? rung() : offset; - allowed_op_funcs::cbrt(_n_samp, _feats[0]->value_ptr(offset + 2), node_value_arrs::get_value_ptr(_arr_ind, offset)); + allowed_op_funcs::cbrt(_n_samp, _feats[0]->value_ptr(offset + 2), node_value_arrs::get_value_ptr(_arr_ind, _feat_ind, offset)); } inline void set_test_value(int offset = -1) diff --git a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/divide.hpp b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/divide.hpp index 9eb404cc10dc0709deca45a6f4cd046e81db51e1..769a17393e40c1b6dcf841091aabff6138365321 100644 --- a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/divide.hpp +++ b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/divide.hpp @@ -29,7 +29,7 @@ public: allowed_op_funcs::div(_n_samp, _feats[0]->value_ptr(offset + 2), _feats[1]->value_ptr(offset + 1), node_value_arrs::get_d_matrix_ptr(_d_mat_ind)); offset = (offset == -1) ? rung() : offset; - allowed_op_funcs::div(_n_samp, _feats[0]->value_ptr(offset + 2), _feats[1]->value_ptr(offset + 1), node_value_arrs::get_value_ptr(_arr_ind, offset)); + allowed_op_funcs::div(_n_samp, _feats[0]->value_ptr(offset + 2), _feats[1]->value_ptr(offset + 1), node_value_arrs::get_value_ptr(_arr_ind, _feat_ind, offset)); } inline void set_test_value(int offset = -1) diff --git a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/exponential.hpp b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/exponential.hpp index 5874321087d3c4e95241a3c16951f1876721275b..138dde1421dfd946af1a2c3b97b0b11c87d27518 100644 --- a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/exponential.hpp +++ b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/exponential.hpp @@ -29,7 +29,7 @@ public: allowed_op_funcs::exp(_n_samp, _feats[0]->value_ptr(offset + 2), node_value_arrs::get_d_matrix_ptr(_d_mat_ind)); offset = (offset == -1) ? rung() : offset; - allowed_op_funcs::exp(_n_samp, _feats[0]->value_ptr(offset + 2), node_value_arrs::get_value_ptr(_arr_ind, offset)); + allowed_op_funcs::exp(_n_samp, _feats[0]->value_ptr(offset + 2), node_value_arrs::get_value_ptr(_arr_ind, _feat_ind, offset)); } inline void set_test_value(int offset = -1) diff --git a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/inverse.hpp b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/inverse.hpp index 849a6d8cb452ab00078d8bcb9b298756f434c4ea..bc942c01b2789d4a8659181b2daf400fb666286c 100644 --- a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/inverse.hpp +++ b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/inverse.hpp @@ -30,7 +30,7 @@ public: allowed_op_funcs::inv(_n_samp, _feats[0]->value_ptr(offset + 2), node_value_arrs::get_d_matrix_ptr(_d_mat_ind)); offset = (offset == -1) ? rung() : offset; - allowed_op_funcs::inv(_n_samp, _feats[0]->value_ptr(offset + 2), node_value_arrs::get_value_ptr(_arr_ind, offset)); + allowed_op_funcs::inv(_n_samp, _feats[0]->value_ptr(offset + 2), node_value_arrs::get_value_ptr(_arr_ind, _feat_ind, offset)); } inline void set_test_value(int offset = -1) diff --git a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/log.hpp b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/log.hpp index 5aa2598f5534ea7f5b5a34b1cfaf9179aa20fc91..81b97ba7722051fd390d40ee5c26d94aee3590c4 100644 --- a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/log.hpp +++ b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/log.hpp @@ -29,7 +29,7 @@ public: allowed_op_funcs::log(_n_samp, _feats[0]->value_ptr(offset + 2), node_value_arrs::get_d_matrix_ptr(_d_mat_ind)); offset = (offset == -1) ? rung() : offset; - allowed_op_funcs::log(_n_samp, _feats[0]->value_ptr(offset + 2), node_value_arrs::get_value_ptr(_arr_ind, offset)); + allowed_op_funcs::log(_n_samp, _feats[0]->value_ptr(offset + 2), node_value_arrs::get_value_ptr(_arr_ind, _feat_ind, offset)); } inline void set_test_value(int offset = -1) diff --git a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/multiply.hpp b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/multiply.hpp index 28280c74f6288f1e1f8fd18621efcc6aeb985e70..a937ca35233d5f65eae8b7547c5a0ad01f4cc0e4 100644 --- a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/multiply.hpp +++ b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/multiply.hpp @@ -30,7 +30,7 @@ public: allowed_op_funcs::mult(_n_samp, _feats[0]->value_ptr(offset + 2), _feats[1]->value_ptr(offset + 1), node_value_arrs::get_d_matrix_ptr(_d_mat_ind)); offset = (offset == -1) ? rung() : offset; - allowed_op_funcs::mult(_n_samp, _feats[0]->value_ptr(offset + 2), _feats[1]->value_ptr(offset + 1), node_value_arrs::get_value_ptr(_arr_ind, offset)); + allowed_op_funcs::mult(_n_samp, _feats[0]->value_ptr(offset + 2), _feats[1]->value_ptr(offset + 1), node_value_arrs::get_value_ptr(_arr_ind, _feat_ind, offset)); } inline void set_test_value(int offset = -1) diff --git a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/negative_exponential.hpp b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/negative_exponential.hpp index 04a8cbff53bbce2f925d002476bc72768fe9b4c7..81f622c02d9a9b9701783cef5bb01383fedf22f6 100644 --- a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/negative_exponential.hpp +++ b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/negative_exponential.hpp @@ -30,7 +30,7 @@ public: allowed_op_funcs::neg_exp(_n_samp, _feats[0]->value_ptr(offset + 2), node_value_arrs::get_d_matrix_ptr(_d_mat_ind)); offset = (offset == -1) ? rung() : offset; - allowed_op_funcs::neg_exp(_n_samp, _feats[0]->value_ptr(offset + 2), node_value_arrs::get_value_ptr(_arr_ind, offset)); + allowed_op_funcs::neg_exp(_n_samp, _feats[0]->value_ptr(offset + 2), node_value_arrs::get_value_ptr(_arr_ind, _feat_ind, offset)); }; inline void set_test_value(int offset = -1) diff --git a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/sin.hpp b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/sin.hpp index 8c27f117d2c1526c459e13fd299f4a51c79d103f..1463ef34b815bd3f81a6c08b5ff21b4bc2122f40 100644 --- a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/sin.hpp +++ b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/sin.hpp @@ -30,7 +30,7 @@ public: allowed_op_funcs::sin(_n_samp, _feats[0]->value_ptr(offset + 2), node_value_arrs::get_d_matrix_ptr(_d_mat_ind)); offset = (offset == -1) ? rung() : offset; - allowed_op_funcs::sin(_n_samp, _feats[0]->value_ptr(offset + 2), node_value_arrs::get_value_ptr(_arr_ind, offset)); + allowed_op_funcs::sin(_n_samp, _feats[0]->value_ptr(offset + 2), node_value_arrs::get_value_ptr(_arr_ind, _feat_ind, offset)); } inline void set_test_value(int offset = -1) diff --git a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/sixth_power.cpp b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/sixth_power.cpp index 31c8b2fe46df3e76a7477c8284f0e2ab3db36860..2e67b4b7d9bd7cceea7a7d3dfbc6e2ef9d5f696a 100644 --- a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/sixth_power.cpp +++ b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/sixth_power.cpp @@ -6,7 +6,7 @@ SixPowNode::SixPowNode() SixPowNode::SixPowNode(std::array<node_ptr, 1> feats, int feat_ind, double l_bound, double u_bound): OperatorNode(feats, feat_ind) { - if((feats[0]->type() == NODE_TYPE::CBRT) || (feats[0]->type() == NODE_TYPE::SQRT) || (feats[0]->type() == NODE_TYPE::INV)) + if((feats[0]->type() == NODE_TYPE::CBRT) || (feats[0]->type() == NODE_TYPE::SQRT) || (feats[0]->type() == NODE_TYPE::SQ) || (feats[0]->type() == NODE_TYPE::CB) || (feats[0]->type() == NODE_TYPE::INV)) throw InvalidFeatureException(); set_value(); @@ -19,7 +19,7 @@ SixPowNode::SixPowNode(std::array<node_ptr, 1> feats, int feat_ind, double l_bou SixPowNode::SixPowNode(node_ptr feat, int feat_ind, double l_bound, double u_bound): OperatorNode({feat}, feat_ind) { - if((feat->type() == NODE_TYPE::CBRT) || (feat->type() == NODE_TYPE::SQRT) || (feat->type() == NODE_TYPE::INV)) + if((feat->type() == NODE_TYPE::CBRT) || (feat->type() == NODE_TYPE::SQRT) || (feat->type() == NODE_TYPE::SQ) || (feat->type() == NODE_TYPE::CB) || (feat->type() == NODE_TYPE::INV)) throw InvalidFeatureException(); set_value(); diff --git a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/sixth_power.hpp b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/sixth_power.hpp index a5fb6a3827bc0b23f6aec559409ee6b07e177588..770af9f940e6665cbdf485a442fb7a6fd535bea8 100644 --- a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/sixth_power.hpp +++ b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/sixth_power.hpp @@ -30,7 +30,7 @@ public: allowed_op_funcs::sixth_pow(_n_samp, _feats[0]->value_ptr(offset + 2), node_value_arrs::get_d_matrix_ptr(_d_mat_ind)); offset = (offset == -1) ? rung() : offset; - allowed_op_funcs::sixth_pow(_n_samp, _feats[0]->value_ptr(offset + 2), node_value_arrs::get_value_ptr(_arr_ind, offset)); + allowed_op_funcs::sixth_pow(_n_samp, _feats[0]->value_ptr(offset + 2), node_value_arrs::get_value_ptr(_arr_ind, _feat_ind, offset)); } inline void set_test_value(int offset = -1) diff --git a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/square.hpp b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/square.hpp index a8d287293236f79418ce828f48cf0c0dd5e27531..7c46c86d5104d8c811b64f083ee73caa8c88977a 100644 --- a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/square.hpp +++ b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/square.hpp @@ -29,7 +29,7 @@ public: allowed_op_funcs::sq(_n_samp, _feats[0]->value_ptr(offset + 2), node_value_arrs::get_d_matrix_ptr(_d_mat_ind)); offset = (offset == -1) ? rung() : offset; - allowed_op_funcs::sq(_n_samp, _feats[0]->value_ptr(offset + 2), node_value_arrs::get_value_ptr(_arr_ind, offset)); + allowed_op_funcs::sq(_n_samp, _feats[0]->value_ptr(offset + 2), node_value_arrs::get_value_ptr(_arr_ind, _feat_ind, offset)); } inline void set_test_value(int offset = -1) diff --git a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/square_root.cpp b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/square_root.cpp index 951f55ec954b7807a0c21e5e6897e63b54320edd..ea54c2cd7578bce3439fa57109a3f239a32fe8fc 100644 --- a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/square_root.cpp +++ b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/square_root.cpp @@ -6,7 +6,7 @@ SqrtNode::SqrtNode() SqrtNode::SqrtNode(std::array<node_ptr, 1> feats, int feat_ind, double l_bound, double u_bound): OperatorNode(feats, feat_ind) { - if((feats[0]->type() == NODE_TYPE::SQ) || (feats[0]->type() == NODE_TYPE::CB) || (feats[0]->type() == NODE_TYPE::CBRT) || (feats[0]->type() == NODE_TYPE::INV)) + if((feats[0]->type() == NODE_TYPE::SQ) || (feats[0]->type() == NODE_TYPE::CB) || (feats[0]->type() == NODE_TYPE::SIX_POW) || (feats[0]->type() == NODE_TYPE::CBRT) || (feats[0]->type() == NODE_TYPE::INV)) throw InvalidFeatureException(); set_value(); @@ -19,7 +19,7 @@ SqrtNode::SqrtNode(std::array<node_ptr, 1> feats, int feat_ind, double l_bound, SqrtNode::SqrtNode(node_ptr feat, int feat_ind, double l_bound, double u_bound): OperatorNode({feat}, feat_ind) { - if((feat->type() == NODE_TYPE::SQ) || (feat->type() == NODE_TYPE::CB) || (feat->type() == NODE_TYPE::CBRT) || (feat->type() == NODE_TYPE::INV)) + if((feat->type() == NODE_TYPE::SQ) || (feat->type() == NODE_TYPE::CB) || (feat->type() == NODE_TYPE::SIX_POW) || (feat->type() == NODE_TYPE::CBRT) || (feat->type() == NODE_TYPE::INV)) throw InvalidFeatureException(); set_value(); diff --git a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/square_root.hpp b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/square_root.hpp index a30822579836aeadd4ebc7bc6078bac3403f1b60..3f327423669998ce8b3ead9e4532b33f4924690f 100644 --- a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/square_root.hpp +++ b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/square_root.hpp @@ -30,7 +30,7 @@ public: allowed_op_funcs::sqrt(_n_samp, _feats[0]->value_ptr(offset + 2), node_value_arrs::get_d_matrix_ptr(_d_mat_ind)); offset = (offset == -1) ? rung() : offset; - allowed_op_funcs::sqrt(_n_samp, _feats[0]->value_ptr(offset + 2), node_value_arrs::get_value_ptr(_arr_ind, offset)); + allowed_op_funcs::sqrt(_n_samp, _feats[0]->value_ptr(offset + 2), node_value_arrs::get_value_ptr(_arr_ind, _feat_ind, offset)); } inline void set_test_value(int offset = -1) diff --git a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/subtract.hpp b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/subtract.hpp index f49d4c060c3dd95376e5aa5a6216f205b6053d60..40b87a26f95f034473ab936701d74be108315938 100644 --- a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/subtract.hpp +++ b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/subtract.hpp @@ -30,7 +30,7 @@ public: allowed_op_funcs::sub(_n_samp, _feats[0]->value_ptr(offset + 2), _feats[1]->value_ptr(offset + 1), node_value_arrs::get_d_matrix_ptr(_d_mat_ind)); offset = (offset == -1) ? rung() : offset; - allowed_op_funcs::sub(_n_samp, _feats[0]->value_ptr(offset + 2), _feats[1]->value_ptr(offset + 1), node_value_arrs::get_value_ptr(_arr_ind, offset)); + allowed_op_funcs::sub(_n_samp, _feats[0]->value_ptr(offset + 2), _feats[1]->value_ptr(offset + 1), node_value_arrs::get_value_ptr(_arr_ind, _feat_ind, offset)); } inline void set_test_value(int offset = -1) diff --git a/src/feature_creation/node/value_storage/nodes_value_containers.cpp b/src/feature_creation/node/value_storage/nodes_value_containers.cpp index 6ab863bb47aa6426209f411efcee37206ce2abaa..11664d6b0718329cc45ebbeef134c8022f186d96 100644 --- a/src/feature_creation/node/value_storage/nodes_value_containers.cpp +++ b/src/feature_creation/node/value_storage/nodes_value_containers.cpp @@ -105,20 +105,20 @@ void node_value_arrs::resize_values_arr(int n_dims, int n_feat, bool use_temp) } } -double* node_value_arrs::get_value_ptr(int ind, int offset) +double* node_value_arrs::get_value_ptr(int arr_ind, int feat_ind, int offset) { - if(ind < N_STORE_FEATURES) - return access_value_arr(ind); - temp_storage_reg(ind, offset) = ind; - return access_temp_storage((ind % N_STORE_FEATURES) + (offset % 3) * N_STORE_FEATURES); + if(arr_ind < N_STORE_FEATURES) + return access_value_arr(arr_ind); + temp_storage_reg(arr_ind, offset) = feat_ind; + return access_temp_storage((arr_ind % N_STORE_FEATURES) + (offset % 3) * N_STORE_FEATURES); } -double* node_value_arrs::get_test_value_ptr(int ind, int offset) +double* node_value_arrs::get_test_value_ptr(int arr_ind, int feat_ind, int offset) { - if(ind < N_STORE_FEATURES) - return access_test_value_arr(ind); - temp_storage_test_reg(ind, offset) = ind; - return access_temp_storage_test((ind % N_STORE_FEATURES) + (offset % 3) * N_STORE_FEATURES); + if(arr_ind < N_STORE_FEATURES) + return access_test_value_arr(arr_ind); + temp_storage_test_reg(arr_ind, offset) = feat_ind; + return access_temp_storage_test((arr_ind % N_STORE_FEATURES) + (offset % 3) * N_STORE_FEATURES); } void node_value_arrs::initialize_d_matrix_arr() 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 7918fa1b0b100dfe227309a69e89182e7d932b28..dcf657c4c4783fc2b0365797e018316a91bfa9aa 100644 --- a/src/feature_creation/node/value_storage/nodes_value_containers.hpp +++ b/src/feature_creation/node/value_storage/nodes_value_containers.hpp @@ -145,7 +145,7 @@ namespace node_value_arrs * * @return The value pointer */ - double* get_value_ptr(int ind, int offset = 0); + double* get_value_ptr(int arr_ind, int feat_ind, int offset = 0); /** * @brief Access the test_value_ptr to a feature @@ -155,7 +155,7 @@ namespace node_value_arrs * * @return The value pointer */ - double* get_test_value_ptr(int ind, int offset = 0); + double* get_test_value_ptr(int arr_ind, int feat_ind, int offset = 0); /** * @brief Get the pointer to a primary feature @@ -167,6 +167,9 @@ namespace node_value_arrs { return D_MATRIX.data() + ind * N_SAMPLES; } + + inline void clear_temp_reg(){std::fill_n(TEMP_STORAGE_REG.data(), TEMP_STORAGE_REG.size(), -1);} + inline void clear_temp_test_reg(){std::fill_n(TEMP_STORAGE_TEST_REG.data(), TEMP_STORAGE_TEST_REG.size(), -1);} } #endif