Class model::Partition
Partition state.
This implements a markov::State that is a partition of N elements into two sets (with the first one of size K). It is optimized for two operations:
- Querying whether a given number is in the first set 2) Swapping two random elements from different groups For this, two internal vectors of the respective elements are kept. These are NOT sorted and the class does not provide an interface to select a specific number to swap (they can only be selected by their index, while the current ordering is unknown).
Note
If you need more sets or don't want the respective set sizes to be fixed, the PottsState is likely a better candidate for your use case.
Constructors
Partition()
Create an uninitialized partition.
Declaration
model::Partition::Partition()
Methods
in_first()
query whether number
is in the first set.
Declaration
bool model::Partition::in_first(size_t number) const
swap_indices()
Swap the indices idx_first, idx_second The indices refer to the current (unsorted) internal list of the elements in the first and second set.
Declaration
void model::Partition::swap_indices(size_t idx_first, size_t idx_second)
render()
Render the two sets.
Declaration
utils::Structure model::Partition::render() const override
copy_state_only()
Declaration
void model::Partition::copy_state_only(const Partition&other)
random()
Generate a random partition of N elements with the first set of size K.
Declaration
Partition model::Partition::random(size_t N, size_t K, utils::RandomGenerator&rng)