diff --git a/src/feature_creation/feature_space/FeatureSpace.cpp b/src/feature_creation/feature_space/FeatureSpace.cpp index 07c09289182e203fa0e5f2c325e1fc9245bdf3a7..956c33971243d32d1a0b93a474aeaa8456766b37 100644 --- a/src/feature_creation/feature_space/FeatureSpace.cpp +++ b/src/feature_creation/feature_space/FeatureSpace.cpp @@ -126,30 +126,21 @@ void FeatureSpace::generate_feature_space() } } _mpi_comm->barrier(); - if(_mpi_comm->rank() == 0) - std::cout << "NEXT_PHI MADE" << std::endl; - else - std::cout << "NNNN NEXT_PHI MADE" << std::endl; _start_gen.push_back(_phi.size()); std::vector<std::vector<node_ptr>> next_phi_gathered; mpi::all_gather(*_mpi_comm, next_phi, next_phi_gathered); - if(_mpi_comm->rank() == 0) - std::cout << "all gather" << std::endl; - else - std::cout << "aaaa all_gather" << std::endl; - + std::cout << nn << " set values" << std::endl; for(auto& next_phi_vec : next_phi_gathered) { + _phi.reserve(_phi.size() + next_phi_vec.size()); for(auto& feat : next_phi_vec) { if(nn <= node_value_arrs::N_RUNGS_STORED) { - std::transform(_phi.begin(), _phi.end(), scores.begin(), [&feat](node_ptr f){return 1.0 - std::abs(util_funcs::r(feat->value_ptr(), f->value_ptr(), f->n_samp()));}); - if(*std::min_element(scores.begin(), scores.begin()+_phi.size()) > 1e-13) - _phi.push_back(feat); feat->set_value(); + _phi.push_back(feat); } else { @@ -157,7 +148,6 @@ void FeatureSpace::generate_feature_space() } } } - std::cout << "DONE"<< std::endl; } _n_feat = _phi.size(); } diff --git a/src/feature_creation/node/FeatureNode.hpp b/src/feature_creation/node/FeatureNode.hpp index 68f0a1a5245c8ecf50b736a4b124cf997518f42c..8d6db1ee1f9e64dfa87afa96bd07b5f89a24f8c7 100644 --- a/src/feature_creation/node/FeatureNode.hpp +++ b/src/feature_creation/node/FeatureNode.hpp @@ -91,6 +91,11 @@ public: return std::all_of(value_ptr(), value_ptr() + _n_samp, [&mean](double d){return std::abs(d - mean) < 1e-12;}); } + /** + * @brief Returns the type of node this is + */ + inline NODE_TYPE type(){return NODE_TYPE::FEAT;} + /** * @brief Accessor function to the value of the feature */ diff --git a/src/feature_creation/node/Node.hpp b/src/feature_creation/node/Node.hpp index fbc18b80516e0e57df59a7d455611276c18172ee..da370a645f4fb88baadc2573d70ee3712efae1e0 100644 --- a/src/feature_creation/node/Node.hpp +++ b/src/feature_creation/node/Node.hpp @@ -105,6 +105,11 @@ public: */ virtual bool is_const() = 0; + /** + * @brief Returns the type of node this is + */ + virtual NODE_TYPE type() = 0; + /** * @brief Serialization function to send over MPI * diff --git a/src/feature_creation/node/operator_nodes/OperatorNode.hpp b/src/feature_creation/node/operator_nodes/OperatorNode.hpp index e2cf435fbc36d5f271acb23781994f0d3ea9cb26..1a3825b407d9eaf5ce4b0d1623d2f1f3162deaf2 100644 --- a/src/feature_creation/node/operator_nodes/OperatorNode.hpp +++ b/src/feature_creation/node/operator_nodes/OperatorNode.hpp @@ -97,6 +97,11 @@ public: return std::all_of(value_ptr(), value_ptr() + _n_samp, [&mean](double d){return std::abs(d - mean) < 1e-12;}); } + /** + * @brief Returns the type of node this is + */ + virtual NODE_TYPE type() = 0; + /** * @brief Set up the feature value pointers */ diff --git a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/absolute_difference.cpp b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/absolute_difference.cpp index 4d4a5271c92578df06de5601bf99ccc5d06e606f..c0590ee18af3f446e1e2e152da82a0a8295e6012 100644 --- a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/absolute_difference.cpp +++ b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/absolute_difference.cpp @@ -11,8 +11,11 @@ AbsDiffNode::AbsDiffNode(std::vector<node_ptr> feats, int rung, int feat_ind) : if(feats[0]->unit() != feats[1]->unit()) throw InvalidFeatureException(); + if((feats[0]->type() == NODE_TYPE::LOG) && (feats[1]->type() == NODE_TYPE::LOG)) + throw InvalidFeatureException(); + set_value(); -if(is_nan() || is_const()) + if(is_nan() || is_const()) throw InvalidFeatureException(); } @@ -22,8 +25,11 @@ AbsDiffNode::AbsDiffNode(node_ptr feat_1, node_ptr feat_2, int rung, int feat_in if(feat_1->unit() != feat_2->unit()) throw InvalidFeatureException(); + if((feat_1->type() == NODE_TYPE::LOG) && (feat_2->type() == NODE_TYPE::LOG)) + throw InvalidFeatureException(); + set_value(); -if(is_nan() || is_const()) + if(is_nan() || is_const()) throw InvalidFeatureException(); } 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 9cf2742f008faa194064b524136ca94e37b71e51..0d3ec143a7a71039d048136e5d00e8a3bfa6db29 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 @@ -19,6 +19,11 @@ public: void set_value(); + /** + * @brief Returns the type of node this is + */ + inline NODE_TYPE type(){return NODE_TYPE::ABS_DIFF;} + template <typename Archive> void serialize(Archive& ar, const unsigned int version) { diff --git a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/absolute_value.cpp b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/absolute_value.cpp index 8212270ee4ebd272533d93f7adebdc3b7de1757c..71f35c943a071f42ab12e8f128c4601e255b6ad0 100644 --- a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/absolute_value.cpp +++ b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/absolute_value.cpp @@ -9,7 +9,7 @@ AbsNode::AbsNode(std::vector<node_ptr> feats, int rung, int feat_ind): OperatorNode(feats, rung, feat_ind) { set_value(); -if(is_nan() || is_const()) + if(is_nan() || is_const()) throw InvalidFeatureException(); } @@ -17,7 +17,7 @@ AbsNode::AbsNode(node_ptr feat, int rung, int feat_ind): OperatorNode({feat}, rung, feat_ind) { set_value(); -if(is_nan() || is_const()) + if(is_nan() || is_const()) throw InvalidFeatureException(); } 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 c38f71b4d217b68da3cd3ec8798eaabe0b528aad..20afc8c52d9c5075547785e16e2fd7229be5b3ce 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 @@ -19,6 +19,11 @@ public: void set_value(); + /** + * @brief Returns the type of node this is + */ + inline NODE_TYPE type(){return NODE_TYPE::ABS;} + template <typename Archive> void serialize(Archive& ar, const unsigned int version) { diff --git a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/add.cpp b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/add.cpp index 0d7081ba6c77d23b1e1bd15cad57fb94f99574b9..1a75d051feb1728aea82172ab05d40120fecd875 100644 --- a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/add.cpp +++ b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/add.cpp @@ -10,7 +10,7 @@ AddNode::AddNode(std::vector<node_ptr> feats, int rung, int feat_ind): throw InvalidFeatureException(); set_value(); -if(is_nan() || is_const()) + if(is_nan() || is_const()) throw InvalidFeatureException(); } @@ -21,7 +21,7 @@ AddNode::AddNode(node_ptr feat_1, node_ptr feat_2, int rung, int feat_ind): throw InvalidFeatureException(); set_value(); -if(is_nan() || is_const()) + if(is_nan() || is_const()) throw InvalidFeatureException(); } 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 6ae01b11bf075f3b4a8f180666c36b319f0ff55c..faff638cfb1e3b932f41fe96c8ce6fe62895c3ca 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 @@ -19,6 +19,11 @@ public: void set_value(); + /** + * @brief Returns the type of node this is + */ + inline NODE_TYPE type(){return NODE_TYPE::ADD;} + template <typename Archive> void serialize(Archive& ar, const unsigned int version) { diff --git a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/cos.cpp b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/cos.cpp index 37f6eab680487ac3c903a59b5f93a9efb71d7791..07d40fb1f319fdaaf628fba1e60f8ad7befed935 100644 --- a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/cos.cpp +++ b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/cos.cpp @@ -9,8 +9,11 @@ CosNode::CosNode(std::vector<node_ptr> feats, int rung, int feat_ind): if(feats[0]->unit() != Unit()) throw InvalidFeatureException(); + if((feats[0]->type() == NODE_TYPE::SIN) || (feats[0]->type() == NODE_TYPE::COS)) + throw InvalidFeatureException(); + set_value(); -if(is_nan() || is_const()) + if(is_nan() || is_const()) throw InvalidFeatureException(); } @@ -20,8 +23,11 @@ CosNode::CosNode(node_ptr feat, int rung, int feat_ind): if(feat->unit() != Unit()) throw InvalidFeatureException(); + if((feat->type() == NODE_TYPE::SIN) || (feat->type() == NODE_TYPE::COS)) + throw InvalidFeatureException(); + set_value(); -if(is_nan() || is_const()) + if(is_nan() || is_const()) throw InvalidFeatureException(); } 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 04c39c81303190aa2e0dc072f2bc559f8bdde6d1..bd246c745632e8827ee97989a31e4193ce157d43 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 @@ -19,6 +19,11 @@ public: void set_value(); + /** + * @brief Returns the type of node this is + */ + inline NODE_TYPE type(){return NODE_TYPE::COS;} + template <typename Archive> void serialize(Archive& ar, const unsigned int version) { diff --git a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/cube.cpp b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/cube.cpp index 1e441a6f330285ce9d36df2fb442b0354d01b7ae..72cd11c9c41501b0d64a4673d2ef1fbc0e032e2d 100644 --- a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/cube.cpp +++ b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/cube.cpp @@ -6,16 +6,22 @@ CbNode::CbNode() CbNode::CbNode(std::vector<node_ptr> feats, int rung, int feat_ind): OperatorNode(feats, rung, feat_ind) { + if(feats[0]->type() == NODE_TYPE::CBRT) + throw InvalidFeatureException(); + set_value(); -if(is_nan() || is_const()) + if(is_nan() || is_const()) throw InvalidFeatureException(); } CbNode::CbNode(node_ptr feat, int rung, int feat_ind): OperatorNode({feat}, rung, feat_ind) { + if(feat->type() == NODE_TYPE::CBRT) + throw InvalidFeatureException(); + set_value(); -if(is_nan() || is_const()) + if(is_nan() || is_const()) throw InvalidFeatureException(); } 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 c62c935100e3e4b53d9b7641c1969971d54b6092..671d7312a268236479ce488c12daaf1a899bdf57 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 @@ -19,6 +19,11 @@ public: void set_value(); + /** + * @brief Returns the type of node this is + */ + inline NODE_TYPE type(){return NODE_TYPE::CB;} + template <typename Archive> void serialize(Archive& ar, const unsigned int version) { 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 eb2517b1ee1819f2c1d16f615cc9fc30b4fec80d..18ab351a758bcf6b6a76704378545c2a73c2ca0e 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,16 +6,22 @@ CbrtNode::CbrtNode() CbrtNode::CbrtNode(std::vector<node_ptr> feats, int rung, int feat_ind): OperatorNode(feats, rung, feat_ind) { + if(feats[0]->type() == NODE_TYPE::CB) + throw InvalidFeatureException(); + set_value(); -if(is_nan() || is_const()) + if(is_nan() || is_const()) throw InvalidFeatureException(); } CbrtNode::CbrtNode(node_ptr feat, int rung, int feat_ind): OperatorNode({feat}, rung, feat_ind) { + if(feat->type() == NODE_TYPE::CB) + throw InvalidFeatureException(); + set_value(); -if(is_nan() || is_const()) + if(is_nan() || is_const()) throw InvalidFeatureException(); } 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 29bab700f8f99457025054a5e92a0645dd2a0608..88f0e9353944fa71afe218292c8f2b4967f71ea0 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 @@ -19,6 +19,11 @@ public: void set_value(); + /** + * @brief Returns the type of node this is + */ + inline NODE_TYPE type(){return NODE_TYPE::CBRT;} + template <typename Archive> void serialize(Archive& ar, const unsigned int version) { diff --git a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/divide.cpp b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/divide.cpp index 8138be107a1c38b5d02d97608c9e3b9690819633..2fcd1955043f72261d2fbdc172795afbb7449a51 100644 --- a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/divide.cpp +++ b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/divide.cpp @@ -6,16 +6,22 @@ DivNode::DivNode() DivNode::DivNode(std::vector<node_ptr> feats, int rung, int feat_ind): OperatorNode(feats, rung, feat_ind) { + if((feats[0]->type() == NODE_TYPE::INV) || (feats[1]->type() == NODE_TYPE::INV)) + throw InvalidFeatureException(); + set_value(); -if(is_nan() || is_const()) + if(is_nan() || is_const()) throw InvalidFeatureException(); } DivNode::DivNode(node_ptr feat_1, node_ptr feat_2, int rung, int feat_ind): OperatorNode({feat_1, feat_2}, rung, feat_ind) { + if((feat_1->type() == NODE_TYPE::INV) || (feat_2->type() == NODE_TYPE::INV)) + throw InvalidFeatureException(); + set_value(); -if(is_nan() || is_const()) + if(is_nan() || is_const()) throw InvalidFeatureException(); } 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 5d5e248ecf64a686fe8362ee27c8d7906fcf42da..08607cc847b87b2bcf9cd25460cb7f9074e419f6 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 @@ -19,6 +19,11 @@ public: void set_value(); + /** + * @brief Returns the type of node this is + */ + inline NODE_TYPE type(){return NODE_TYPE::DIV;} + template <typename Archive> void serialize(Archive& ar, const unsigned int version) { diff --git a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/exponential.cpp b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/exponential.cpp index a2a8d845882e7825da3b59e89bcf8edc00ec1054..ed2450d69fb893c9d5077576490ae535a58e8273 100644 --- a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/exponential.cpp +++ b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/exponential.cpp @@ -9,8 +9,11 @@ ExpNode::ExpNode(std::vector<node_ptr> feats, int rung, int feat_ind): if(feats[0]->unit() != Unit()) throw InvalidFeatureException(); + if((feats[0]->type() == NODE_TYPE::NEG_EXP) || (feats[0]->type() == NODE_TYPE::EXP) || (feats[0]->type() == NODE_TYPE::ADD) || (feats[0]->type() == NODE_TYPE::SUB) || (feats[0]->type() == NODE_TYPE::LOG)) + throw InvalidFeatureException(); + set_value(); -if(is_nan() || is_const()) + if(is_nan() || is_const()) throw InvalidFeatureException(); } @@ -20,8 +23,11 @@ ExpNode::ExpNode(node_ptr feat, int rung, int feat_ind): if(feat->unit() != Unit()) throw InvalidFeatureException(); + if((feat->type() == NODE_TYPE::NEG_EXP) || (feat->type() == NODE_TYPE::EXP) || (feat->type() == NODE_TYPE::ADD) || (feat->type() == NODE_TYPE::SUB) || (feat->type() == NODE_TYPE::LOG)) + throw InvalidFeatureException(); + set_value(); -if(is_nan() || is_const()) + if(is_nan() || is_const()) throw InvalidFeatureException(); } 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 6b5ed68f6ecd1729f78c446e5ef44f98d04bddf9..46eb66c428c5ac45ff5724693106f4b538120909 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 @@ -19,6 +19,11 @@ public: void set_value(); + /** + * @brief Returns the type of node this is + */ + inline NODE_TYPE type(){return NODE_TYPE::EXP;} + template <typename Archive> void serialize(Archive& ar, const unsigned int version) { diff --git a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/inverse.cpp b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/inverse.cpp index 6449a65ceaab0164d13dfb7f109fdf1fb218bf0a..e33471a12ae5c35f6cd731cfc2b5fbc427815e6b 100644 --- a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/inverse.cpp +++ b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/inverse.cpp @@ -6,16 +6,22 @@ InvNode::InvNode() InvNode::InvNode(std::vector<node_ptr> feats, int rung, int feat_ind): OperatorNode(feats, rung, feat_ind) { + if(feats[0]->type() == NODE_TYPE::DIV) + throw InvalidFeatureException(); + set_value(); -if(is_nan() || is_const()) + if(is_nan() || is_const()) throw InvalidFeatureException(); } InvNode::InvNode(node_ptr feat, int rung, int feat_ind): OperatorNode({feat}, rung, feat_ind) { + if(feat->type() == NODE_TYPE::DIV) + throw InvalidFeatureException(); + set_value(); -if(is_nan() || is_const()) + if(is_nan() || is_const()) throw InvalidFeatureException(); } 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 7a6e3fb4433d837d9c59a141153b7b55b3838c0a..6bd02488feb01f600aa160b9129c618820cdceee 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 @@ -19,6 +19,11 @@ public: void set_value(); + /** + * @brief Returns the type of node this is + */ + inline NODE_TYPE type(){return NODE_TYPE::INV;} + template <typename Archive> void serialize(Archive& ar, const unsigned int version) { diff --git a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/log.cpp b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/log.cpp index 0f9939b042a55fc5be941ebfc8281cd84cee60ef..2a3e77e2156d24bf38989db31b6436ee9eab6c8c 100644 --- a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/log.cpp +++ b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/log.cpp @@ -9,8 +9,11 @@ LogNode::LogNode(std::vector<node_ptr> feats, int rung, int feat_ind): if(feats[0]->unit() != Unit()) throw InvalidFeatureException(); + if((feats[0]->type() == NODE_TYPE::NEG_EXP) || (feats[0]->type() == NODE_TYPE::EXP) || (feats[0]->type() == NODE_TYPE::DIV) || (feats[0]->type() == NODE_TYPE::MULT) || (feats[0]->type() == NODE_TYPE::LOG)) + throw InvalidFeatureException(); + set_value(); -if(is_nan() || is_const()) + if(is_nan() || is_const()) throw InvalidFeatureException(); } @@ -20,8 +23,11 @@ LogNode::LogNode(node_ptr feat, int rung, int feat_ind): if(feat->unit() != Unit()) throw InvalidFeatureException(); + if((feat->type() == NODE_TYPE::NEG_EXP) || (feat->type() == NODE_TYPE::EXP) || (feat->type() == NODE_TYPE::DIV) || (feat->type() == NODE_TYPE::MULT) || (feat->type() == NODE_TYPE::LOG)) + throw InvalidFeatureException(); + set_value(); -if(is_nan() || is_const()) + if(is_nan() || is_const()) throw InvalidFeatureException(); } 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 b728a1d4b4279308b724c990a64c2e7b26a85a21..db792788c06436b7789d6aba37c3f976c8e0f6a8 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 @@ -19,6 +19,11 @@ public: void set_value(); + /** + * @brief Returns the type of node this is + */ + inline NODE_TYPE type(){return NODE_TYPE::LOG;} + template <typename Archive> void serialize(Archive& ar, const unsigned int version) { diff --git a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/multiply.cpp b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/multiply.cpp index 88661f5c04e0efe171c8a4cf8aec5180312ee58a..66729c8070977eff9ad5daebeb859c885544f005 100644 --- a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/multiply.cpp +++ b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/multiply.cpp @@ -7,7 +7,7 @@ MultNode::MultNode(std::vector<node_ptr> feats, int rung, int feat_ind): OperatorNode(feats, rung, feat_ind) { set_value(); -if(is_nan() || is_const()) + if(is_nan() || is_const()) throw InvalidFeatureException(); } @@ -15,7 +15,7 @@ MultNode::MultNode(node_ptr feat_1, node_ptr feat_2, int rung, int feat_ind): OperatorNode({feat_1, feat_2}, rung, feat_ind) { set_value(); -if(is_nan() || is_const()) + if(is_nan() || is_const()) throw InvalidFeatureException(); } 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 9fc77618f9d449ad67f0fca1533ef4f3928f77af..9460ac6fdd968d9ad75480f482ace94b3b92f965 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 @@ -19,6 +19,11 @@ public: void set_value(); + /** + * @brief Returns the type of node this is + */ + inline NODE_TYPE type(){return NODE_TYPE::MULT;} + template <typename Archive> void serialize(Archive& ar, const unsigned int version) { diff --git a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/negative_exponential.cpp b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/negative_exponential.cpp index f706206e4673a31c5e5a63b225c2129a1069b235..ac6ff99606c3203a7e5b6ba926392eb00512c50e 100644 --- a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/negative_exponential.cpp +++ b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/negative_exponential.cpp @@ -9,8 +9,12 @@ NegExpNode::NegExpNode(std::vector<node_ptr> feats, int rung, int feat_ind): if(feats[0]->unit() != Unit()) throw InvalidFeatureException(); + if((feats[0]->type() == NODE_TYPE::NEG_EXP) || (feats[0]->type() == NODE_TYPE::EXP) || (feats[0]->type() == NODE_TYPE::ADD) || (feats[0]->type() == NODE_TYPE::SUB) || (feats[0]->type() == NODE_TYPE::LOG)) + throw InvalidFeatureException(); + set_value(); -if(is_nan() || is_const()) + + if(is_nan() || is_const()) throw InvalidFeatureException(); } @@ -20,8 +24,12 @@ NegExpNode::NegExpNode(node_ptr feat, int rung, int feat_ind): if(feat->unit() != Unit()) throw InvalidFeatureException(); + if((feat->type() == NODE_TYPE::NEG_EXP) || (feat->type() == NODE_TYPE::EXP) || (feat->type() == NODE_TYPE::ADD) || (feat->type() == NODE_TYPE::SUB) || (feat->type() == NODE_TYPE::LOG)) + throw InvalidFeatureException(); + set_value(); -if(is_nan() || is_const()) + + if(is_nan() || is_const()) throw InvalidFeatureException(); } 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 01aa9c0c88033461b564aca9a0f461475ec01b5a..129036fd26121c034a7d862c63aea1e53d36db76 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 @@ -19,6 +19,11 @@ public: void set_value(); + /** + * @brief Returns the type of node this is + */ + inline NODE_TYPE type(){return NODE_TYPE::NEG_EXP;} + template <typename Archive> void serialize(Archive& ar, const unsigned int version) { diff --git a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/sin.cpp b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/sin.cpp index 65ada0ceb2a4dd8cba6f1af51f36231573420cdf..c9845a1e62d05628a32fcfe4de725d65532e386a 100644 --- a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/sin.cpp +++ b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/sin.cpp @@ -9,8 +9,11 @@ SinNode::SinNode(std::vector<node_ptr> feats, int rung, int feat_ind): if(feats[0]->unit() != Unit()) throw InvalidFeatureException(); + if((feats[0]->type() == NODE_TYPE::SIN) || (feats[0]->type() == NODE_TYPE::COS)) + throw InvalidFeatureException(); + set_value(); -if(is_nan() || is_const()) + if(is_nan() || is_const()) throw InvalidFeatureException(); } @@ -20,8 +23,11 @@ SinNode::SinNode(node_ptr feat, int rung, int feat_ind): if(feat->unit() != Unit()) throw InvalidFeatureException(); + if((feat->type() == NODE_TYPE::SIN) || (feat->type() == NODE_TYPE::COS)) + throw InvalidFeatureException(); + set_value(); -if(is_nan() || is_const()) + if(is_nan() || is_const()) throw InvalidFeatureException(); } 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 aa7c415ecd03307133ccc5dda62cb46f1118c8b5..306381ccfea02e0bcc80b1fe8059ed9fc2ab7c02 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 @@ -19,6 +19,11 @@ public: void set_value(); + /** + * @brief Returns the type of node this is + */ + inline NODE_TYPE type(){return NODE_TYPE::SIN;} + template <typename Archive> void serialize(Archive& ar, const unsigned int version) { 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 c419acfab1b787653011d207104069c4220813f3..e69e3195185f18386bc7de9e0aa6fcfc69c9ac91 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,16 +6,22 @@ SixPowNode::SixPowNode() SixPowNode::SixPowNode(std::vector<node_ptr> feats, int rung, int feat_ind): OperatorNode(feats, rung, feat_ind) { + if((feats[0]->type() == NODE_TYPE::CBRT) || (feats[0]->type() == NODE_TYPE::SQRT)) + throw InvalidFeatureException(); + set_value(); -if(is_nan() || is_const()) + if(is_nan() || is_const()) throw InvalidFeatureException(); } SixPowNode::SixPowNode(node_ptr feat, int rung, int feat_ind): OperatorNode({feat}, rung, feat_ind) { + if((feat->type() == NODE_TYPE::CBRT) || (feat->type() == NODE_TYPE::SQRT)) + throw InvalidFeatureException(); + set_value(); -if(is_nan() || is_const()) + if(is_nan() || is_const()) throw InvalidFeatureException(); } 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 06057fa13808f6ac3e7dd3a9c33958d2fe031e62..85062f99c9ad76aa52e5624fdb5feec246bb4e84 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 @@ -19,6 +19,11 @@ public: void set_value(); + /** + * @brief Returns the type of node this is + */ + inline NODE_TYPE type(){return NODE_TYPE::SIX_POW;} + template <typename Archive> void serialize(Archive& ar, const unsigned int version) { diff --git a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/square.cpp b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/square.cpp index 2f23801ac2a6a5432bc01c333ad1c936967f9773..1fe69a5adecb01bf37911bd92a038b37a9adf5e9 100644 --- a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/square.cpp +++ b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/square.cpp @@ -6,16 +6,22 @@ SqNode::SqNode() SqNode::SqNode(std::vector<node_ptr> feats, int rung, int feat_ind): OperatorNode(feats, rung, feat_ind) { + if(feats[0]->type() == NODE_TYPE::SQRT) + throw InvalidFeatureException(); + set_value(); -if(is_nan() || is_const()) + if(is_nan() || is_const()) throw InvalidFeatureException(); } SqNode::SqNode(node_ptr feat, int rung, int feat_ind): OperatorNode({feat}, rung, feat_ind) { + if(feat->type() == NODE_TYPE::SQRT) + throw InvalidFeatureException(); + set_value(); -if(is_nan() || is_const()) + if(is_nan() || is_const()) throw InvalidFeatureException(); } 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 118eb3c442ae90f4c505b3a9d9c7469cdbae7507..8ced543357f1a84d642e533cb7dbd7fc935f138b 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 @@ -19,6 +19,11 @@ public: void set_value(); + /** + * @brief Returns the type of node this is + */ + inline NODE_TYPE type(){return NODE_TYPE::SQ;} + template <typename Archive> void serialize(Archive& ar, const unsigned int version) { 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 8a3b89e003e309a4f1349319e3112e1de575f97e..09673fd7f18a87a5d5ca6b54c1a22e3963bf5b44 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,16 +6,22 @@ SqrtNode::SqrtNode() SqrtNode::SqrtNode(std::vector<node_ptr> feats, int rung, int feat_ind): OperatorNode(feats, rung, feat_ind) { + if(feats[0]->type() == NODE_TYPE::SQRT) + throw InvalidFeatureException(); + set_value(); -if(is_nan() || is_const()) + if(is_nan() || is_const()) throw InvalidFeatureException(); } SqrtNode::SqrtNode(node_ptr feat, int rung, int feat_ind): OperatorNode({feat}, rung, feat_ind) { + if(feat->type() == NODE_TYPE::SQRT) + throw InvalidFeatureException(); + set_value(); -if(is_nan() || is_const()) + if(is_nan() || is_const()) throw InvalidFeatureException(); } 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 bed54677842becaacfbc75a6435f0b26f21c48cf..ab93e8e1652751b74590254224cd524b3573b316 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 @@ -19,6 +19,11 @@ public: void set_value(); + /** + * @brief Returns the type of node this is + */ + inline NODE_TYPE type(){return NODE_TYPE::SQRT;} + template <typename Archive> void serialize(Archive& ar, const unsigned int version) { diff --git a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/subtract.cpp b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/subtract.cpp index 3874f9c0d6631730724181de3a542c0abab6afc1..4b7e6c7dae7f3f22cf8542e51dd1a0b5ba25b4fb 100644 --- a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/subtract.cpp +++ b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/subtract.cpp @@ -10,7 +10,7 @@ SubNode::SubNode(std::vector<node_ptr> feats, int rung, int feat_ind): throw InvalidFeatureException(); set_value(); -if(is_nan() || is_const()) + if(is_nan() || is_const()) throw InvalidFeatureException(); } @@ -21,7 +21,7 @@ SubNode::SubNode(node_ptr feat_1, node_ptr feat_2, int rung, int feat_ind): throw InvalidFeatureException(); set_value(); -if(is_nan() || is_const()) + if(is_nan() || is_const()) throw InvalidFeatureException(); } 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 10fc8a6e034099738337f2d98408e598bd0a7814..5be24fe019a7a2770314d099ac5a0bf630462e7e 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 @@ -19,6 +19,11 @@ public: void set_value(); + /** + * @brief Returns the type of node this is + */ + inline NODE_TYPE type(){return NODE_TYPE::SUB;} + template <typename Archive> void serialize(Archive& ar, const unsigned int version) { 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 2d2a02bd9da6cd4b00ab8002073719569e376ac4..d14f1c61e1e13f16d041ed292838beab0d76606c 100644 --- a/src/feature_creation/node/value_storage/nodes_value_containers.cpp +++ b/src/feature_creation/node/value_storage/nodes_value_containers.cpp @@ -57,5 +57,6 @@ void node_value_arrs::setup_values_arr(int n_samples, int n_rung, int n_primary_ VALUES_ARR = std::unique_ptr<double[]>(new double[N_STORE_FEATURES * N_SAMPLES]); TEMP_STORAGE_ARR = std::unique_ptr<double[]>(new double[3 * N_STORE_FEATURES * N_SAMPLES]); TEMP_STORAGE_REG = std::unique_ptr<int[]>(new int[3 * N_STORE_FEATURES]); + std::copy_n(std::vector<int>(3*N_STORE_FEATURES, -1).data(), 3*N_STORE_FEATURES, TEMP_STORAGE_REG.get()); } 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 d06c82ac81e7e62f5486d78e8f42e0c2dc1bf7b4..daefbebad2d1202166eeab0b0c6035381aa0da5a 100644 --- a/src/feature_creation/node/value_storage/nodes_value_containers.hpp +++ b/src/feature_creation/node/value_storage/nodes_value_containers.hpp @@ -1,6 +1,7 @@ #ifndef NODE_VALEU_ARR #define NODE_VALEU_ARR +#include <algorithm> #include <memory> #include <vector>