diff --git a/src/descriptor_identifier/SISSORegressor.cpp b/src/descriptor_identifier/SISSORegressor.cpp index 4db934c203661ee7ec60d3a9af5ae12e1e07c24c..1c547dd1750ee2d72186b6aec63b19e843ec46ca 100644 --- a/src/descriptor_identifier/SISSORegressor.cpp +++ b/src/descriptor_identifier/SISSORegressor.cpp @@ -1,22 +1,21 @@ #include <descriptor_identifier/SISSORegressor.hpp> SISSORegressor::SISSORegressor(std::shared_ptr<FeatureSpace> feat_space, std::vector<double> prop, std::vector<double> prop_test, int n_dim, int n_residual): + _prop(prop), + _prop_test(prop_test), + _a(new double[(n_dim + 1) * prop.size()]), + _b(new double[prop.size()]), + _ones(new double[prop.size()]), + _error(new double[prop.size()]), + _work(nullptr), + _s(new double[n_dim + 1]), _feat_space(feat_space), _mpi_comm(feat_space->mpi_comm()), _n_samp(prop.size()), _n_dim(n_dim), _n_residual(n_residual), _lwork(-1), - _rank(0), - _a(new double[(_n_dim + 1) * _n_samp]), - _b(new double[_n_samp]), - _ones(new double[_n_samp]), - _error(new double[_n_samp]), - _work(nullptr), - _s(new double[n_dim + 1]), - _models(), - _prop(prop), - _prop_test(prop_test) + _rank(0) { // Initialize a, b, ones, s, and _error arrays diff --git a/src/descriptor_identifier/SISSORegressor.hpp b/src/descriptor_identifier/SISSORegressor.hpp index ab4e7e688ee06f735cf374bd47ccf575c03c3843..02d1af20551c511541bbcfa3214301de903aa691 100644 --- a/src/descriptor_identifier/SISSORegressor.hpp +++ b/src/descriptor_identifier/SISSORegressor.hpp @@ -12,6 +12,18 @@ class SISSORegressor { protected: + std::vector<std::vector<Model>> _models; //!< List of models + + std::vector<double> _prop; //!< Property array + std::vector<double> _prop_test; //!< Property array + + std::unique_ptr<double[]> _a; //!< A matrix for least squares + std::unique_ptr<double[]> _b; //!< Solution array for least squares + std::unique_ptr<double[]> _ones; //!< Array of ones to copy over for least squares comparison + std::unique_ptr<double[]> _error; //!< Array to calculate the residuals for the models + std::unique_ptr<double[]> _work; //!< The work array for least squares problems + std::unique_ptr<double[]> _s; //!< The S array for least squares problems + std::shared_ptr<FeatureSpace> _feat_space; //!< Feature Space for the problem std::shared_ptr<MPI_Interface> _mpi_comm; //!< MPI Communicator @@ -21,16 +33,7 @@ protected: int _lwork; //!< size of the work array int _rank; //!< Ranks for the least squares problem - std::unique_ptr<double[]> _a; //!< A matrix for least squares - std::unique_ptr<double[]> _b; //!< Solution array for least squares - std::unique_ptr<double[]> _ones; //!< Array of ones to copy over for least squares comparison - std::unique_ptr<double[]> _error; //!< Array to calculate the residuals for the models - std::unique_ptr<double[]> _work; //!< The work array for least squares problems - std::unique_ptr<double[]> _s; //!< The S array for least squares problems - std::vector<std::vector<Model>> _models; //!< List of models - std::vector<double> _prop; //!< Property array - std::vector<double> _prop_test; //!< Property array public: /** diff --git a/src/feature_creation/feature_space/FeatureSpace.cpp b/src/feature_creation/feature_space/FeatureSpace.cpp index e27a8bd39a2eb5fe76bede5daf8ee510af4f0c6a..38e8e96a6c6b20040c16beadc63d20167db01b9b 100644 --- a/src/feature_creation/feature_space/FeatureSpace.cpp +++ b/src/feature_creation/feature_space/FeatureSpace.cpp @@ -25,8 +25,8 @@ FeatureSpace::FeatureSpace( int max_phi, int n_sis_select, int max_store_rung, - double max_abs_feat_val, - double min_abs_feat_val + double min_abs_feat_val, + double max_abs_feat_val ): _phi(phi_0), _phi_0(phi_0), @@ -386,12 +386,9 @@ void FeatureSpace::sis(std::vector<double>& prop) int unique_scores = 1; if(_mpi_comm->rank() == 0) { - std::vector<mpi::request> reqs(_mpi_comm->size()-1); std::copy_n(scores_selected.data(), _n_sis_select, sent_scores.data()); for(int rr = 1; rr < _mpi_comm->size(); ++rr) - reqs[rr - 1] = _mpi_comm->irecv(rr, _mpi_comm->cantorTagGen(rr, 0, 1, 0), &sent_scores[rr * _n_sis_select], _n_sis_select); - - mpi::wait_all(reqs.begin(), reqs.end()); + _mpi_comm->recv(rr, _mpi_comm->cantorTagGen(rr, 0, 1, 0), &sent_scores[rr * _n_sis_select], _n_sis_select); // Sort the scores and see how many features we need to guarantee we get n_sis unique features inds = util_funcs::argsort(sent_scores); @@ -408,7 +405,7 @@ void FeatureSpace::sis(std::vector<double>& prop) } else { - _mpi_comm->isend(0, _mpi_comm->cantorTagGen(_mpi_comm->rank(), 0, 1, 0), scores_selected.data(), _n_sis_select); + _mpi_comm->send(0, _mpi_comm->cantorTagGen(_mpi_comm->rank(), 0, 1, 0), scores_selected.data(), _n_sis_select); inds = {}; } mpi::broadcast(*_mpi_comm, inds, 0); @@ -435,14 +432,12 @@ void FeatureSpace::sis(std::vector<double>& prop) std::copy_n(scores_selected.begin(), _n_sis_select, sent_scores.begin()); std::copy_n(phi_selected.begin(), _n_sis_select, sent_phi.begin()); - std::vector<mpi::request> reqs(2 * (_mpi_comm->size()-1)); for(int rr = 1; rr < _mpi_comm->size(); ++rr) { - reqs[2*(rr - 1)] = _mpi_comm->irecv(rr, _mpi_comm->cantorTagGen(rr, 0, 2, 0), &sent_scores[rr * _n_sis_select], _n_sis_select); - reqs[2*(rr - 1)+1] = _mpi_comm->irecv(rr, _mpi_comm->cantorTagGen(rr, 0, 2, 1), &sent_phi[rr * _n_sis_select], _n_sis_select); + _mpi_comm->recv(rr, _mpi_comm->cantorTagGen(rr, 0, 2, 0), &sent_scores[rr * _n_sis_select], _n_sis_select); + _mpi_comm->recv(rr, _mpi_comm->cantorTagGen(rr, 0, 2, 1), &sent_phi[rr * _n_sis_select], _n_sis_select); } - mpi::wait_all(reqs.begin(), reqs.end()); if(inds.size() == unique_scores) { inds = util_funcs::argsort(sent_scores); @@ -488,14 +483,14 @@ void FeatureSpace::sis(std::vector<double>& prop) ++ii; } } - if(cur_feat_local != _n_sis_select) + if(_phi_selected.size() != node_value_arrs::N_SELECTED) throw std::logic_error("SIS went through all features and did not select enough."); cur_feat -= cur_feat_local; } else { - _mpi_comm->isend(0, _mpi_comm->cantorTagGen(_mpi_comm->rank(), 0, 2, 0), scores_selected.data(), _n_sis_select); - _mpi_comm->isend(0, _mpi_comm->cantorTagGen(_mpi_comm->rank(), 0, 2, 1), phi_selected.data(), _n_sis_select); + _mpi_comm->send(0, _mpi_comm->cantorTagGen(_mpi_comm->rank(), 0, 2, 0), scores_selected.data(), _n_sis_select); + _mpi_comm->send(0, _mpi_comm->cantorTagGen(_mpi_comm->rank(), 0, 2, 1), phi_selected.data(), _n_sis_select); _phi_selected.resize(node_value_arrs::N_SELECTED); } mpi::broadcast(*_mpi_comm, &_phi_selected[_phi_selected.size() - _n_sis_select], _n_sis_select, 0); diff --git a/src/feature_creation/feature_space/FeatureSpace.hpp b/src/feature_creation/feature_space/FeatureSpace.hpp index 33ce9d290341d20d7fdb1e259cb1634a5b4799da..de7f41a98ff9db7a4a0aebc5273d7b43486a215d 100644 --- a/src/feature_creation/feature_space/FeatureSpace.hpp +++ b/src/feature_creation/feature_space/FeatureSpace.hpp @@ -62,8 +62,8 @@ public: int max_phi=1, int n_sis_select=1, int max_store_rung=2, - double max_abs_feat_val=1e50, - double min_abs_feat_val=1e-50 + double min_abs_feat_val=1e-50, + double max_abs_feat_val=1e50 ); /** 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 ef1c8af651c219582b9415b40cae390a8e34545d..0aca901696c85e45f9eeaf7517b29359cc2f2e80 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 @@ -16,9 +16,9 @@ class AbsDiffNode: public OperatorNode<2> public: AbsDiffNode(); - AbsDiffNode(std::array<node_ptr, 2> feats, int rung, int feat_ind, double l_bound = 1e-50, double u_bound = 1e50); + AbsDiffNode(std::array<node_ptr, 2> feats, int rung, int feat_ind, double l_bound, double u_bound); - AbsDiffNode(node_ptr feat_1, node_ptr feat_2, int rung, int feat_ind, double l_bound = 1e-50, double u_bound = 1e50); + AbsDiffNode(node_ptr feat_1, node_ptr feat_2, int rung, int feat_ind, double l_bound, double u_bound); inline Unit unit(){return _feats[0]->unit();} 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 dee59b374a8bbaad8cea43561d46f6165da7b82e..c42265ca26a775239b5e739956f918f504514304 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 @@ -15,9 +15,9 @@ class AbsNode: public OperatorNode<1> public: AbsNode(); - AbsNode(std::array<node_ptr, 1> feats, int rung, int feat_ind, double l_bound = 1e-50, double u_bound = 1e50); + AbsNode(std::array<node_ptr, 1> feats, int rung, int feat_ind, double l_bound, double u_bound); - AbsNode(node_ptr feat, int rung, int feat_ind, double l_bound = 1e-50, double u_bound = 1e50); + AbsNode(node_ptr feat, int rung, int feat_ind, double l_bound, double u_bound); inline Unit unit(){return _feats[0]->unit();} 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 4cb337292c55a137323a664bf7c42eed6f9aa87c..b2579b811cc2eb09e53f2cd259c4bd53f6a31788 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 @@ -15,9 +15,9 @@ class AddNode: public OperatorNode<2> public: AddNode(); - AddNode(std::array<node_ptr, 2> feats, int rung, int feat_ind, double l_bound = 1e-50, double u_bound = 1e50); + AddNode(std::array<node_ptr, 2> feats, int rung, int feat_ind, double l_bound, double u_bound); - AddNode(node_ptr feat_1, node_ptr feat_2, int rung, int feat_ind, double l_bound = 1e-50, double u_bound = 1e50); + AddNode(node_ptr feat_1, node_ptr feat_2, int rung, int feat_ind, double l_bound, double u_bound); inline Unit unit(){return _feats[0]->unit();} 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 28824afa78aec13835405c55934bea68c5d63c0c..c006a46bf64ae01c83d912ca6350b54cf5407f42 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 @@ -15,9 +15,9 @@ class CosNode: public OperatorNode<1> public: CosNode(); - CosNode(std::array<node_ptr, 1> feats, int rung, int feat_ind, double l_bound = 1e-50, double u_bound = 1e50); + CosNode(std::array<node_ptr, 1> feats, int rung, int feat_ind, double l_bound, double u_bound); - CosNode(node_ptr feat, int rung, int feat_ind, double l_bound = 1e-50, double u_bound = 1e50); + CosNode(node_ptr feat, int rung, int feat_ind, double l_bound, double u_bound); inline Unit unit(){return Unit();} 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 50e33677def3fa2251929f2d55a4c6de542b89ef..3d7eac11b6eedf921111ae9cc1cb7a726928aa5d 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 @@ -15,9 +15,9 @@ class CbNode: public OperatorNode<1> public: CbNode(); - CbNode(std::array<node_ptr, 1> feats, int rung, int feat_ind, double l_bound = 1e-50, double u_bound = 1e50); + CbNode(std::array<node_ptr, 1> feats, int rung, int feat_ind, double l_bound, double u_bound); - CbNode(node_ptr feat, int rung, int feat_ind, double l_bound = 1e-50, double u_bound = 1e50); + CbNode(node_ptr feat, int rung, int feat_ind, double l_bound, double u_bound); inline Unit unit(){return _feats[0]->unit()^(3.0);} 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 0d34ae51697ef0f38c7b042e6e876cebba9579ee..1509726f0154c30c4ed8fe0912370a8e040f381c 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 @@ -15,9 +15,9 @@ class CbrtNode: public OperatorNode<1> public: CbrtNode(); - CbrtNode(std::array<node_ptr, 1> feats, int rung, int feat_ind, double l_bound = 1e-50, double u_bound = 1e50); + CbrtNode(std::array<node_ptr, 1> feats, int rung, int feat_ind, double l_bound, double u_bound); - CbrtNode(node_ptr feat, int rung, int feat_ind, double l_bound = 1e-50, double u_bound = 1e50); + CbrtNode(node_ptr feat, int rung, int feat_ind, double l_bound, double u_bound); inline Unit unit(){return _feats[0]->unit()^(1.0 / 3.0);} 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 24395909614b9af9530ab143dfcc8e7ccb6e1906..7b6e07d79131e43f13b1b0ad1bfa0a8802b1847e 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 @@ -15,9 +15,9 @@ class DivNode: public OperatorNode<2> public: DivNode(); - DivNode(std::array<node_ptr, 2> feats, int rung, int feat_ind, double l_bound = 1e-50, double u_bound = 1e50); + DivNode(std::array<node_ptr, 2> feats, int rung, int feat_ind, double l_bound, double u_bound); - DivNode(node_ptr feat_1, node_ptr feat_2, int rung, int feat_ind, double l_bound = 1e-50, double u_bound = 1e50); + DivNode(node_ptr feat_1, node_ptr feat_2, int rung, int feat_ind, double l_bound, double u_bound); inline Unit unit(){return _feats[0]->unit() / _feats[1]->unit();} 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 61e3d72022be607adc681c1d4c3de24b443192cc..7870d772afdd52afba999ad72869e264258a01f3 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 @@ -15,9 +15,9 @@ class ExpNode: public OperatorNode<1> public: ExpNode(); - ExpNode(std::array<node_ptr, 1> feats, int rung, int feat_ind, double l_bound = 1e-50, double u_bound = 1e50); + ExpNode(std::array<node_ptr, 1> feats, int rung, int feat_ind, double l_bound, double u_bound); - ExpNode(node_ptr feat, int rung, int feat_ind, double l_bound = 1e-50, double u_bound = 1e50); + ExpNode(node_ptr feat, int rung, int feat_ind, double l_bound, double u_bound); inline Unit unit(){return Unit();} 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 197835b98cd389a1079735840ac58fbe04a97520..384fff3d18995d74e0e834b55ef95dff0613364a 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 @@ -16,9 +16,9 @@ class InvNode: public OperatorNode<1> public: InvNode(); - InvNode(std::array<node_ptr, 1> feats, int rung, int feat_ind, double l_bound = 1e-50, double u_bound = 1e50); + InvNode(std::array<node_ptr, 1> feats, int rung, int feat_ind, double l_bound, double u_bound); - InvNode(node_ptr feat, int rung, int feat_ind, double l_bound = 1e-50, double u_bound = 1e50); + InvNode(node_ptr feat, int rung, int feat_ind, double l_bound, double u_bound); inline Unit unit(){return _feats[0]->unit() ^ (-1.0);} 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 2359c07ac512921f4a78e417099694e29ff8bf02..11f0e8460e89164646f05b11928d5dfeef40bd65 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 @@ -15,9 +15,9 @@ class LogNode: public OperatorNode<1> public: LogNode(); - LogNode(std::array<node_ptr, 1> feats, int rung, int feat_ind, double l_bound = 1e-50, double u_bound = 1e50); + LogNode(std::array<node_ptr, 1> feats, int rung, int feat_ind, double l_bound, double u_bound); - LogNode(node_ptr feat, int rung, int feat_ind, double l_bound = 1e-50, double u_bound = 1e50); + LogNode(node_ptr feat, int rung, int feat_ind, double l_bound, double u_bound); inline Unit unit(){return Unit();} 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 a6a7a841dc637f8238595916e98b6f61f8bf4cb7..58e8df98d9e3ec517a3dd9ea0d378d4568acdbfc 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 @@ -16,9 +16,9 @@ class MultNode: public OperatorNode<2> public: MultNode(); - MultNode(std::array<node_ptr, 2> feats, int rung, int feat_ind, double l_bound = 1e-50, double u_bound = 1e50); + MultNode(std::array<node_ptr, 2> feats, int rung, int feat_ind, double l_bound, double u_bound); - MultNode(node_ptr feat_1, node_ptr feat_2, int rung, int feat_ind, double l_bound = 1e-50, double u_bound = 1e50); + MultNode(node_ptr feat_1, node_ptr feat_2, int rung, int feat_ind, double l_bound, double u_bound); inline Unit unit(){return _feats[0]->unit() * _feats[1]->unit();} 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 de6ba6603778189186e1c3d685a211feb56fde46..2b509ade484936ee5b4bc5d02914c0429cab886c 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 @@ -16,9 +16,9 @@ class NegExpNode: public OperatorNode<1> public: NegExpNode(); - NegExpNode(std::array<node_ptr, 1> feats, int rung, int feat_ind, double l_bound = 1e-50, double u_bound = 1e50); + NegExpNode(std::array<node_ptr, 1> feats, int rung, int feat_ind, double l_bound, double u_bound); - NegExpNode(node_ptr feat, int rung, int feat_ind, double l_bound = 1e-50, double u_bound = 1e50); + NegExpNode(node_ptr feat, int rung, int feat_ind, double l_bound, double u_bound); inline Unit unit(){return Unit();} 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 3e3ff10588d621f865e0a14ce3969defb7bb3aac..4654cc380d51e382f9a324781a05047d87b16a54 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 @@ -16,9 +16,9 @@ class SinNode: public OperatorNode<1> public: SinNode(); - SinNode(std::array<node_ptr, 1> feats, int rung, int feat_ind, double l_bound = 1e-50, double u_bound = 1e50); + SinNode(std::array<node_ptr, 1> feats, int rung, int feat_ind, double l_bound, double u_bound); - SinNode(node_ptr feat, int rung, int feat_ind, double l_bound = 1e-50, double u_bound = 1e50); + SinNode(node_ptr feat, int rung, int feat_ind, double l_bound, double u_bound); inline Unit unit(){return Unit();} 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 0dae9c876a9a52b67be80d564eb750e2b620bdc6..8329bae7290c5381ab1a62ac8963747e4a6e572a 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 @@ -16,9 +16,9 @@ class SixPowNode: public OperatorNode<1> public: SixPowNode(); - SixPowNode(std::array<node_ptr, 1> feats, int rung, int feat_ind, double l_bound = 1e-50, double u_bound = 1e50); + SixPowNode(std::array<node_ptr, 1> feats, int rung, int feat_ind, double l_bound, double u_bound); - SixPowNode(node_ptr feat, int rung, int feat_ind, double l_bound = 1e-50, double u_bound = 1e50); + SixPowNode(node_ptr feat, int rung, int feat_ind, double l_bound, double u_bound); inline Unit unit(){return _feats[0]->unit()^(6.0);} 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 1836c6092db9fe4b97445011a38f99ea0e66582b..449c6b48984c22aa5e5251497bdeb0fa35cde007 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 @@ -15,9 +15,9 @@ class SqNode: public OperatorNode<1> public: SqNode(); - SqNode(std::array<node_ptr, 1> feats, int rung, int feat_ind, double l_bound = 1e-50, double u_bound = 1e50); + SqNode(std::array<node_ptr, 1> feats, int rung, int feat_ind, double l_bound, double u_bound); - SqNode(node_ptr feat, int rung, int feat_ind, double l_bound = 1e-50, double u_bound = 1e50); + SqNode(node_ptr feat, int rung, int feat_ind, double l_bound, double u_bound); inline Unit unit(){return _feats[0]->unit()^(2.0);} 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 b701f53d4a9b57ad2b90bab11c6ac825a18ab524..1cfbe8ce1de74e0140f7645ad1b9ab53375777cf 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 @@ -16,9 +16,9 @@ class SqrtNode: public OperatorNode<1> public: SqrtNode(); - SqrtNode(std::array<node_ptr, 1> feats, int rung, int feat_ind, double l_bound = 1e-50, double u_bound = 1e50); + SqrtNode(std::array<node_ptr, 1> feats, int rung, int feat_ind, double l_bound, double u_bound); - SqrtNode(node_ptr feat, int rung, int feat_ind, double l_bound = 1e-50, double u_bound = 1e50); + SqrtNode(node_ptr feat, int rung, int feat_ind, double l_bound, double u_bound); inline Unit unit(){return _feats[0]->unit()^(0.5);} 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 6dd01afe40f0edbefc38b0123f14ea9f31c90824..0ea056cab5ee220c77a872c9a85dada086494c2b 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 @@ -16,9 +16,9 @@ class SubNode: public OperatorNode<2> public: SubNode(); - SubNode(std::array<node_ptr, 2> feats, int rung, int feat_ind, double l_bound = 1e-50, double u_bound = 1e50); + SubNode(std::array<node_ptr, 2> feats, int rung, int feat_ind, double l_bound, double u_bound); - SubNode(node_ptr feat_1, node_ptr feat_2, int rung, int feat_ind, double l_bound = 1e-50, double u_bound = 1e50); + SubNode(node_ptr feat_1, node_ptr feat_2, int rung, int feat_ind, double l_bound, double u_bound); inline Unit unit(){return _feats[0]->unit();} diff --git a/src/feature_creation/node/operator_nodes/allowed_ops.cpp b/src/feature_creation/node/operator_nodes/allowed_ops.cpp index 21da62c160e555128f6b0d6de3dfe5921bcb4d2c..f93bd046e01a6059e1e11e4fe26a53d500c8a5c1 100644 --- a/src/feature_creation/node/operator_nodes/allowed_ops.cpp +++ b/src/feature_creation/node/operator_nodes/allowed_ops.cpp @@ -5,22 +5,22 @@ std::map<std::string, bin_op_node_gen> allowed_op_maps::binary_operator_map; void allowed_op_maps::set_node_maps() { - allowed_op_maps::binary_operator_map["add"] = [](node_ptr f1, node_ptr f2, int rung, int feat_ind, double l_bound, double u_bound){return std::make_shared<AddNode>(f1, f2, rung, feat_ind);}; - allowed_op_maps::binary_operator_map["sub"] = [](node_ptr f1, node_ptr f2, int rung, int feat_ind, double l_bound, double u_bound){return std::make_shared<SubNode>(f1, f2, rung, feat_ind);};; - allowed_op_maps::binary_operator_map["abs_diff"] = [](node_ptr f1, node_ptr f2, int rung, int feat_ind, double l_bound, double u_bound){return std::make_shared<AbsDiffNode>(f1, f2, rung, feat_ind);};; - allowed_op_maps::binary_operator_map["mult"] = [](node_ptr f1, node_ptr f2, int rung, int feat_ind, double l_bound, double u_bound){return std::make_shared<MultNode>(f1, f2, rung, feat_ind);};; - allowed_op_maps::binary_operator_map["div"] = [](node_ptr f1, node_ptr f2, int rung, int feat_ind, double l_bound, double u_bound){return std::make_shared<DivNode>(f1, f2, rung, feat_ind);};; + allowed_op_maps::binary_operator_map["add"] = [](node_ptr f1, node_ptr f2, int rung, int feat_ind, double l_bound, double u_bound){return std::make_shared<AddNode>(f1, f2, rung, feat_ind, l_bound, u_bound);}; + allowed_op_maps::binary_operator_map["sub"] = [](node_ptr f1, node_ptr f2, int rung, int feat_ind, double l_bound, double u_bound){return std::make_shared<SubNode>(f1, f2, rung, feat_ind, l_bound, u_bound);};; + allowed_op_maps::binary_operator_map["abs_diff"] = [](node_ptr f1, node_ptr f2, int rung, int feat_ind, double l_bound, double u_bound){return std::make_shared<AbsDiffNode>(f1, f2, rung, feat_ind, l_bound, u_bound);};; + allowed_op_maps::binary_operator_map["mult"] = [](node_ptr f1, node_ptr f2, int rung, int feat_ind, double l_bound, double u_bound){return std::make_shared<MultNode>(f1, f2, rung, feat_ind, l_bound, u_bound);};; + allowed_op_maps::binary_operator_map["div"] = [](node_ptr f1, node_ptr f2, int rung, int feat_ind, double l_bound, double u_bound){return std::make_shared<DivNode>(f1, f2, rung, feat_ind, l_bound, u_bound);};; - allowed_op_maps::unary_operator_map["exp"] = [](node_ptr f1, int rung, int feat_ind, double l_bound, double u_bound){return std::make_shared<ExpNode>(f1, rung, feat_ind);}; - allowed_op_maps::unary_operator_map["neg_exp"] = [](node_ptr f1, int rung, int feat_ind, double l_bound, double u_bound){return std::make_shared<NegExpNode>(f1, rung, feat_ind);}; - allowed_op_maps::unary_operator_map["inv"] = [](node_ptr f1, int rung, int feat_ind, double l_bound, double u_bound){return std::make_shared<InvNode>(f1, rung, feat_ind);}; - allowed_op_maps::unary_operator_map["sq"] = [](node_ptr f1, int rung, int feat_ind, double l_bound, double u_bound){return std::make_shared<SqNode>(f1, rung, feat_ind);}; - allowed_op_maps::unary_operator_map["cb"] = [](node_ptr f1, int rung, int feat_ind, double l_bound, double u_bound){return std::make_shared<CbNode>(f1, rung, feat_ind);}; - allowed_op_maps::unary_operator_map["six_pow"] = [](node_ptr f1, int rung, int feat_ind, double l_bound, double u_bound){return std::make_shared<SixPowNode>(f1, rung, feat_ind);}; - allowed_op_maps::unary_operator_map["sqrt"] = [](node_ptr f1, int rung, int feat_ind, double l_bound, double u_bound){return std::make_shared<SqrtNode>(f1, rung, feat_ind);}; - allowed_op_maps::unary_operator_map["cbrt"] = [](node_ptr f1, int rung, int feat_ind, double l_bound, double u_bound){return std::make_shared<CbrtNode>(f1, rung, feat_ind);}; - allowed_op_maps::unary_operator_map["log"] = [](node_ptr f1, int rung, int feat_ind, double l_bound, double u_bound){return std::make_shared<LogNode>(f1, rung, feat_ind);}; - allowed_op_maps::unary_operator_map["abs"] = [](node_ptr f1, int rung, int feat_ind, double l_bound, double u_bound){return std::make_shared<AbsNode>(f1, rung, feat_ind);}; - allowed_op_maps::unary_operator_map["sin"] = [](node_ptr f1, int rung, int feat_ind, double l_bound, double u_bound){return std::make_shared<SinNode>(f1, rung, feat_ind);}; - allowed_op_maps::unary_operator_map["cos"] = [](node_ptr f1, int rung, int feat_ind, double l_bound, double u_bound){return std::make_shared<CosNode>(f1, rung, feat_ind);}; + allowed_op_maps::unary_operator_map["exp"] = [](node_ptr f1, int rung, int feat_ind, double l_bound, double u_bound){return std::make_shared<ExpNode>(f1, rung, feat_ind, l_bound, u_bound);}; + allowed_op_maps::unary_operator_map["neg_exp"] = [](node_ptr f1, int rung, int feat_ind, double l_bound, double u_bound){return std::make_shared<NegExpNode>(f1, rung, feat_ind, l_bound, u_bound);}; + allowed_op_maps::unary_operator_map["inv"] = [](node_ptr f1, int rung, int feat_ind, double l_bound, double u_bound){return std::make_shared<InvNode>(f1, rung, feat_ind, l_bound, u_bound);}; + allowed_op_maps::unary_operator_map["sq"] = [](node_ptr f1, int rung, int feat_ind, double l_bound, double u_bound){return std::make_shared<SqNode>(f1, rung, feat_ind, l_bound, u_bound);}; + allowed_op_maps::unary_operator_map["cb"] = [](node_ptr f1, int rung, int feat_ind, double l_bound, double u_bound){return std::make_shared<CbNode>(f1, rung, feat_ind, l_bound, u_bound);}; + allowed_op_maps::unary_operator_map["six_pow"] = [](node_ptr f1, int rung, int feat_ind, double l_bound, double u_bound){return std::make_shared<SixPowNode>(f1, rung, feat_ind, l_bound, u_bound);}; + allowed_op_maps::unary_operator_map["sqrt"] = [](node_ptr f1, int rung, int feat_ind, double l_bound, double u_bound){return std::make_shared<SqrtNode>(f1, rung, feat_ind, l_bound, u_bound);}; + allowed_op_maps::unary_operator_map["cbrt"] = [](node_ptr f1, int rung, int feat_ind, double l_bound, double u_bound){return std::make_shared<CbrtNode>(f1, rung, feat_ind, l_bound, u_bound);}; + allowed_op_maps::unary_operator_map["log"] = [](node_ptr f1, int rung, int feat_ind, double l_bound, double u_bound){return std::make_shared<LogNode>(f1, rung, feat_ind, l_bound, u_bound);}; + allowed_op_maps::unary_operator_map["abs"] = [](node_ptr f1, int rung, int feat_ind, double l_bound, double u_bound){return std::make_shared<AbsNode>(f1, rung, feat_ind, l_bound, u_bound);}; + allowed_op_maps::unary_operator_map["sin"] = [](node_ptr f1, int rung, int feat_ind, double l_bound, double u_bound){return std::make_shared<SinNode>(f1, rung, feat_ind, l_bound, u_bound);}; + allowed_op_maps::unary_operator_map["cos"] = [](node_ptr f1, int rung, int feat_ind, double l_bound, double u_bound){return std::make_shared<CosNode>(f1, rung, feat_ind, l_bound, u_bound);}; } diff --git a/src/inputs/InputParser.cpp b/src/inputs/InputParser.cpp index 16f6cbd6f9fd91339ab945b9eda5f62ac0a561e7..58063aadffccc28f009d52068e578ef50d41c200 100644 --- a/src/inputs/InputParser.cpp +++ b/src/inputs/InputParser.cpp @@ -1,17 +1,19 @@ #include <inputs/InputParser.hpp> InputParser::InputParser(boost::property_tree::ptree IP, std::string fn, std::shared_ptr<MPI_Interface> comm) : + _opset(as_vector<std::string>(IP, "opset")), + _leave_out_inds(as_vector<int>(IP, "leave_out_inds")), + _filename(fn), + _data_file(IP.get<std::string>("data_file", "data.csv")), + _prop_key(IP.get<std::string>("property_key", "prop")), + _l_bound(IP.get<double>("min_abs_feat_val", 1e-50)), + _u_bound(IP.get<double>("max_abs_feat_val", 1e50)), _n_dim(IP.get<int>("desc_dim")), _n_sis_select(IP.get<int>("_n_sis_select")), _max_rung(IP.get<int>("max_rung")), _max_store_rung(IP.get<int>("n_rung_store", _max_rung - 1)), _n_samp(-1), - _n_residuals(IP.get<int>("n_residual", 1)), - _filename(fn), - _data_file(IP.get<std::string>("data_file", "data.csv")), - _prop_key(IP.get<std::string>("property_key", "prop")), - _leave_out_inds(as_vector<int>(IP, "leave_out_inds")), - _opset(as_vector<std::string>(IP, "opset")) + _n_residuals(IP.get<int>("n_residual", 1)) { std::ifstream data_stream; @@ -177,7 +179,7 @@ void InputParser::generate_feature_space(std::shared_ptr<MPI_Interface> comm) for(int ff = 0; ff < headers.size(); ++ff) phi_0.push_back(std::make_shared<FeatureNode>(ff, headers[ff], data[ff], test_data[ff], units[ff])); - _feat_space = std::make_shared<FeatureSpace>(comm, phi_0, _opset, _max_rung, _n_sis_select, _max_store_rung); + _feat_space = std::make_shared<FeatureSpace>(comm, phi_0, _opset, _max_rung, _n_sis_select, _max_store_rung, _l_bound, _u_bound); } void stripComments(std::string& filename) diff --git a/src/inputs/InputParser.hpp b/src/inputs/InputParser.hpp index e0ec8b105bf454bd176827934a2cba13c8b7a04a..a3801fac23842fe0a9107a8d36bf9f7104a4c413 100644 --- a/src/inputs/InputParser.hpp +++ b/src/inputs/InputParser.hpp @@ -25,7 +25,20 @@ class InputParser { public: + std::vector<std::string> _opset; + std::vector<double> _prop_train; + std::vector<double> _prop_test; + std::vector<int> _leave_out_inds; + + std::string _filename; + std::string _data_file; + std::string _prop_key; + std::shared_ptr<FeatureSpace> _feat_space; + + double _l_bound; + double _u_bound; + int _n_dim; int _max_rung; int _max_store_rung; @@ -34,16 +47,6 @@ public: int _n_residuals; int _n_leave_out; - std::string _filename; - std::string _data_file; - std::string _prop_key; - - std::vector<int> _leave_out_inds; - std::vector<double> _prop_train; - std::vector<double> _prop_test; - std::vector<std::string> _opset; - - InputParser(boost::property_tree::ptree IP, std::string fn, std::shared_ptr<MPI_Interface> comm); inline std::shared_ptr<FeatureSpace> feat_space(){return _feat_space;} void generate_feature_space(std::shared_ptr<MPI_Interface> comm);