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

#include <individual.h>

Inheritance diagram for ultra::ga::individual:
ultra::vector_individual< D_INT > ultra::individual

Public Member Functions

 individual (const ultra::problem &p)
unsigned mutation (const problem &, double=1.0)
template<class F>
requires std::invocable<F &, T &> && std::same_as<std::invoke_result_t<F &, T &>, void>
void apply_each (std::size_t, std::size_t, F &&)
template<class F>
requires std::invocable<F &, T &> && std::same_as<std::invoke_result_t<F &, T &>, void>
void apply_each (F &&)
vector_individual & operator= (const std::vector< T > &)
Public Member Functions inherited from ultra::vector_individual< D_INT >
void apply_each (std::size_t first, std::size_t last, F &&f)
void apply_each (F &&f)
const_iterator begin () const noexcept
const_iterator end () const noexcept
const value_type & operator[] (std::size_t) const
vector_individual & operator= (const std::vector< D_INT > &)
bool empty () const noexcept
std::size_t size () const noexcept
std::size_t parameters () const noexcept
 operator const std::vector< D_INT > & () 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

Friends

individual crossover (const problem &, const individual &, const individual &)

Additional Inherited Members

Public Types inherited from ultra::vector_individual< D_INT >
using genome_t
using const_iterator
using iterator
using value_type
Public Types inherited from ultra::individual
using age_t = unsigned
Protected Member Functions inherited from ultra::vector_individual< D_INT >
hash_t hash () const override
Protected Member Functions inherited from ultra::individual
void set_if_older_age (age_t) noexcept
Protected Attributes inherited from ultra::vector_individual< D_INT >
genome_t genome_
Protected Attributes inherited from ultra::individual
hash_t signature_ {}

Detailed Description

An GA-individual optimized for combinatorial optimization.

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.

Member Function Documentation

◆ apply_each() [1/2]

template<class F>
requires std::invocable<F &, T &> && std::same_as<std::invoke_result_t<F &, T &>, void>
void ultra::vector_individual< T >::apply_each ( F && f)

Applies an operation to every gene and updates the signature.

Parameters
fmutating callable returning void
Precondition
no concurrent access

◆ apply_each() [2/2]

template<class F>
requires std::invocable<F &, T &> && std::same_as<std::invoke_result_t<F &, T &>, void>
void ultra::vector_individual< T >::apply_each ( std::size_t first,
std::size_t last,
F && f )

Applies an operation to a range of genes and updates the signature.

Parameters
firstfirst index (inclusive)
lastone past the last index (exclusive)
fmutating callable returning void
Precondition
first <= last <= parameters(); no concurrent access

◆ mutation()

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

Mutates the current individual.

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=()

vector_individual< T > & vector_individual::operator= ( const std::vector< T > & v)

Replaces the genome and updates its signature.

Parameters
[in]vreplacement genes
Returns
a reference to *this

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