Commit c6892407 authored by Thomas Purcell's avatar Thomas Purcell
Browse files

Make feat_inds a unsigned long int to avoid int overflow

int overflows are leading to issues
parent 381f5860
......@@ -130,9 +130,9 @@ void FeatureSpace::initialize_fs(std::vector<double> prop, std::string project_t
_scores.resize(_phi.size());
}
void FeatureSpace::generate_new_feats(std::vector<node_ptr>::iterator& feat, std::vector<node_ptr>& feat_set, int& feat_ind, double l_bound, double u_bound)
void FeatureSpace::generate_new_feats(std::vector<node_ptr>::iterator& feat, std::vector<node_ptr>& feat_set, unsigned long int& feat_ind, double l_bound, double u_bound)
{
int phi_ind = feat - _phi.begin();
unsigned long int phi_ind = feat - _phi.begin();
feat_set.reserve(feat_set.size() + _un_operators.size() + phi_ind * (_com_bin_operators.size() + 2 * _bin_operators.size()));
for(auto& op : _un_operators)
......@@ -171,7 +171,7 @@ void FeatureSpace::generate_feature_space(std::vector<double>& prop)
std::vector<node_ptr> next_phi;
_n_feat = _phi.size();
int feat_ind = _phi.size();
unsigned long int feat_ind = _phi.size();
node_value_arrs::clear_temp_reg();
double start = omp_get_wtime();
......@@ -450,11 +450,10 @@ void FeatureSpace::project_generated(double* prop, int size, std::vector<node_pt
std::vector<node_ptr> phi_sel_private(phi_sel);
std::vector<double> scores_sel_private(scores_sel);
int feat_ind = _phi.size();
#pragma omp for schedule(dynamic)
for(auto feat = _phi.begin() + _start_gen.back() + _mpi_comm->rank(); feat < _phi.end(); feat += _mpi_comm->size())
{
unsigned long int feat_ind = _phi.size();
node_value_arrs::clear_temp_reg_thread();
std::vector<node_ptr> generated_phi;
generate_new_feats(feat, generated_phi, feat_ind, _l_bound, _u_bound);
......
......@@ -215,7 +215,7 @@ public:
* @param l_bound lower bound for the absolute value of the feature
* @param u_bound upper bound for the abosulte value of the feature
*/
void generate_new_feats(std::vector<node_ptr>::iterator& feat, std::vector<node_ptr>& feat_set, int& feat_ind, double l_bound=1e-50, double u_bound=1e50);
void generate_new_feats(std::vector<node_ptr>::iterator& feat, std::vector<node_ptr>& feat_set, unsigned long int& feat_ind, double l_bound=1e-50, double u_bound=1e50);
/**
* @brief Calculate the SIS Scores for feature generated on the fly
......
......@@ -3,7 +3,7 @@
FeatureNode::FeatureNode()
{}
FeatureNode::FeatureNode(int feat_ind, std::string expr, std::vector<double> value, std::vector<double> test_value, Unit unit, bool set_val) :
FeatureNode::FeatureNode(unsigned long int feat_ind, std::string expr, std::vector<double> value, std::vector<double> test_value, Unit unit, bool set_val) :
Node(feat_ind, value.size(), test_value.size()),
_value(value),
_test_value(test_value),
......
......@@ -70,7 +70,7 @@ public:
* @param value Value of the feature for each test sample
* @param unit Unit of the feature
*/
FeatureNode(int feat_ind, std::string expr, std::vector<double> value, std::vector<double> test_value, Unit unit, bool set_val = true);
FeatureNode(unsigned long int feat_ind, std::string expr, std::vector<double> value, std::vector<double> test_value, Unit unit, bool set_val = true);
#ifdef PY_BINDINGS
/**
* @brief Constructs a feature node using numpy arrays (cpp definition in <python/feature_creation/FeatureNode.cpp)
......@@ -81,7 +81,7 @@ public:
* @param value Value of the feature for each test sample
* @param unit Unit of the feature
*/
FeatureNode(int feat_ind, std::string expr, np::ndarray value, np::ndarray test_value, Unit unit);
FeatureNode(unsigned long int feat_ind, std::string expr, np::ndarray value, np::ndarray test_value, Unit unit);
/**
* @brief Constructs a feature node using Python lists (cpp definition in <python/feature_creation/FeatureNode.cpp)
......@@ -92,7 +92,7 @@ public:
* @param value Value of the feature for each test sample
* @param unit Unit of the feature
*/
FeatureNode(int feat_ind, std::string expr, py::list value, py::list test_value, Unit unit);
FeatureNode(unsigned long int feat_ind, std::string expr, py::list value, py::list test_value, Unit unit);
#endif
/**
......
......@@ -3,7 +3,7 @@
ModelNode::ModelNode()
{}
ModelNode::ModelNode(int feat_ind, int rung, std::string expr, std::string latex_expr, std::string post_fix_expr, std::vector<double> value, std::vector<double> test_value, Unit unit) :
ModelNode::ModelNode(unsigned long int feat_ind, int rung, std::string expr, std::string latex_expr, std::string post_fix_expr, std::vector<double> value, std::vector<double> test_value, Unit unit) :
FeatureNode(feat_ind, expr, value, test_value, unit, false),
_value_svm(_n_samp),
_test_value_svm(_n_test_samp),
......
......@@ -64,7 +64,7 @@ public:
* @param value Value of the feature for each test sample
* @param unit Unit of the feature
*/
ModelNode(int feat_ind, int rung, std::string expr, std::string latex_expr, std::string expr_postfix, std::vector<double> value, std::vector<double> test_value, Unit unit);
ModelNode(unsigned long int feat_ind, int rung, std::string expr, std::string latex_expr, std::string expr_postfix, std::vector<double> value, std::vector<double> test_value, Unit unit);
/**
* @brief Copy Constructor
......
......@@ -3,7 +3,7 @@
Node::Node()
{}
Node::Node(int feat_ind, int n_samp, int n_test_samp) :
Node::Node(unsigned long int feat_ind, int n_samp, int n_test_samp) :
_n_test_samp(n_test_samp),
_n_samp(n_samp),
_feat_ind(feat_ind),
......
......@@ -61,8 +61,8 @@ class Node
protected:
int _n_test_samp; //!< Number of samples in the feature's test set
int _n_samp; //!< Number of samples in the feature's test set
int _feat_ind; //!< Index of the feature
int _arr_ind; //!< Index of the feature for the value arrays
unsigned long int _feat_ind; //!< Index of the feature
unsigned long int _arr_ind; //!< Index of the feature for the value arrays
int _d_mat_ind; //!< Index for the feature matrix
bool _selected; //!< True if the feature is selected;
......@@ -80,7 +80,7 @@ public:
* @param n_samp number of samples in the node
* @param n_samp number of test samples in the node
*/
Node(int feat_ind, int n_samp, int n_test_samp);
Node(unsigned long int feat_ind, int n_samp, int n_test_samp);
/**
* @brief Copy Constructor
......@@ -122,7 +122,7 @@ public:
*
* @param ind(int) the new feature and array index
*/
inline void reindex(int ind){_feat_ind = ind; _arr_ind = ind;}
inline void reindex(unsigned long int ind){_feat_ind = ind; _arr_ind = ind;}
// DocString: node_reindex_2
/**
......@@ -132,7 +132,7 @@ public:
* @param ind(int) the new feature index
* @param arr_ind(int) the new array index
*/
inline void reindex(int ind, int arr_ind){_feat_ind = ind; _arr_ind = arr_ind;}
inline void reindex(unsigned long int ind, unsigned long int arr_ind){_feat_ind = ind; _arr_ind = arr_ind;}
// DocString: node_samp
/**
......@@ -150,13 +150,13 @@ public:
/**
* @brief The feature index
*/
inline int feat_ind(){return _feat_ind;}
inline unsigned long int feat_ind(){return _feat_ind;}
// DocString: node_arr_ind
/**
* @brief The feature array index
*/
inline int arr_ind(){return _arr_ind;}
inline unsigned long int arr_ind(){return _arr_ind;}
// DocString: node_selected
/**
......
......@@ -61,7 +61,7 @@ public:
* @param feats array of features that the operator will act on
* @param feat_ind index of the feature
*/
OperatorNode(std::array<node_ptr, N> feats, int feat_ind) :
OperatorNode(std::array<node_ptr, N> feats, unsigned long int feat_ind) :
Node(feat_ind, feats[0]->n_samp(), feats[0]->n_test_samp()),
_feats(feats)
{}
......
#include <feature_creation/node/operator_nodes/allowed_operator_nodes/abs/absolute_value.hpp>
void generateAbsNode(std::vector<node_ptr>& feat_list, node_ptr feat, int& feat_ind, double l_bound, double u_bound)
void generateAbsNode(std::vector<node_ptr>& feat_list, node_ptr feat, unsigned long int& feat_ind, double l_bound, double u_bound)
{
++feat_ind;
if((feat->type() == NODE_TYPE::ABS) || (feat->type() == NODE_TYPE::ABS_DIFF))
......@@ -23,11 +23,11 @@ void generateAbsNode(std::vector<node_ptr>& feat_list, node_ptr feat, int& feat_
AbsNode::AbsNode()
{}
AbsNode::AbsNode(node_ptr feat, int feat_ind):
AbsNode::AbsNode(node_ptr feat, unsigned long int feat_ind):
OperatorNode({feat}, feat_ind)
{}
AbsNode::AbsNode(node_ptr feat, int feat_ind, double l_bound, double u_bound):
AbsNode::AbsNode(node_ptr feat, unsigned long int feat_ind, double l_bound, double u_bound):
OperatorNode({feat}, feat_ind)
{
if((feat->type() == NODE_TYPE::ABS) || (feat->type() == NODE_TYPE::ABS_DIFF))
......
......@@ -46,7 +46,7 @@ public:
* @param l_bound Minimum absolute value allowed for the feature.
* @param u_bound Maximum absolute value allowed for the feature.
*/
AbsNode(node_ptr feat, int feat_ind);
AbsNode(node_ptr feat, unsigned long int feat_ind);
/**
* @brief Constructor
......@@ -57,7 +57,7 @@ public:
* @param l_bound Minimum absolute value allowed for the feature.
* @param u_bound Maximum absolute value allowed for the feature.
*/
AbsNode(node_ptr feat, int feat_ind, double l_bound, double u_bound);
AbsNode(node_ptr feat, unsigned long int feat_ind, double l_bound, double u_bound);
// DocString: abs_node_unit
/**
......@@ -134,6 +134,6 @@ public:
*/
void update_div_mult_leaves(std::map<std::string, double>& div_mult_leaves, double fact, double& expected_abs_tot);
};
void generateAbsNode(std::vector<node_ptr>& feat_list, node_ptr feat, int& feat_ind, double l_bound, double u_bound);
void generateAbsNode(std::vector<node_ptr>& feat_list, node_ptr feat, unsigned long int& feat_ind, double l_bound, double u_bound);
#endif
#include <feature_creation/node/operator_nodes/allowed_operator_nodes/abs_diff/absolute_difference.hpp>
void generateAbsDiffNode(std::vector<node_ptr>& feat_list, node_ptr feat_1, node_ptr feat_2, int& feat_ind, double l_bound, double u_bound)
void generateAbsDiffNode(std::vector<node_ptr>& feat_list, node_ptr feat_1, node_ptr feat_2, unsigned long int& feat_ind, double l_bound, double u_bound)
{
++feat_ind;
if(feat_1->unit() != feat_2->unit())
......@@ -32,11 +32,11 @@ void generateAbsDiffNode(std::vector<node_ptr>& feat_list, node_ptr feat_1, node
AbsDiffNode::AbsDiffNode()
{}
AbsDiffNode::AbsDiffNode(node_ptr feat_1, node_ptr feat_2, int feat_ind):
AbsDiffNode::AbsDiffNode(node_ptr feat_1, node_ptr feat_2, unsigned long int feat_ind):
OperatorNode({feat_1, feat_2}, feat_ind)
{}
AbsDiffNode::AbsDiffNode(node_ptr feat_1, node_ptr feat_2, int feat_ind, double l_bound, double u_bound):
AbsDiffNode::AbsDiffNode(node_ptr feat_1, node_ptr feat_2, unsigned long int feat_ind, double l_bound, double u_bound):
OperatorNode({feat_1, feat_2}, feat_ind)
{
if(feat_1->unit() != feat_2->unit())
......
......@@ -48,7 +48,7 @@ public:
* @param l_bound Minimum absolute value allowed for the feature.
* @param u_bound Maximum absolute value allowed for the feature.
*/
AbsDiffNode(node_ptr feat_1, node_ptr feat_2, int feat_ind);
AbsDiffNode(node_ptr feat_1, node_ptr feat_2, unsigned long int feat_ind);
/**
* @brief Constructor
......@@ -60,7 +60,7 @@ public:
* @param l_bound Minimum absolute value allowed for the feature.
* @param u_bound Maximum absolute value allowed for the feature.
*/
AbsDiffNode(node_ptr feat_1, node_ptr feat_2, int feat_ind, double l_bound, double u_bound);
AbsDiffNode(node_ptr feat_1, node_ptr feat_2, unsigned long int feat_ind, double l_bound, double u_bound);
// DocString: abs_diff_node_unit
/**
......@@ -138,6 +138,6 @@ public:
void update_div_mult_leaves(std::map<std::string, double>& div_mult_leaves, double fact, double& expected_abs_tot);
};
void generateAbsDiffNode(std::vector<node_ptr>& feat_list, node_ptr feat_1, node_ptr feat_2, int& feat_ind, double l_bound, double u_bound);
void generateAbsDiffNode(std::vector<node_ptr>& feat_list, node_ptr feat_1, node_ptr feat_2, unsigned long int& feat_ind, double l_bound, double u_bound);
#endif
#include <feature_creation/node/operator_nodes/allowed_operator_nodes/add/add.hpp>
void generateAddNode(std::vector<node_ptr>& feat_list, node_ptr feat_1, node_ptr feat_2, int& feat_ind, double l_bound, double u_bound)
void generateAddNode(std::vector<node_ptr>& feat_list, node_ptr feat_1, node_ptr feat_2, unsigned long int& feat_ind, double l_bound, double u_bound)
{
++feat_ind;
if(feat_1->unit() != feat_2->unit())
......@@ -31,11 +31,11 @@ void generateAddNode(std::vector<node_ptr>& feat_list, node_ptr feat_1, node_ptr
AddNode::AddNode()
{}
AddNode::AddNode(node_ptr feat_1, node_ptr feat_2, int feat_ind):
AddNode::AddNode(node_ptr feat_1, node_ptr feat_2, unsigned long int feat_ind):
OperatorNode({feat_1, feat_2}, feat_ind)
{}
AddNode::AddNode(node_ptr feat_1, node_ptr feat_2, int feat_ind, double l_bound, double u_bound):
AddNode::AddNode(node_ptr feat_1, node_ptr feat_2, unsigned long int feat_ind, double l_bound, double u_bound):
OperatorNode({feat_1, feat_2}, feat_ind)
{
if(feat_1->unit() != feat_2->unit())
......
......@@ -45,7 +45,7 @@ public:
* @param feat_2 shared_ptr of the second feature to operate on (B)
* @param feat_ind Index of the new feature
*/
AddNode(node_ptr feat_1, node_ptr feat_2, int feat_ind);
AddNode(node_ptr feat_1, node_ptr feat_2, unsigned long int feat_ind);
/**
* @brief Constructor
......@@ -57,7 +57,7 @@ public:
* @param l_bound Minimum absolute value allowed for the feature.
* @param u_bound Maximum absolute value allowed for the feature.
*/
AddNode(node_ptr feat_1, node_ptr feat_2, int feat_ind, double l_bound, double u_bound);
AddNode(node_ptr feat_1, node_ptr feat_2, unsigned long int feat_ind, double l_bound, double u_bound);
// DocString: add_node_unit
/**
......@@ -134,6 +134,6 @@ public:
*/
void update_div_mult_leaves(std::map<std::string, double>& div_mult_leaves, double fact, double& expected_abs_tot);
};
void generateAddNode(std::vector<node_ptr>& feat_list, node_ptr feat_1, node_ptr feat_2, int& feat_ind, double l_bound, double u_bound);
void generateAddNode(std::vector<node_ptr>& feat_list, node_ptr feat_1, node_ptr feat_2, unsigned long int& feat_ind, double l_bound, double u_bound);
#endif
#include <feature_creation/node/operator_nodes/allowed_operator_nodes/cb/cube.hpp>
void generateCbNode(std::vector<node_ptr>& feat_list, node_ptr feat, int& feat_ind, double l_bound, double u_bound)
void generateCbNode(std::vector<node_ptr>& feat_list, node_ptr feat, unsigned long int& feat_ind, double l_bound, double u_bound)
{
++feat_ind;
if((feat->type() == NODE_TYPE::CBRT) || (feat->type() == NODE_TYPE::SQ) || (feat->type() == NODE_TYPE::INV))
......@@ -19,11 +19,11 @@ void generateCbNode(std::vector<node_ptr>& feat_list, node_ptr feat, int& feat_i
CbNode::CbNode()
{}
CbNode::CbNode(node_ptr feat, int feat_ind):
CbNode::CbNode(node_ptr feat, unsigned long int feat_ind):
OperatorNode({feat}, feat_ind)
{}
CbNode::CbNode(node_ptr feat, int feat_ind, double l_bound, double u_bound):
CbNode::CbNode(node_ptr feat, unsigned long int feat_ind, double l_bound, double u_bound):
OperatorNode({feat}, feat_ind)
{
if((feat->type() == NODE_TYPE::CBRT) || (feat->type() == NODE_TYPE::SQ) || (feat->type() == NODE_TYPE::INV))
......
......@@ -44,7 +44,7 @@ public:
* @param feat shared_ptr of the feature to operate on (A)
* @param feat_ind Index of the new feature
*/
CbNode(node_ptr feat, int feat_ind);
CbNode(node_ptr feat, unsigned long int feat_ind);
/**
* @brief Constructor
......@@ -55,7 +55,7 @@ public:
* @param l_bound Minimum absolute value allowed for the feature.
* @param u_bound Maximum absolute value allowed for the feature.
*/
CbNode(node_ptr feat, int feat_ind, double l_bound, double u_bound);
CbNode(node_ptr feat, unsigned long int feat_ind, double l_bound, double u_bound);
// DocString: cb_node_unit
/**
......@@ -132,6 +132,6 @@ public:
*/
void update_div_mult_leaves(std::map<std::string, double>& div_mult_leaves, double fact, double& expected_abs_tot);
};
void generateCbNode(std::vector<node_ptr>& feat_list, node_ptr feat, int& feat_ind, double l_bound, double u_bound);
void generateCbNode(std::vector<node_ptr>& feat_list, node_ptr feat, unsigned long int& feat_ind, double l_bound, double u_bound);
#endif
#include <feature_creation/node/operator_nodes/allowed_operator_nodes/cbrt/cube_root.hpp>
void generateCbrtNode(std::vector<node_ptr>& feat_list, node_ptr feat, int& feat_ind, double l_bound, double u_bound)
void generateCbrtNode(std::vector<node_ptr>& feat_list, node_ptr feat, unsigned long int& feat_ind, double l_bound, double u_bound)
{
++feat_ind;
if((feat->type() == NODE_TYPE::CB) || (feat->type() == NODE_TYPE::SQ) || (feat->type() == NODE_TYPE::SIX_POW) || (feat->type() == NODE_TYPE::INV))
......@@ -19,11 +19,11 @@ void generateCbrtNode(std::vector<node_ptr>& feat_list, node_ptr feat, int& feat
CbrtNode::CbrtNode()
{}
CbrtNode::CbrtNode(node_ptr feat, int feat_ind):
CbrtNode::CbrtNode(node_ptr feat, unsigned long int feat_ind):
OperatorNode({feat}, feat_ind)
{}
CbrtNode::CbrtNode(node_ptr feat, int feat_ind, double l_bound, double u_bound):
CbrtNode::CbrtNode(node_ptr feat, unsigned long 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::SIX_POW) || (feat->type() == NODE_TYPE::INV))
......
......@@ -44,7 +44,7 @@ public:
* @param feat shared_ptr of the feature to operate on (A)
* @param feat_ind Index of the new feature
*/
CbrtNode(node_ptr feat, int feat_ind);
CbrtNode(node_ptr feat, unsigned long int feat_ind);
/**
* @brief Constructor
......@@ -55,7 +55,7 @@ public:
* @param l_bound Minimum absolute value allowed for the feature.
* @param u_bound Maximum absolute value allowed for the feature.
*/
CbrtNode(node_ptr feat, int feat_ind, double l_bound, double u_bound);
CbrtNode(node_ptr feat, unsigned long int feat_ind, double l_bound, double u_bound);
// DocString: cbrt_node_unit
/**
......@@ -132,6 +132,6 @@ public:
*/
void update_div_mult_leaves(std::map<std::string, double>& div_mult_leaves, double fact, double& expected_abs_tot);
};
void generateCbrtNode(std::vector<node_ptr>& feat_list, node_ptr feat, int& feat_ind, double l_bound, double u_bound);
void generateCbrtNode(std::vector<node_ptr>& feat_list, node_ptr feat, unsigned long int& feat_ind, double l_bound, double u_bound);
#endif
#include <feature_creation/node/operator_nodes/allowed_operator_nodes/cos/cos.hpp>
void generateCosNode(std::vector<node_ptr>& feat_list, node_ptr feat, int& feat_ind, double l_bound, double u_bound)
void generateCosNode(std::vector<node_ptr>& feat_list, node_ptr feat, unsigned long int& feat_ind, double l_bound, double u_bound)
{
++feat_ind;
if(feat->unit() != Unit() || (feat->type() == NODE_TYPE::SIN) || (feat->type() == NODE_TYPE::COS))
......@@ -19,11 +19,11 @@ void generateCosNode(std::vector<node_ptr>& feat_list, node_ptr feat, int& feat_
CosNode::CosNode()
{}
CosNode::CosNode(node_ptr feat, int feat_ind):
CosNode::CosNode(node_ptr feat, unsigned long int feat_ind):
OperatorNode({feat}, feat_ind)
{}
CosNode::CosNode(node_ptr feat, int feat_ind, double l_bound, double u_bound):
CosNode::CosNode(node_ptr feat, unsigned long int feat_ind, double l_bound, double u_bound):
OperatorNode({feat}, feat_ind)
{
if(feat->unit() != Unit())
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment