Ultra 0.9.4
Loading...
Searching...
No Matches
hga/individual.h
Go to the documentation of this file.
1
12
13#if !defined(ULTRA_HGA_INDIVIDUAL_H)
14#define ULTRA_HGA_INDIVIDUAL_H
15
17
18#include <functional>
19
20namespace ultra::hga
21{
22
26class individual final : public vector_individual<value_t>
27{
28private:
29 class modify_proxy;
30
31public:
32 // ---- Constructors ----
33 individual() = default;
34 explicit individual(const ultra::problem &);
36 // ---- Modifiers ----
37 template<class F>
38 requires
39 std::invocable<F &, individual::modify_proxy &>
40 && std::same_as<std::invoke_result_t<F &, individual::modify_proxy&>, void>
41 void modify(F &&);
42
43 using vector_individual::operator=;
45 // ---- Recombination operators ----
46 unsigned mutation(const problem &, double = 1.0);
47 friend individual crossover(const problem &,
48 const individual &, const individual &);
49
50private:
51 // ---- Hashing ----
52 [[nodiscard]] std::vector<std::byte> pack() const;
53 [[nodiscard]] hash_t hash() const final;
54
55 // ---- Printing ----
56 void print_impl(std::ostream &, out::print_format_t) const override;
57}; // class individual
58
59
60// ---- Non-member functions ----
61[[nodiscard]] unsigned distance(const individual &, const individual &);
62
63[[nodiscard]] individual crossover(const problem &,
64 const individual &, const individual &);
65
66#include "kernel/hga/individual.tcc"
67
68} // namespace ultra::hga
69
71
72#endif // include guard
Definition hga/individual.h:36
void modify(F &&)
Definition hga/individual.h:103
unsigned mutation(const problem &, double=1.0)
Definition hga/individual.cc:61
Definition hga/problem.h:30
hash_t hash() const override
Definition vector_individual.h:193
STL namespace.
Definition hash_t.h:34
Definition problem.h:26