Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
SubsetEnumerator.h
Go to the documentation of this file.
1#ifndef STORM_STORAGE_GEOMETRY_NATIVEPOLYTOPECONVERSION_SUBSETENUMERATOR_H_
2#define STORM_STORAGE_GEOMETRY_NATIVEPOLYTOPECONVERSION_SUBSETENUMERATOR_H_
3
4#include <cstdint>
5#include <vector>
6
7namespace storm {
8namespace storage {
9namespace geometry {
22template<typename DataType = std::nullptr_t>
24 public:
25 // A typedef for the filter.
26 // Note that the function will be called with subset.size() in {0, ..., k-1}.
27 typedef bool (*SubsetFilter)(std::vector<uint_fast64_t> const& subset, uint_fast64_t const& item, DataType const& data);
28
29 /*
30 * Constructs a subset enumerator that can enumerate all k-sized Subsets of {0,...,n-1}
31 * The given filter can be used to skip certain subsets.
32 * @note call "setToFirstSubset()" before retrieving the first subset
33 */
34 SubsetEnumerator(uint_fast64_t n, uint_fast64_t k, DataType const& data = DataType(), SubsetFilter subsetFilter = trueFilter);
35
37
38 // returns the current subset of size k.
39 // Arbitrary behavior if setToFirstSubset or incrementSubset returned false or have never been executed
40 std::vector<uint_fast64_t> const& getCurrentSubset();
41
42 // Sets the current subset to the very first one.
43 // @note Needs to be called initially.
44 // Returns true iff there actually is a first subset and false if not (e.g. when n<k or the filter answers false in all cases).
45 bool setToFirstSubset();
46
47 // Increments the current subset.
48 // Returns true if there is a new subset and false if the current subset is already the last one.
49 bool incrementSubset();
50
51 // Default filter that returns always true.
52 static bool trueFilter(std::vector<uint_fast64_t> const& subset, uint_fast64_t const& item, DataType const& data);
53
54 private:
55 uint_fast64_t n; // the size of the source set
56 uint_fast64_t k; // the size of the desired subsets
57 DataType const& data; // The data which is given as additional information when invoking the filter
58 SubsetFilter filter; // returns true iff it is okay to insert a new element
59 std::vector<uint_fast64_t> current; // the current subset
60 std::vector<uint_fast64_t> upperBoundaries; // will always be [n-k, ..., n-1]. Used to easily check whether we can increment the subset at a given position
61};
62} // namespace geometry
63} // namespace storage
64} // namespace storm
65
66#endif /* STORM_STORAGE_GEOMETRY_NATIVEPOLYTOPECONVERSION_SUBSETENUMERATOR_H_ */
This class can be used to enumerate all k-sized subsets of {0,...,n-1}.
static bool trueFilter(std::vector< uint_fast64_t > const &subset, uint_fast64_t const &item, DataType const &data)
std::vector< uint_fast64_t > const & getCurrentSubset()
bool(* SubsetFilter)(std::vector< uint_fast64_t > const &subset, uint_fast64_t const &item, DataType const &data)
LabParser.cpp.
Definition cli.cpp:18