Commit 265dc3c6 authored by Thomas Purcell's avatar Thomas Purcell
Browse files

Bug Fix

Ensure MAX_RUNG is set when loading from a file
parent ab138f72
Pipeline #109857 passed with stages
in 60 minutes and 38 seconds
......@@ -74,16 +74,16 @@ node_ptr str2node::postfix2node(const std::string postfix_expr, const std::vecto
if(op_terms[0] == "add")
{
#ifndef PARAMETERIZE
stack[stack.size() - 2] = std::make_shared<AddNode>(stack[stack.size() - 2], stack[stack.size() - 1], feat_ind, 1e-50, 1e50);
stack[stack.size() - 2] = std::make_shared<AddNode>(stack[stack.size() - 2], stack[stack.size() - 1], feat_ind);
#else
if(op_terms.size() > 1)
{
stack[stack.size() - 2] = std::make_shared<AddParamNode>(stack[stack.size() - 2], stack[stack.size() - 1], feat_ind, 1e-50, 1e50);
stack[stack.size() - 2] = std::make_shared<AddParamNode>(stack[stack.size() - 2], stack[stack.size() - 1], feat_ind);
set_parameters(stack[stack.size() - 2], op_terms);
}
else
{
stack[stack.size() - 2] = std::make_shared<AddNode>(stack[stack.size() - 2], stack[stack.size() - 1], feat_ind, 1e-50, 1e50);
stack[stack.size() - 2] = std::make_shared<AddNode>(stack[stack.size() - 2], stack[stack.size() - 1], feat_ind);
}
#endif
stack.pop_back();
......@@ -91,16 +91,16 @@ node_ptr str2node::postfix2node(const std::string postfix_expr, const std::vecto
else if(op_terms[0] == "sub")
{
#ifndef PARAMETERIZE
stack[stack.size() - 2] = std::make_shared<SubNode>(stack[stack.size() - 2], stack[stack.size() - 1], feat_ind, 1e-50, 1e50);
stack[stack.size() - 2] = std::make_shared<SubNode>(stack[stack.size() - 2], stack[stack.size() - 1], feat_ind);
#else
if(op_terms.size() > 1)
{
stack[stack.size() - 2] = std::make_shared<SubParamNode>(stack[stack.size() - 2], stack[stack.size() - 1], feat_ind, 1e-50, 1e50);
stack[stack.size() - 2] = std::make_shared<SubParamNode>(stack[stack.size() - 2], stack[stack.size() - 1], feat_ind);
set_parameters(stack[stack.size() - 2], op_terms);
}
else
{
stack[stack.size() - 2] = std::make_shared<SubNode>(stack[stack.size() - 2], stack[stack.size() - 1], feat_ind, 1e-50, 1e50);
stack[stack.size() - 2] = std::make_shared<SubNode>(stack[stack.size() - 2], stack[stack.size() - 1], feat_ind);
}
#endif
stack.pop_back();
......@@ -108,16 +108,16 @@ node_ptr str2node::postfix2node(const std::string postfix_expr, const std::vecto
else if(op_terms[0] == "abd")
{
#ifndef PARAMETERIZE
stack[stack.size() - 2] = std::make_shared<AbsDiffNode>(stack[stack.size() - 2], stack[stack.size() - 1], feat_ind, 1e-50, 1e50);
stack[stack.size() - 2] = std::make_shared<AbsDiffNode>(stack[stack.size() - 2], stack[stack.size() - 1], feat_ind);
#else
if(op_terms.size() > 1)
{
stack[stack.size() - 2] = std::make_shared<AbsDiffParamNode>(stack[stack.size() - 2], stack[stack.size() - 1], feat_ind, 1e-50, 1e50);
stack[stack.size() - 2] = std::make_shared<AbsDiffParamNode>(stack[stack.size() - 2], stack[stack.size() - 1], feat_ind);
set_parameters(stack[stack.size() - 2], op_terms);
}
else
{
stack[stack.size() - 2] = std::make_shared<AbsDiffNode>(stack[stack.size() - 2], stack[stack.size() - 1], feat_ind, 1e-50, 1e50);
stack[stack.size() - 2] = std::make_shared<AbsDiffNode>(stack[stack.size() - 2], stack[stack.size() - 1], feat_ind);
}
#endif
stack.pop_back();
......@@ -125,16 +125,16 @@ node_ptr str2node::postfix2node(const std::string postfix_expr, const std::vecto
else if(op_terms[0] == "mult")
{
#ifndef PARAMETERIZE
stack[stack.size() - 2] = std::make_shared<MultNode>(stack[stack.size() - 2], stack[stack.size() - 1], feat_ind, 1e-50, 1e50);
stack[stack.size() - 2] = std::make_shared<MultNode>(stack[stack.size() - 2], stack[stack.size() - 1], feat_ind);
#else
if(op_terms.size() > 1)
{
stack[stack.size() - 2] = std::make_shared<MultParamNode>(stack[stack.size() - 2], stack[stack.size() - 1], feat_ind, 1e-50, 1e50);
stack[stack.size() - 2] = std::make_shared<MultParamNode>(stack[stack.size() - 2], stack[stack.size() - 1], feat_ind);
set_parameters(stack[stack.size() - 2], op_terms);
}
else
{
stack[stack.size() - 2] = std::make_shared<MultNode>(stack[stack.size() - 2], stack[stack.size() - 1], feat_ind, 1e-50, 1e50);
stack[stack.size() - 2] = std::make_shared<MultNode>(stack[stack.size() - 2], stack[stack.size() - 1], feat_ind);
}
#endif
stack.pop_back();
......@@ -142,16 +142,16 @@ node_ptr str2node::postfix2node(const std::string postfix_expr, const std::vecto
else if(op_terms[0] == "div")
{
#ifndef PARAMETERIZE
stack[stack.size() - 2] = std::make_shared<DivNode>(stack[stack.size() - 2], stack[stack.size() - 1], feat_ind, 1e-50, 1e50);
stack[stack.size() - 2] = std::make_shared<DivNode>(stack[stack.size() - 2], stack[stack.size() - 1], feat_ind);
#else
if(op_terms.size() > 1)
{
stack[stack.size() - 2] = std::make_shared<DivParamNode>(stack[stack.size() - 2], stack[stack.size() - 1], feat_ind, 1e-50, 1e50);
stack[stack.size() - 2] = std::make_shared<DivParamNode>(stack[stack.size() - 2], stack[stack.size() - 1], feat_ind);
set_parameters(stack[stack.size() - 2], op_terms);
}
else
{
stack[stack.size() - 2] = std::make_shared<DivNode>(stack[stack.size() - 2], stack[stack.size() - 1], feat_ind, 1e-50, 1e50);
stack[stack.size() - 2] = std::make_shared<DivNode>(stack[stack.size() - 2], stack[stack.size() - 1], feat_ind);
}
#endif
stack.pop_back();
......@@ -159,193 +159,193 @@ node_ptr str2node::postfix2node(const std::string postfix_expr, const std::vecto
else if(op_terms[0] == "abs")
{
#ifndef PARAMETERIZE
stack[stack.size() - 1] = std::make_shared<AbsNode>(stack[stack.size() - 1], feat_ind, 1e-50, 1e50);
stack[stack.size() - 1] = std::make_shared<AbsNode>(stack[stack.size() - 1], feat_ind);
#else
if(op_terms.size() > 1)
{
stack[stack.size() - 1] = std::make_shared<AbsParamNode>(stack[stack.size() - 1], feat_ind, 1e-50, 1e50);
stack[stack.size() - 1] = std::make_shared<AbsParamNode>(stack[stack.size() - 1], feat_ind);
set_parameters(stack[stack.size() - 1], op_terms);
set_parameters(stack[stack.size() - 1], op_terms);
}
else
{
stack[stack.size() - 1] = std::make_shared<AbsNode>(stack[stack.size() - 1], feat_ind, 1e-50, 1e50);
stack[stack.size() - 1] = std::make_shared<AbsNode>(stack[stack.size() - 1], feat_ind);
}
#endif
}
else if(op_terms[0] == "inv")
{
#ifndef PARAMETERIZE
stack[stack.size() - 1] = std::make_shared<InvNode>(stack[stack.size() - 1], feat_ind, 1e-50, 1e50);
stack[stack.size() - 1] = std::make_shared<InvNode>(stack[stack.size() - 1], feat_ind);
#else
if(op_terms.size() > 1)
{
stack[stack.size() - 1] = std::make_shared<InvParamNode>(stack[stack.size() - 1], feat_ind, 1e-50, 1e50);
stack[stack.size() - 1] = std::make_shared<InvParamNode>(stack[stack.size() - 1], feat_ind);
set_parameters(stack[stack.size() - 1], op_terms);
}
else
{
stack[stack.size() - 1] = std::make_shared<InvNode>(stack[stack.size() - 1], feat_ind, 1e-50, 1e50);
stack[stack.size() - 1] = std::make_shared<InvNode>(stack[stack.size() - 1], feat_ind);
}
#endif
}
else if(op_terms[0] == "exp")
{
#ifndef PARAMETERIZE
stack[stack.size() - 1] = std::make_shared<ExpNode>(stack[stack.size() - 1], feat_ind, 1e-50, 1e50);
stack[stack.size() - 1] = std::make_shared<ExpNode>(stack[stack.size() - 1], feat_ind);
#else
if(op_terms.size() > 1)
{
stack[stack.size() - 1] = std::make_shared<ExpParamNode>(stack[stack.size() - 1], feat_ind, 1e-50, 1e50);
stack[stack.size() - 1] = std::make_shared<ExpParamNode>(stack[stack.size() - 1], feat_ind);
set_parameters(stack[stack.size() - 1], op_terms);
}
else
{
stack[stack.size() - 1] = std::make_shared<ExpNode>(stack[stack.size() - 1], feat_ind, 1e-50, 1e50);
stack[stack.size() - 1] = std::make_shared<ExpNode>(stack[stack.size() - 1], feat_ind);
}
#endif
}
else if(op_terms[0] == "nexp")
{
#ifndef PARAMETERIZE
stack[stack.size() - 1] = std::make_shared<NegExpNode>(stack[stack.size() - 1], feat_ind, 1e-50, 1e50);
stack[stack.size() - 1] = std::make_shared<NegExpNode>(stack[stack.size() - 1], feat_ind);
#else
if(op_terms.size() > 1)
{
stack[stack.size() - 1] = std::make_shared<NegExpParamNode>(stack[stack.size() - 1], feat_ind, 1e-50, 1e50);
stack[stack.size() - 1] = std::make_shared<NegExpParamNode>(stack[stack.size() - 1], feat_ind);
set_parameters(stack[stack.size() - 1], op_terms);
}
else
{
stack[stack.size() - 1] = std::make_shared<NegExpNode>(stack[stack.size() - 1], feat_ind, 1e-50, 1e50);
stack[stack.size() - 1] = std::make_shared<NegExpNode>(stack[stack.size() - 1], feat_ind);
}
#endif
}
else if(op_terms[0] == "log")
{
#ifndef PARAMETERIZE
stack[stack.size() - 1] = std::make_shared<LogNode>(stack[stack.size() - 1], feat_ind, 1e-50, 1e50);
stack[stack.size() - 1] = std::make_shared<LogNode>(stack[stack.size() - 1], feat_ind);
#else
if(op_terms.size() > 1)
{
stack[stack.size() - 1] = std::make_shared<LogParamNode>(stack[stack.size() - 1], feat_ind, 1e-50, 1e50);
stack[stack.size() - 1] = std::make_shared<LogParamNode>(stack[stack.size() - 1], feat_ind);
set_parameters(stack[stack.size() - 1], op_terms);
}
else
{
stack[stack.size() - 1] = std::make_shared<LogNode>(stack[stack.size() - 1], feat_ind, 1e-50, 1e50);
stack[stack.size() - 1] = std::make_shared<LogNode>(stack[stack.size() - 1], feat_ind);
}
#endif
}
else if(op_terms[0] == "sin")
{
#ifndef PARAMETERIZE
stack[stack.size() - 1] = std::make_shared<SinNode>(stack[stack.size() - 1], feat_ind, 1e-50, 1e50);
stack[stack.size() - 1] = std::make_shared<SinNode>(stack[stack.size() - 1], feat_ind);
#else
if(op_terms.size() > 1)
{
stack[stack.size() - 1] = std::make_shared<SinParamNode>(stack[stack.size() - 1], feat_ind, 1e-50, 1e50);
stack[stack.size() - 1] = std::make_shared<SinParamNode>(stack[stack.size() - 1], feat_ind);
set_parameters(stack[stack.size() - 1], op_terms);
}
else
{
stack[stack.size() - 1] = std::make_shared<SinNode>(stack[stack.size() - 1], feat_ind, 1e-50, 1e50);
stack[stack.size() - 1] = std::make_shared<SinNode>(stack[stack.size() - 1], feat_ind);
}
#endif
}
else if(op_terms[0] == "cos")
{
#ifndef PARAMETERIZE
stack[stack.size() - 1] = std::make_shared<CosNode>(stack[stack.size() - 1], feat_ind, 1e-50, 1e50);
stack[stack.size() - 1] = std::make_shared<CosNode>(stack[stack.size() - 1], feat_ind);
#else
if(op_terms.size() > 1)
{
stack[stack.size() - 1] = std::make_shared<CosParamNode>(stack[stack.size() - 1], feat_ind, 1e-50, 1e50);
stack[stack.size() - 1] = std::make_shared<CosParamNode>(stack[stack.size() - 1], feat_ind);
set_parameters(stack[stack.size() - 1], op_terms);
}
else
{
stack[stack.size() - 1] = std::make_shared<CosNode>(stack[stack.size() - 1], feat_ind, 1e-50, 1e50);
stack[stack.size() - 1] = std::make_shared<CosNode>(stack[stack.size() - 1], feat_ind);
}
#endif
}
else if(op_terms[0] == "sq")
{
#ifndef PARAMETERIZE
stack[stack.size() - 1] = std::make_shared<SqNode>(stack[stack.size() - 1], feat_ind, 1e-50, 1e50);
stack[stack.size() - 1] = std::make_shared<SqNode>(stack[stack.size() - 1], feat_ind);
#else
if(op_terms.size() > 1)
{
stack[stack.size() - 1] = std::make_shared<SqParamNode>(stack[stack.size() - 1], feat_ind, 1e-50, 1e50);
stack[stack.size() - 1] = std::make_shared<SqParamNode>(stack[stack.size() - 1], feat_ind);
set_parameters(stack[stack.size() - 1], op_terms);
}
else
{
stack[stack.size() - 1] = std::make_shared<SqNode>(stack[stack.size() - 1], feat_ind, 1e-50, 1e50);
stack[stack.size() - 1] = std::make_shared<SqNode>(stack[stack.size() - 1], feat_ind);
}
#endif
}
else if(op_terms[0] == "sqrt")
{
#ifndef PARAMETERIZE
stack[stack.size() - 1] = std::make_shared<SqrtNode>(stack[stack.size() - 1], feat_ind, 1e-50, 1e50);
stack[stack.size() - 1] = std::make_shared<SqrtNode>(stack[stack.size() - 1], feat_ind);
#else
if(op_terms.size() > 1)
{
stack[stack.size() - 1] = std::make_shared<SqrtParamNode>(stack[stack.size() - 1], feat_ind, 1e-50, 1e50);
stack[stack.size() - 1] = std::make_shared<SqrtParamNode>(stack[stack.size() - 1], feat_ind);
set_parameters(stack[stack.size() - 1], op_terms);
}
else
{
stack[stack.size() - 1] = std::make_shared<SqrtNode>(stack[stack.size() - 1], feat_ind, 1e-50, 1e50);
stack[stack.size() - 1] = std::make_shared<SqrtNode>(stack[stack.size() - 1], feat_ind);
}
#endif
}
else if(op_terms[0] == "cb")
{
#ifndef PARAMETERIZE
stack[stack.size() - 1] = std::make_shared<CbNode>(stack[stack.size() - 1], feat_ind, 1e-50, 1e50);
stack[stack.size() - 1] = std::make_shared<CbNode>(stack[stack.size() - 1], feat_ind);
#else
if(op_terms.size() > 1)
{
stack[stack.size() - 1] = std::make_shared<CbParamNode>(stack[stack.size() - 1], feat_ind, 1e-50, 1e50);
stack[stack.size() - 1] = std::make_shared<CbParamNode>(stack[stack.size() - 1], feat_ind);
set_parameters(stack[stack.size() - 1], op_terms);
}
else
{
stack[stack.size() - 1] = std::make_shared<CbNode>(stack[stack.size() - 1], feat_ind, 1e-50, 1e50);
stack[stack.size() - 1] = std::make_shared<CbNode>(stack[stack.size() - 1], feat_ind);
}
#endif
}
else if(op_terms[0] == "cbrt")
{
#ifndef PARAMETERIZE
stack[stack.size() - 1] = std::make_shared<CbrtNode>(stack[stack.size() - 1], feat_ind, 1e-50, 1e50);
stack[stack.size() - 1] = std::make_shared<CbrtNode>(stack[stack.size() - 1], feat_ind);
#else
if(op_terms.size() > 1)
{
stack[stack.size() - 1] = std::make_shared<CbrtParamNode>(stack[stack.size() - 1], feat_ind, 1e-50, 1e50);
stack[stack.size() - 1] = std::make_shared<CbrtParamNode>(stack[stack.size() - 1], feat_ind);
set_parameters(stack[stack.size() - 1], op_terms);
}
else
{
stack[stack.size() - 1] = std::make_shared<CbrtNode>(stack[stack.size() - 1], feat_ind, 1e-50, 1e50);
stack[stack.size() - 1] = std::make_shared<CbrtNode>(stack[stack.size() - 1], feat_ind);
}
#endif
}
else if(op_terms[0] == "sp")
{
#ifndef PARAMETERIZE
stack[stack.size() - 1] = std::make_shared<SixPowNode>(stack[stack.size() - 1], feat_ind, 1e-50, 1e50);
stack[stack.size() - 1] = std::make_shared<SixPowNode>(stack[stack.size() - 1], feat_ind);
#else
if(op_terms.size() > 1)
{
stack[stack.size() - 1] = std::make_shared<SixPowParamNode>(stack[stack.size() - 1], feat_ind, 1e-50, 1e50);
stack[stack.size() - 1] = std::make_shared<SixPowParamNode>(stack[stack.size() - 1], feat_ind);
set_parameters(stack[stack.size() - 1], op_terms);
}
else
{
stack[stack.size() - 1] = std::make_shared<SixPowNode>(stack[stack.size() - 1], feat_ind, 1e-50, 1e50);
stack[stack.size() - 1] = std::make_shared<SixPowNode>(stack[stack.size() - 1], feat_ind);
}
#endif
}
......
......@@ -110,8 +110,11 @@ FeatureSpace::FeatureSpace(
std::vector<int> rung_inds = util_funcs::argsort<int>(rungs);
_max_rung = *std::max_element(rungs.begin(), rungs.end());
node_value_arrs::MAX_RUNG = _max_rung;
#ifdef PARAMETERIZE
node_value_arrs::set_max_rung(_max_rung, _allowed_param_ops.size() > 0);
#else
node_value_arrs::set_max_rung(_max_rung, false);
#endif
_phi[0] = phi_temp[rung_inds[0]];
for(int ff = 1; ff < _n_feat; ++ff)
{
......@@ -280,7 +283,11 @@ FeatureSpace::FeatureSpace(
std::vector<int> rung_inds = util_funcs::argsort<int>(rungs);
_max_rung = *std::max_element(rungs.begin(), rungs.end());
node_value_arrs::MAX_RUNG = _max_rung;
#ifdef PARAMETERIZE
node_value_arrs::set_max_rung(_max_rung, _allowed_param_ops.size() > 0);
#else
node_value_arrs::set_max_rung(_max_rung, false);
#endif
_phi[0] = phi_temp[rung_inds[0]];
for(int ff = 1; ff < _n_feat; ++ff)
......
Markdown is supported
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