Vita
gene.h
Go to the documentation of this file.
1
13#if !defined(VITA_GENE_H)
14#define VITA_GENE_H
15
16#include "kernel/random.h"
17#include "kernel/gp/function.h"
18#include "kernel/gp/locus.h"
19#include "kernel/gp/terminal.h"
20#include "utility/small_vector.h"
21#include "utility/utility.h"
22
23namespace vita
24{
32template<unsigned K>
34{
35public:
36 basic_gene() {}
37 explicit basic_gene(const terminal &);
38 basic_gene(const std::pair<symbol *, std::vector<index_t>> &);
40
41 [[nodiscard]] locus locus_of_argument(std::size_t) const;
42 small_vector<locus, K> arguments() const;
43
44 // Types and constants.
45 using packed_index_t = std::uint16_t;
46 using arg_pack = small_vector<packed_index_t, K>;
47
48 enum : decltype(K) {k_args = K};
49
50 // Public data members.
51 const symbol *sym;
52 terminal_param_t par;
53 arg_pack args;
54
55private:
56 void init_if_parametric();
57};
58
59template<unsigned K>
60std::ostream &operator<<(std::ostream &, const basic_gene<K> &);
61
62template<unsigned K>
63bool operator==(const basic_gene<K> &, const basic_gene<K> &);
64template<unsigned K>
65bool operator!=(const basic_gene<K> &, const basic_gene<K> &);
66
74
75#include "kernel/gp/gene.tcc"
76} // namespace vita
77
78#endif // include guard
A gene is a unit of heredity in a living organism.
Definition: gene.h:34
Together functions and terminals are referred to as symbols.
Definition: symbol.h:36
A symbol with zero-arity.
Definition: terminal.h:27
The main namespace for the project.
std::size_t index_t
Index in the genome.
Definition: locus.h:25
std::ostream & operator<<(std::ostream &o, hash_t h)
Mainly useful for debugging / testing.
Definition: cache_hash.cc:56