![]() |
Ultra 0.9.4
|
#include <individual.h>
Public Member Functions | |
| individual (const ultra::problem &p) | |
| individual | crossover (double, const interval< double > &, const individual &, const individual &, const individual &) const |
| 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_DOUBLE > | |
| 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_DOUBLE > &) |
| bool | empty () const noexcept |
| std::size_t | size () const noexcept |
| std::size_t | parameters () const noexcept |
| operator const std::vector< D_DOUBLE > & () 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 | |
| Public Types inherited from ultra::vector_individual< D_DOUBLE > | |
| 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_DOUBLE > | |
| 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_DOUBLE > | |
| genome_t | genome_ |
| Protected Attributes inherited from ultra::individual | |
| hash_t | signature_ {} |
| Related Symbols inherited from ultra::vector_individual< D_DOUBLE > | |
| bool | operator== (const vector_individual< D_DOUBLE > &lhs, const vector_individual< D_DOUBLE > &rhs) noexcept |
| std::size_t | active_slots (const vector_individual< D_DOUBLE > &ind) noexcept |
An individual optimized for differential evolution.
| void ultra::vector_individual< T >::apply_each | ( | F && | f | ) |
Applies an operation to every gene and updates the signature.
| f | mutating callable returning 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.
| first | first index (inclusive) |
| last | one past the last index (exclusive) |
| f | mutating callable returning void |
|
nodiscard |
Differential evolution crossover.
| [in] | p | crossover probability (parameters.evolution.p_cross) |
| [in] | f | scaling factor interval (parameters.de.weight) |
| [in] | a | base vector |
| [in] | b | first vector used for calculating the difference vector |
| [in] | c | second vector used for calculating the difference vector |
First the search direction is defined by calculating a difference vector between the pair of vectors b and c (usually chosen at random from the population). This difference vector is scaled by using the scale factor F. This way no separate probability distribution has to be used which makes the scheme completely self-organizing.
The scaled difference vector is then added to a third vector a, called the base vector. As a result a new vector is obtained, known as the mutant or donor vector:
m = a + F * (b - c)
The mutation strategy used is named DE/rand/1. Now the offspring, also called trial, vector is generated as follows:
offspring = crossover(this, m)
The mutant vector is recombined, based on a user defined parameter, called crossover probability, with this (the target / parent vector). The offspring gets at least one component of the mutant vector (the last). This scheme is called binomial.
b and c are used for mutation, this and m for crossover.
| vector_individual< T > & vector_individual::operator= | ( | const std::vector< T > & | v | ) |
Replaces the genome and updates its signature.
| [in] | v | replacement genes |