7 os <<
"nt: " << nt << endl;
25 return fmt::format(
"{:.2f}*{}",
W,
feature);
31 return fmt::format(
"{:.2f}",
W);
38 return fmt::format(
"{:.2f}",
W);
42 return fmt::format(
"{:.2f}+Sum",
W);
44 return fmt::format(
"Sum");
47 return fmt::format(
"{:.2f}*{}",
W,
name);
57 return fmt::format(
"If({}>={:.2f},{},{})",
68 return fmt::format(
"If({},{},{})",
75 return fmt::format(
"If({}>={:.2f},{},{})",
86 args = fmt::format(
"{:.2f},",
W);
88 for (
int i = 0; i < children.size(); ++i){
89 args += children.at(i);
90 if (i < children.size()-1)
94 return fmt::format(
"Sum({})", args);
98 for (
int i = 0; i < children.size(); ++i){
99 args += children.at(i);
100 if (i < children.size()-1)
104 return fmt::format(
"{}({})",
get_name(), args);
210 auto msg = fmt::format(
"Can't infer arguments for {} from json."
211 " Please provide them.\n",n);
221 char last_char = node.
feature.back();
251 if (j.contains(
"node_type"))
256 if (j.contains(
"name"))
257 j.at(
"name").get_to(p.
name);
261 if (j.contains(
"center_op"))
265 if (j.contains(
"feature"))
267 j.at(
"feature").get_to(p.
feature);
270 if (j.contains(
"feature_type"))
277 bool make_signature=
false;
279 if (j.contains(
"ret_type"))
280 j.at(
"ret_type").get_to(p.
ret_type);
283 if (j.contains(
"arg_types"))
287 if (j.contains(
"sig_hash"))
288 j.at(
"sig_hash").get_to(p.
sig_hash);
291 if (j.contains(
"sig_dual_hash"))
305 if (j.contains(
"fixed"))
307 j.at(
"fixed").get_to(p.
fixed);
310 if (j.contains(
"is_weighted"))
315 if (j.contains(
"prob_change"))
322 j.at(
"W").get_to(p.
W);
#define HANDLE_ERROR_THROW(err)
< 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 fixed
whether the node is replaceable. Weights are still optimized.
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
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,...
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