Browse Source

Bugfixes for new set class.

Former-commit-id: 10d9632922
tempestpy_adaptions
dehnert 11 years ago
parent
commit
a33717787c
  1. 2
      src/counterexamples/SMTMinimalCommandSetGenerator.h
  2. 11
      src/storage/VectorSet.h
  3. 29
      src/utility/counterexamples.h

2
src/counterexamples/SMTMinimalCommandSetGenerator.h

@ -120,7 +120,6 @@ namespace storm {
}
}
// Compute the set of labels that are known to be taken in any case.
relevancyInformation.knownLabels = storm::utility::counterexamples::getGuaranteedLabelSet(labeledMdp, psiStates, relevancyInformation.relevantLabels);
if (!relevancyInformation.knownLabels.empty()) {
@ -331,7 +330,6 @@ namespace storm {
formulae.push_back(!variableInformation.labelVariables.at(variableInformation.labelToIndexMap.at(labelSetPair.first)));
}
for (auto followingLabel : labelSetPair.second) {
std::cout << "2 " << followingLabel << std::endl;
if (followingLabel != labelSetPair.first) {
formulae.push_back(variableInformation.labelVariables.at(variableInformation.labelToIndexMap.at(followingLabel)));
}

11
src/storage/VectorSet.h

@ -48,8 +48,9 @@ namespace storm {
ensureSet();
}
VectorSet(VectorSet const& other) : data(other.data), dirty(other.dirty) {
// Intentionally left empty.
VectorSet(VectorSet const& other) : dirty(false) {
other.ensureSet();
data = other.data;
}
VectorSet& operator=(VectorSet const& other) {
@ -69,11 +70,13 @@ namespace storm {
}
bool operator==(VectorSet const& other) const {
ensureSet();
if (this->size() != other.size()) return false;
return std::equal(data.begin(), data.end(), other.begin(), other.end());
}
bool operator<(VectorSet const& other) const {
ensureSet();
if (this->size() < other.size()) return true;
if (this->size() > other.size()) return false;
for (auto it1 = this->begin(), it2 = other.begin(); it1 != this->end(); ++it1, ++it2) {
@ -150,11 +153,13 @@ namespace storm {
template<typename InputIterator>
iterator insert(InputIterator first, InputIterator last) {
dirty = true;
return data.insert(data.end(), first, last);
}
template<typename InputIterator>
iterator insert(InputIterator pos, T element) {
dirty = true;
return data.insert(pos, element);
}
@ -178,7 +183,7 @@ namespace storm {
uint_fast64_t lowerBound = 0;
uint_fast64_t upperBound = data.size();
while (lowerBound != upperBound) {
uint_fast64_t currentPosition = (upperBound - lowerBound) / 2;
uint_fast64_t currentPosition = lowerBound + (upperBound - lowerBound) / 2;
bool searchInLowerHalf = element < data[currentPosition];
if (searchInLowerHalf) {
upperBound = currentPosition;

29
src/utility/counterexamples.h

@ -49,41 +49,44 @@ namespace storm {
uint_fast64_t currentState = currentStateTargetStatePair.first;
uint_fast64_t targetState = currentStateTargetStatePair.second;
size_t analysisInformationSizeBefore = analysisInformation[currentState].size();
// Iterate over the successor states for all choices and compute new analysis information.
storm::storage::VectorSet<uint_fast64_t> intersection(analysisInformation[currentState]);
for (uint_fast64_t currentChoice = nondeterministicChoiceIndices[currentState]; currentChoice < nondeterministicChoiceIndices[currentState + 1]; ++currentChoice) {
storm::storage::VectorSet<uint_fast64_t> tmpIntersection;
storm::storage::VectorSet<uint_fast64_t> tmpUnion;
bool choiceTargetsTargetState = false;
for (typename storm::storage::SparseMatrix<T>::ConstIndexIterator successorIt = transitionMatrix.constColumnIteratorBegin(currentChoice), successorIte = transitionMatrix.constColumnIteratorEnd(currentChoice); successorIt != successorIte; ++successorIt) {
// If we can reach the target state with this choice, we need to intersect the current
// analysis information with the union of the new analysis information of the target state
// and the choice labels.
if (*successorIt == targetState) {
choiceTargetsTargetState = true;
std::set_union(analysisInformation[targetState].begin(), analysisInformation[targetState].end(), choiceLabeling[currentChoice].begin(), choiceLabeling[currentChoice].end(), std::inserter(tmpUnion, tmpUnion.end()));
break;
}
}
// If we can reach the target state with this choice, we need to intersect the current
// analysis information with the union of the new analysis information of the target state
// and the choice labels.
if (choiceTargetsTargetState) {
std::set_intersection(intersection.begin(), intersection.end(), tmpUnion.begin(), tmpUnion.end(), std::inserter(tmpIntersection, tmpIntersection.end()));
std::swap(intersection, tmpIntersection);
std::set_intersection(analysisInformation[currentState].begin(), analysisInformation[currentState].end(), analysisInformation[targetState].begin(), analysisInformation[targetState].end(), std::inserter(tmpIntersection, tmpIntersection.end()));
std::set_intersection(analysisInformation[currentState].begin(), analysisInformation[currentState].end(), choiceLabeling[currentChoice].begin(), choiceLabeling[currentChoice].end(), std::inserter(tmpIntersection, tmpIntersection.end()));
analysisInformation[currentState] = std::move(tmpIntersection);
}
}
// If the analysis information changed, we need to update it and put all the predecessors of this
// state in the worklist.
if (analysisInformation[currentState].size() != intersection.size()) {
analysisInformation[currentState] = std::move(intersection);
if (analysisInformation[currentState].size() != analysisInformationSizeBefore) {
for (typename storm::storage::SparseMatrix<T>::ConstIndexIterator predecessorIt = backwardTransitions.constColumnIteratorBegin(currentState), predecessorIte = backwardTransitions.constColumnIteratorEnd(currentState); predecessorIt != predecessorIte; ++predecessorIt) {
worklist.push(std::make_pair(*predecessorIt, currentState));
// Only put the predecessor in the worklist if it's not already a target state.
if (!psiStates.get(*predecessorIt)) {
worklist.push(std::make_pair(*predecessorIt, currentState));
}
}
}
worklist.pop();
}
return analysisInformation;
}

Loading…
Cancel
Save