Storm 1.14.0.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
ChoiceOrigins.cpp
Go to the documentation of this file.
2
4
8
10
11namespace storm {
12namespace storage {
13namespace sparse {
14
15ChoiceOrigins::ChoiceOrigins(std::vector<uint_fast64_t> const& indexToIdentifierMapping) : indexToIdentifier(indexToIdentifierMapping) {
16 // Intentionally left empty
17}
18
19ChoiceOrigins::ChoiceOrigins(std::vector<uint_fast64_t>&& indexToIdentifierMapping) : indexToIdentifier(std::move(indexToIdentifierMapping)) {
20 // Intentionally left empty
21}
22
24 return false;
25}
26
28 return false;
29}
30
34
36 return dynamic_cast<PrismChoiceOrigins const&>(*this);
37}
38
42
44 return dynamic_cast<JaniChoiceOrigins const&>(*this);
45}
46
47uint_fast64_t ChoiceOrigins::getIdentifier(uint_fast64_t choiceIndex) const {
48 STORM_LOG_ASSERT(choiceIndex < indexToIdentifier.size(), "Invalid choice index: " << choiceIndex);
49 return indexToIdentifier[choiceIndex];
50}
51
52std::vector<uint_fast64_t> const& ChoiceOrigins::getIdentifiers() const {
53 return indexToIdentifier;
54}
55
56uint_fast64_t ChoiceOrigins::getNumberOfChoices() const {
57 return indexToIdentifier.size();
58}
59
61 return 0;
62}
63
64std::string const& ChoiceOrigins::getIdentifierInfo(uint_fast64_t identifier) const {
65 STORM_LOG_ASSERT(identifier < this->getNumberOfIdentifiers(), "Invalid choice origin identifier: " << identifier);
66 if (identifierToInfo.empty()) {
68 }
69 return identifierToInfo[identifier];
70}
71
72std::string const& ChoiceOrigins::getChoiceInfo(uint_fast64_t choiceIndex) const {
73 return getIdentifierInfo(getIdentifier(choiceIndex));
74}
75
76typename ChoiceOrigins::Json const& ChoiceOrigins::getIdentifierAsJson(uint_fast64_t identifier) const {
77 STORM_LOG_ASSERT(identifier < this->getNumberOfIdentifiers(), "Invalid choice origin identifier: " << identifier);
78 if (identifierToJson.empty()) {
80 }
81 return identifierToJson[identifier];
82}
83
84typename ChoiceOrigins::Json const& ChoiceOrigins::getChoiceAsJson(uint_fast64_t choiceIndex) const {
85 return getIdentifierAsJson(getIdentifier(choiceIndex));
86}
87
88std::shared_ptr<ChoiceOrigins> ChoiceOrigins::selectChoices(storm::storage::BitVector const& selectedChoices) const {
89 std::vector<uint_fast64_t> indexToIdentifierMapping(selectedChoices.getNumberOfSetBits());
90 storm::utility::vector::selectVectorValues(indexToIdentifierMapping, selectedChoices, indexToIdentifier);
91 return cloneWithNewIndexToIdentifierMapping(std::move(indexToIdentifierMapping));
92}
93
94void ChoiceOrigins::clearOriginOfChoice(uint_fast64_t choiceIndex) {
96}
97
98std::shared_ptr<ChoiceOrigins> ChoiceOrigins::selectChoices(std::vector<uint_fast64_t> const& selectedChoices) const {
99 std::vector<uint_fast64_t> indexToIdentifierMapping;
100 indexToIdentifierMapping.reserve(selectedChoices.size());
101 for (auto const& selectedChoice : selectedChoices) {
102 if (selectedChoice < this->indexToIdentifier.size()) {
103 indexToIdentifierMapping.push_back(indexToIdentifier[selectedChoice]);
104 } else {
105 indexToIdentifierMapping.push_back(getIdentifierForChoicesWithNoOrigin());
106 }
107 }
108 return cloneWithNewIndexToIdentifierMapping(std::move(indexToIdentifierMapping));
109}
110
113 for (uint_fast64_t identifier = 0; identifier < this->getNumberOfIdentifiers(); ++identifier) {
114 storm::storage::BitVector choicesWithIdentifier =
115 storm::utility::vector::filter<uint_fast64_t>(indexToIdentifier, [&identifier](uint_fast64_t i) -> bool { return i == identifier; });
116 if (!choicesWithIdentifier.empty()) {
117 result.addLabel(getIdentifierInfo(identifier), std::move(choicesWithIdentifier));
118 }
119 }
120 return result;
121}
122} // namespace sparse
123} // namespace storage
124} // namespace storm
This class manages the labeling of the choice space with a number of (atomic) labels.
void addLabel(std::string const &label)
Adds a new label to the labelings.
A bit vector that is internally represented as a vector of 64-bit values.
Definition BitVector.h:16
bool empty() const
Retrieves whether no bits are set to true in this bit vector.
uint64_t getNumberOfSetBits() const
Returns the number of bits that are set to true in this bit vector.
virtual std::shared_ptr< ChoiceOrigins > cloneWithNewIndexToIdentifierMapping(std::vector< uint_fast64_t > &&indexToIdentifierMapping) const =0
std::vector< uint_fast64_t > indexToIdentifier
virtual uint_fast64_t getNumberOfIdentifiers() const =0
std::string const & getChoiceInfo(uint_fast64_t choiceIndex) const
void clearOriginOfChoice(uint_fast64_t choiceIndex)
virtual void computeIdentifierInfos() const =0
uint_fast64_t getIdentifier(uint_fast64_t choiceIndex) const
JaniChoiceOrigins & asJaniChoiceOrigins()
virtual void computeIdentifierJson() const =0
storm::models::sparse::ChoiceLabeling toChoiceLabeling() const
PrismChoiceOrigins & asPrismChoiceOrigins()
std::vector< std::string > identifierToInfo
static uint_fast64_t getIdentifierForChoicesWithNoOrigin()
storm::json< storm::RationalNumber > Json
std::shared_ptr< ChoiceOrigins > selectChoices(storm::storage::BitVector const &selectedChoices) const
ChoiceOrigins(std::vector< uint_fast64_t > const &indexToIdentifierMapping)
Json const & getChoiceAsJson(uint_fast64_t choiceIndex) const
Json const & getIdentifierAsJson(uint_fast64_t identifier) const
std::vector< uint_fast64_t > const & getIdentifiers() const
std::string const & getIdentifierInfo(uint_fast64_t identifier) const
This class represents for each choice the origin in the jani specification // TODO complete this.
This class represents for each choice the set of prism commands that induced the choice.
#define STORM_LOG_ASSERT(cond, message)
Definition macros.h:9
storm::storage::BitVector filter(std::vector< T > const &values, std::function< bool(T const &value)> const &function)
Retrieves a bit vector containing all the indices for which the value at this position makes the give...
Definition vector.h:487
void selectVectorValues(std::vector< T > &vector, storm::storage::BitVector const &positions, std::vector< T > const &values)
Selects the elements from a vector at the specified positions and writes them consecutively into anot...
Definition vector.h:185