Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
Partition.h
Go to the documentation of this file.
1#ifndef STORM_STORAGE_BISIMULATION_PARTITION_H_
2#define STORM_STORAGE_BISIMULATION_PARTITION_H_
3
4#include <cstddef>
5#include <list>
6#include <memory>
7
9
11
12namespace storm {
13namespace storage {
14namespace bisimulation {
15
16template<typename DataType>
17class Partition {
18 public:
24 Partition(std::size_t numberOfStates);
25
38 Partition(std::size_t numberOfStates, storm::storage::BitVector const& prob0States, storm::storage::BitVector const& prob1States,
39 boost::optional<storm::storage::sparse::state_type> representativeProb1State);
40
41 Partition() = default;
42 Partition(Partition const& other) = default;
43 Partition& operator=(Partition const& other) = default;
44 Partition(Partition&& other) = default;
45 Partition& operator=(Partition&& other) = default;
46
47 // Retrieves the size of the partition, i.e. the number of blocks.
48 std::size_t size() const;
49
50 // Prints the partition to the standard output.
51 void print() const;
52
53 // Splits the block at the given position and inserts a new block after the current one holding the rest
54 // of the states.
55 std::pair<typename std::vector<std::unique_ptr<Block<DataType>>>::iterator, bool> splitBlock(Block<DataType>& block,
57
58 // Sorts the given range of the partitition according to the given order.
60 std::function<bool(storm::storage::sparse::state_type, storm::storage::sparse::state_type)> const& less, bool updatePositions = true);
61
62 // Sorts the block according to the given order.
64 bool updatePositions = true);
65
66 // Computes the start indices of equal ranges within the given range wrt. to the given less function.
67 std::vector<uint_fast64_t> computeRangesOfEqualValue(
68 uint_fast64_t startIndex, uint_fast64_t endIndex,
70
71 // Splits the block by sorting the states according to the given function and then identifying the split
72 // points. The callback function is called for every newly created block.
74 std::function<void(Block<DataType>&)> const& newBlockCallback);
75
76 // Splits the block by sorting the states according to the given function and then identifying the split
77 // points.
79
80 // Splits all blocks by using the sorting-based splitting. The callback is called for all newly created
81 // blocks.
83 std::function<void(Block<DataType>&)> const& newBlockCallback);
84
85 // Splits all blocks by using the sorting-based splitting.
87
88 // Splits the block such that the resulting blocks contain only states in the given set or none at all.
89 // If the block is split, the given block will contain the states *not* in the given set and the newly
90 // created block will contain the states *in* the given set.
91 void splitStates(Block<DataType>& block, storm::storage::BitVector const& states);
92
97 void splitStates(storm::storage::BitVector const& states);
98
99 // Sorts the block based on the state indices.
100 void sortBlock(Block<DataType> const& block);
101
102 // Retrieves the blocks of the partition.
103 std::vector<std::unique_ptr<Block<DataType>>> const& getBlocks() const;
104
105 // Retrieves the blocks of the partition.
106 std::vector<std::unique_ptr<Block<DataType>>>& getBlocks();
107
108 // Checks the partition for internal consistency.
109 bool check() const;
110
111 // Returns an iterator to the beginning of the states of the given block.
112 std::vector<storm::storage::sparse::state_type>::iterator begin(Block<DataType> const& block);
113
114 // Returns an iterator to the beginning of the states of the given block.
115 std::vector<storm::storage::sparse::state_type>::const_iterator begin(Block<DataType> const& block) const;
116
117 // Returns an iterator to the beginning of the states of the given block.
118 std::vector<storm::storage::sparse::state_type>::iterator end(Block<DataType> const& block);
119
120 // Returns an iterator to the beginning of the states of the given block.
121 std::vector<storm::storage::sparse::state_type>::const_iterator end(Block<DataType> const& block) const;
122
123 // Returns an iterator to the beginning of the states in the partition.
124 std::vector<storm::storage::sparse::state_type>::iterator begin();
125
126 // Returns an iterator to the beginning of the states in the partition.
127 std::vector<storm::storage::sparse::state_type>::const_iterator begin() const;
128
129 // Returns an iterator to the end of the states in the partition.
130 std::vector<storm::storage::sparse::state_type>::iterator end();
131
132 // Returns an iterator to the end of the states in the partition.
133 std::vector<storm::storage::sparse::state_type>::const_iterator end() const;
134
135 // Swaps the positions of the two given states.
137
138 // Retrieves the block of the given state.
140
141 // Retrieves the block of the given state.
143
144 // Retrieves the position of the given state.
146
147 // Sets the position of the state to the given position.
149
150 // Updates the block mapping for the given range of states to the specified block.
151 void mapStatesToBlock(Block<DataType>& block, std::vector<storm::storage::sparse::state_type>::iterator first,
152 std::vector<storm::storage::sparse::state_type>::iterator last);
153
154 // Update the state to position for the states in the given block.
155 void mapStatesToPositions(Block<DataType> const& block);
156
157 // Update the state to position for the states in the given range.
158 void mapStatesToPositions(std::vector<storm::storage::sparse::state_type>::const_iterator first,
159 std::vector<storm::storage::sparse::state_type>::const_iterator last);
160
161 // Swaps the positions of the two states given by their positions.
163
164 private:
165 // The of blocks in the partition.
166 std::vector<std::unique_ptr<Block<DataType>>> blocks;
167
168 // A mapping of states to their blocks.
169 std::vector<Block<DataType>*> stateToBlockMapping;
170
171 // A vector containing all the states. It is ordered in a way such that the blocks only need to define
172 // their start/end indices.
173 std::vector<storm::storage::sparse::state_type> states;
174
175 // This vector keeps track of the position of each state in the state vector.
176 std::vector<storm::storage::sparse::state_type> positions;
177};
178} // namespace bisimulation
179} // namespace storage
180} // namespace storm
181
182#endif /* STORM_STORAGE_BISIMULATION_PARTITION_H_ */
A bit vector that is internally represented as a vector of 64-bit values.
Definition BitVector.h:18
void sortRange(storm::storage::sparse::state_type beginIndex, storm::storage::sparse::state_type endIndex, std::function< bool(storm::storage::sparse::state_type, storm::storage::sparse::state_type)> const &less, bool updatePositions=true)
storm::storage::sparse::state_type const & getPosition(storm::storage::sparse::state_type state) const
Definition Partition.cpp:90
std::pair< typename std::vector< std::unique_ptr< Block< DataType > > >::iterator, bool > splitBlock(Block< DataType > &block, storm::storage::sparse::state_type position)
Block< DataType > & getBlock(storm::storage::sparse::state_type state)
storm::storage::sparse::state_type const & getState(storm::storage::sparse::state_type position) const
Definition Partition.cpp:95
void sortBlock(Block< DataType > &block, std::function< bool(storm::storage::sparse::state_type, storm::storage::sparse::state_type)> const &less, bool updatePositions=true)
void splitStates(Block< DataType > &block, storm::storage::BitVector const &states)
void mapStatesToPositions(Block< DataType > const &block)
Partition(Partition const &other)=default
Partition & operator=(Partition &&other)=default
void swapStates(storm::storage::sparse::state_type state1, storm::storage::sparse::state_type state2)
Definition Partition.cpp:75
std::vector< std::unique_ptr< Block< DataType > > > const & getBlocks() const
Partition & operator=(Partition const &other)=default
Partition(Partition &&other)=default
bool split(std::function< bool(storm::storage::sparse::state_type, storm::storage::sparse::state_type)> const &less, std::function< void(Block< DataType > &)> const &newBlockCallback)
std::vector< storm::storage::sparse::state_type >::iterator begin()
void mapStatesToBlock(Block< DataType > &block, std::vector< storm::storage::sparse::state_type >::iterator first, std::vector< storm::storage::sparse::state_type >::iterator last)
void swapStatesAtPositions(storm::storage::sparse::state_type position1, storm::storage::sparse::state_type position2)
Definition Partition.cpp:81
std::vector< storm::storage::sparse::state_type >::iterator end()
std::vector< uint_fast64_t > computeRangesOfEqualValue(uint_fast64_t startIndex, uint_fast64_t endIndex, std::function< bool(storm::storage::sparse::state_type, storm::storage::sparse::state_type)> const &less)
LabParser.cpp.
Definition cli.cpp:18