Generation of sequences.
More...
Generation of sequences.
Examples
Random 20 distinct values from 1 to 100.
std::cout <<
sequence & distinct(std::set< int > indices)
Restricts generator s.t. all values at index set are distinct.
instance gen() const
Generates a random instance from the set of valid sequences.
Random Palindrome of length 7.
for (int i = 0; i <= 2; ++i) s.equal(i, 6-i);
std::cout << s.gen() << std::endl;
Random 3 runs of 4 equal numbers. Values between runs are distinct.
std::cout <<
.
distinct({0, 4, 8}).gen() << std::endl;
sequence & equal_range(int left, int right)
Restricts generator s.t. all values at index range are the same.
Random DNA sequence of length 8 with no equal adjacent values.
for (
int i = 1; i < 8; i++) s2.
different(i-1, i);
std::cout << s2.
gen() << std::endl;
sequence & different(int idx_1, int idx_2)
Restricts generator s.t. values at two indices are different.
Random binary sequence of length 10 with 5 1's that start with 1.
std::cout <<
auto vec = inst.to_std();
return accumulate(vec.begin(), vec.end(), 0) == 5;
}, 100) << std::endl;
instance gen_until(Pred predicate, int max_tries) const
Generates a random instance from the set of valid sequences until a condition is met.
sequence & set(int idx, T value)
Restricts generator s.t. value at index is fixed.