Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
JaniChoiceOrigins.cpp
Go to the documentation of this file.
2
5
8
9namespace storm {
10namespace storage {
11namespace sparse {
12
13JaniChoiceOrigins::JaniChoiceOrigins(std::shared_ptr<storm::jani::Model const> const& janiModel, std::vector<uint_fast64_t> const& indexToIdentifierMapping,
14 std::vector<EdgeIndexSet> const& identifierToEdgeIndexSetMapping)
15 : ChoiceOrigins(indexToIdentifierMapping), model(janiModel), identifierToEdgeIndexSet(identifierToEdgeIndexSetMapping) {
16 STORM_LOG_THROW(identifierToEdgeIndexSet[this->getIdentifierForChoicesWithNoOrigin()].empty(), storm::exceptions::InvalidArgumentException,
17 "The given edge set for the choices without origin is non-empty");
18}
19
21 return true;
22}
23
25 return identifierToEdgeIndexSet.size();
26}
27
29 return *model;
30}
31
33 return identifierToEdgeIndexSet[this->getIdentifier(choiceIndex)];
34}
35
36std::shared_ptr<ChoiceOrigins> JaniChoiceOrigins::cloneWithNewIndexToIdentifierMapping(std::vector<uint_fast64_t>&& indexToIdentifierMapping) const {
37 auto result = std::make_shared<JaniChoiceOrigins>(this->model, std::move(indexToIdentifierMapping), std::move(identifierToEdgeIndexSet));
38 result->identifierToInfo = this->identifierToInfo;
39 return result;
40}
41
42void JaniChoiceOrigins::computeIdentifierInfos() const {
43 this->identifierToInfo.clear();
44 this->identifierToInfo.reserve(this->getNumberOfIdentifiers());
45
46 for (auto const& edgeSet : identifierToEdgeIndexSet) {
47 std::stringstream ss;
48
49 for (auto const& edgeIndex : edgeSet) {
50 auto autAndEdgeOffset = model->decodeAutomatonAndEdgeIndices(edgeIndex);
51 ss << model->getAutomaton(autAndEdgeOffset.first).getEdge(autAndEdgeOffset.second).toString();
52 ss << ",\n";
53 }
54 this->identifierToInfo.emplace_back(ss.str());
55 ss.clear();
56 }
57}
58
59void JaniChoiceOrigins::computeIdentifierJson() const {
60 this->identifierToJson.clear();
61 this->identifierToJson.reserve(this->getNumberOfIdentifiers());
62 for (auto const& set : identifierToEdgeIndexSet) {
63 Json setJson;
64 if (set.empty()) {
65 setJson = "No origin";
66 } else {
67 bool first = true;
68 std::vector<Json> edgesJson;
69 for (auto const& edgeIndex : set) {
70 auto autAndEdgeOffset = model->decodeAutomatonAndEdgeIndices(edgeIndex);
71 auto const& automaton = model->getAutomaton(autAndEdgeOffset.first);
72 auto const& edge = automaton.getEdge(autAndEdgeOffset.second);
73 if (first) {
74 setJson["action-label"] = model->getAction(edge.getActionIndex()).getName();
75 first = false;
76 }
77 edgesJson.push_back(storm::jani::JsonExporter::getEdgeAsJson(*model, autAndEdgeOffset.first, autAndEdgeOffset.second));
78 edgesJson.back()["automaton"] = automaton.getName();
79 }
80 setJson["transitions"] = std::move(edgesJson);
81 }
82 this->identifierToJson.push_back(std::move(setJson));
83 }
84}
85
86std::size_t JaniChoiceOrigins::hash() const {
87 return 0;
88}
89} // namespace sparse
90} // namespace storage
91} // namespace storm
static ExportJsonType getEdgeAsJson(storm::jani::Model const &janiModel, uint64_t automatonIndex, uint64_t edgeIndex, bool commentExpressions=true)
This class represents the origin of the choices of a model in terms of the input model specification ...
uint_fast64_t getIdentifier(uint_fast64_t choiceIndex) const
std::vector< std::string > identifierToInfo
static uint_fast64_t getIdentifierForChoicesWithNoOrigin()
storm::json< storm::RationalNumber > Json
storm::jani::Model const & getModel() const
Retrieves the associated JANI model.
virtual bool isJaniChoiceOrigins() const override
JaniChoiceOrigins(std::shared_ptr< storm::jani::Model const > const &janiModel, std::vector< uint_fast64_t > const &indexToIdentifierMapping, std::vector< EdgeIndexSet > const &identifierToEdgeIndexSetMapping)
Creates a new representation of the choice indices to their origin in the Jani specification.
storm::storage::FlatSet< uint_fast64_t > EdgeIndexSet
virtual uint_fast64_t getNumberOfIdentifiers() const override
EdgeIndexSet const & getEdgeIndexSet(uint_fast64_t choiceIndex) const
#define STORM_LOG_THROW(cond, exception, message)
Definition macros.h:30
LabParser.cpp.
Definition cli.cpp:18