From d6f65465d27bee0d9cde5ed15dc72d276875ea50 Mon Sep 17 00:00:00 2001 From: TimQu Date: Wed, 27 Jan 2016 17:51:25 +0100 Subject: [PATCH] Number of non-const states and transitions Former-commit-id: 67e7dced616af1479019d738f335db88550873cd --- src/cli/entrypoints.h | 3 ++- src/storage/SparseMatrix.cpp | 25 +++++++++++++++++++++++++ src/storage/SparseMatrix.h | 10 ++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/src/cli/entrypoints.h b/src/cli/entrypoints.h index 5b1de2b0c..dec8043c2 100644 --- a/src/cli/entrypoints.h +++ b/src/cli/entrypoints.h @@ -156,7 +156,8 @@ namespace storm { storm::settings::generalSettings().getConstantDefinitionString() << ";" << modelProgramPair.model->getNumberOfStates() << ";" << modelProgramPair.model->getNumberOfTransitions() << ";" << std::endl; - + std::cout << "Num of states with nonconstant transitions; Num of nonconstant transitions" << std::endl; + std::cout << "NUM_PARS" << modelProgramPair.model->as>().getTransitionMatrix().getNonconstantRowGroupCont() << ";" << modelProgramPair.model->as>().getTransitionMatrix().getNonconstantRowGroupCont() << std::endl; // Preprocess the model if needed. BRANCH_ON_MODELTYPE(modelProgramPair.model, modelProgramPair.model, ValueType, LibraryType, preprocessModel, formulas); diff --git a/src/storage/SparseMatrix.cpp b/src/storage/SparseMatrix.cpp index 7d55a8850..8469f80d3 100644 --- a/src/storage/SparseMatrix.cpp +++ b/src/storage/SparseMatrix.cpp @@ -1143,6 +1143,31 @@ namespace storm { return sum; } + template + typename SparseMatrix::index_type SparseMatrix::getNonconstantEntryCount() const { + index_type nonConstEntries = 0; + for( auto const& entry : *this){ + if(!storm::utility::isConstant(entry.getValue())){ + ++nonConstEntries; + } + } + return nonConstEntries; + } + + template + typename SparseMatrix::index_type SparseMatrix::getNonconstantRowGroupCount() const { + index_type nonConstRowGroups = 0; + for (index_type rowGroup=0; rowGroup < this->getRowGroupIndices().size(); ++rowGroup) { + for( auto const& entry : this->getRowGroup(rowGroup)){ + if(!storm::utility::isConstant(entry.getValue())){ + ++nonConstRowGroups; + break; + } + } + } + return nonConstRowGroups; + } + template bool SparseMatrix::isProbabilistic() const { storm::utility::ConstantsComparator comparator; diff --git a/src/storage/SparseMatrix.h b/src/storage/SparseMatrix.h index 9040a1c7e..911b9d04a 100644 --- a/src/storage/SparseMatrix.h +++ b/src/storage/SparseMatrix.h @@ -770,6 +770,16 @@ namespace storm { */ value_type getRowSum(index_type row) const; + /*! + * Returns the number of non-constant entries + */ + index_type getNonconstantEntryCount() const; + + /*! + * Returns the number of rowGroups that contain a non-constant value + */ + index_type getNonconstantRowGroupCount() const; + /*! * Checks for each row whether it sums to one. */