Ultra 0.9.4
Loading...
Searching...
No Matches
ultra::gp::individual Class Referencefinal

#include <individual.h>

Inheritance diagram for ultra::gp::individual:
ultra::individual

Public Types

enum  crossover_t {
  one_point , two_points , tree , uniform ,
  dependency , NUM_CROSSOVERS
}
using const_exon_iterator = internal::basic_exon_iterator<true>
using exon_iterator = internal::basic_exon_iterator<false>
Public Types inherited from ultra::individual
using age_t = unsigned

Public Member Functions

 individual (const problem &)
 individual (const std::vector< gene > &)
symbol::category_t categories () const noexcept
bool empty () const noexcept
locus::index_t size () const noexcept
const gene & operator[] (const locus &) const noexcept
locus start () const noexcept
unsigned mutation (const problem &, double=1.0)
void apply_decision_vector (const decision_vector &)
crossover_t active_crossover_type () const noexcept
matrix< unsigned > analyse_importance (const std::vector< locus > &) const
const_exon_view cexons () const
auto begin () const noexcept
auto end () const noexcept
bool operator== (const individual &) const noexcept
bool is_valid () const
Public Member Functions inherited from ultra::individual
age_t age () const noexcept
void inc_age (unsigned=1) noexcept
bool load (std::istream &, const symbol_set &={})
bool save (std::ostream &) const
hash_t signature () const noexcept
std::string format (out::print_format_t) const

Additional Inherited Members

Protected Member Functions inherited from ultra::individual
void set_if_older_age (age_t) noexcept
Protected Attributes inherited from ultra::individual
hash_t signature_ {}

Detailed Description

A single member of a genetic programming population.

Straight Line Program (SLP) is the encoding / data structure used to represent the individual.

Note
This class implements a value type with no internal synchronisation. Any operation that mutates the individual is not thread-safe and must not run concurrently with any member function unless externally synchronised.
Examples
symbolic_regression03.cc.

Constructor & Destructor Documentation

◆ individual() [1/2]

ultra::gp::individual::individual ( const problem & p)
explicit

Generates the initial, random expressions that make up an individual.

Parameters
[in]pbase problem

The constructor is implemented so as to ensure that there is no violation of the type system's constraints.

◆ individual() [2/2]

ultra::gp::individual::individual ( const std::vector< gene > & gv)
explicit

Creates a new individual containing genes from gv.

Parameters
[in]gvvector of genes
Precondition
gv is not empty
the final gene produces the default category

This is useful for debugging purpose (i.e. setup ad-hoc individuals).

Member Function Documentation

◆ active_crossover_type()

individual::crossover_t ultra::gp::individual::active_crossover_type ( ) const
nodiscardnoexcept
Returns
the active crossover type for this individual

◆ analyse_importance()

matrix< unsigned > ultra::gp::individual::analyse_importance ( const std::vector< locus > & loci) const
nodiscard

Calculates the importance of genes contributing to selected loci.

Parameters
[in]lociloci from which dependency analysis starts
Returns
a matrix containing the importance of every gene
Precondition
every locus must belong to this individual

Importance is the number of dependency paths from the selected loci to each gene. Counts saturate at the maximum value of unsigned.

◆ apply_decision_vector()

void ultra::gp::individual::apply_decision_vector ( const decision_vector & v)

Applies a decision vector to this individual.

Parameters
[in]vdecision vector previously extracted from a compatible individual
Precondition
  • v.is_valid();
  • v must have been obtained from an individual with the same structure (same active exons, loci, and argument layout). Applying a decision vector to a structurally different individual results in undefined behaviour.

Each entry of the decision vector is written back to the corresponding argument in the genome, as identified by decision_vector::coordinate. Real-valued parameters are copied directly, while integer parameters are reconstructed by rounding the provided value to the nearest integer (std::lround).

◆ categories()

symbol::category_t ultra::gp::individual::categories ( ) const
nodiscardnoexcept
Returns
the total number of categories the individual is using

◆ cexons()

const_exon_view ultra::gp::individual::cexons ( ) const
nodiscard
Returns
a const range to iterate through exons (active genes).

◆ empty()

bool ultra::gp::individual::empty ( ) const
nodiscardnoexcept
Returns
true if the individual isn't initialized

◆ is_valid()

bool ultra::gp::individual::is_valid ( ) const
nodiscard
Returns
true if the individual passes the internal consistency check

◆ mutation()

unsigned ultra::gp::individual::mutation ( const problem & prb,
double temperature = 1.0 )

A new individual is created mutating this.

Parameters
[in]prbthe current problem
[in]temperaturemutation intensity (1.0 preserves the configured probability)
Returns
number of mutations performed
Note
External parameters: evolution.p_mutation

◆ operator==()

bool ultra::gp::individual::operator== ( const individual & rhs) const
nodiscardnoexcept
Parameters
[in]rhssecond term of comparison
Returns
true if the two individuals are equal (symbol by symbol, including introns)
Note
Age is not checked.

◆ operator[]()

const gene & ultra::gp::individual::operator[] ( const locus & l) const
nodiscardnoexcept
Parameters
[in]llocus of a gene
Returns
the l-th gene of this individual

◆ size()

locus::index_t ultra::gp::individual::size ( ) const
nodiscardnoexcept
Returns
the total size of the individual (effective size + introns)
Remarks
Size is constant for any individual (it's chosen at initialization time).
See also
eff_size()

◆ start()

locus ultra::gp::individual::start ( ) const
nodiscardnoexcept
Returns
the first gene of the individual (the first instruction of the program)

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