Ultra 0.9.4
Loading...
Searching...
No Matches
ultra Namespace Reference

Namespaces

namespace  exception
namespace  integer

Classes

class  alps_layer_pair
struct  group_stat
class  analyzer
class  cache
struct  decision_vector
class  distribution
class  test_evaluator
class  evaluator_proxy
class  evolution
class  layered_population
struct  scored_individual
class  summary
class  evolution_status
class  evolution_strategy
class  alps_es
class  std_es
class  de_es
class  with_size
class  fitnd
class  function
struct  gene
class  interpreter
struct  locus
struct  is_bitmask_enum< symbol_init >
 Enable bitmask operations for symbol_init. More...
struct  hash_t
class  murmurhash3
class  murmurhash3_sink
class  individual
struct  interval
class  linear_population
struct  model_measurements
class  nullary
struct  parameters
struct  problem
class  refiner
class  basic_search
class  search_log
class  search_stats
class  symbol
class  symbol_set
class  terminal
class  validation_strategy
class  as_is_validation
class  vector_individual

Concepts

concept  has_active_crossover_type
concept  DecisionVector
 Checks whether a type models a concrete decision-vector representation.
concept  DecisionVectorExtractable
 Checks whether a type supports decision vector extraction.
concept  NumericalOptimisable
 Supports numerical optimisation via decision-vector perturbation.
concept  ClearableEvaluator
concept  Evaluator
concept  Strategy
concept  RefinementStrategy
concept  Fitness
concept  MultiDimFitness
concept  Individual
concept  ArithmeticScalar
concept  RandomAccessIndividuals
concept  Population
concept  LayeredPopulation
concept  SizedRandomAccessPopulation
concept  PopulationWithMutex
concept  Symbol
concept  Terminal
concept  ValidationStrategy

Typedefs

using bitwidth = unsigned
 Type alias for the number of bits.
template<class I>
using decision_vector_t
 Concrete decision-vector type associated with I.
template<Evaluator E>
using evaluator_individual_t = closure_arg_t<E>
template<Evaluator E>
using evaluator_fitness_t = closure_return_t<E>
template<Individual I, Fitness F>
using after_generation_callback_t
template<Individual I, Fitness F>
using on_new_best_callback_t
template<Evaluator E>
using refinement_callback_t
using shake_function_callback_t = std::function<evaluation_context(unsigned)>
using hash = murmurhash3
using hash_sink = murmurhash3_sink
using population_uid = unsigned
using D_VOID = std::monostate
using D_INT = int
using D_DOUBLE = double
using D_STRING = std::string
using D_NULLARY = nullary
using D_ADDRESS = param_address
using D_VARIABLE = src::variable
using D_IVECTOR = std::vector<int>
using value_t

Enumerations

enum class  dv_param_kind : unsigned char { real , integer }
 Original scalar category used when writing back an optimised value.
enum class  evaluation_context { unchanged , changed }
enum class  test_evaluator_type { realistic , fixed , random , age }
enum class  symbol_init : unsigned {
  disabled = 0 , variables = 1 , attributes = 2 , ephemerals = 4 ,
  functions = 8 , all = 15
}
enum  domain_t {
  d_void = 0 , d_int , d_double , d_string ,
  d_nullary , d_address , d_variable , d_ivector
}

Functions

template<class Layer>
 alps_layer_pair (Layer &) -> alps_layer_pair< Layer >
template<class Layer>
 alps_layer_pair (Layer &, Layer &) -> alps_layer_pair< Layer >
template<class Layer>
 alps_layer_pair (const Layer &) -> alps_layer_pair< const Layer >
template<class Layer>
 alps_layer_pair (const Layer &, const Layer &) -> alps_layer_pair< const Layer >
template<LayeredPopulation P, Evaluator E>
 analyzer (const P &, const E &) -> analyzer< typename P::value_type, evaluator_fitness_t< E > >
template<class E>
void invalidate_cache_if_supported (E &eva)
template<Evaluator E>
bool load_eva (std::istream &in, E *e)
template<Evaluator E>
bool save_eva (std::ostream &out, const E &e)
fitnd operator* (fitnd::value_type v, fitnd f)
fitnd operator- (fitnd f)
fitnd abs (fitnd f)
fitnd sqrt (fitnd f)
fitnd operator+ (fitnd, const fitnd &)
fitnd operator- (fitnd, const fitnd &)
fitnd operator* (fitnd, const fitnd &)
fitnd operator/ (fitnd, const fitnd &)
fitnd operator* (fitnd, fitnd::value_type)
fitnd operator/ (fitnd, fitnd::value_type)
bool load (std::istream &, fitnd *)
std::ostream & operator<< (std::ostream &, const fitnd &)
std::istream & operator>> (std::istream &, fitnd &)
template<Fitness F>
constexpr F lowest () noexcept
template<std::integral F>
bool isfinite (F) noexcept
template<std::floating_point F>
bool isfinite (F f)
template<MultiDimFitness F>
bool isfinite (const F &f)
template<Fitness F>
requires std::is_arithmetic_v<F>
bool dominating (const F &lhs, const F &rhs)
template<MultiDimFitness F>
bool dominating (const F &lhs, const F &rhs)
template<MultiDimFitness F>
bool almost_equal (const F &lhs, const F &rhs)
template<Fitness F>
requires std::is_arithmetic_v<F>
double distance (F f1, F f2)
template<MultiDimFitness F>
double distance (const F &f1, const F &f2)
template<Fitness F>
requires std::floating_point<F>
bool save (std::ostream &out, F f)
template<std::integral F>
bool save (std::ostream &out, F f)
template<MultiDimFitness F>
requires std::floating_point<std::ranges::range_value_t<F>>
bool save (std::ostream &out, const F &f)
template<std::floating_point F>
bool load (std::istream &in, F *f)
template<std::integral F>
bool load (std::istream &in, F *f)
value_t run (const gp::individual &ind)
bool operator< (const locus &l1, const locus &l2) noexcept
bool operator> (const locus &l1, const locus &l2) noexcept
locus operator+ (const locus &l, locus::index_t i) noexcept
std::ostream & operator<< (std::ostream &s, const locus &l)
std::ostream & operator<< (std::ostream &o, hash_t h)
std::span< const std::byte > bytes_view (const std::string &s) noexcept
template<class T>
requires (std::integral<T> || std::floating_point<T>)
std::span< const std::byte, sizeof(T)> bytes_view (const T &t) noexcept
std::ostream & operator<< (std::ostream &os, const ultra::individual &ind)
template<Fitness F>
auto operator<=> (const model_measurements< F > &, const model_measurements< F > &) noexcept
template<Individual I, Fitness F>
auto operator<=> (const scored_individual< I, F > &, const scored_individual< I, F > &) noexcept
template<Evaluator E>
 search (problem &, E) -> search< E >
std::filesystem::path dynamic_from_basename (const std::string &basename)
std::filesystem::path layers_from_basename (const std::string &basename)
std::filesystem::path population_from_basename (const std::string &basename)
std::filesystem::path summary_from_basename (std::filesystem::path basename)
std::filesystem::path basename_from_summary (std::filesystem::path summary)
template<Symbol S>
auto get_if (const symbol *s)
template<Symbol S>
auto get_if (const symbol &s)
template<Symbol S>
bool is (const symbol *s)
std::ostream & operator<< (std::ostream &, const symbol_set &)
bool has_value (const value_t &v) noexcept
bool basic_data_type (domain_t d) noexcept
bool numerical_data_type (domain_t d) noexcept
const D_NULLARY * get_if_nullary (const value_t &v) noexcept
std::ostream & operator<< (std::ostream &o, const value_t &v)
bool load (std::istream &in, const symbol_set &ss, value_t &v)
bool save (std::ostream &out, const value_t &v)
constexpr param_address operator""_addr (unsigned long long a)
bool basic_data_type (const value_t &) noexcept
bool numerical_data_type (const value_t &) noexcept
template<class T>
bool operator== (const vector_individual< T > &, const vector_individual< T > &) noexcept
template<class T>
std::size_t active_slots (const vector_individual< T > &) noexcept
bool load (std::istream &in, fitnd *f)
std::ostream & operator<< (std::ostream &o, const fitnd &f)
std::istream & operator>> (std::istream &in, fitnd &f)
fitnd operator+ (fitnd lhs, const fitnd &rhs)
fitnd operator- (fitnd lhs, const fitnd &rhs)
fitnd operator* (fitnd lhs, const fitnd &rhs)
fitnd operator/ (fitnd lhs, const fitnd &rhs)
fitnd operator/ (fitnd f, fitnd::value_type v)
fitnd operator* (fitnd f, fitnd::value_type v)
fitnd combine (const fitnd &f1, const fitnd &f2)
std::ostream & operator<< (std::ostream &o, const symbol_set &ss)
template<class T>
bool operator== (const vector_individual< T > &lhs, const vector_individual< T > &rhs) noexcept
template<class T>
std::size_t active_slots (const vector_individual< T > &ind) noexcept

Variables

constexpr symbol_init def_terminal_init

Detailed Description

The main namespace for the project.

Typedef Documentation

◆ after_generation_callback_t

template<Individual I, Fitness F>
using ultra::after_generation_callback_t
Initial value:
std::function<void(const layered_population<I> &, const summary<I, F> &)>
Definition layered_population.h:41
Definition evolution_summary.h:33

◆ decision_vector_t

template<class I>
using ultra::decision_vector_t
Initial value:
std::remove_cvref_t<
decltype(extract_decision_vector(std::declval<const I &>()))>

Concrete decision-vector type associated with I.

◆ on_new_best_callback_t

template<Individual I, Fitness F>
using ultra::on_new_best_callback_t
Initial value:
std::function<void (const scored_individual<I, F> &)>
Definition scored_individual.h:48

◆ population_uid

using ultra::population_uid = unsigned

The numerical type used for population unique ID.

◆ refinement_callback_t

template<Evaluator E>
using ultra::refinement_callback_t
Initial value:
std::function<std::optional<evaluator_fitness_t<E>>(
evaluator_individual_t<E> &, const E &,
Parameters controlling numerical optimisation of GP individuals.
Definition parameters.h:203

Refinement backend callback.

Backends are responsible for deciding whether a refined individual should replace the original one (return std::nullopt to leave the population unchanged).

When refinement is performed in parallel, this callback may be invoked concurrently for distinct candidate individuals. Implementations must be thread-safe and must synchronize access to shared state they capture.

◆ value_t

Initial value:
std::variant<D_VOID, D_INT, D_DOUBLE, D_STRING,
const D_NULLARY *, D_ADDRESS, const D_VARIABLE *,
D_IVECTOR>

A variant containing the data types used by the interpreter for internal calculations / output value and for storing examples.

Examples
symbolic_regression03.cc.

Enumeration Type Documentation

◆ domain_t

Numerical ID of supported data types.

◆ evaluation_context

enum class ultra::evaluation_context
nodiscardstrong

Describes whether an operation changed the semantic context used to evaluate individuals.

When the context changes, cached evaluator results may no longer be valid.

◆ symbol_init

enum class ultra::symbol_init : unsigned
strong

Bitmask flags for configuring symbol initialisation stages.

Can be combined using bitwise operators.

Enumerator
disabled 

No initialisation.

variables 

Initialises input variables.

attributes 

Initialises attributes.

ephemerals 

Initialises ephemeral values.

functions 

Initialises the function set.

all 

Initialises everything.

Function Documentation

◆ abs()

fitnd ultra::abs ( fitnd f)
nodiscard
Parameters
[in]fa fitness value
Returns
a new vector obtained taking the absolute value of each component of f

◆ basic_data_type()

bool ultra::basic_data_type ( domain_t d)
nodiscardnoexcept
Parameters
[in]ddomain to be checked
Returns
true for numbers and strings

◆ bytes_view() [1/2]

std::span< const std::byte > ultra::bytes_view ( const std::string & s)
nodiscardnoexcept
Parameters
[in]sa string
Returns
the string content viewed as a raw sequence of bytes

◆ bytes_view() [2/2]

template<class T>
requires (std::integral<T> || std::floating_point<T>)
std::span< const std::byte, sizeof(T)> ultra::bytes_view ( const T & t)
nodiscardnoexcept
Parameters
[in]ta value belonging to a fundamental types
Returns
the value content viewed as a raw sequence of bytes

◆ distance()

template<Fitness F>
requires std::is_arithmetic_v<F>
double ultra::distance ( F f1,
F f2 )
nodiscard

Taxicab distance between two vectors.

Parameters
[in]f1first fitness value
[in]f2second fitness value
Returns
the distance between f1 and f2

The taxicab distance between two vectors in an n-dimensional real vector space with fixed Cartesian coordinate system, is the sum of the lengths of the projections of the line segment between the points onto the coordinate axes.

◆ dominating()

template<Fitness F>
requires std::is_arithmetic_v<F>
bool ultra::dominating ( const F & lhs,
const F & rhs )
nodiscard

Pareto dominance comparison.

Parameters
[in]lhsfirst term of comparison
[in]rhssecond term of comparison
Returns
true if lhs is a Pareto improvement of rhs

lhs dominates rhs (is a Pareto improvement) if:

  • each component of lhs is not strictly worst (less) than the corresponding component of rhs;
  • there is at least one component in which lhs is better than rhs.
Note
An interesting property is that if a vector x does not dominate a vector y, this does not imply that y dominates x (they can be both non-dominated).

◆ get_if() [1/2]

template<Symbol S>
auto ultra::get_if ( const symbol & s)
nodiscard

Attempts to retrieve a pointer to a specific derived symbol type.

Template Parameters
Sexpected dynamic type, which must derive from symbol
Parameters
[in]sreference to the symbol to inspect
Returns
pointer to const S if s refers to an object of type S, otherwise a null pointer
Remarks
This overload is equivalent to calling get_if<S>(&s).

◆ get_if() [2/2]

template<Symbol S>
auto ultra::get_if ( const symbol * s)
nodiscard

Attempts to retrieve a pointer to a specific derived symbol type.

Template Parameters
Sexpected dynamic type, which must derive from symbol
Parameters
[in]spointer to the symbol to inspect
Returns
pointer to const S if s refers to an object of type S, otherwise a null pointer
Remarks
This function performs a runtime-checked downcast. It is intended for situations where heterogeneous symbol containers must be inspected safely without relying on external type tags.

◆ get_if_nullary()

const D_NULLARY * ultra::get_if_nullary ( const value_t & v)
nodiscardnoexcept
Parameters
[in]vcontainer object
Returns
a pointer to the nullary object contained in v if present, otherwise nullptr

◆ has_value()

bool ultra::has_value ( const value_t & v)
nodiscardnoexcept

Checks whether a given value_t contains a value.

Parameters
[in]vvalue to be checked
Returns
true if v isn't empty
Examples
symbolic_regression03.cc.

◆ invalidate_cache_if_supported()

template<class E>
void ultra::invalidate_cache_if_supported ( E & eva)

Invalidates cached evaluator state if the evaluator exposes a compatible clear() member function.

◆ is()

template<Symbol S>
bool ultra::is ( const symbol * s)
nodiscard

Checks whether a symbol is of a given derived type.

Template Parameters
Sexpected dynamic type, which must derive from symbol
Parameters
[in]spointer to the symbol to inspect
Returns
true if s refers to an object of type S, false otherwise
Remarks
This is a convenience wrapper around get_if<S>() intended for readability when only a boolean test is required.

◆ isfinite()

template<MultiDimFitness F>
bool ultra::isfinite ( const F & f)
nodiscard
Parameters
[in]ffitness to check
Returns
true if every component of the fitness is finite

◆ load() [1/3]

bool ultra::load ( std::istream & in,
const symbol_set & ss,
value_t & v )
Parameters
[in]ininput stream
[in]sssymbol set used for decoding d_address / d_nullary
[out]vvalue_t coming from the input stream
Returns
true if the object has been loaded correctly
Note
If the load operation isn't successful v isn't modified.

◆ load() [2/3]

template<std::floating_point F>
bool ultra::load ( std::istream & in,
F * f )
Parameters
[in]ininput stream
[out]fload the fitness here
Returns
true if the object has been loaded correctly
Note
If the load operation isn't successful f isn't changed.

◆ load_eva()

template<Evaluator E>
bool ultra::load_eva ( std::istream & in,
E * e )

Loads the persistent state of an evaluator, if supported.

Template Parameters
Ean Evaluator type
Parameters
[in,out]ininput stream
[in,out]epointer to the evaluator instance
Returns
true if the evaluator was loaded successfully or if the evaluator doesn't support persistence

This function provides optional persistence support for evaluators. If the evaluator type E defines a member function with the signature:

bool load(std::istream &);

then that function is invoked. Otherwise, the evaluator is assumed to have no persistent state and the operation succeeds trivially.

◆ numerical_data_type()

bool ultra::numerical_data_type ( domain_t d)
nodiscardnoexcept
Parameters
[in]ddomain to be checked
Returns
true for numbers

◆ operator+() [1/2]

locus ultra::operator+ ( const locus & l,
locus::index_t i )
inlinenodiscardnoexcept
Parameters
[in]lbase locus
[in]idisplacement
Returns
a new locus obtained from l incrementing index component by i (and not changing the category component)

◆ operator<()

bool ultra::operator< ( const locus & l1,
const locus & l2 )
inlinenodiscardnoexcept
Parameters
[in]l1first locus
[in]l2second locus
Returns
true if l1 precedes l2 in lexicographic order (https://en.wikipedia.org/wiki/Lexicographical_order)

◆ operator<<() [1/5]

std::ostream & ultra::operator<< ( std::ostream & o,
const value_t & v )

Streams a value_t object.

Parameters
[out]ooutput stream
[in]vvalue to be streamed
Returns
a reference to the output stream

Mainly used for debugging. Both serialization and source code visualization require different / more information.

◆ operator<<() [2/5]

std::ostream & ultra::operator<< ( std::ostream & o,
hash_t h )

Mainly useful for debugging / testing.

Parameters
[out]ooutput stream
[in]hhash signature to be printed
Returns
the updated ostream

◆ operator<<() [3/5]

std::ostream & ultra::operator<< ( std::ostream & s,
const locus & l )
inline
Parameters
[out]soutput stream
[in]llocus to print
Returns
output stream including l

◆ operator<=>() [1/2]

template<Fitness F>
auto ultra::operator<=> ( const model_measurements< F > & lhs,
const model_measurements< F > & rhs )
nodiscardnoexcept
Parameters
[in]lhsfirst term of comparison
[in]rhssecond term of comparison
Returns
a partial ordering result

The comparison criterion is Pareto dominance (https://en.wikipedia.org/wiki/Pareto_efficiency)

◆ operator<=>() [2/2]

template<Individual I, Fitness F>
auto ultra::operator<=> ( const scored_individual< I, F > & lhs,
const scored_individual< I, F > & rhs )
nodiscardnoexcept

Orders two scored individuals by fitness.

Parameters
lhsfirst scored individual
rhssecond scored individual
Returns
the ordering of lhs.fit and rhs.fit

The comparison is based only on the fitness value and is intended for ranking and selection purposes (e.g. best/worst individual).

Note
This operator deliberately provides ordering only. Equality (operator==) is not defined, because fitness values are typically floating-point and exact equality would be semantically misleading.

As a consequence, scored_individual does not model a totally ordered type and cannot be used with default std::ranges::less. Algorithms requiring ordering should supply an explicit comparator or projection.

◆ operator>()

bool ultra::operator> ( const locus & l1,
const locus & l2 )
inlinenodiscardnoexcept
Parameters
[in]l1first locus
[in]l2second locus
Returns
true if l2 precedes l1 in lexicographic order (https://en.wikipedia.org/wiki/Lexicographical_order)

◆ run()

value_t ultra::run ( const gp::individual & ind)

Executes the associated individual starting from its default entry point.

Parameters
[in]indindividual/program to be run
Returns
the value produced by evaluating the individual

This overload uses the individual's first available locus as the initial instruction pointer.

Examples
symbolic_regression03.cc.

◆ save() [1/2]

bool ultra::save ( std::ostream & out,
const value_t & v )
Parameters
[out]outoutput stream
[in]vvalue_t to be saved
Returns
true if v has been saved correctly
Remarks
d_void values are completely skipped.

◆ save() [2/2]

template<Fitness F>
requires std::floating_point<F>
bool ultra::save ( std::ostream & out,
F f )
nodiscard
Parameters
[out]outoutput stream
[in]ffitness to be saved
Returns
true if object has been saved correctly

◆ save_eva()

template<Evaluator E>
bool ultra::save_eva ( std::ostream & out,
const E & e )

Saves the persistent state of an evaluator, if supported.

Template Parameters
Ean Evaluator type
Parameters
[out]outoutput stream
[in]eevaluator instance
Returns
true if the evaluator was saved successfully or if the evaluator doesn't support persistence

This function provides optional persistence support for evaluators. If the evaluator type E defines a member function with the signature:

bool save(std::ostream &) const;
bool save(std::ostream &out, F f)
Definition fitness.h:151

then that function is invoked. Otherwise, the evaluator is assumed to have no persistent state and the operation succeeds trivially.

◆ sqrt()

fitnd ultra::sqrt ( fitnd f)
nodiscard
Parameters
[in]fa fitness
Returns
a new vector obtained taking the square root of each component of f

Variable Documentation

◆ def_terminal_init

symbol_init ultra::def_terminal_init
constexpr
Initial value:
=
@ attributes
Initialises attributes.
Definition gp/src/problem.h:38
@ variables
Initialises input variables.
Definition gp/src/problem.h:37

By default, the only terminals automatically initialised are variables and attributes. This is sensible because users can often deduce more appropriate ranges for ephemerals.