Browse Source

use map rather than set for target[Prob]

tempestpy_adaptions
tomjanson 9 years ago
committed by Tom Janson
parent
commit
235671d67d
  1. 8
      src/utility/shortestPaths.cpp
  2. 2
      src/utility/shortestPaths.h

8
src/utility/shortestPaths.cpp

@ -13,7 +13,9 @@ namespace storm {
metaTarget(model->getNumberOfStates()), // first unused state number
initialStates(model->getInitialStates()),
targets(targets) {
targetSet = std::unordered_set<state_t>(targets.begin(), targets.end());
for (state_t target : targets) {
targetProbMap.emplace(target, one<T>());
}
computePredecessors();
@ -134,7 +136,7 @@ namespace storm {
state_t currentNode = (*dijkstraQueue.begin()).second;
dijkstraQueue.erase(dijkstraQueue.begin());
if (targetSet.count(currentNode) == 0) {
if (targetProbMap.count(currentNode) == 0) {
// non-target node, treated normally
for (auto const& transition : transitionMatrix.getRowGroup(currentNode)) {
state_t otherNode = transition.getColumn();
@ -223,7 +225,7 @@ namespace storm {
return utility::zero<T>();
} else {
// edge must be "virtual edge" from target state to meta-target
assert(targetSet.count(tailNode) == 1);
assert(targetProbMap.count(tailNode) == 1);
return utility::one<T>();
}
}

2
src/utility/shortestPaths.h

@ -99,10 +99,10 @@ namespace storm {
private:
storage::SparseMatrix<T> transitionMatrix;
state_t numStates; // includes meta-target, i.e. states in model + 1
std::unordered_set<state_t> targetSet;
state_t metaTarget;
storage::BitVector initialStates;
state_list_t targets;
std::unordered_map<state_t, T> targetProbMap;
std::vector<state_list_t> graphPredecessors;
std::vector<boost::optional<state_t>> shortestPathPredecessors;

Loading…
Cancel
Save