Browse Source

Convenience function in model and automaton, building explicit mappings (independent of implementation)

Former-commit-id: e183ae7ea8 [formerly 62b52cb78b]
Former-commit-id: 8204f5b655
tempestpy_adaptions
sjunges 8 years ago
parent
commit
20eaac6918
  1. 11
      src/storage/jani/Automaton.cpp
  2. 5
      src/storage/jani/Automaton.h
  3. 10
      src/storage/jani/Model.cpp
  4. 5
      src/storage/jani/Model.h

11
src/storage/jani/Automaton.cpp

@ -149,6 +149,16 @@ namespace storm {
return initialLocationIndices; return initialLocationIndices;
} }
std::map<uint64_t, std::string> Automaton::buildIdToLocationNameMap() const {
std::map<uint64_t, std::string> mapping;
uint64_t i = 0;
for(auto const& loc : locations) {
mapping[i] = loc.getName();
++i;
}
return mapping;
}
Automaton::Edges Automaton::getEdgesFromLocation(std::string const& name) { Automaton::Edges Automaton::getEdgesFromLocation(std::string const& name) {
auto it = locationToIndex.find(name); auto it = locationToIndex.find(name);
STORM_LOG_THROW(it != locationToIndex.end(), storm::exceptions::InvalidArgumentException, "Cannot retrieve edges from unknown location '" << name << "."); STORM_LOG_THROW(it != locationToIndex.end(), storm::exceptions::InvalidArgumentException, "Cannot retrieve edges from unknown location '" << name << ".");
@ -299,6 +309,7 @@ namespace storm {
actionIndices.insert(edge.getActionIndex()); actionIndices.insert(edge.getActionIndex());
} }
std::vector<Edge>& Automaton::getEdges() { std::vector<Edge>& Automaton::getEdges() {
return edges; return edges;
} }

5
src/storage/jani/Automaton.h

@ -193,6 +193,11 @@ namespace storm {
*/ */
std::set<uint64_t> const& getInitialLocationIndices() const; std::set<uint64_t> const& getInitialLocationIndices() const;
/*!
* Builds a map from ID to Location Name.
*/
std::map<uint64_t, std::string> buildIdToLocationNameMap() const;
/*! /*!
* Retrieves the edges of the location with the given name. * Retrieves the edges of the location with the given name.
*/ */

10
src/storage/jani/Model.cpp

@ -260,6 +260,16 @@ namespace storm {
return result; return result;
} }
std::map<uint64_t, std::string> Model::buildActionToNameMap() const {
std::map<uint64_t, std::string> mapping;
uint64_t i = 0;
for(auto const& act : actions) {
mapping[i] = act.getName();
++i;
}
return mapping;
}
std::string const& Model::getSilentActionName() const { std::string const& Model::getSilentActionName() const {
return actions[silentActionIndex].getName(); return actions[silentActionIndex].getName();
} }

5
src/storage/jani/Model.h

@ -82,6 +82,11 @@ namespace storm {
*/ */
std::vector<Action> const& getActions() const; std::vector<Action> const& getActions() const;
/*!
* Builds a map with action indices mapped to their names
*/
std::map<uint64_t, std::string> buildActionToNameMap() const;
/*! /*!
* Retrieves all non-silent action indices of the model. * Retrieves all non-silent action indices of the model.
*/ */

Loading…
Cancel
Save