![]() |
Ultra 0.9.4
|
#include <symbol.h>
Public Types | |
| enum | format { c_format , cpp_format , python_format , sup_format } |
| Supported rendering formats for symbol stringification. | |
| using | category_t = unsigned |
| using | opcode_t = unsigned |
Public Member Functions | |
| 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 |
| virtual std::string | to_string (format=c_format) const =0 |
| void | category (category_t) noexcept |
| virtual bool | is_valid () const |
Static Public Attributes | |
| 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. | |
Base class for all symbols.
In ULTRA, symbols are the atomic building blocks from which programs are constructed. Together, functions (internal nodes) and terminals (leaf nodes) form the symbol set used by the evolutionary algorithm to assemble executable program structures.
A symbol is uniquely identified across runs by its name. Symbols may also belong to a category, which is used to enforce strong typing in GP and to manage value domains in GA / DE contexts.
| using ultra::symbol::category_t = unsigned |
Type used to represent symbol categories.
Categories are used to:
A category represents a sub-domain of values. The same numerical value may belong to different categories (e.g. "kg" vs "km/h").
| using ultra::symbol::opcode_t = unsigned |
Type used as a fast, session-local identifier for symbols.
Opcodes are unique within a single execution and are primarily used for hashing and fast comparisons. They are not stable across executions and must not be serialised.
|
explicit |
Constructs a symbol with the given name and category.
| [in] | name | name of the symbol (unique textual identifier) |
| [in] | c | category of the symbol |
|
nodiscardnoexcept |
Returns the category of the symbol.
|
noexcept |
Assigns a category to the symbol.
| [in] | c | new category value |
|
nodiscardvirtual |
Performs an internal consistency check.
Reimplemented in ultra::function.
|
nodiscardnoexcept |
Returns the name of the symbol.
|
nodiscardnoexcept |
Returns the opcode of the symbol.
|
nodiscardpure virtual |
Implemented in ultra::function, ultra::integer::add, ultra::integer::div, ultra::integer::ife, ultra::integer::ifl, ultra::integer::ifz, ultra::integer::mod, ultra::integer::mul, ultra::integer::shl, ultra::integer::sub, ultra::real::abs, ultra::real::add, ultra::real::aq, ultra::real::cos, ultra::real::div, ultra::real::exp, ultra::real::gt, ultra::real::idiv, ultra::real::ife, ultra::real::ifl, ultra::real::ifz, ultra::real::length, ultra::real::ln, ultra::real::lt, ultra::real::max, ultra::real::mod, ultra::real::mul, ultra::real::sigmoid, ultra::real::sin, ultra::real::sqrt, ultra::real::sub, and ultra::str::ife.
|
staticconstexpr |
Sentinel value indicating that the category has not yet been assigned.