Vita
mep/interpreter.h
Go to the documentation of this file.
1
13#if !defined(VITA_MEP_INTERPRETER_H)
14#define VITA_MEP_INTERPRETER_H
15
17#include "kernel/gp/function.h"
18#include "kernel/gp/gene.h"
19#include "kernel/vitafwd.h"
20#include "utility/matrix.h"
21
22namespace vita
23{
41template<>
43{
44public:
45 explicit interpreter(const i_mep *);
46
47 [[nodiscard]] index_t fetch_index(unsigned) const;
48
49 [[nodiscard]] const i_mep &program() const { return *prg_; }
50
51 [[nodiscard]] terminal_param_t fetch_param() const final;
52 [[nodiscard]] value_t fetch_arg(unsigned) final;
53 value_t fetch_opaque_arg(unsigned) final;
54
55private:
56 // *** Private support methods ***
57 value_t run_locus(const locus &);
58 [[nodiscard]] double penalty_locus(const locus &);
59
60 // Nonvirtual interface.
61 value_t run_nvi() override;
62 [[nodiscard]] double penalty_nvi() override;
63 [[nodiscard]] bool is_valid_nvi() const override;
64
65 // *** Private data members ***
66 const i_mep *prg_;
67
68 struct elem_ {bool valid; value_t value;};
69 mutable matrix<elem_> cache_;
70
71 // Instruction pointer.
72 locus ip_;
73};
74
75} // namespace vita
76
77#endif // include guard
Minimum interface of an interpreter.
A MEP (Multi Expression Programming) single member of a population.
Definition: i_mep.h:34
The main namespace for the project.
std::size_t index_t
Index in the genome.
Definition: locus.h:25
std::variant< D_VOID, D_INT, D_DOUBLE, D_STRING > value_t
A variant containing the data types used by the interpreter for internal calculations / output value ...
Definition: value.h:45