Vita
individual.h
Go to the documentation of this file.
1
13#if !defined(VITA_INDIVIDUAL_H)
14#define VITA_INDIVIDUAL_H
15
16#include <fstream>
17
18#include "kernel/cache.h"
19#include "kernel/environment.h"
20#include "kernel/gp/locus.h"
21#include "kernel/problem.h"
22#include "kernel/vitafwd.h"
23
24namespace vita
25{
39template<class Derived>
41{
42public:
43 unsigned age() const;
44 void inc_age();
45
46 // Serialization.
47 bool load(std::istream &, const symbol_set & = symbol_set());
48 bool save(std::ostream &) const;
49
50protected:
51 // Protected to prevent individual<Derived> from being instantiated as a non
52 // base class.
53 individual() = default;
54 ~individual() = default;
55
56 void set_older_age(unsigned);
57
58 // Note that syntactically distinct (but logically equivalent) individuals
59 // have the same signature. This is a very interesting property, useful
60 // for individual comparison, information retrieval, entropy calculation...
61 mutable hash_t signature_;
62
63private:
64 unsigned age_;
65}; // class individual
66
70template<class T> struct has_introns : std::false_type {};
71
72namespace out
73{
74bool long_form_flag(std::ostream &);
75print_format_t print_format_flag(std::ostream &);
76
78{
79public:
80 explicit print_format(print_format_t t) : t_(t) {}
81
82 friend std::ostream &operator<<(std::ostream &, print_format);
83
84private:
86};
87
88std::ostream &c_language(std::ostream &);
89std::ostream &cpp_language(std::ostream &);
90std::ostream &dump(std::ostream &);
91std::ostream &graphviz(std::ostream &);
92std::ostream &in_line(std::ostream &);
93std::ostream &list(std::ostream &);
94std::ostream &mql_language(std::ostream &);
95std::ostream &python_language(std::ostream &);
96std::ostream &tree(std::ostream &);
97
98std::ostream &long_form(std::ostream &);
99std::ostream &short_form(std::ostream &);
100} // namespace out
101
102#include "kernel/individual.tcc"
103
104} // namespace vita
105#endif // include guard
A single member of a population.
Definition: individual.h:41
A container for the symbols used by the GP engine.
Definition: symbol_set.h:37
print_format_t
Rendering format used to print an individual.
Definition: environment.h:37
std::ostream & graphviz(std::ostream &o)
Used to print a graph, in dot language, representing the individual.
Definition: individual.cc:124
std::ostream & python_language(std::ostream &o)
Used to print the content of an individual in python-language format.
Definition: individual.cc:100
std::ostream & cpp_language(std::ostream &o)
Used to print the content of an individual in cpp-language format.
Definition: individual.cc:78
std::ostream & long_form(std::ostream &o)
Enable printing of every detail of the individual.
Definition: individual.cc:176
std::ostream & list(std::ostream &o)
Used to print a human readable representation of the individual.
Definition: individual.cc:154
std::ostream & in_line(std::ostream &o)
Used to print the individual on a single line.
Definition: individual.cc:137
std::ostream & tree(std::ostream &o)
Used to print the individual as a tree structure.
Definition: individual.cc:165
std::ostream & c_language(std::ostream &o)
Used to print the content of an individual in c-language format.
Definition: individual.cc:67
std::ostream & short_form(std::ostream &o)
Hide secondary details of the individual.
Definition: individual.cc:187
std::ostream & dump(std::ostream &o)
Used to print the complete content of an individual.
Definition: individual.cc:112
std::ostream & mql_language(std::ostream &o)
Used to print the content of an individual in MQL-language format.
Definition: individual.cc:89
Contains flags and manipulators to control the output format of individuals.
The main namespace for the project.
The SFINAE way of recognizing if an individual has introns.
Definition: individual.h:70
A 128bit unsigned integer used as individual's signature / hash table look-up key.
Definition: cache_hash.h:27