Ultra 0.9.4
Loading...
Searching...
No Matches
ultra::terminal Class Referenceabstract

#include <terminal.h>

Inheritance diagram for ultra::terminal:
ultra::symbol ultra::de::real ultra::ga::integer ultra::hga::integer ultra::hga::permutation ultra::integer::literal ultra::integer::number ultra::nullary ultra::real::integer ultra::real::literal ultra::real::number ultra::src::variable ultra::str::literal

Public Member Functions

virtual value_t instance () const =0
std::string to_string (format=c_format) const override
 symbol (const std::string &, category_t=default_category)
Public Member Functions inherited from ultra::symbol
 symbol (const std::string &, category_t=default_category)
virtual ~symbol ()=default
 Virtual destructor to allow safe polymorphic deletion.
category_t category () const noexcept
opcode_t opcode () const noexcept
const std::string & name () const noexcept
void category (category_t) noexcept
virtual bool is_valid () const

Additional Inherited Members

Public Types inherited from ultra::symbol
enum  format { c_format , cpp_format , python_format , sup_format }
 Supported rendering formats for symbol stringification.
using category_t = unsigned
using opcode_t = unsigned
Static Public Attributes inherited from ultra::symbol
static constexpr category_t default_category = 0
 Default category assigned when typing is not used.
static constexpr category_t undefined_category
 Sentinel value indicating that the category has not yet been assigned.

Detailed Description

Leaf symbol in a genetic programming expression.

A terminal represents an atomic value in a GP expression tree or linear program. Unlike functions, terminals do not take arguments and therefore have arity zero.

Typical examples of terminals include:

  • input variables (e.g. program inputs or features);
  • constant literals;
  • nullary functions (functions with no parameters).

Terminals are evaluated by directly producing a value, rather than combining the results of sub-expressions. As such, they always appear as leaves in the program structure.

See also
symbol
Examples
symbolic_regression03.cc.

Member Function Documentation

◆ instance()

virtual value_t ultra::terminal::instance ( ) const
nodiscardpure virtual

Produce the runtime value of the terminal.

Returns
the value associated with this terminal

This function returns the value represented by the terminal when the program is evaluated. The returned value may depend on the evaluation context (e.g. the current input vector), but does not depend on any child expressions.

Note
Implementations must not throw exceptions and should be side-effect free to preserve referential transparency during program evaluation.

Implemented in ultra::de::real, ultra::ga::integer, ultra::hga::integer, ultra::hga::permutation, ultra::integer::literal, ultra::integer::number, ultra::nullary, ultra::real::integer, ultra::real::literal, ultra::real::number, ultra::src::variable, and ultra::str::literal.

Examples
symbolic_regression03.cc.

◆ symbol()

ultra::symbol::symbol ( const std::string & name,
category_t c = default_category )
explicit

Constructs a symbol with the given name and category.

Parameters
[in]namename of the symbol (unique textual identifier)
[in]ccategory of the symbol
Warning
The symbol name is used for serialisation and must be globally unique within a symbol set. While opcodes are also unique, they are assigned dynamically and may differ between executions.

◆ to_string()

std::string ultra::terminal::to_string ( format = c_format) const
inlinenodiscardoverridevirtual

Implements ultra::symbol.


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