|
|
@ -238,6 +238,110 @@ namespace storm { |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
template <typename T> |
|
|
|
storm::storage::PartialScheduler computeSchedulerStayingInStates(storm::storage::BitVector const& states, storm::storage::SparseMatrix<T> const& transitionMatrix) { |
|
|
|
storm::storage::PartialScheduler result; |
|
|
|
std::vector<uint_fast64_t> const& nondeterministicChoiceIndices = transitionMatrix.getRowGroupIndices(); |
|
|
|
|
|
|
|
for (auto const& state : states) { |
|
|
|
for (uint_fast64_t choice = nondeterministicChoiceIndices[state]; choice < nondeterministicChoiceIndices[state + 1]; ++choice) { |
|
|
|
bool allSuccessorsInStates = true; |
|
|
|
for (auto const& element : transitionMatrix.getRow(choice)) { |
|
|
|
if (!states.get(element.getColumn())) { |
|
|
|
allSuccessorsInStates = false; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
if (allSuccessorsInStates) { |
|
|
|
result.setChoice(state, choice); |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
template <typename T> |
|
|
|
storm::storage::PartialScheduler computeSchedulerWithOneSuccessorInStates(storm::storage::BitVector const& states, storm::storage::SparseMatrix<T> const& transitionMatrix) { |
|
|
|
storm::storage::PartialScheduler result; |
|
|
|
std::vector<uint_fast64_t> const& nondeterministicChoiceIndices = transitionMatrix.getRowGroupIndices(); |
|
|
|
|
|
|
|
for (auto const& state : states) { |
|
|
|
for (uint_fast64_t choice = nondeterministicChoiceIndices[state]; choice < nondeterministicChoiceIndices[state + 1]; ++choice) { |
|
|
|
bool oneSuccessorInStates = false; |
|
|
|
for (auto const& element : transitionMatrix.getRow(choice)) { |
|
|
|
if (states.get(element.getColumn())) { |
|
|
|
oneSuccessorInStates = true; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
if (oneSuccessorInStates) { |
|
|
|
result.setChoice(state, choice); |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
template <typename T> |
|
|
|
storm::storage::PartialScheduler computeSchedulerProbGreater0E(storm::storage::BitVector const& probGreater0EStates, storm::storage::SparseMatrix<T> const& transitionMatrix) { |
|
|
|
return computeSchedulerWithOneSuccessorInStates(probGreater0EStates, transitionMatrix); |
|
|
|
} |
|
|
|
|
|
|
|
template <typename T> |
|
|
|
storm::storage::PartialScheduler computeSchedulerProb0E(storm::storage::BitVector const& prob0EStates, storm::storage::SparseMatrix<T> const& transitionMatrix) { |
|
|
|
return computeSchedulerStayingInStates(prob0EStates, transitionMatrix); |
|
|
|
} |
|
|
|
|
|
|
|
template <typename T> |
|
|
|
storm::storage::PartialScheduler computeSchedulerProb1E(storm::storage::BitVector const& prob1EStates, storm::storage::SparseMatrix<T> const& transitionMatrix, storm::storage::SparseMatrix<T> const& backwardTransitions, storm::storage::BitVector const& phiStates, storm::storage::BitVector const& psiStates) { |
|
|
|
|
|
|
|
storm::storage::PartialScheduler result; |
|
|
|
std::vector<uint_fast64_t> const& nondeterministicChoiceIndices = transitionMatrix.getRowGroupIndices(); |
|
|
|
std::vector<uint_fast64_t> stack; |
|
|
|
storm::storage::BitVector currentStates(psiStates); |
|
|
|
stack.insert(stack.end(), currentStates.begin(), currentStates.end()); |
|
|
|
uint_fast64_t currentState = 0; |
|
|
|
|
|
|
|
while (!stack.empty()) { |
|
|
|
currentState = stack.back(); |
|
|
|
stack.pop_back(); |
|
|
|
|
|
|
|
for (typename storm::storage::SparseMatrix<T>::const_iterator predecessorEntryIt = backwardTransitions.begin(currentState), predecessorEntryIte = backwardTransitions.end(currentState); predecessorEntryIt != predecessorEntryIte; ++predecessorEntryIt) { |
|
|
|
if (phiStates.get(predecessorEntryIt->getColumn()) && !currentStates.get(predecessorEntryIt->getColumn())) { |
|
|
|
// Check whether the predecessor has only successors in the prob1E state set for one of the
|
|
|
|
// nondeterminstic choices.
|
|
|
|
for (uint_fast64_t row = nondeterministicChoiceIndices[predecessorEntryIt->getColumn()]; row < nondeterministicChoiceIndices[predecessorEntryIt->getColumn() + 1]; ++row) { |
|
|
|
bool allSuccessorsInProb1EStates = true; |
|
|
|
bool hasSuccessorInCurrentStates = false; |
|
|
|
for (typename storm::storage::SparseMatrix<T>::const_iterator successorEntryIt = transitionMatrix.begin(row), successorEntryIte = transitionMatrix.end(row); successorEntryIt != successorEntryIte; ++successorEntryIt) { |
|
|
|
if (!prob1EStates.get(successorEntryIt->getColumn())) { |
|
|
|
allSuccessorsInProb1EStates = false; |
|
|
|
break; |
|
|
|
} else if (currentStates.get(successorEntryIt->getColumn())) { |
|
|
|
hasSuccessorInCurrentStates = true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// If all successors for a given nondeterministic choice are in the prob1E state set, we
|
|
|
|
// perform a backward search from that state.
|
|
|
|
if (allSuccessorsInProb1EStates && hasSuccessorInCurrentStates) { |
|
|
|
result.setChoice(predecessorEntryIt->getColumn(), row); |
|
|
|
currentStates.set(predecessorEntryIt->getColumn(), true); |
|
|
|
stack.push_back(predecessorEntryIt->getColumn()); |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
template <typename T> |
|
|
|
storm::storage::BitVector performProbGreater0E(storm::storage::SparseMatrix<T> const& transitionMatrix, std::vector<uint_fast64_t> const& nondeterministicChoiceIndices, storm::storage::SparseMatrix<T> const& backwardTransitions, storm::storage::BitVector const& phiStates, storm::storage::BitVector const& psiStates, bool useStepBound, uint_fast64_t maximalSteps) { |
|
|
|
size_t numberOfStates = phiStates.size(); |
|
|
@ -333,17 +437,20 @@ namespace storm { |
|
|
|
// nondeterminstic choices.
|
|
|
|
for (uint_fast64_t row = nondeterministicChoiceIndices[predecessorEntryIt->getColumn()]; row < nondeterministicChoiceIndices[predecessorEntryIt->getColumn() + 1]; ++row) { |
|
|
|
bool allSuccessorsInCurrentStates = true; |
|
|
|
bool hasNextStateSuccessor = false; |
|
|
|
for (typename storm::storage::SparseMatrix<T>::const_iterator successorEntryIt = transitionMatrix.begin(row), successorEntryIte = transitionMatrix.end(row); successorEntryIt != successorEntryIte; ++successorEntryIt) { |
|
|
|
if (!currentStates.get(successorEntryIt->getColumn())) { |
|
|
|
allSuccessorsInCurrentStates = false; |
|
|
|
break; |
|
|
|
} else if (nextStates.get(successorEntryIt->getColumn())) { |
|
|
|
hasNextStateSuccessor = true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// If all successors for a given nondeterministic choice are in the current state set, we
|
|
|
|
// add it to the set of states for the next iteration and perform a backward search from
|
|
|
|
// that state.
|
|
|
|
if (allSuccessorsInCurrentStates) { |
|
|
|
if (allSuccessorsInCurrentStates && hasNextStateSuccessor) { |
|
|
|
nextStates.set(predecessorEntryIt->getColumn(), true); |
|
|
|
stack.push_back(predecessorEntryIt->getColumn()); |
|
|
|
break; |
|
|
@ -843,6 +950,12 @@ namespace storm { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template storm::storage::PartialScheduler computeSchedulerProbGreater0E(storm::storage::BitVector const& probGreater0EStates, storm::storage::SparseMatrix<double> const& transitionMatrix); |
|
|
|
|
|
|
|
template storm::storage::PartialScheduler computeSchedulerProb0E(storm::storage::BitVector const& prob0EStates, storm::storage::SparseMatrix<double> const& transitionMatrix); |
|
|
|
|
|
|
|
template storm::storage::PartialScheduler computeSchedulerProb1E(storm::storage::BitVector const& prob1EStates, storm::storage::SparseMatrix<double> const& transitionMatrix, storm::storage::SparseMatrix<double> const& backwardTransitions, storm::storage::BitVector const& phiStates, storm::storage::BitVector const& psiStates); |
|
|
|
|
|
|
|
template storm::storage::BitVector performProbGreater0E(storm::storage::SparseMatrix<double> const& transitionMatrix, std::vector<uint_fast64_t> const& nondeterministicChoiceIndices, storm::storage::SparseMatrix<double> const& backwardTransitions, storm::storage::BitVector const& phiStates, storm::storage::BitVector const& psiStates, bool useStepBound = false, uint_fast64_t maximalSteps = 0) ; |
|
|
|
|
|
|
|
template storm::storage::BitVector performProb0A(storm::storage::SparseMatrix<double> const& transitionMatrix, std::vector<uint_fast64_t> const& nondeterministicChoiceIndices, storm::storage::SparseMatrix<double> const& backwardTransitions, storm::storage::BitVector const& phiStates, storm::storage::BitVector const& psiStates); |
|
|
|