#include "src/models/PseudoModel.h" #include "src/utility/constants.h" #include "src/models/AbstractModel.h" namespace storm { namespace models { template ModelBasedPseudoModel::ModelBasedPseudoModel(storm::models::AbstractModel const& model) : _model(model) { // Intentionally left empty. } template NonDeterministicMatrixBasedPseudoModel::NonDeterministicMatrixBasedPseudoModel(storm::storage::SparseMatrix const& matrix, std::vector const& nondeterministicChoiceIndices) : _matrix(matrix), _nondeterministicChoiceIndices(nondeterministicChoiceIndices) { // Intentionally left empty. } template DeterministicMatrixBasedPseudoModel::DeterministicMatrixBasedPseudoModel(storm::storage::SparseMatrix const& matrix) : _matrix(matrix) { // Intentionally left empty. } template typename storm::storage::SparseMatrix::const_rows ModelBasedPseudoModel::getRows(uint_fast64_t state) const { return this->_model.getRows(state); } template typename storm::storage::SparseMatrix::const_rows NonDeterministicMatrixBasedPseudoModel::getRows(uint_fast64_t state) const { return this->_matrix.getRows(this->_nondeterministicChoiceIndices[state], this->_nondeterministicChoiceIndices[state + 1] - 1); } template typename storm::storage::SparseMatrix::const_rows DeterministicMatrixBasedPseudoModel::getRows(uint_fast64_t state) const { return this->_matrix.getRows(state, state); } template uint_fast64_t ModelBasedPseudoModel::getNumberOfStates() const { return this->_model.getNumberOfStates(); } template uint_fast64_t NonDeterministicMatrixBasedPseudoModel::getNumberOfStates() const { return this->_matrix.getColumnCount(); } template uint_fast64_t DeterministicMatrixBasedPseudoModel::getNumberOfStates() const { return this->_matrix.getColumnCount(); } template storm::storage::SparseMatrix AbstractPseudoModel::extractPartitionDependencyGraph(storm::storage::Decomposition const& decomposition) const { uint_fast64_t numberOfStates = decomposition.size(); // First, we need to create a mapping of states to their SCC index, to ease the computation of dependency transitions later. std::vector stateToBlockMap(this->getNumberOfStates()); for (uint_fast64_t i = 0; i < decomposition.size(); ++i) { for (auto state : decomposition[i]) { stateToBlockMap[state] = i; } } // The resulting sparse matrix will have as many rows/columns as there are blocks in the partition. storm::storage::SparseMatrixBuilder dependencyGraphBuilder(numberOfStates, numberOfStates); for (uint_fast64_t currentBlockIndex = 0; currentBlockIndex < decomposition.size(); ++currentBlockIndex) { // Get the next block. typename storm::storage::StateBlock const& block = decomposition[currentBlockIndex]; // Now, we determine the blocks which are reachable (in one step) from the current block. boost::container::flat_set allTargetBlocks; for (auto state : block) { for (auto const& transitionEntry : this->getRows(state)) { uint_fast64_t targetBlock = stateToBlockMap[transitionEntry.getColumn()]; // We only need to consider transitions that are actually leaving the SCC. if (targetBlock != currentBlockIndex) { allTargetBlocks.insert(targetBlock); } } } // Now we can just enumerate all the target SCCs and insert the corresponding transitions. for (auto targetBlock : allTargetBlocks) { dependencyGraphBuilder.addNextValue(currentBlockIndex, targetBlock, storm::utility::one()); } } return dependencyGraphBuilder.build(); } template class ModelBasedPseudoModel; template class NonDeterministicMatrixBasedPseudoModel; template class DeterministicMatrixBasedPseudoModel; template class ModelBasedPseudoModel ; template class NonDeterministicMatrixBasedPseudoModel ; template class DeterministicMatrixBasedPseudoModel ; template class ModelBasedPseudoModel; template class NonDeterministicMatrixBasedPseudoModel; template class DeterministicMatrixBasedPseudoModel; } // namespace models } // namespace storm