Vita
Public Member Functions | Static Public Member Functions | List of all members
vita::terminal Class Reference

A symbol with zero-arity. More...

#include <terminal.h>

Inherits vita::symbol.

Inherited by vita::ga::detail::number< int >, vita::ga::detail::number< double >, vita::boolean::one, vita::boolean::zero, vita::constant< T >, vita::constant< std::string >, vita::ga::detail::number< T >, vita::integer::number, vita::real::integer, vita::real::real, and vita::variable.

Public Member Functions

unsigned arity () const final
 
virtual std::string display (terminal_param_t, format=c_format) const
 
virtual terminal_param_t init () const
 Used to initialize the internal parameter of the terminal. More...
 
virtual bool parametric () const
 A parametric terminal needs an additional parameter to be evaluated. More...
 
 symbol (const std::string &, category_t=0)
 
- 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 terminalcast (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...
 

Detailed Description

A symbol with zero-arity.

A terminal might be a variable (input to the program), a constant value or a function taking no arguments (e.g. move-north).

Examples
example6.cc.

Definition at line 26 of file terminal.h.

Member Function Documentation

◆ arity()

unsigned vita::terminal::arity ( ) const
inlinefinalvirtual
Returns
0 (this is a terminal!)

Implements vita::symbol.

Definition at line 46 of file terminal.h.

◆ cast()

const terminal * vita::terminal::cast ( const symbol s)
inlinestatic

This is a short cut function.

Parameters
[in]ssymbol pointer
Returns
s casted to a vita::terminal pointer

Definition at line 83 of file terminal.h.

◆ display()

std::string vita::terminal::display ( terminal_param_t  v,
format  = c_format 
) const
virtual
Parameters
[in]vadditional informations regarding parametric symbols
Returns
a string representing the symbol

The v argument is required for parametric symbols (i.e. for a numeric terminal we have to print 123 rather than "NUMBER").

Reimplemented in vita::integer::number, vita::real::real, vita::real::integer, vita::boolean::zero, vita::boolean::one, vita::constant< T >, vita::constant< std::string >, and vita::variable.

Definition at line 24 of file terminal.cc.

◆ init()

terminal_param_t vita::terminal::init ( ) const
inlinevirtual

Used to initialize the internal parameter of the terminal.

Returns
0.0
Remarks
Derived classes should redefine this member function in a meaningful way.

Reimplemented in vita::integer::number, vita::real::real, and vita::real::integer.

Definition at line 72 of file terminal.h.

◆ parametric()

bool vita::terminal::parametric ( ) const
inlinevirtual

A parametric terminal needs an additional parameter to be evaluated.

Returns
true for parametric symbols

Genes associated with parametric symbols store an additional parameter fetched at run-time and used for symbol evaluation.

Reimplemented in vita::integer::number, vita::real::real, and vita::real::integer.

Definition at line 59 of file terminal.h.

◆ symbol()

vita::symbol::symbol ( const std::string &  name,
category_t  c = 0 
)
explicit
Parameters
[in]namename of the symbol
[in]ccategory of the symbol
Note
By default a symbol:
  • is NOT associative;
  • is NOT an input;
  • is NOT parametric. These are safe values for derived classes.
Warning
Since the name of the symbol is used for serialization, it must be unique. Even the opcode is unique, but it can change between executions.

Definition at line 41 of file symbol.cc.


The documentation for this class was generated from the following files: