Permutation generator.
More...
|
| | permutation (int size) |
| | Creates permutation generator defined by size.
|
| permutation & | fix (int idx, int value) |
| | Restricts generator s.t. value at index is fixed.
|
| permutation & | cycles (const std::vector< int > &cycle_sizes) |
| | Restricts generator s.t. cycle sizes are fixed.
|
| instance | gen () const |
| | Generates a random instance from the set of valid permutations.
|
| auto | gen_list (int size, Args &&...args) const |
| | Generates a list of several generation calls.
|
| auto | gen_until (Pred predicate, int max_tries, Args &&...args) const |
| | Generates a random instance from the valid set until a condition is met.
|
| auto | unique (Args &&...args) const |
| | Creates unique generator for current generator.
|
Permutation generator.
Defines a set of permutations, subject to restrictions.
A uniformly random tgen::permutation::instance from this set of permutations (that satisfies the restrictions) can be generated with tgen::permutation::gen.
Definition at line 1642 of file tgen.h.
◆ permutation()
| tgen::permutation::permutation |
( |
int | size | ) |
|
|
inline |
Creates permutation generator defined by size.
- Parameters
-
| size | Size of the permutation. |
Examples
Definition at line 1648 of file tgen.h.
◆ cycles()
| permutation & tgen::permutation::cycles |
( |
const std::vector< int > & | cycle_sizes | ) |
|
|
inline |
Restricts generator s.t. cycle sizes are fixed.
- Parameters
-
| cycle_sizes | Sizes of cycles. |
The sizes of cycles of the generated permuttion will be cycle_sizes.
Examples
permutation & cycles(const std::vector< int > &cycle_sizes)
Restricts generator s.t. cycle sizes are fixed.
instance gen() const
Generates a random instance from the set of valid permutations.
Definition at line 1661 of file tgen.h.
◆ fix()
| permutation & tgen::permutation::fix |
( |
int | idx, |
|
|
int | value ) |
|
inline |
Restricts generator s.t. value at index is fixed.
- Parameters
-
Examples
permutation & fix(int idx, int value)
Restricts generator s.t. value at index is fixed.
Definition at line 1653 of file tgen.h.
◆ gen()
| instance tgen::permutation::gen |
( |
| ) |
const |
|
inline |
Generates a random instance from the set of valid permutations.
- Returns
- A uniformly random tgen::permutation::instance from the set of valid permutations, given the added restrictions.
- Exceptions
-
| std::runtime_error | if there is no valid permutation satisfying all added restrictions. |
Complexity
O(n).
Examples
std::cout << inst << std::endl;
Definition at line 1783 of file tgen.h.
The documentation for this struct was generated from the following files:
- /home/runner/work/tgen/tgen/single_include/tgen.h
- permutation.dox