|
Storm 1.14.0.1
A Modern Probabilistic Model Checker
|
Represents a partition of a set of consecutive indices. More...
#include <Partition.h>
Classes | |
| struct | BlockCompare |
| Orders blocks by their size (ascending) and, for equally sized blocks, by their location in memory. More... | |
| class | NonSuperBlockSet |
| Set of blocks that are no proper superblock. More... | |
Public Types | |
| using | ElementIndex = uint64_t |
| The type used to index the elements of the partition. | |
| using | Block = std::span<ElementIndex const> |
| A contiguous range of elements that form a (possibly proper super-) block of the partition. | |
| using | OrderedBlockSet = std::set<Block, BlockCompare> |
| A set of blocks, ordered by their size (smallest first). | |
| template<typename T> | |
| using | OrderedBlockMap = std::map<Block, T, BlockCompare> |
| A map of blocks, ordered by their size (smallest first). | |
Public Member Functions | |
| Partition ()=default | |
| Partition (Partition const &other)=default | |
| Partition & | operator= (Partition const &other)=default |
| Partition (Partition &&other) noexcept=default | |
| Partition & | operator= (Partition &&other)=default |
| Partition (ElementIndex numElements) | |
| Creates the partition { {0,1,...,numElements-1} } with a single block that contains all elements. | |
| std::size_t | getNumberOfBlocks () const |
| Retrieves the number of blocks. | |
| std::size_t | getNumberOfElements () const |
| Retrieves the number of elements. | |
| Block | getUniversalBlock () const |
| Block | getBlockOfElement (ElementIndex element) const |
| bool | contains (Block const &block, ElementIndex element) const |
| bool | isSubBlockOf (Block const &subblock, Block const &superblock) const |
| bool | isEqualBlock (Block const &lhs, Block const &rhs) const |
| bool | isSameBlock (ElementIndex const &element1, ElementIndex const &element2) const |
| bool | isBlockOfElement (Block const &block, ElementIndex const &element) const |
| bool | checkBlockValidity (Block const &block) const |
| Checks if the given block is a valid block in the partition. | |
| bool | isProperSuperBlock (Block const &block) const |
| template<typename Func> requires std::invocable<Func, Block> | |
| void | forEachBlock (Func const &f) const |
| Applies the given function on each block in the partition. | |
| template<typename Func> requires std::invocable<Func, Block> | |
| void | forEachSubBlock (Block const &superBlock, Func const &f) const |
| Applies the given function on each block in the given super block. | |
| template<typename SplittingOrder> requires std::invocable<SplittingOrder, ElementIndex, ElementIndex> | |
| bool | splitBlockByOrder (Block const &block, SplittingOrder const &less) |
| Splits the given block according to the given order. | |
| template<typename Order, typename Condition> requires std::invocable<Order, ElementIndex, ElementIndex> && std::invocable<Condition, ElementIndex, ElementIndex> | |
| bool | splitBlockByOrder (Block const &block, Order const &less, Condition const &splitCondition) |
| Splits the given block according to the given order and splitting condition. | |
| template<typename Condition> requires std::invocable<Condition, ElementIndex, ElementIndex> | |
| bool | splitBlockByClustering (Block const &block, Condition const &condition) |
| Splits the given block by anchor-based clustering: repeatedly picks the first not-yet-grouped element as the anchor of a new group, moves every remaining not-yet-grouped element e with !condition(anchor, e) into that group (wherever it currently sits in the block), and finalizes the group once no more such elements remain; then continues with the next not-yet-grouped element as the next anchor. | |
| template<typename SplittingPredicate> requires std::predicate<SplittingPredicate, ElementIndex> | |
| std::pair< Block, Block > | splitBlockByPredicate (Block const &block, SplittingPredicate const &f) |
| Splits the given block according to the given predicate. | |
| template<typename SplitRange> requires std::ranges::input_range<std::remove_reference_t<SplitRange>> && std::same_as<std::ranges::range_value_t<std::remove_reference_t<SplitRange>>, ElementIndex> | |
| std::pair< Block, Block > | splitBlockByRange (Block const &block, SplitRange &&r) |
| Splits the given block according to the given range of elements. | |
Represents a partition of a set of consecutive indices.
Allows efficient access to the blocks of the partition and the elements in each block. Memory is cache-friendly and linear in the number of elements (independent of block count). The downside is that merging blocks is not supported.
Definition at line 20 of file Partition.h.
| using storm::bisimulation::Partition::Block = std::span<ElementIndex const> |
A contiguous range of elements that form a (possibly proper super-) block of the partition.
Note: Splitting a block changes the order of the contained elements.
Definition at line 27 of file Partition.h.
| using storm::bisimulation::Partition::ElementIndex = uint64_t |
The type used to index the elements of the partition.
Definition at line 23 of file Partition.h.
| using storm::bisimulation::Partition::OrderedBlockMap = std::map<Block, T, BlockCompare> |
A map of blocks, ordered by their size (smallest first).
Definition at line 54 of file Partition.h.
| using storm::bisimulation::Partition::OrderedBlockSet = std::set<Block, BlockCompare> |
A set of blocks, ordered by their size (smallest first).
Definition at line 48 of file Partition.h.
|
default |
|
default |
|
defaultnoexcept |
|
explicit |
Creates the partition { {0,1,...,numElements-1} } with a single block that contains all elements.
| numElements | the number of elements. Must be positive. |
Definition at line 51 of file Partition.cpp.
| bool storm::bisimulation::Partition::checkBlockValidity | ( | Block const & | block | ) | const |
Checks if the given block is a valid block in the partition.
Useful for sanity checks (e.g. via assertions). Does not assert itself.
Definition at line 134 of file Partition.cpp.
| bool storm::bisimulation::Partition::contains | ( | Block const & | block, |
| ElementIndex | element ) const |
Definition at line 79 of file Partition.cpp.
|
inline |
Applies the given function on each block in the partition.
Definition at line 184 of file Partition.h.
|
inline |
Applies the given function on each block in the given super block.
For example, if superBlock = {0,1,2,3,4} and the partition currently has blocks {{0}, {1,2,3}, {4}, ...}, the function will be called with the blocks {0}, {1,2,3}, and {4}.
Definition at line 196 of file Partition.h.
| Partition::Block storm::bisimulation::Partition::getBlockOfElement | ( | ElementIndex | element | ) | const |
Definition at line 74 of file Partition.cpp.
| std::size_t storm::bisimulation::Partition::getNumberOfBlocks | ( | ) | const |
Retrieves the number of blocks.
Only counts those blocks that do not contain other (smaller) blocks
Definition at line 61 of file Partition.cpp.
| std::size_t storm::bisimulation::Partition::getNumberOfElements | ( | ) | const |
Retrieves the number of elements.
Definition at line 66 of file Partition.cpp.
| Partition::Block storm::bisimulation::Partition::getUniversalBlock | ( | ) | const |
Definition at line 70 of file Partition.cpp.
| bool storm::bisimulation::Partition::isBlockOfElement | ( | Block const & | block, |
| ElementIndex const & | element ) const |
Definition at line 103 of file Partition.cpp.
Definition at line 91 of file Partition.cpp.
| bool storm::bisimulation::Partition::isProperSuperBlock | ( | Block const & | block | ) | const |
Definition at line 185 of file Partition.cpp.
| bool storm::bisimulation::Partition::isSameBlock | ( | ElementIndex const & | element1, |
| ElementIndex const & | element2 ) const |
Definition at line 97 of file Partition.cpp.
| bool storm::bisimulation::Partition::isSubBlockOf | ( | Block const & | subblock, |
| Block const & | superblock ) const |
Definition at line 84 of file Partition.cpp.
|
inline |
Splits the given block by anchor-based clustering: repeatedly picks the first not-yet-grouped element as the anchor of a new group, moves every remaining not-yet-grouped element e with !condition(anchor, e) into that group (wherever it currently sits in the block), and finalizes the group once no more such elements remain; then continues with the next not-yet-grouped element as the next anchor.
Unlike splitBlockByOrder, this does not require condition to be consistent with any (total or weak) order over the block's elements.
| condition | returns true for pairs of elements that should not be in the same block; only ever invoked with the (still not-yet-grouped) anchor of the group currently being built as the first argument. |
Definition at line 288 of file Partition.h.
|
inline |
Splits the given block according to the given order and splitting condition.
Specifically, the elements in the block are first sorted according to the given order resulting in a (sorted) block [e_0, e_1, e_2, ..., e_m]. Then, indices i_0, i_1, ..., i_k are determined such that
| less | must define a strict weak order (required for well-defined sorting) |
| splitCondition | returns true for elements that should not be in the same block as explained above |
Definition at line 232 of file Partition.h.
|
inline |
Splits the given block according to the given order.
Specifically, the elements in the block are sorted according to the given order and then the block is split into multiple blocks, divided at every position where the order changes.
| less | must define a strict weak order (required for well-defined sorting) |
Definition at line 215 of file Partition.h.
|
inline |
Splits the given block according to the given predicate.
Specifically, the elements in the block are swapped around, such that all elements where the predicate f evaluates to false come first. Then, two sub-blocks are created accordingly. If all elements are true/false, no splitting is performed.
Definition at line 329 of file Partition.h.
|
inline |
Splits the given block according to the given range of elements.
Specifically, the elements in the block are swapped around, such that all elements that are not in the given range come first. Then, two sub-blocks are created accordingly. If the range is empty or contains all elements of the block, no splitting is performed.
| r | the input range. |
Definition at line 362 of file Partition.h.