Storm
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
52uint_fast64_t ChoiceOrigins::getNumberOfChoices() const {
53 return indexToIdentifier.size();
54}
55
57 return 0;
58}
59
60std::string const& ChoiceOrigins::getIdentifierInfo(uint_fast64_t identifier) const {
61 STORM_LOG_ASSERT(identifier < this->getNumberOfIdentifiers(), "Invalid choice origin identifier: " << identifier);
62 if (identifierToInfo.empty()) {
64 }
65 return identifierToInfo[identifier];
66}
67
68std::string const& ChoiceOrigins::getChoiceInfo(uint_fast64_t choiceIndex) const {
69 return getIdentifierInfo(getIdentifier(choiceIndex));
70}
71
72typename ChoiceOrigins::Json const& ChoiceOrigins::getIdentifierAsJson(uint_fast64_t identifier) const {
73 STORM_LOG_ASSERT(identifier < this->getNumberOfIdentifiers(), "Invalid choice origin identifier: " << identifier);
74 if (identifierToJson.empty()) {
76 }
77 return identifierToJson[identifier];
78}
79
80typename ChoiceOrigins::Json const& ChoiceOrigins::getChoiceAsJson(uint_fast64_t choiceIndex) const {
81 return getIdentifierAsJson(getIdentifier(choiceIndex));
82}
83
84std::shared_ptr<ChoiceOrigins> ChoiceOrigins::selectChoices(storm::storage::BitVector const& selectedChoices) const {
85 std::vector<uint_fast64_t> indexToIdentifierMapping(selectedChoices.getNumberOfSetBits());
86 storm::utility::vector::selectVectorValues(indexToIdentifierMapping, selectedChoices, indexToIdentifier);
87 return cloneWithNewIndexToIdentifierMapping(std::move(indexToIdentifierMapping));
88}
89
90void ChoiceOrigins::clearOriginOfChoice(uint_fast64_t choiceIndex) {
92}
93
94std::shared_ptr<ChoiceOrigins> ChoiceOrigins::selectChoices(std::vector<uint_fast64_t> const& selectedChoices) const {
95 std::vector<uint_fast64_t> indexToIdentifierMapping;
96 indexToIdentifierMapping.reserve(selectedChoices.size());
97 for (auto const& selectedChoice : selectedChoices) {
98 if (selectedChoice < this->indexToIdentifier.size()) {
99 indexToIdentifierMapping.push_back(indexToIdentifier[selectedChoice]);
100 } else {
101 indexToIdentifierMapping.push_back(getIdentifierForChoicesWithNoOrigin());
102 }
103 }
104 return cloneWithNewIndexToIdentifierMapping(std::move(indexToIdentifierMapping));
105}
106
109 for (uint_fast64_t identifier = 0; identifier < this->getNumberOfIdentifiers(); ++identifier) {
110 storm::storage::BitVector choicesWithIdentifier =
111 storm::utility::vector::filter<uint_fast64_t>(indexToIdentifier, [&identifier](uint_fast64_t i) -> bool { return i == identifier; });
112 if (!choicesWithIdentifier.empty()) {
113 result.addLabel(getIdentifierInfo(identifier), std::move(choicesWithIdentifier));
114 }
115 }
116 return result;
117}
118} // namespace sparse
119} // namespace storage
120} // 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:18
bool empty() const
Retrieves whether no bits are set to true in this bit vector.
uint_fast64_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::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:11
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:189
LabParser.cpp.
Definition cli.cpp:18