7 os <<
"nt: " << nt << endl;
26 return fmt::format(
"{:.2f}*{}",
W,
feature);
32 return fmt::format(
"{:.2f}",
W);
39 return fmt::format(
"{:.2f}",
W);
43 return fmt::format(
"{:.2f}+Sum",
W);
45 return fmt::format(
"Sum");
48 return fmt::format(
"{:.2f}*{}",
W,
name);
58 return fmt::format(
"If({}>{:.2f},{},{})",
69 return fmt::format(
"If({},{},{})",
76 return fmt::format(
"If({}>{:.2f},{},{})",
87 args = fmt::format(
"{:.2f},",
W);
89 for (
int i = 0; i < children.size(); ++i){
90 args += children.at(i);
91 if (i < children.size()-1)
95 return fmt::format(
"Sum({})", args);
99 for (
int i = 0; i < children.size(); ++i){
100 args += children.at(i);
101 if (i < children.size()-1)
105 return fmt::format(
"{}({})",
get_name(), args);
208 auto msg = fmt::format(
"Can't infer arguments for {} from json."
209 " Please provide them.\n",n);
226 if (j.contains(
"node_type"))
231 if (j.contains(
"name"))
232 j.at(
"name").get_to(p.
name);
236 if (j.contains(
"center_op"))
239 if (j.contains(
"feature"))
244 if (j.contains(
"feature_type"))
251 bool make_signature=
false;
253 if (j.contains(
"ret_type"))
254 j.at(
"ret_type").get_to(p.
ret_type);
257 if (j.contains(
"arg_types"))
261 if (j.contains(
"sig_hash"))
262 j.at(
"sig_hash").get_to(p.
sig_hash);
265 if (j.contains(
"sig_dual_hash"))
277 if (j.contains(
"fixed"))
279 j.at(
"fixed").get_to(p.
fixed);
282 if (j.contains(
"is_weighted"))
287 if (j.contains(
"prob_change"))
294 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
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
bool fixed
whether node is modifiable
NodeType node_type
the node type
DataType ret_type
return data type
void set_feature(string f)
string get_feature() const
std::size_t sig_hash
a hash of the signature
void set_feature_type(DataType ft)
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
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