Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
ItemLabeling.h
Go to the documentation of this file.
1#pragma once
2
3#include <iostream>
4#include <set>
5#include <string>
6#include <unordered_map>
7
10
11namespace storm {
12namespace models {
13namespace sparse {
14
15class StateLabeling;
16class ChoiceLabeling;
17
22 public:
28 explicit ItemLabeling(uint64_t itemCount = 0);
29
30 ItemLabeling(ItemLabeling const& other) = default;
31 ItemLabeling& operator=(ItemLabeling const& other) = default;
32
33 virtual ~ItemLabeling() = default;
34
35 virtual bool isStateLabeling() const;
36 virtual bool isChoiceLabeling() const;
37
38 StateLabeling const& asStateLabeling() const;
40 ChoiceLabeling const& asChoiceLabeling() const;
42
49 bool operator==(ItemLabeling const& other) const;
50
56 void addLabel(std::string const& label);
57
63 void removeLabel(std::string const& label);
64
70 std::set<std::string> getLabels() const;
71
79 void addLabel(std::string const& label, storage::BitVector const& labeling);
80
88 void addLabel(std::string const& label, storage::BitVector&& labeling);
89
99 std::string addUniqueLabel(std::string const& prefix, storage::BitVector const& labeling);
100
110 std::string addUniqueLabel(std::string const& prefix, storage::BitVector const&& labeling);
111
117 void join(ItemLabeling const& other);
118
124 bool containsLabel(std::string const& label) const;
125
131 std::size_t getNumberOfLabels() const;
132
138 std::size_t getNumberOfItems() const;
139
140 void permuteItems(std::vector<uint64_t> const& inversePermutation);
141
142 virtual std::size_t hash() const;
143
149 void printLabelingInformationToStream(std::ostream& out = std::cout) const;
150
156 void printCompleteLabelingInformationToStream(std::ostream& out = std::cout) const;
157
158 friend std::ostream& operator<<(std::ostream& out, ItemLabeling const& labeling);
159
160 protected:
167
174 virtual std::set<std::string> getLabelsOfItem(uint64_t item) const;
175
183 virtual bool getItemHasLabel(std::string const& label, uint64_t item) const;
184
191 virtual storm::storage::BitVector const& getItems(std::string const& label) const;
192
199 virtual void setItems(std::string const& label, storage::BitVector const& labeling);
200
207 virtual void setItems(std::string const& label, storage::BitVector&& labeling);
208
215 virtual void addLabelToItem(std::string const& label, uint64_t item);
216
223 virtual void removeLabelFromItem(std::string const& label, uint64_t item);
224
225 // The number of items for which this object can hold the labeling.
226 uint64_t itemCount;
227
228 // A mapping from labels to the index of the corresponding bit vector in the vector.
229 std::unordered_map<std::string, uint64_t> nameToLabelingIndexMap;
230
231 // A vector that holds the labeling for all known labels.
232 std::vector<storm::storage::BitVector> labelings;
233
237 std::string generateUniqueLabel(const std::string& prefix) const;
238};
239
240} // namespace sparse
241} // namespace models
242} // namespace storm
This class manages the labeling of the choice space with a number of (atomic) labels.
A base class managing the labeling of items with a number of (atomic) labels.
virtual std::size_t hash() const
virtual std::set< std::string > getLabelsOfItem(uint64_t item) const
Retrieves the set of labels attached to the given item.
virtual void setItems(std::string const &label, storage::BitVector const &labeling)
Sets the labeling of items associated with the given label.
std::string addUniqueLabel(std::string const &prefix, storage::BitVector const &labeling)
Creates a new label with a unique name, derived from the prefix, and attaches it to the given items.
std::set< std::string > getLabels() const
Retrieves the set of labels contained in this labeling.
ItemLabeling(uint64_t itemCount=0)
Constructs an empty labeling for the given number of items.
virtual bool isChoiceLabeling() const
virtual bool getItemHasLabel(std::string const &label, uint64_t item) const
Checks whether a given item is labeled with the given label.
void addLabel(std::string const &label)
Adds a new label to the labelings.
void permuteItems(std::vector< uint64_t > const &inversePermutation)
ChoiceLabeling const & asChoiceLabeling() const
ItemLabeling getSubLabeling(storm::storage::BitVector const &items) const
Retrieves the sub labeling that represents the same labeling as the current one for all selected item...
void join(ItemLabeling const &other)
Adds all labels from the other labeling to this labeling.
bool containsLabel(std::string const &label) const
Checks whether a label is registered within this labeling.
std::size_t getNumberOfItems() const
Returns the number of items managed by this object.
void removeLabel(std::string const &label)
Removes a label from the labelings.
void printCompleteLabelingInformationToStream(std::ostream &out=std::cout) const
Prints the complete labeling to the specified stream.
std::unordered_map< std::string, uint64_t > nameToLabelingIndexMap
StateLabeling const & asStateLabeling() const
ItemLabeling & operator=(ItemLabeling const &other)=default
virtual storm::storage::BitVector const & getItems(std::string const &label) const
Returns the labeling of items associated with the given label.
virtual void addLabelToItem(std::string const &label, uint64_t item)
Adds a label to a given item.
bool operator==(ItemLabeling const &other) const
Checks whether the two labelings are equal.
void printLabelingInformationToStream(std::ostream &out=std::cout) const
Prints information about the labeling to the specified stream.
std::vector< storm::storage::BitVector > labelings
virtual void removeLabelFromItem(std::string const &label, uint64_t item)
Removes a label from a given item.
std::size_t getNumberOfLabels() const
Returns the number of labels managed by this object.
std::string generateUniqueLabel(const std::string &prefix) const
Generate a unique, previously unused label from the given prefix string.
friend std::ostream & operator<<(std::ostream &out, ItemLabeling const &labeling)
ItemLabeling(ItemLabeling const &other)=default
This class manages the labeling of the state space with a number of (atomic) labels.
A bit vector that is internally represented as a vector of 64-bit values.
Definition BitVector.h:18
LabParser.cpp.
Definition cli.cpp:18