33 std::generate(genome_.begin(), genome_.end(),
36 return p.sset.roulette_terminal(n++).init();
55 for (
const auto &g : genome_)
56 s <<
"g [label=" << g <<
", shape=circle];";
72 std::copy(de.
begin(), de.
end(), infix_iterator<i_de::value_type>(s,
" "));
107 Expects(0.0 <= p && p <= 1.0);
117 const auto rf(random::in(f));
121 for (
auto i(
decltype(ps){0}); i < ps - 1; ++i)
122 if (random::boolean(p))
123 ret[i] += rf * (a[i] - b[i]);
125 ret[i] = operator[](i);
126 ret[ps - 1] += rf * (a[ps - 1] - b[ps - 1]);
128 ret.set_older_age(std::max({age(), a.age(), b.age()}));
130 ret.signature_.
clear();
142 if (signature_.
empty())
157 const auto len(genome_.size() *
sizeof(genome_[0]));
175 for (
unsigned i(0); i < cs; ++i)
176 d += std::fabs(lhs[i] - rhs[i]);
204 if (!genome_.empty())
206 vitaERROR <<
"Inconsistent internal status for empty individual";
210 if (!signature_.
empty())
212 vitaERROR <<
"Empty individual must have empty signature";
219 if (!signature_.
empty() && signature_ !=
hash())
221 vitaERROR <<
"Wrong signature: " << signature_ <<
" should be " <<
hash();
236bool i_de::load_impl(std::istream &in,
const symbol_set &)
242 decltype(genome_) v(sz);
244 if (!load_float_from_stream(in, &g))
256bool i_de::save_impl(std::ostream &
out)
const
259 for (
const auto &v : genome_)
261 save_float_to_stream(
out, v);
277 return in_line(ind, s);
286i_de::operator std::vector<i_de::value_type>()
const
An individual optimized for differential evolution.
std::ostream & operator<<(std::ostream &s, const i_de &ind)
std::ostream & in_line(const i_de &de, std::ostream &s)
Prints the genes of the individual.
std::size_t parameters() const
void graphviz(std::ostream &) const
Inserts into the output stream the graph representation of the individual.
const_iterator begin() const
i_de crossover(double, const range_t< double > &, const i_de &, const i_de &, const i_de &) const
Differential evolution crossover.
const_iterator end() const
i_de & operator=(const std::vector< value_type > &)
Sets up the individual with values from a vector.
A single member of a population.
MurmurHash3 (https://github.com/aappleby/smhasher) by Austin Appleby.
static hash_t hash128(const void *const, std::size_t, std::uint32_t=1973)
Hashes a single message in one call, return 128-bit output.
Aggregates the problem-related data needed by an evolutionary program.
A container for the symbols used by the GP engine.
Contains flags and manipulators to control the output format of individuals.
The main namespace for the project.
std::pair< T, T > range_t
Right-open interval.
A 128bit unsigned integer used as individual's signature / hash table look-up key.
bool empty() const
We assume that a string of 128 zero bits means empty.
void clear()
Resets the content of the object.