Vita
evaluator.h
Go to the documentation of this file.
1
13#if !defined(VITA_EVALUATOR_H)
14#define VITA_EVALUATOR_H
15
16#include "kernel/fitness.h"
18#include "kernel/random.h"
19
20namespace vita
21{
22
24{
25public:
28 virtual void clear() {}
29};
30
52template<class T>
54{
55public:
56 virtual ~evaluator() = default;
57
59 virtual fitness_t operator()(const T &) = 0;
60
61 // Serialization.
62 virtual bool load(std::istream &);
63 virtual bool save(std::ostream &) const;
64
65 // The following methods have a default implementation (usually empty).
66 virtual fitness_t fast(const T &);
67 virtual std::unique_ptr<basic_lambda_f> lambdify(const T &) const;
68};
69
70enum class test_evaluator_type {distinct, fixed, random};
71
84template<class T>
85class test_evaluator final : public vita::evaluator<T>
86{
87public:
88 explicit test_evaluator(test_evaluator_type = test_evaluator_type::random);
89
90 fitness_t operator()(const T &) override;
91
92private:
93 std::vector<T> buffer_;
94 test_evaluator_type et_;
95};
96#include "kernel/evaluator.tcc"
97
98} // namespace vita
99
100#endif // include guard
virtual void clear()
Clear possible cached values.
Definition: evaluator.h:28
Calculates the fitness of an individual.
Definition: evaluator.h:54
virtual fitness_t operator()(const T &)=0
A fitness function used for debug purpose.
Definition: evaluator.h:86
fitness_t operator()(const T &) override
The main namespace for the project.