From 457943351d31e315853a8e7dcabb762d9dbab750 Mon Sep 17 00:00:00 2001 From: TimQu Date: Thu, 30 Mar 2017 16:17:50 +0200 Subject: [PATCH] fixed matrix building in ModelInstantiator for deterministic models. Previously, a non-trivial row grouping was introduced. --- src/storm/utility/ModelInstantiator.cpp | 27 ++++++++++++++++--------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/src/storm/utility/ModelInstantiator.cpp b/src/storm/utility/ModelInstantiator.cpp index df8dc025a..7b370274d 100644 --- a/src/storm/utility/ModelInstantiator.cpp +++ b/src/storm/utility/ModelInstantiator.cpp @@ -40,16 +40,24 @@ namespace storm { storm::storage::SparseMatrixBuilder matrixBuilder(parametricMatrix.getRowCount(), parametricMatrix.getColumnCount(), parametricMatrix.getEntryCount(), - true, // no force dimensions - true, //Custom row grouping - parametricMatrix.getRowGroupCount()); - for(std::size_t rowGroup = 0; rowGroup < parametricMatrix.getRowGroupCount(); ++rowGroup){ - matrixBuilder.newRowGroup(parametricMatrix.getRowGroupIndices()[rowGroup]); - for(std::size_t row = parametricMatrix.getRowGroupIndices()[rowGroup]; row < parametricMatrix.getRowGroupIndices()[rowGroup+1]; ++row){ - ConstantType dummyValue = storm::utility::one(); - for(auto const& paramEntry : parametricMatrix.getRow(row)){ + true, + !parametricMatrix.hasTrivialRowGrouping(), + parametricMatrix.hasTrivialRowGrouping() ? 0 : parametricMatrix.getRowGroupCount()); + ConstantType dummyValue = storm::utility::one(); + if (parametricMatrix.hasTrivialRowGrouping()) { + for (uint_fast64_t row = 0; row < parametricMatrix.getRowCount(); ++row) { + for (auto const& paramEntry : parametricMatrix.getRow(row)) { matrixBuilder.addNextValue(row, paramEntry.getColumn(), dummyValue); - dummyValue = storm::utility::zero(); + } + } + } + else { + for(uint_fast64_t rowGroup = 0; rowGroup < parametricMatrix.getRowGroupCount(); ++rowGroup){ + matrixBuilder.newRowGroup(parametricMatrix.getRowGroupIndices()[rowGroup]); + for (uint_fast64_t row = parametricMatrix.getRowGroupIndices()[rowGroup]; row < parametricMatrix.getRowGroupIndices()[rowGroup+1]; ++row) { + for(auto const& paramEntry : parametricMatrix.getRow(row)){ + matrixBuilder.addNextValue(row, paramEntry.getColumn(), dummyValue); + } } } } @@ -103,7 +111,6 @@ namespace storm { ++parametricEntryIt; } STORM_LOG_ASSERT(constantEntryIt == constantMatrix.end(), "Parametric matrix seems to have more or less entries then the constant matrix"); - //TODO: is this necessary? constantMatrix.updateNonzeroEntryCount(); }