Vita
|
A symbol with arity() > 0
.
More...
#include <function.h>
Inherits vita::symbol.
Inherited by vita::boolean::l_and, vita::boolean::l_not, vita::boolean::l_or, vita::integer::add, vita::integer::div, vita::integer::ife, vita::integer::ifl, vita::integer::ifz, vita::integer::mod, vita::integer::mul, vita::integer::shl, vita::integer::sub, vita::real::abs, vita::real::add, vita::real::aq, vita::real::cos, vita::real::div, vita::real::gt, vita::real::idiv, vita::real::ifb, vita::real::ife, vita::real::ifl, vita::real::ifz, vita::real::length, vita::real::ln, vita::real::lt, vita::real::max, vita::real::mod, vita::real::mul, vita::real::sigmoid, vita::real::sin, vita::real::sqrt, vita::real::sub, and vita::str::ife.
Public Member Functions | |
category_t | arg_category (std::size_t) const |
unsigned | arity () const final |
virtual bool | associative () const |
Is the symbol subject to the associative law of arithmetic? More... | |
virtual std::string | display (format=c_format) const |
function (const std::string &, category_t, cvect) | |
function (const std::string &, std::size_t) | |
bool | is_valid () const override |
Public Member Functions inherited from vita::symbol | |
virtual unsigned | arity () const =0 |
category_t | category () const |
The type (a.k.a. More... | |
void | category (category_t) |
Changes the category of a symbol. More... | |
virtual value_t | eval (symbol_params &) const =0 |
Calculates the value of / performs the action associated with the symbol (it's implementation specific). More... | |
virtual bool | input () const |
An input variable is a feature from the learning domain. More... | |
virtual bool | is_valid () const |
std::string | name () const |
opcode_t | opcode () const |
An opcode is a unique, numerical session ID for a symbol. More... | |
double | penalty (core_interpreter *) const |
Used for automatic calculation of penalities due to broken constraints. More... | |
symbol (const std::string &, category_t=0) | |
bool | terminal () const |
Static Public Member Functions | |
static const function * | cast (const symbol *) |
This is a short cut function. More... | |
Additional Inherited Members | |
Public Types inherited from vita::symbol | |
enum | format { c_format , cpp_format , mql_format , python_format , sup_format } |
Symbol rendering format. More... | |
A symbol with arity() > 0
.
A function labels the internal (non-leaf) points of the parse trees that represent the programs in the population. An example function set might be {+, -, *}.
Definition at line 34 of file function.h.
vita::function::function | ( | const std::string & | dis, |
category_t | c, | ||
cvect | args | ||
) |
[in] | dis | string representation of the function (e.g. for the plus function it could by "ADD" or "+") |
[in] | c | category of the function (i.e. the category of the output value) |
[in] | args | input parameters (type and number) of the function (in C++ they are called the "function signature") |
Definition at line 25 of file function.cc.
vita::function::function | ( | const std::string & | dis, |
std::size_t | n_args | ||
) |
[in] | dis | string representation of the function (e.g. for the plus function it could by "ADD" or "+") |
[in] | n_args | number of arguments of the function |
Assumes category 0
for the function and its arguments. This constructor is usually chosen when types are not used.
Definition at line 39 of file function.cc.
|
inline |
[in] | i | index of a function argument |
i
-th function argument Definition at line 89 of file function.h.
|
inlinefinalvirtual |
Implements vita::symbol.
Definition at line 59 of file function.h.
|
inlinevirtual |
Is the symbol subject to the associative law of arithmetic?
true
if the function is associativeOP
is associative iff:
a OP (b OP c) = (a OP b) OP c = a OP b OP c
This information can be used for optimization and visualization.
false
. Reimplemented in vita::boolean::l_and, vita::boolean::l_or, vita::integer::add, vita::integer::mul, and vita::real::add.
Definition at line 80 of file function.h.
This is a short cut function.
[in] | s | symbol pointer |
s
casted to a vita::function pointer Definition at line 101 of file function.h.
|
virtual |
Reimplemented in vita::boolean::l_and, vita::boolean::l_not, vita::boolean::l_or, vita::real::abs, vita::real::aq, vita::real::cos, vita::real::gt, vita::real::idiv, vita::real::ifb, vita::real::ife, vita::real::ifl, vita::real::ifz, vita::real::length, vita::real::ln, vita::real::lt, vita::real::max, vita::real::mod, vita::real::sin, vita::real::sqrt, vita::real::sigmoid, vita::str::ife, vita::real::add, vita::real::div, vita::real::mul, and vita::real::sub.
Definition at line 52 of file function.cc.
|
overridevirtual |
true
if the object passes the internal consistency check Reimplemented from vita::symbol.
Definition at line 64 of file function.cc.