Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | List of all members
cuml::genetic::node Struct Reference

Represents a node in the syntax tree. More...

#include <node.h>

Collaboration diagram for cuml::genetic::node:
Collaboration graph

Public Types

enum class  type : uint32_t {
  variable = 0 , constant , functions_begin , binary_begin = functions_begin ,
  add = binary_begin , atan2 , div , fdim ,
  max , min , mul , pow ,
  sub , binary_end = sub , unary_begin , abs = unary_begin ,
  acos , acosh , asin , asinh ,
  atan , atanh , cbrt , cos ,
  cosh , cube , exp , inv ,
  log , neg , rcbrt , rsqrt ,
  sin , sinh , sq , sqrt ,
  tan , tanh , unary_end = tanh , functions_end = unary_end
}
 All possible types of nodes. For simplicity, all the terminal and non-terminal types are clubbed together. More...
 

Public Member Functions

 node ()
 Default constructor for node. More...
 
 node (type ft)
 Construct a function node. More...
 
 node (int fid)
 Construct a variable node. More...
 
 node (float val)
 Construct a constant node. More...
 
 node (const node &src)
 
nodeoperator= (const node &src)
 assignment operator More...
 
bool is_terminal () const
 
bool is_nonterminal () const
 
int arity () const
 

Static Public Member Functions

static type from_str (const std::string &ntype)
 Helper method to get node type from input string. More...
 

Public Attributes

type t
 
union {
   int   fid
 
   float   val
 
u
 

Static Public Attributes

static const int kInvalidFeatureId
 

Detailed Description

Represents a node in the syntax tree.

// A non-terminal (aka function) node
node func_node{node::type::sub};
// A constant node
float const_value = 2.f;
node const_node{const_value};
// A variable (aka feature) node
node var_node{20};
node()
Default constructor for node.

Member Enumeration Documentation

◆ type

enum cuml::genetic::node::type : uint32_t
strong

All possible types of nodes. For simplicity, all the terminal and non-terminal types are clubbed together.

Enumerator
variable 
constant 
functions_begin 
binary_begin 
add 
atan2 
div 
fdim 
max 
min 
mul 
pow 
sub 
binary_end 
unary_begin 
abs 
acos 
acosh 
asin 
asinh 
atan 
atanh 
cbrt 
cos 
cosh 
cube 
exp 
inv 
log 
neg 
rcbrt 
rsqrt 
sin 
sinh 
sq 
sqrt 
tan 
tanh 
unary_end 
functions_end 

Constructor & Destructor Documentation

◆ node() [1/5]

cuml::genetic::node::node ( )
explicit

Default constructor for node.

◆ node() [2/5]

cuml::genetic::node::node ( type  ft)
explicit

Construct a function node.

Parameters
[in]ftfunction type

◆ node() [3/5]

cuml::genetic::node::node ( int  fid)
explicit

Construct a variable node.

Parameters
[in]fidfeature id that represents the variable

◆ node() [4/5]

cuml::genetic::node::node ( float  val)
explicit

Construct a constant node.

Parameters
[in]valconstant value

◆ node() [5/5]

cuml::genetic::node::node ( const node src)
explicit
Parameters
[in]srcsource node to be copied

Member Function Documentation

◆ arity()

int cuml::genetic::node::arity ( ) const

Get the arity of the node. If it is a terminal, then a 0 is returned

◆ from_str()

static type cuml::genetic::node::from_str ( const std::string &  ntype)
static

Helper method to get node type from input string.

Parameters
[in]ntypenode type in string. Possible strings correlate one-to-one with the enum values for type
Returns
type

◆ is_nonterminal()

bool cuml::genetic::node::is_nonterminal ( ) const

whether the current node is a function

◆ is_terminal()

bool cuml::genetic::node::is_terminal ( ) const

whether the current is either a variable or a constant

◆ operator=()

node& cuml::genetic::node::operator= ( const node src)

assignment operator

Parameters
[in]srcsource node to be copied
Returns
current node reference

Member Data Documentation

◆ fid

int cuml::genetic::node::fid

if the node is variable type, then this is the column id to be used to fetch its value, from the input dataset

◆ kInvalidFeatureId

const int cuml::genetic::node::kInvalidFeatureId
static

constant used to represent invalid feature id

◆ t

type cuml::genetic::node::t

node type

◆ 

union { ... } cuml::genetic::node::u

◆ val

float cuml::genetic::node::val

if the node is constant type, then this is the value of the node


The documentation for this struct was generated from the following file: