7 os <<
"nt: " << nt << endl;
22 constexpr float atol = 1e-6f;
23 const bool weight_is_one = std::fabs(
W - 1.0f) <= atol;
27 if (
is_weighted && !weight_is_one && include_weight)
28 return fmt::format(
"{:.2f}*{}",
W,
feature);
34 return fmt::format(
"{:.2f}",
W);
40 return fmt::format(
"{:.2f}",
W);
45 return fmt::format(
"{:.2f}+Add",
W);
49 else if (
is_weighted && !weight_is_one && include_weight)
51 return fmt::format(
"{:.2f}*{}",
W,
name);
63 return fmt::format(
"If({}>={:.2f},{},{})",
74 return fmt::format(
"If({},{},{})",
81 return fmt::format(
"If({}>={:.2f},{},{})",
92 args = fmt::format(
"{:.2f},",
W);
94 for (
int i = 0; i < children.size(); ++i){
95 args += children.at(i);
96 if (i < children.size()-1)
100 return fmt::format(
"Add({})", args);
104 for (
int i = 0; i < children.size(); ++i){
105 args += children.at(i);
106 if (i < children.size()-1)
110 return fmt::format(
"{}({})",
get_name(), args);
249 auto msg = fmt::format(
"Can't infer arguments for {} from json."
250 " Please provide them.\n",n);
266 char last_char = node.
feature.back();
312 if (j.contains(
"node_type"))
317 if (j.contains(
"name"))
318 j.at(
"name").get_to(p.
name);
322 if (j.contains(
"center_op"))
326 if (j.contains(
"feature"))
328 j.at(
"feature").get_to(p.
feature);
331 if (j.contains(
"feature_type"))
338 bool make_signature=
false;
340 if (j.contains(
"ret_type"))
341 j.at(
"ret_type").get_to(p.
ret_type);
344 if (j.contains(
"arg_types"))
348 if (j.contains(
"sig_hash"))
349 j.at(
"sig_hash").get_to(p.
sig_hash);
352 if (j.contains(
"sig_dual_hash"))
366 if (j.contains(
"node_is_fixed"))
371 if (j.contains(
"weight_is_fixed"))
376 if (j.contains(
"is_weighted"))
381 if (j.contains(
"prob_change"))
388 j.at(
"W").get_to(p.
W);
#define HANDLE_ERROR_THROW(err)
TimeSeries< float > TimeSeriesf
< nsga2 selection operator for getting the front
ostream & operator<<(ostream &os, DataType n)
Eigen::Array< bool, Eigen::Dynamic, 1 > ArrayXb
void from_json(const json &j, Fitness &f)
auto Is(NodeType nt) -> bool
void to_json(json &j, const Fitness &f)
void init_node_with_default_signature(Node &node)
std::map< NodeType, std::string > NodeTypeName
Eigen::Array< int, Eigen::Dynamic, 1 > ArrayXi
class holding the data for a node in a tree.
bool center_op
whether to center the operator in pretty printing
std::vector< DataType > arg_types
argument data types
DataType feature_type
feature type for terminals or splitting nodes
bool weight_is_fixed
whether the weight should be kept during variation. Notice that weight_is_fixed alows us to fix the w...
NodeType node_type
the node type
DataType get_feature_type() const
DataType ret_type
return data type
string get_feature() const
std::size_t sig_hash
a hash of the signature
float prob_change
chance of node being selected for variation. This will take into account if the node is fixed,...
string get_name(bool include_weight=true) const noexcept
gets a string version of the node for printing.
float W
the weights of the node. also used for splitting thresholds.
bool is_weighted
whether this node is weighted (ignored in nodes that must have weights, such as meanLabel,...
bool node_is_fixed
whether the node is replaceable. Weights are still optimized.
string feature
feature name for terminals or splitting nodes
string name
full name of the node, with types
std::size_t sig_dual_hash
a hash of the dual of the signature (for NLS)
string get_model(const vector< string > &) const noexcept