![]() |
Ultra 0.9.4
|
#include <individual.h>
Classes | |
| class | modify_proxy |
Public Member Functions | |
| individual (const ultra::problem &) | |
| template<class F> requires std::invocable<F &, individual::modify_proxy &> && std::same_as<std::invoke_result_t<F &, individual::modify_proxy&>, void> | |
| void | modify (F &&) |
| unsigned | mutation (const problem &, double=1.0) |
| vector_individual & | operator= (const std::vector< T > &) |
| Public Member Functions inherited from ultra::vector_individual< value_t > | |
| 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< value_t > &) |
| bool | empty () const noexcept |
| std::size_t | size () const noexcept |
| std::size_t | parameters () const noexcept |
| operator const std::vector< value_t > & () 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 &) |
Related Symbols | |
(Note that these are not member symbols.) | |
| D_IVECTOR | pmx (const D_IVECTOR &lhs, const D_IVECTOR &rhs) |
| individual | crossover (const problem &prb, const individual &lhs, const individual &rhs) |
| Related Symbols inherited from ultra::vector_individual< value_t > | |
| bool | operator== (const vector_individual< value_t > &lhs, const vector_individual< value_t > &rhs) noexcept |
| std::size_t | active_slots (const vector_individual< value_t > &ind) noexcept |
Additional Inherited Members | |
| Public Types inherited from ultra::vector_individual< value_t > | |
| 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< value_t > | |
| 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< value_t > | |
| genome_t | genome_ |
| Protected Attributes inherited from ultra::individual | |
| hash_t | signature_ {} |
An heterogeneous GA-individual.
|
explicit |
Constructs a new, random HGA individual.
| [in] | p | current problem |
The process that generates the initial, random expressions has to be implemented so as to ensure that they don't violate the type system's constraints.
| void ultra::hga::individual::modify | ( | F && | f | ) |
Perform a controlled modification of the individual.
| F | callable type accepting a modify_proxy |
| f | callable invoked with a modification proxy |
Executes the callable f with a temporary modification proxy granting exclusive write access to the genome. During execution of f, class invariants of individual may be temporarily violated. All invariants are restored when this function returns. This is the only public entry point that permits arbitrary mutation of the individual.
| unsigned ultra::hga::individual::mutation | ( | const problem & | prb, |
| double | temperature = 1.0 ) |
Mutates the current individual.
| [in] | prb | the current problem |
| [in] | temperature | mutation intensity (1.0 preserves the configured probability) |
| vector_individual< T > & vector_individual::operator= | ( | const std::vector< T > & | v | ) |
Replaces the genome and updates its signature.
| [in] | v | replacement genes |
|
Heterogeneous crossover.
| [in] | prb | the current problem |
| [in] | lhs | first parent |
| [in] | rhs | second parent |
Genes of class integer are crossed using homogenous crossover; genes of class permutation are recombinex using PMX.
|
Partially mapped crossover (PMX).
| [in] | lhs | first permutation |
| [in] | rhs | second permutation |
The Partially Mapped Crossover (PMX) is a recombination operator, initially designed for TSP like problems, that utilizes the genetic material of two parent solutions to propose a new offspring. It is one of the most commonly used crossover operator for permutation-encoded chromosomes. The principle behind PMX is to preserve the arrangement of genes from a parent while allowing variation in genes.