Ultra 0.9.4
Loading...
Searching...
No Matches
ga/primitive.h
Go to the documentation of this file.
1
12
13#if !defined(ULTRA_GA_PRIMITIVE_H)
14#define ULTRA_GA_PRIMITIVE_H
15
16#include <string>
17
18#include "kernel/random.h"
19#include "kernel/terminal.h"
20
21namespace ultra::ga
22{
23
27class integer : public terminal
28{
29public:
45 explicit integer(interval<int> interval = {-1000, 1000},
47 : terminal("INTEGER", category), interval_(interval)
48 {
49 }
50
51 [[nodiscard]] constexpr int min() const noexcept { return interval_.min; }
52 [[nodiscard]] constexpr int sup() const noexcept { return interval_.sup; }
53
54 [[nodiscard]] value_t instance() const final
55 { return random::element(interval_); }
56
57private:
58 const interval<int> interval_;
59};
60
61} // namespace ultra::ga
62
63#endif // include guard
integer(interval< int > interval={-1000, 1000}, symbol::category_t category=symbol::undefined_category)
Definition ga/primitive.h:45
value_t instance() const final
Definition ga/primitive.h:54
static constexpr category_t undefined_category
Sentinel value indicating that the category has not yet been assigned.
Definition symbol.h:61
category_t category() const noexcept
Definition symbol.cc:79
unsigned category_t
Definition symbol.h:55
Definition terminal.h:41
std::variant< D_VOID, D_INT, D_DOUBLE, D_STRING, const D_NULLARY *, D_ADDRESS, const D_VARIABLE *, D_IVECTOR > value_t
Definition value.h:54
std::ranges::range_reference_t< const C > element(const C &c)
Definition random.h:114
Definition interval.h:37