|
|
@ -16,12 +16,17 @@ namespace storm { |
|
|
|
template <typename ValueType> |
|
|
|
StronglyConnectedComponentDecomposition<ValueType>::StronglyConnectedComponentDecomposition(storm::models::AbstractModel<ValueType> const& model, StateBlock const& block, bool dropNaiveSccs, bool onlyBottomSccs) { |
|
|
|
storm::storage::BitVector subsystem(model.getNumberOfStates(), block.begin(), block.end()); |
|
|
|
performSccDecomposition(model, subsystem, dropNaiveSccs, onlyBottomSccs); |
|
|
|
performSccDecomposition(model.getTransitionMatrix(), subsystem, dropNaiveSccs, onlyBottomSccs); |
|
|
|
} |
|
|
|
|
|
|
|
template <typename ValueType> |
|
|
|
StronglyConnectedComponentDecomposition<ValueType>::StronglyConnectedComponentDecomposition(storm::models::AbstractModel<ValueType> const& model, storm::storage::BitVector const& subsystem, bool dropNaiveSccs, bool onlyBottomSccs) { |
|
|
|
performSccDecomposition(model, subsystem, dropNaiveSccs, onlyBottomSccs); |
|
|
|
performSccDecomposition(model.getTransitionMatrix(), subsystem, dropNaiveSccs, onlyBottomSccs); |
|
|
|
} |
|
|
|
|
|
|
|
template <typename ValueType> |
|
|
|
StronglyConnectedComponentDecomposition<ValueType>::StronglyConnectedComponentDecomposition(storm::storage::SparseMatrix<ValueType> const& transitionMatrix, storm::storage::BitVector const& subsystem, bool dropNaiveSccs, bool onlyBottomSccs) { |
|
|
|
performSccDecomposition(transitionMatrix, subsystem, dropNaiveSccs, onlyBottomSccs); |
|
|
|
} |
|
|
|
|
|
|
|
template <typename ValueType> |
|
|
@ -47,8 +52,8 @@ namespace storm { |
|
|
|
} |
|
|
|
|
|
|
|
template <typename ValueType> |
|
|
|
void StronglyConnectedComponentDecomposition<ValueType>::performSccDecomposition(storm::models::AbstractModel<ValueType> const& model, storm::storage::BitVector const& subsystem, bool dropNaiveSccs, bool onlyBottomSccs) { |
|
|
|
uint_fast64_t numberOfStates = model.getNumberOfStates(); |
|
|
|
void StronglyConnectedComponentDecomposition<ValueType>::performSccDecomposition(storm::storage::SparseMatrix<ValueType> const& transitionMatrix, storm::storage::BitVector const& subsystem, bool dropNaiveSccs, bool onlyBottomSccs) { |
|
|
|
uint_fast64_t numberOfStates = transitionMatrix.getRowGroupCount(); |
|
|
|
|
|
|
|
// Set up the environment of the algorithm.
|
|
|
|
// Start with the two stacks it maintains.
|
|
|
@ -71,7 +76,7 @@ namespace storm { |
|
|
|
uint_fast64_t currentIndex = 0; |
|
|
|
for (auto state : subsystem) { |
|
|
|
if (!hasPreorderNumber.get(state)) { |
|
|
|
performSccDecompositionGCM(model, state, statesWithSelfLoop, subsystem, currentIndex, hasPreorderNumber, preorderNumbers, s, p, stateHasScc, stateToSccMapping, sccCount); |
|
|
|
performSccDecompositionGCM(transitionMatrix, state, statesWithSelfLoop, subsystem, currentIndex, hasPreorderNumber, preorderNumbers, s, p, stateHasScc, stateToSccMapping, sccCount); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -103,7 +108,7 @@ namespace storm { |
|
|
|
for (uint_fast64_t state = 0; state < numberOfStates; ++state) { |
|
|
|
// If the block of the state is already known to be dropped, we don't need to check the transitions.
|
|
|
|
if (!blocksToDrop.get(stateToSccMapping[state])) { |
|
|
|
for (typename storm::storage::SparseMatrix<ValueType>::const_iterator successorIt = model.getRows(state).begin(), successorIte = model.getRows(state).end(); successorIt != successorIte; ++successorIt) { |
|
|
|
for (typename storm::storage::SparseMatrix<ValueType>::const_iterator successorIt = transitionMatrix.getRowGroup(state).begin(), successorIte = transitionMatrix.getRowGroup(state).end(); successorIt != successorIte; ++successorIt) { |
|
|
|
if (subsystem.get(successorIt->getColumn()) && stateToSccMapping[state] != stateToSccMapping[successorIt->getColumn()]) { |
|
|
|
blocksToDrop.set(stateToSccMapping[state]); |
|
|
|
break; |
|
|
@ -134,15 +139,15 @@ namespace storm { |
|
|
|
storm::storage::BitVector fullSystem(model.getNumberOfStates(), true); |
|
|
|
|
|
|
|
// Call the overloaded function.
|
|
|
|
performSccDecomposition(model, fullSystem, dropNaiveSccs, onlyBottomSccs); |
|
|
|
performSccDecomposition(model.getTransitionMatrix(), fullSystem, dropNaiveSccs, onlyBottomSccs); |
|
|
|
} |
|
|
|
|
|
|
|
template <typename ValueType> |
|
|
|
void StronglyConnectedComponentDecomposition<ValueType>::performSccDecompositionGCM(storm::models::AbstractModel<ValueType> const& model, uint_fast64_t startState, storm::storage::BitVector& statesWithSelfLoop, storm::storage::BitVector const& subsystem, uint_fast64_t& currentIndex, storm::storage::BitVector& hasPreorderNumber, std::vector<uint_fast64_t>& preorderNumbers, std::vector<uint_fast64_t>& s, std::vector<uint_fast64_t>& p, storm::storage::BitVector& stateHasScc, std::vector<uint_fast64_t>& stateToSccMapping, uint_fast64_t& sccCount) { |
|
|
|
void StronglyConnectedComponentDecomposition<ValueType>::performSccDecompositionGCM(storm::storage::SparseMatrix<ValueType> const& transitionMatrix, uint_fast64_t startState, storm::storage::BitVector& statesWithSelfLoop, storm::storage::BitVector const& subsystem, uint_fast64_t& currentIndex, storm::storage::BitVector& hasPreorderNumber, std::vector<uint_fast64_t>& preorderNumbers, std::vector<uint_fast64_t>& s, std::vector<uint_fast64_t>& p, storm::storage::BitVector& stateHasScc, std::vector<uint_fast64_t>& stateToSccMapping, uint_fast64_t& sccCount) { |
|
|
|
|
|
|
|
// Prepare the stack used for turning the recursive procedure into an iterative one.
|
|
|
|
std::vector<uint_fast64_t> recursionStateStack; |
|
|
|
recursionStateStack.reserve(model.getNumberOfStates()); |
|
|
|
recursionStateStack.reserve(transitionMatrix.getRowGroupCount()); |
|
|
|
recursionStateStack.push_back(startState); |
|
|
|
|
|
|
|
while (!recursionStateStack.empty()) { |
|
|
@ -157,7 +162,7 @@ namespace storm { |
|
|
|
s.push_back(currentState); |
|
|
|
p.push_back(currentState); |
|
|
|
|
|
|
|
for (auto const& successor : model.getRows(currentState)) { |
|
|
|
for (auto const& successor : transitionMatrix.getRowGroup(currentState)) { |
|
|
|
if (subsystem.get(successor.getColumn()) && successor.getValue() != storm::utility::constantZero<ValueType>()) { |
|
|
|
if (currentState == successor.getColumn()) { |
|
|
|
statesWithSelfLoop.set(currentState); |
|
|
|