Commit 2c4240f7 authored by Thomas Purcell's avatar Thomas Purcell
Browse files

Add const terms for nodes, utils and NL OPt

parent 80de62fd
......@@ -11,7 +11,7 @@ ConvexHull1D::ConvexHull1D() :
_n_class(0)
{}
ConvexHull1D::ConvexHull1D(const std::vector<int>& sizes, double* prop) :
ConvexHull1D::ConvexHull1D(const std::vector<int>& sizes, const double* prop) :
_sorted_value(std::accumulate(sizes.begin(), sizes.end(), 0), 0.0),
_cls_max(),
_cls_min(),
......@@ -24,7 +24,7 @@ ConvexHull1D::ConvexHull1D(const std::vector<int>& sizes, double* prop) :
initialize_prop(sizes, prop);
}
void ConvexHull1D::initialize_prop(const std::vector<int>& sizes, double* prop)
void ConvexHull1D::initialize_prop(const std::vector<int>& sizes, const double* prop)
{
_n_task = sizes.size();
......@@ -42,7 +42,7 @@ void ConvexHull1D::initialize_prop(const std::vector<int>& sizes, double* prop)
for(int tt = 0; tt < sizes.size(); ++tt)
{
int start_original = start;
util_funcs::argsort(_sorted_prop_inds.data() + start, _sorted_prop_inds.data() + start + sizes[tt], prop + start);
util_funcs::argsort<double>(_sorted_prop_inds.data() + start, _sorted_prop_inds.data() + start + sizes[tt], prop + start);
for(int pp = start + 1; pp < start_original + sizes[tt]; ++pp)
{
if(prop[_sorted_prop_inds[pp]] != prop[_sorted_prop_inds[pp - 1]])
......@@ -146,5 +146,5 @@ double ConvexHull1D::overlap_1d(double* value, double width)
}
}
}
return util_funcs::mean(_task_scores);
return util_funcs::mean<double>(_task_scores);
}
......@@ -36,7 +36,7 @@ public:
* @param sizes The size of the tasks
* @param prop The pointer to the property vector
*/
ConvexHull1D(const std::vector<int>& sizes, double* prop);
ConvexHull1D(const std::vector<int>& sizes, const double* prop);
/**
* @brief Initialize the projection objects
......@@ -49,14 +49,7 @@ public:
* @param sizes The size of the tasks
* @param prop The pointer to the property vector
*/
void initialize_prop(const std::vector<int>& sizes, double* prop);
/**
* @brief Change the property vectors
*
* @param prop The new property
*/
void reset_prop(double* prop);
void initialize_prop(const std::vector<int>& sizes, const double* prop);
/**
* @brief Calculate the projection scores of a set of features to a vector via Pearson correlation
......
......@@ -202,7 +202,7 @@ public:
* @brief The unit of the property
* @return The unit of the property
*/
inline Unit prop_unit(){return _prop_unit;}
inline Unit prop_unit() const {return _prop_unit;}
// DocString: model_prop_label
/**
......
......@@ -422,11 +422,11 @@ void ModelClassifier::set_train_test_error()
// Set up sorted data for LP claculations
std::vector<int> inds_train(_task_sizes_train[tt], 0);
std::iota(inds_train.begin(), inds_train.end(), task_start_train);
util_funcs::argsort(inds_train.data(), inds_train.data() + inds_train.size(), &_prop_train[task_start_train]);
util_funcs::argsort<double>(inds_train.data(), inds_train.data() + inds_train.size(), &_prop_train[task_start_train]);
std::vector<int> inds_test(_task_sizes_test[tt], 0);
std::iota(inds_test.begin(), inds_test.end(), task_start_test);
util_funcs::argsort(inds_test.data(), inds_test.data() + inds_test.size(), &_prop_test[task_start_test]);
util_funcs::argsort<double>(inds_test.data(), inds_test.data() + inds_test.size(), &_prop_test[task_start_test]);
std::vector<std::vector<int>> inds_class_train(1, {inds_train[0]});
......
......@@ -562,12 +562,12 @@ double ModelRegressor::mape()
{
std::vector<double> percent_error(_train_error.size(), 0.0);
std::transform(_train_error.begin(), _train_error.end(), _prop_train.begin(), percent_error.begin(), [](double e, double p){return std::abs(e / p);});
return util_funcs::mean(percent_error);
return util_funcs::mean<double>(percent_error);
}
double ModelRegressor::test_mape()
{
std::vector<double> percent_error(_test_error.size(), 0.0);
std::transform(_test_error.begin(), _test_error.end(), _prop_test.begin(), percent_error.begin(), [](double e, double p){return std::abs(e / p);});
return util_funcs::mean(percent_error);
return util_funcs::mean<double>(percent_error);
}
......@@ -36,7 +36,7 @@ void SISSOClassifier::check_prop_test(std::vector<double> prop, std::vector<doub
void SISSOClassifier::setup_prop(std::vector<double> prop, std::vector<double> prop_test)
{
std::vector<int> inds = util_funcs::argsort(prop);
std::vector<int> inds = util_funcs::argsort<double>(prop);
std::map<double, double> class_map;
double class_num = 0;
prop[inds[0]] = 0;
......@@ -82,7 +82,7 @@ std::vector<LPWrapper> SISSOClassifier::setup_lp(int n_dim)
std::vector<int> inds(_task_sizes_train[tt]);
std::iota(inds.begin(), inds.end(), task_start);
util_funcs::argsort(inds.data(), inds.data() + inds.size(), &_prop[task_start]);
util_funcs::argsort<double>(inds.data(), inds.data() + inds.size(), &_prop[task_start]);
_sample_inds_to_sorted_dmat_inds[inds[0]] = task_start;
int cls_start = 0;
......@@ -317,7 +317,7 @@ void SISSOClassifier::l0_norm(std::vector<double>& prop, int n_dim)
[&max_dist](double margin, double score){return score + (1.0 - margin / max_dist);}
);
inds = util_funcs::argsort(scores);
inds = util_funcs::argsort<double>(scores);
std::vector<model_node_ptr> min_nodes(n_dim);
std::vector<ModelClassifier> models;
......
......@@ -166,7 +166,7 @@ void SISSOLogRegressor::l0_norm(std::vector<double>& prop, int n_dim)
mpi::all_gather(*_mpi_comm, min_errors.data(), n_get_models, all_min_error);
mpi::all_gather(*_mpi_comm, min_inds.data(), n_get_models * n_dim, all_min_inds);
inds = util_funcs::argsort(all_min_error);
inds = util_funcs::argsort<double>(all_min_error);
for(int rr = 0; rr < n_get_models; ++rr)
{
std::vector<int> indexes(n_dim);
......
......@@ -224,7 +224,7 @@ void SISSORegressor::l0_norm(std::vector<double>& prop, int n_dim)
mpi::all_gather(*_mpi_comm, min_errors.data(), n_get_models, all_min_error);
mpi::all_gather(*_mpi_comm, min_inds.data(), n_get_models * n_dim, all_min_inds);
inds = util_funcs::argsort(all_min_error);
inds = util_funcs::argsort<double>(all_min_error);
for(int rr = 0; rr < n_get_models; ++rr)
{
std::vector<int> indexes(n_dim);
......
......@@ -390,7 +390,7 @@ void FeatureSpace::generate_feature_space()
_mpi_comm->barrier();
project_funcs::project_r(_prop.data(), _scores.data(), _phi, _task_sizes, 1);
_scores.erase(_scores.begin(), _scores.begin() + _start_gen[_start_gen.size() - 1]);
inds = util_funcs::argsort(_scores);
inds = util_funcs::argsort<double>(_scores);
std::vector<int> del_inds;
......@@ -457,7 +457,7 @@ void FeatureSpace::generate_feature_space()
}
}
inds = util_funcs::argsort(del_inds);
inds = util_funcs::argsort<int>(del_inds);
for(int ii = 0; ii < inds.size(); ++ii)
{
_phi.erase(_phi.begin() - del_inds[inds[ii]]);
......@@ -689,7 +689,7 @@ void FeatureSpace::project_generated(double* prop, int size, std::vector<node_pt
std::vector<double> scores(generated_phi.size());
_project_no_omp(prop, scores.data(), generated_phi, _task_sizes, size / _n_samp);
std::vector<int> inds = util_funcs::argsort(scores);
std::vector<int> inds = util_funcs::argsort<double>(scores);
int ii = 0;
while((ii < inds.size()) && (scores[inds[ii]] < -1.0))
......@@ -809,7 +809,7 @@ void FeatureSpace::sis(std::vector<double>& prop)
}
// Sort the scores to get inds
std::vector<int> inds = util_funcs::argsort(_scores);
std::vector<int> inds = util_funcs::argsort<double>(_scores);
int ii = 0;
int cur_feat_local = 0;
double cur_score = 0.0;
......@@ -949,7 +949,7 @@ void FeatureSpace::sis(std::vector<double>& prop)
cur_feat_local = 0;
// Move selected features into _phi_selected and add the features to the output files
inds = util_funcs::argsort(scores_sel);
inds = util_funcs::argsort<double>(scores_sel);
for(auto& ind : inds)
{
node_value_arrs::clear_temp_reg();
......
......@@ -65,10 +65,10 @@ class FeatureSpace
const std::string _feature_space_file; //!< File to store information about the selected features
const std::string _feature_space_summary_file; //!< File to store information about the selected features
std::function<void(double*, double*, std::vector<node_ptr>&, const std::vector<int>&, int)> _project; //!< Function used to calculate the scores for SIS
std::function<void(double*, double*, std::vector<node_ptr>&, const std::vector<int>&, int)> _project_no_omp; //!< Function used to calculate the scores for SIS without changing omp environment
std::function<bool(double*, int, double, std::vector<double>&, double, int, int)> _is_valid; //!< Function used to calculate the scores for SIS
std::function<bool(double*, int, double, std::vector<node_ptr>&, std::vector<double>&, double)> _is_valid_feat_list; //!< Function used to calculate the scores for SIS without changing omp environment
std::function<void(const double*, double*, const std::vector<node_ptr>&, const std::vector<int>&, const int)> _project; //!< Function used to calculate the scores for SIS
std::function<void(const double*, double*, const std::vector<node_ptr>&, const std::vector<int>&, const int)> _project_no_omp; //!< Function used to calculate the scores for SIS without changing omp environment
std::function<bool(const double*, const int, const double, const std::vector<double>&, const double, const int, const int)> _is_valid; //!< Function used to calculate the scores for SIS
std::function<bool(const double*, const int, const double, const std::vector<node_ptr>&, const std::vector<double>&, const double)> _is_valid_feat_list; //!< Function used to calculate the scores for SIS without changing omp environment
std::shared_ptr<MPI_Interface> _mpi_comm; //!< MPI communicator
......
......@@ -3,7 +3,7 @@
FeatureNode::FeatureNode()
{}
FeatureNode::FeatureNode(unsigned long int feat_ind, std::string expr, std::vector<double> value, std::vector<double> test_value, Unit unit, bool set_val) :
FeatureNode::FeatureNode(const unsigned long int feat_ind, const std::string expr, const std::vector<double> value, const std::vector<double> test_value, const Unit unit, const bool set_val) :
Node(feat_ind, value.size(), test_value.size()),
_value(value),
_test_value(test_value),
......@@ -21,7 +21,7 @@ FeatureNode::FeatureNode(unsigned long int feat_ind, std::string expr, std::vect
FeatureNode::~FeatureNode()
{}
bool FeatureNode::is_const()
bool FeatureNode::is_const() const
{
bool is_c = false;
int pos = 0;
......@@ -29,14 +29,14 @@ bool FeatureNode::is_const()
double* val_ptr = value_ptr();
for(auto& sz : node_value_arrs::TASK_SZ_TRAIN)
{
double mean = util_funcs::mean(val_ptr + pos, sz);
double mean = util_funcs::mean<double>(val_ptr + pos, sz);
is_c = is_c || std::all_of(val_ptr + pos, val_ptr + pos + sz, [&mean](double d){return std::abs(d - mean) < 1e-12;});
pos += sz;
}
return is_c;
}
void FeatureNode::update_add_sub_leaves(std::map<std::string, int>& add_sub_leaves, int pl_mn, int& expected_abs_tot)
void FeatureNode::update_add_sub_leaves(std::map<std::string, int>& add_sub_leaves, const int pl_mn, int& expected_abs_tot) const
{
if(add_sub_leaves.count(_expr) > 0)
{
......@@ -50,7 +50,7 @@ void FeatureNode::update_add_sub_leaves(std::map<std::string, int>& add_sub_leav
++expected_abs_tot;
}
void FeatureNode::update_div_mult_leaves(std::map<std::string, double>& div_mult_leaves, double fact, double& expected_abs_tot)
void FeatureNode::update_div_mult_leaves(std::map<std::string, double>& div_mult_leaves, const double fact, double& expected_abs_tot) const
{
if(div_mult_leaves.count(_expr) > 0)
{
......@@ -64,14 +64,14 @@ void FeatureNode::update_div_mult_leaves(std::map<std::string, double>& div_mult
expected_abs_tot += std::abs(fact);
}
std::map<int, int> FeatureNode::primary_feature_decomp()
std::map<int, int> FeatureNode::primary_feature_decomp() const
{
std::map<int, int> pf_decomp;
pf_decomp[_arr_ind] = 1;
return pf_decomp;
}
void FeatureNode::update_primary_feature_decomp(std::map<int, int>& pf_decomp)
void FeatureNode::update_primary_feature_decomp(std::map<int, int>& pf_decomp) const
{
if(pf_decomp.count(_arr_ind) > 0)
{
......
......@@ -71,7 +71,14 @@ public:
* @param unit Unit of the feature
* @param set_val if true set the value inside the VALUES_ARR object
*/
FeatureNode(unsigned long int feat_ind, std::string expr, std::vector<double> value, std::vector<double> test_value, Unit unit, bool set_val = true);
FeatureNode(
const unsigned long int feat_ind,
const std::string expr,
const std::vector<double> value,
const std::vector<double> test_value,
const Unit unit,
const bool set_val=true
);
#ifdef PY_BINDINGS
/**
* @brief Constructs a feature node using numpy arrays (cpp definition in <python/feature_creation/FeatureNode.cpp)
......@@ -132,7 +139,7 @@ public:
* @brief Get the list of feature expressions
* @return vector storing the expressions for all primary features that show up in feature in the order they appear in the postfix notation
*/
virtual inline std::vector<std::string> get_x_in_expr_list(){return std::vector<std::string>(1, _expr);}
virtual inline std::vector<std::string> get_x_in_expr_list() const {return std::vector<std::string>(1, _expr);}
/**
* @brief return the number of leaves in the feature
......@@ -140,13 +147,7 @@ public:
* @param cur_n_leaves The current number of primary features that are inside the feature
* @return total number of leaves of the binary expression tree
*/
virtual inline int n_leaves(int cur_n_leaves = 0){return cur_n_leaves + 1;}
// DocString: feat_node_expr_1
/**
* @brief Get the string expression used to represent the primary feature
*/
inline std::string expr(){return _expr;}
virtual inline int n_leaves(int cur_n_leaves = 0) const {return cur_n_leaves + 1;}
// DocString: feat_node_expr_const
/**
......@@ -158,23 +159,23 @@ public:
/**
* @brief Get the latexified expression for the overall feature (From root node down)
*/
inline std::string get_latex_expr(){return str_utils::latexify(_expr);}
inline std::string get_latex_expr() const {return str_utils::latexify(_expr);}
// DocString: feat_node_unit
/**
* @brief The unit of the primary feature
*/
inline Unit unit(){return _unit;}
inline Unit unit() const {return _unit;}
/**
* @brief Get the training data of the feature
*/
inline std::vector<double> value(){return _value;}
inline std::vector<double> value() const {return _value;}
/**
* @brief Get the test data for the feature
*/
inline std::vector<double> test_value(){return _test_value;}
inline std::vector<double> test_value() const {return _test_value;}
// DocString: feat_node_set_value
/**
......@@ -183,7 +184,7 @@ public:
* @param offset(int) Key to determine which part of the temporary storage array to look into
* @param for_comp(bool) If true then the evaluation is for comparing features
*/
inline void set_value(int offset=-1, bool for_comp=false)
inline void set_value(int offset=-1, const bool for_comp=false) const
{
std::copy_n(_value.data(), _n_samp, value_ptr());
}
......@@ -195,16 +196,19 @@ public:
* @param offset(int) Key to determine which part of the temporary storage array to look into
* @param for_comp(bool) If true then the evaluation is for comparing features
*/
inline void set_test_value(int offset=-1, bool for_comp=false)
inline void set_test_value(int offset=-1, const bool for_comp=false) const
{
if(!_selected) std::copy_n(_test_value.data(), _n_test_samp, test_value_ptr());
if(!_selected)
{
std::copy_n(_test_value.data(), _n_test_samp, test_value_ptr());
}
}
// DocString: feat_node_is_nan
/**
* @brief Check if the feature contains NaN
*/
inline bool is_nan()
inline bool is_nan() const
{
return std::any_of(value_ptr(), value_ptr() + _n_samp, [](double d){return !std::isfinite(d);});
}
......@@ -213,12 +217,12 @@ public:
/**
* @brief Check if feature is constant
*/
bool is_const();
bool is_const() const;
/**
* @brief Returns the type of node this is
*/
inline NODE_TYPE type(){return NODE_TYPE::FEAT;}
inline NODE_TYPE type() const {return NODE_TYPE::FEAT;}
/**
* @brief The pointer to where the feature's training data is stored
......@@ -226,7 +230,7 @@ public:
* @param offset(int) Key to determine which part of the temporary storage array to look into
* @param for_comp(bool) If true then the evaluation is for comparing features
*/
inline double* value_ptr(int offset=-1, bool for_comp=false)
virtual inline double* value_ptr(int offset=-1, const bool for_comp=false) const
{
return _selected ? node_value_arrs::get_d_matrix_ptr(_d_mat_ind) : node_value_arrs::get_value_ptr(_arr_ind, _feat_ind, 0, offset, for_comp);
}
......@@ -237,7 +241,7 @@ public:
* @param offset(int) Key to determine which part of the temporary storage array to look into
* @param for_comp(bool) If true then the evaluation is for comparing features
*/
inline double* test_value_ptr(int offset=-1, bool for_comp=false)
virtual inline double* test_value_ptr(int offset=-1, const bool for_comp=false) const
{
return node_value_arrs::get_test_value_ptr(_arr_ind, _feat_ind, 0, offset, for_comp);
}
......@@ -248,20 +252,20 @@ public:
*
* @param cur_rung The rung current rung of the feature tree (used to recursively calculate rung)
*/
inline int rung(int cur_rung = 0){return cur_rung;}
inline int rung(int cur_rung = 0) const {return cur_rung;}
/**
* @brief Get the primary feature decomposition of a feature
* @return A map representing the primary feature comprising a feature
*/
std::map<int, int> primary_feature_decomp();
std::map<int, int> primary_feature_decomp() const;
/**
* @brief Update the primary feature decomposition of a feature
*
* @param pf_decomp The primary feature decomposition of the feature calling this function.
*/
void update_primary_feature_decomp(std::map<int, int>& pf_decomp);
void update_primary_feature_decomp(std::map<int, int>& pf_decomp) const;
/**
* @brief Converts a feature into a postfix expression (reverse polish notation)
......@@ -272,7 +276,7 @@ public:
* @param add_params If true add the parameters
* @return The current postfix expression of the feature
*/
inline void update_postfix(std::string& cur_expr, bool add_params=true)
inline void update_postfix(std::string& cur_expr, const bool add_params=true) const
{
cur_expr = get_postfix_term() + "|" + cur_expr;
}
......@@ -281,14 +285,14 @@ public:
* @brief Get the three character representation of the operator
* @return the three character representation of the operator
*/
inline std::string get_postfix_term(){return std::to_string(_feat_ind);}
inline std::string get_postfix_term() const {return std::to_string(_feat_ind);}
//DocString: feat_node_nfeats
/**
* @brief Number of features used for an operator node
* @return the number of features for an operator node
*/
inline int n_feats(){return 0;}
inline int n_feats() const {return 0;}
//DocString: feat_node_feat
/**
......@@ -297,7 +301,7 @@ public:
* @param ind the index of the node to access
* @return the ind feature in feature_list
*/
inline node_ptr feat(int ind)
inline node_ptr feat(const int ind) const
{
if(ind > 0)
{
......@@ -313,7 +317,7 @@ public:
* @param pl_mn if for an addition node: 1 if for a subtraction node: -1
* @param expected_abs_tot The expected absolute sum of all values in add_sub_leaves
*/
void update_add_sub_leaves(std::map<std::string, int>& add_sub_leaves, int pl_mn, int& expected_abs_tot);
void update_add_sub_leaves(std::map<std::string, int>& add_sub_leaves, const int pl_mn, int& expected_abs_tot) const;
/**
* @brief update the dictionary used to check if a mult/div node is valid
......@@ -323,20 +327,20 @@ public:
* @param expected_abs_tot The expected absolute sum of all values in div_mult_leaves
*
*/
void update_div_mult_leaves(std::map<std::string, double>& div_mult_leaves, double fact, double& expected_abs_tot);
void update_div_mult_leaves(std::map<std::string, double>& div_mult_leaves, const double fact, double& expected_abs_tot) const;
#ifdef PARAMETERIZE
/**
* @brief The parameters used for introducing more non linearity in the operators
*/
inline std::vector<double> parameters(){return std::vector<double>();};
inline std::vector<double> parameters() const {return std::vector<double>();};
/**
* @brief Set the non-linear parameters
* @param params The new parameters of the node
* @param check_sz If true check the size of the parameters
*/
inline void set_parameters(std::vector<double> params, bool check_sz=true){};
inline void set_parameters(const std::vector<double> params, const bool check_sz=true){};
/**
* @brief returns the number of parameters for this feature
......@@ -345,7 +349,7 @@ public:
* @param depth the current depth of the node on the Binary expression tree
* @return the number of parameters (_params.size())
*/
inline int n_params(int n_cur=0, int depth = 1){return n_cur;};
inline int n_params(int n_cur=0, int depth = 1) const {return n_cur;};
/**
* @brief Set the values of the training data for the feature inside of the value storage arrays
......@@ -355,7 +359,7 @@ public:
* @param for_comp(bool) If true then the evaluation is for comparing features
* @param depth the current depth of the node on the Binary expression tree
*/
inline void set_value(const double* params, int offset=-1, bool for_comp=false, int depth=0){set_value(offset);};
inline void set_value(const double* params, int offset=-1, const bool for_comp=false, const int depth=0) const {set_value(offset);};
/**
* @brief The pointer to where the feature's training data is stored
......@@ -366,7 +370,7 @@ public:
* @param depth the current depth of the node on the Binary expression tree
* @returns the pointer to the feature's data
*/
inline double* value_ptr(const double* params, int offset=-1, bool for_comp=false, int depth=0){return value_ptr(offset);};
inline double* value_ptr(const double* params, int offset=-1, const bool for_comp=false, const int depth=0) const {return value_ptr(offset);};
/**
* @brief Set the values of the test data for the feature inside of the value storage arrays
......@@ -376,7 +380,7 @@ public:
* @param for_comp(bool) If true then the evaluation is for comparing features
* @param depth the current depth of the node on the Binary expression tree
*/
inline void set_test_value(const double* params, int offset=-1, bool for_comp=false, int depth=0){set_test_value(offset);};
inline void set_test_value(const double* params, int offset=-1, const bool for_comp=false, const int depth=0) const {set_test_value(offset);};
/**
* @brief The pointer to where the feature's test data is stored
......@@ -387,7 +391,7 @@ public:
* @param depth the current depth of the node on the Binary expression tree
* @returns the pointer to the feature's data
*/
inline double* test_value_ptr(const double* params, int offset=-1, bool for_comp=false, int depth=0){return test_value_ptr(offset);};
inline double* test_value_ptr(const double* params, int offset=-1, const bool for_comp=false, const int depth=0) const {return test_value_ptr(offset);};
/**
* @brief The expression of the feature
......@@ -396,7 +400,7 @@ public:
* @param depth the current depth of the node on the Binary expression tree
* @return feature expression
*/
inline std::string expr(double* params, int depth = 1){return _expr;};
inline std::string expr(const double* params, const int depth = 1) const {return _expr;};
/**
* @brief Get the latexified expression for the overall feature (From root node down)
......@@ -405,7 +409,7 @@ public:
* @param depth the current depth of the node on the Binary expression tree
* @return the latexified expression
*/
inline std::string get_latex_expr(double* params, int depth=1){return str_utils::latexify(_expr);}
inline std::string get_latex_expr(const double* params, const int depth=1) const {return str_utils::latexify(_expr);}
/**
* @brief Set the bounds for the nl parameterization
......@@ -415,7 +419,7 @@ public:
* @param from_parent How many parameters are between the start of this node's parameters and its parent
* @param depth the current depth of the node on the Binary expression tree
*/
inline void set_bounds(double* lb, double* ub, int from_parent=2, int depth = 1){};
inline void set_bounds(double* lb, double* ub, const int from_parent=2, const int depth = 1) const {};
/**
* @brief Calculates the derivative of an operation with respect to the parameters for a given sample
......@@ -423,7 +427,7 @@ public:
* @param params pointer to the parameters
* @param dfdp pointer to where the feature derivative pointers are located
*/
void param_derivative(const double* params, double* dfdp){}
void param_derivative(const double* params, double* dfdp) const {}
/**
* @brief Get the parameter gradient for non-linear optimization
......@@ -431,7 +435,7 @@ public:
* @param grad pointer to the gradient storage
* @param dfdp pointer to where the feature derivative pointers are located
*/
virtual void gradient(double* grad, double* dfdp)
virtual void gradient(double* grad, double* dfdp) const
{
throw std::logic_error("Asking for the gradient of non-parameterized feature");
}
......@@ -443,7 +447,7 @@ public:
* @param dfdp pointer to where the feature derivative pointers are located
* @param params pointer to the parameters vector
*/
inline void gradient(double* grad, double* dfdp, const double* params){};
inline void gradient(double* grad, double* dfdp, const double* params) const {};
#endif
};
......
......@@ -4,15 +4,15 @@ ModelNode::ModelNode()
{}
ModelNode::ModelNode(
unsigned long int feat_ind,