Browse Source

Fixed some warnings in various places.

Former-commit-id: fbfbfc2bcb
tempestpy_adaptions
dehnert 10 years ago
parent
commit
ac420f13d0
  1. 20
      src/parser/CslParser.cpp
  2. 10
      src/parser/LtlParser.cpp
  3. 20
      src/parser/PrctlParser.cpp
  4. 202
      src/storage/SparseMatrix.cpp
  5. 162
      src/storage/SparseMatrix.h
  6. 8
      test/functional/solver/Z3SmtSolverTest.cpp

20
src/parser/CslParser.cpp

@ -98,11 +98,11 @@ struct CslParser::CslGrammar : qi::grammar<Iterator, std::shared_ptr<csl::CslFil
pathFormula = (timeBoundedEventually | eventually | globally | next | timeBoundedUntil | until | (qi::lit("(") >> pathFormula >> qi::lit(")")) | (qi::lit("[") >> pathFormula >> qi::lit("]")));
pathFormula.name("path formula");
timeBoundedEventually = (
(qi::lit("F") >> qi::lit("[") >> qi::double_ >> qi::lit(",") > qi::double_ > qi::lit("]") > stateFormula)[qi::_val =
((qi::lit("F") >> qi::lit("[") >> qi::double_ >> qi::lit(",")) > qi::double_ > qi::lit("]") > stateFormula)[qi::_val =
MAKE(csl::TimeBoundedEventually<double>, qi::_1, qi::_2, qi::_3)] |
(qi::lit("F") >> (qi::lit("<=") | qi::lit("<")) > qi::double_ > stateFormula)[qi::_val =
((qi::lit("F") >> (qi::lit("<=") | qi::lit("<"))) > qi::double_ > stateFormula)[qi::_val =
MAKE(csl::TimeBoundedEventually<double>, 0, qi::_1, qi::_2)] |
(qi::lit("F") >> (qi::lit(">=") | qi::lit(">")) > qi::double_ > stateFormula)[qi::_val =
((qi::lit("F") >> (qi::lit(">=") | qi::lit(">"))) > qi::double_ > stateFormula)[qi::_val =
MAKE(csl::TimeBoundedEventually<double>, qi::_1, std::numeric_limits<double>::infinity(), qi::_2)]
);
timeBoundedEventually.name("time bounded eventually");
@ -135,14 +135,14 @@ struct CslParser::CslGrammar : qi::grammar<Iterator, std::shared_ptr<csl::CslFil
noBoundOperator = (probabilisticNoBoundOperator | steadyStateNoBoundOperator);
noBoundOperator.name("no bound operator");
probabilisticNoBoundOperator =
(qi::lit("P") >> qi::lit("min") >> qi::lit("=") > qi::lit("?") >> pathFormula)[qi::_val =
((qi::lit("P") >> qi::lit("min") >> qi::lit("=")) > qi::lit("?") >> pathFormula)[qi::_val =
MAKE(csl::CslFilter<double>, qi::_1, storm::properties::MINIMIZE)] |
(qi::lit("P") >> qi::lit("max") >> qi::lit("=") > qi::lit("?") >> pathFormula)[qi::_val =
((qi::lit("P") >> qi::lit("max") >> qi::lit("=")) > qi::lit("?") >> pathFormula)[qi::_val =
MAKE(csl::CslFilter<double>, qi::_1, storm::properties::MAXIMIZE)] |
(qi::lit("P") >> qi::lit("=") > qi::lit("?") >> pathFormula)[qi::_val =
((qi::lit("P") >> qi::lit("=")) > qi::lit("?") >> pathFormula)[qi::_val =
MAKE(csl::CslFilter<double>, qi::_1)];
probabilisticNoBoundOperator.name("probabilistic no bound operator");
steadyStateNoBoundOperator = (qi::lit("S") >> qi::lit("=") > qi::lit("?") >> stateFormula )[qi::_val =
steadyStateNoBoundOperator = ((qi::lit("S") >> qi::lit("=")) > qi::lit("?") >> stateFormula )[qi::_val =
MAKE(csl::CslFilter<double>, qi::_1, storm::properties::UNDEFINED, true)];
steadyStateNoBoundOperator.name("steady state no bound operator");
@ -159,7 +159,7 @@ struct CslParser::CslGrammar : qi::grammar<Iterator, std::shared_ptr<csl::CslFil
formulaAction.name("formula action");
rangeAction = (
(qi::lit("range") >> qi::lit("(") >> qi::uint_ >> qi::lit(",") > qi::uint_ >> qi::lit(")"))[qi::_val =
((qi::lit("range") >> qi::lit("(") >> qi::uint_ >> qi::lit(",")) > qi::uint_ >> qi::lit(")"))[qi::_val =
MAKE(storm::properties::action::RangeAction<double>, qi::_1, qi::_2)] |
(qi::lit("range") >> qi::lit("(") >> qi::uint_ >> qi::lit(")"))[qi::_val =
MAKE(storm::properties::action::RangeAction<double>, qi::_1, qi::_1 + 1)]
@ -181,9 +181,9 @@ struct CslParser::CslGrammar : qi::grammar<Iterator, std::shared_ptr<csl::CslFil
filter = (qi::lit("filter") >> qi::lit("[") >> +abstractAction >> qi::lit("]") >> qi::lit("(") >> formula >> qi::lit(")"))[qi::_val =
MAKE(csl::CslFilter<double>, qi::_2, qi::_1)] |
(qi::lit("filter") >> qi::lit("[") >> qi::lit("max") > +abstractAction >> qi::lit("]") >> qi::lit("(") >> formula >> qi::lit(")"))[qi::_val =
((qi::lit("filter") >> qi::lit("[") >> qi::lit("max")) > +abstractAction >> qi::lit("]") >> qi::lit("(") >> formula >> qi::lit(")"))[qi::_val =
MAKE(csl::CslFilter<double>, qi::_2, qi::_1, storm::properties::MAXIMIZE)] |
(qi::lit("filter") >> qi::lit("[") >> qi::lit("min") > +abstractAction >> qi::lit("]") >> qi::lit("(") >> formula >> qi::lit(")"))[qi::_val =
((qi::lit("filter") >> qi::lit("[") >> qi::lit("min")) > +abstractAction >> qi::lit("]") >> qi::lit("(") >> formula >> qi::lit(")"))[qi::_val =
MAKE(csl::CslFilter<double>, qi::_2, qi::_1, storm::properties::MINIMIZE)] |
(noBoundOperator)[qi::_val =
qi::_1] |

10
src/parser/LtlParser.cpp

@ -77,7 +77,7 @@ struct LtlParser::LtlGrammar : qi::grammar<Iterator, std::shared_ptr<storm::prop
MAKE(ltl::And<double>, qi::_val, qi::_1)];
andFormula.name("And");
untilFormula = notFormula[qi::_val = qi::_1] >
*((qi::lit("U") >> qi::lit("<=") > qi::int_ > notFormula)[qi::_val = MAKE(ltl::BoundedUntil<double>, qi::_val, qi::_2, qi::_1)] |
*(((qi::lit("U") >> qi::lit("<=")) > qi::int_ > notFormula)[qi::_val = MAKE(ltl::BoundedUntil<double>, qi::_val, qi::_2, qi::_1)] |
(qi::lit("U") > notFormula)[qi::_val = MAKE(ltl::Until<double>, qi::_val, qi::_1)]);
until.name("Until");
notFormula = atomicLtlFormula[qi::_val = qi::_1] | (qi::lit("!") > atomicLtlFormula)[qi::_val =
@ -95,7 +95,7 @@ struct LtlParser::LtlGrammar : qi::grammar<Iterator, std::shared_ptr<storm::prop
//This block defines rules for parsing probabilistic path formulas
pathFormula = (boundedEventually | eventually | globally | next);
pathFormula.name("Path Formula");
boundedEventually = (qi::lit("F") >> qi::lit("<=") > qi::int_ > formula)[qi::_val =
boundedEventually = ((qi::lit("F") >> qi::lit("<=")) > qi::int_ > formula)[qi::_val =
MAKE(ltl::BoundedEventually<double>, qi::_2, qi::_1)];
boundedEventually.name("Bounded Eventually");
eventually = (qi::lit("F") >> formula)[qi::_val =
@ -117,7 +117,7 @@ struct LtlParser::LtlGrammar : qi::grammar<Iterator, std::shared_ptr<storm::prop
invertAction.name("invert action");
rangeAction = (
(qi::lit("range") >> qi::lit("(") >> qi::uint_ >> qi::lit(",") > qi::uint_ >> qi::lit(")"))[qi::_val =
((qi::lit("range") >> qi::lit("(") >> qi::uint_ >> qi::lit(",")) > qi::uint_ >> qi::lit(")"))[qi::_val =
MAKE(storm::properties::action::RangeAction<double>, qi::_1, qi::_2)] |
(qi::lit("range") >> qi::lit("(") >> qi::uint_ >> qi::lit(")"))[qi::_val =
MAKE(storm::properties::action::RangeAction<double>, qi::_1, qi::_1 + 1)]
@ -139,9 +139,9 @@ struct LtlParser::LtlGrammar : qi::grammar<Iterator, std::shared_ptr<storm::prop
filter = (qi::lit("filter") >> qi::lit("[") >> +abstractAction >> qi::lit("]") > qi::lit("(") >> formula >> qi::lit(")"))[qi::_val =
MAKE(ltl::LtlFilter<double>, qi::_2, qi::_1)] |
(qi::lit("filter") >> qi::lit("[") >> qi::lit("max") > +abstractAction >> qi::lit("]") >> qi::lit("(") >> formula >> qi::lit(")"))[qi::_val =
((qi::lit("filter") >> qi::lit("[") >> qi::lit("max")) > +abstractAction >> qi::lit("]") >> qi::lit("(") >> formula >> qi::lit(")"))[qi::_val =
MAKE(ltl::LtlFilter<double>, qi::_2, qi::_1, storm::properties::MAXIMIZE)] |
(qi::lit("filter") >> qi::lit("[") >> qi::lit("min") > +abstractAction >> qi::lit("]") >> qi::lit("(") >> formula >> qi::lit(")"))[qi::_val =
((qi::lit("filter") >> qi::lit("[") >> qi::lit("min")) > +abstractAction >> qi::lit("]") >> qi::lit("(") >> formula >> qi::lit(")"))[qi::_val =
MAKE(ltl::LtlFilter<double>, qi::_2, qi::_1, storm::properties::MINIMIZE)] |
(formula)[qi::_val =
MAKE(ltl::LtlFilter<double>, qi::_1)];

20
src/parser/PrctlParser.cpp

@ -89,7 +89,7 @@ struct PrctlParser::PrctlGrammar : qi::grammar<Iterator, std::shared_ptr<storm::
// This block defines rules for parsing probabilistic path formulas
pathFormula = (boundedEventually | eventually | next | globally | boundedUntil | until | qi::lit("(") >> pathFormula >> qi::lit(")") | qi::lit("[") >> pathFormula >> qi::lit("]"));
pathFormula.name("path formula");
boundedEventually = (qi::lit("F") >> qi::lit("<=") > qi::int_ > stateFormula)[qi::_val =
boundedEventually = ((qi::lit("F") >> qi::lit("<=")) > qi::int_ > stateFormula)[qi::_val =
MAKE(prctl::BoundedEventually<double>, qi::_2, qi::_1)];
boundedEventually.name("bounded eventually");
eventually = (qi::lit("F") > stateFormula)[qi::_val =
@ -132,21 +132,21 @@ struct PrctlParser::PrctlGrammar : qi::grammar<Iterator, std::shared_ptr<storm::
noBoundOperator = (probabilisticNoBoundOperator | rewardNoBoundOperator);
noBoundOperator.name("no bound operator");
probabilisticNoBoundOperator = (
(qi::lit("P") >> qi::lit("min") >> qi::lit("=") > qi::lit("?") >> pathFormula )[qi::_val =
((qi::lit("P") >> qi::lit("min") >> qi::lit("=")) > qi::lit("?") >> pathFormula )[qi::_val =
MAKE(prctl::PrctlFilter<double>, qi::_1, storm::properties::MINIMIZE)] |
(qi::lit("P") >> qi::lit("max") >> qi::lit("=") > qi::lit("?") >> pathFormula )[qi::_val =
((qi::lit("P") >> qi::lit("max") >> qi::lit("=")) > qi::lit("?") >> pathFormula )[qi::_val =
MAKE(prctl::PrctlFilter<double>, qi::_1, storm::properties::MAXIMIZE)] |
(qi::lit("P") >> qi::lit("=") > qi::lit("?") >> pathFormula )[qi::_val =
((qi::lit("P") >> qi::lit("=")) > qi::lit("?") >> pathFormula )[qi::_val =
MAKE(prctl::PrctlFilter<double>, qi::_1)]
);
probabilisticNoBoundOperator.name("no bound operator");
rewardNoBoundOperator = (
(qi::lit("R") >> qi::lit("min") >> qi::lit("=") > qi::lit("?") >> rewardPathFormula )[qi::_val =
((qi::lit("R") >> qi::lit("min") >> qi::lit("=")) > qi::lit("?") >> rewardPathFormula )[qi::_val =
MAKE(prctl::PrctlFilter<double>, qi::_1, storm::properties::MINIMIZE)] |
(qi::lit("R") >> qi::lit("max") >> qi::lit("=") > qi::lit("?") >> rewardPathFormula )[qi::_val =
((qi::lit("R") >> qi::lit("max") >> qi::lit("=")) > qi::lit("?") >> rewardPathFormula )[qi::_val =
MAKE(prctl::PrctlFilter<double>, qi::_1, storm::properties::MAXIMIZE)] |
(qi::lit("R") >> qi::lit("=") > qi::lit("?") >> rewardPathFormula )[qi::_val =
((qi::lit("R") >> qi::lit("=")) > qi::lit("?") >> rewardPathFormula )[qi::_val =
MAKE(prctl::PrctlFilter<double>, qi::_1)]
);
@ -166,7 +166,7 @@ struct PrctlParser::PrctlGrammar : qi::grammar<Iterator, std::shared_ptr<storm::
formulaAction.name("formula action");
rangeAction = (
(qi::lit("range") >> qi::lit("(") >> qi::uint_ >> qi::lit(",") > qi::uint_ >> qi::lit(")"))[qi::_val =
((qi::lit("range") >> qi::lit("(") >> qi::uint_ >> qi::lit(",")) > qi::uint_ >> qi::lit(")"))[qi::_val =
MAKE(storm::properties::action::RangeAction<double>, qi::_1, qi::_2)] |
(qi::lit("range") >> qi::lit("(") >> qi::uint_ >> qi::lit(")"))[qi::_val =
MAKE(storm::properties::action::RangeAction<double>, qi::_1, qi::_1 + 1)]
@ -188,9 +188,9 @@ struct PrctlParser::PrctlGrammar : qi::grammar<Iterator, std::shared_ptr<storm::
filter = (qi::lit("filter") >> qi::lit("[") >> +abstractAction >> qi::lit("]") > qi::lit("(") >> formula >> qi::lit(")"))[qi::_val =
MAKE(prctl::PrctlFilter<double>, qi::_2, qi::_1)] |
(qi::lit("filter") >> qi::lit("[") >> qi::lit("max") > +abstractAction >> qi::lit("]") >> qi::lit("(") >> formula >> qi::lit(")"))[qi::_val =
((qi::lit("filter") >> qi::lit("[") >> qi::lit("max")) > +abstractAction >> qi::lit("]") >> qi::lit("(") >> formula >> qi::lit(")"))[qi::_val =
MAKE(prctl::PrctlFilter<double>, qi::_2, qi::_1, storm::properties::MAXIMIZE)] |
(qi::lit("filter") >> qi::lit("[") >> qi::lit("min") > +abstractAction >> qi::lit("]") >> qi::lit("(") >> formula >> qi::lit(")"))[qi::_val =
((qi::lit("filter") >> qi::lit("[") >> qi::lit("min")) > +abstractAction >> qi::lit("]") >> qi::lit("(") >> formula >> qi::lit(")"))[qi::_val =
MAKE(prctl::PrctlFilter<double>, qi::_2, qi::_1, storm::properties::MINIMIZE)] |
(noBoundOperator)[qi::_val =
qi::_1] |

202
src/storage/SparseMatrix.cpp

@ -53,12 +53,12 @@ namespace storm {
}
template<typename ValueType>
SparseMatrixBuilder<ValueType>::SparseMatrixBuilder(IndexType rows, IndexType columns, IndexType entries, bool hasCustomRowGrouping, IndexType rowGroups) : rowCountSet(rows != 0), rowCount(rows), columnCountSet(columns != 0), columnCount(columns), entryCount(entries), hasCustomRowGrouping(hasCustomRowGrouping), rowGroupCountSet(rowGroups != 0), rowGroupCount(rowGroups), rowGroupIndices(), storagePreallocated(rows != 0 && columns != 0 && entries != 0), columnsAndValues(), rowIndications(), currentEntryCount(0), lastRow(0), lastColumn(0), currentRowGroup(0) {
SparseMatrixBuilder<ValueType>::SparseMatrixBuilder(index_type rows, index_type columns, index_type entries, bool hasCustomRowGrouping, index_type rowGroups) : rowCountSet(rows != 0), rowCount(rows), columnCountSet(columns != 0), columnCount(columns), entryCount(entries), hasCustomRowGrouping(hasCustomRowGrouping), rowGroupCountSet(rowGroups != 0), rowGroupCount(rowGroups), rowGroupIndices(), storagePreallocated(rows != 0 && columns != 0 && entries != 0), columnsAndValues(), rowIndications(), currentEntryCount(0), lastRow(0), lastColumn(0), currentRowGroup(0) {
this->prepareInternalStorage();
}
template<typename ValueType>
void SparseMatrixBuilder<ValueType>::addNextValue(IndexType row, IndexType column, ValueType const& value) {
void SparseMatrixBuilder<ValueType>::addNextValue(index_type row, index_type column, ValueType const& value) {
// Depending on whether the internal data storage was preallocated or not, adding the value is done somewhat
// differently.
if (storagePreallocated) {
@ -94,18 +94,18 @@ namespace storm {
if (storagePreallocated) {
// If the storage was preallocated, we can access the elements in the vectors with the subscript
// operator.
for (IndexType i = lastRow + 1; i <= row; ++i) {
for (index_type i = lastRow + 1; i <= row; ++i) {
rowIndications[i] = currentEntryCount;
}
} else {
// Otherwise, we need to push the correct values to the vectors, which might trigger reallocations.
for (IndexType i = lastRow + 1; i <= row; ++i) {
for (index_type i = lastRow + 1; i <= row; ++i) {
rowIndications.push_back(currentEntryCount);
}
}
if (!hasCustomRowGrouping) {
for (IndexType i = lastRow + 1; i <= row; ++i) {
for (index_type i = lastRow + 1; i <= row; ++i) {
rowGroupIndices.push_back(i);
++currentRowGroup;
}
@ -132,7 +132,7 @@ namespace storm {
}
template<typename ValueType>
void SparseMatrixBuilder<ValueType>::newRowGroup(IndexType startingRow) {
void SparseMatrixBuilder<ValueType>::newRowGroup(index_type startingRow) {
if (!hasCustomRowGrouping) {
throw storm::exceptions::InvalidStateException() << "Illegal call to SparseMatrix::newRowGroup: matrix was not created to have a custom row grouping.";
} else if (rowGroupIndices.size() > 0 && startingRow < rowGroupIndices.back()) {
@ -147,21 +147,21 @@ namespace storm {
}
template<typename ValueType>
SparseMatrix<ValueType> SparseMatrixBuilder<ValueType>::build(IndexType overriddenRowCount, IndexType overriddenColumnCount, IndexType overriddenRowGroupCount) {
SparseMatrix<ValueType> SparseMatrixBuilder<ValueType>::build(index_type overriddenRowCount, index_type overriddenColumnCount, index_type overriddenRowGroupCount) {
// Check whether it's safe to finalize the matrix and throw error otherwise.
if (storagePreallocated && currentEntryCount != entryCount) {
throw storm::exceptions::InvalidStateException() << "Illegal call to SparseMatrix::build: expected " << entryCount << " entries, but got " << currentEntryCount << " instead.";
} else {
// Fill in the missing entries in the row indices array, as there may be empty rows at the end.
if (storagePreallocated) {
for (IndexType i = lastRow + 1; i < rowCount; ++i) {
for (index_type i = lastRow + 1; i < rowCount; ++i) {
rowIndications[i] = currentEntryCount;
}
} else {
if (!rowCountSet) {
rowCount = std::max(overriddenRowCount, rowCount);
}
for (IndexType i = lastRow + 1; i < rowCount; ++i) {
for (index_type i = lastRow + 1; i < rowCount; ++i) {
rowIndications.push_back(currentEntryCount);
}
}
@ -184,12 +184,12 @@ namespace storm {
rowGroupIndices[rowGroupCount] = rowCount;
} else {
if (!hasCustomRowGrouping) {
for (IndexType i = currentRowGroup; i < rowCount; ++i) {
for (index_type i = currentRowGroup; i < rowCount; ++i) {
rowGroupIndices.push_back(i + 1);
}
} else {
overriddenRowGroupCount = std::max(overriddenRowGroupCount, currentRowGroup + 1);
for (IndexType i = currentRowGroup; i < overriddenRowGroupCount; ++i) {
for (index_type i = currentRowGroup; i < overriddenRowGroupCount; ++i) {
rowGroupIndices.push_back(rowCount);
}
}
@ -203,8 +203,8 @@ namespace storm {
void SparseMatrixBuilder<ValueType>::prepareInternalStorage() {
// Only allocate the memory for the matrix contents if the dimensions of the matrix are already known.
if (storagePreallocated) {
columnsAndValues = std::vector<MatrixEntry<IndexType, ValueType>>(entryCount, MatrixEntry<IndexType, ValueType>(0, storm::utility::constantZero<ValueType>()));
rowIndications = std::vector<IndexType>(rowCount + 1, 0);
columnsAndValues = std::vector<MatrixEntry<index_type, ValueType>>(entryCount, MatrixEntry<index_type, ValueType>(0, storm::utility::constantZero<ValueType>()));
rowIndications = std::vector<index_type>(rowCount + 1, 0);
} else {
rowIndications.push_back(0);
}
@ -212,7 +212,7 @@ namespace storm {
// Only allocate the memory for the row grouping of the matrix contents if the number of groups is already
// known.
if (hasCustomRowGrouping && rowGroupCountSet) {
rowGroupIndices = std::vector<IndexType>(rowGroupCount + 1, 0);
rowGroupIndices = std::vector<index_type>(rowGroupCount + 1, 0);
} else {
if (hasCustomRowGrouping) {
// Nothing to do in this case
@ -223,7 +223,7 @@ namespace storm {
}
template<typename ValueType>
SparseMatrix<ValueType>::rows::rows(iterator begin, IndexType entryCount) : beginIterator(begin), entryCount(entryCount) {
SparseMatrix<ValueType>::rows::rows(iterator begin, index_type entryCount) : beginIterator(begin), entryCount(entryCount) {
// Intentionally left empty.
}
@ -238,12 +238,12 @@ namespace storm {
}
template<typename ValueType>
typename SparseMatrix<ValueType>::IndexType SparseMatrix<ValueType>::rows::getNumberOfEntries() const {
typename SparseMatrix<ValueType>::index_type SparseMatrix<ValueType>::rows::getNumberOfEntries() const {
return this->entryCount;
}
template<typename ValueType>
SparseMatrix<ValueType>::const_rows::const_rows(const_iterator begin, IndexType entryCount) : beginIterator(begin), entryCount(entryCount) {
SparseMatrix<ValueType>::const_rows::const_rows(const_iterator begin, index_type entryCount) : beginIterator(begin), entryCount(entryCount) {
// Intentionally left empty.
}
@ -258,7 +258,7 @@ namespace storm {
}
template<typename ValueType>
typename SparseMatrix<ValueType>::IndexType SparseMatrix<ValueType>::const_rows::getNumberOfEntries() const {
typename SparseMatrix<ValueType>::index_type SparseMatrix<ValueType>::const_rows::getNumberOfEntries() const {
return this->entryCount;
}
@ -281,7 +281,7 @@ namespace storm {
}
template<typename ValueType>
SparseMatrix<ValueType>::SparseMatrix(IndexType columnCount, std::vector<IndexType> const& rowIndications, std::vector<MatrixEntry<IndexType, ValueType>> const& columnsAndValues, std::vector<IndexType> const& rowGroupIndices) : rowCount(rowIndications.size() - 1), columnCount(columnCount), entryCount(columnsAndValues.size()), nonzeroEntryCount(0), columnsAndValues(columnsAndValues), rowIndications(rowIndications), rowGroupIndices(rowGroupIndices) {
SparseMatrix<ValueType>::SparseMatrix(index_type columnCount, std::vector<index_type> const& rowIndications, std::vector<MatrixEntry<index_type, ValueType>> const& columnsAndValues, std::vector<index_type> const& rowGroupIndices) : rowCount(rowIndications.size() - 1), columnCount(columnCount), entryCount(columnsAndValues.size()), nonzeroEntryCount(0), columnsAndValues(columnsAndValues), rowIndications(rowIndications), rowGroupIndices(rowGroupIndices) {
for (auto const& element : *this) {
if (element.getValue() != storm::utility::constantZero<ValueType>()) {
++this->nonzeroEntryCount;
@ -290,7 +290,7 @@ namespace storm {
}
template<typename ValueType>
SparseMatrix<ValueType>::SparseMatrix(IndexType columnCount, std::vector<IndexType>&& rowIndications, std::vector<MatrixEntry<IndexType, ValueType>>&& columnsAndValues, std::vector<IndexType>&& rowGroupIndices) : rowCount(rowIndications.size() - 1), columnCount(columnCount), entryCount(columnsAndValues.size()), nonzeroEntryCount(0), columnsAndValues(std::move(columnsAndValues)), rowIndications(std::move(rowIndications)), rowGroupIndices(std::move(rowGroupIndices)) {
SparseMatrix<ValueType>::SparseMatrix(index_type columnCount, std::vector<index_type>&& rowIndications, std::vector<MatrixEntry<index_type, ValueType>>&& columnsAndValues, std::vector<index_type>&& rowGroupIndices) : rowCount(rowIndications.size() - 1), columnCount(columnCount), entryCount(columnsAndValues.size()), nonzeroEntryCount(0), columnsAndValues(std::move(columnsAndValues)), rowIndications(std::move(rowIndications)), rowGroupIndices(std::move(rowGroupIndices)) {
for (auto const& element : *this) {
if (element.getValue() != storm::utility::constantZero<ValueType>()) {
++this->nonzeroEntryCount;
@ -341,12 +341,21 @@ namespace storm {
bool equalityResult = true;
equalityResult &= this->getRowCount() == other.getRowCount();
if (!equalityResult) {
return false;
}
equalityResult &= this->getColumnCount() == other.getColumnCount();
if (!equalityResult) {
return false;
}
equalityResult &= this->getRowGroupIndices() == other.getRowGroupIndices();
if (!equalityResult) {
return false;
}
// For the actual contents, we need to do a little bit more work, because we want to ignore elements that
// are set to zero, please they may be represented implicitly in the other matrix.
for (IndexType row = 0; row < this->getRowCount(); ++row) {
for (index_type row = 0; row < this->getRowCount(); ++row) {
for (const_iterator it1 = this->begin(row), ite1 = this->end(row), it2 = other.begin(row), ite2 = other.end(row); it1 != ite1 && it2 != ite2; ++it1, ++it2) {
// Skip over all zero entries in both matrices.
while (it1 != ite1 && it1->getValue() == storm::utility::constantZero<ValueType>()) {
@ -365,43 +374,46 @@ namespace storm {
}
}
}
if (!equalityResult) {
return false;
}
}
return equalityResult;
}
template<typename ValueType>
typename SparseMatrix<ValueType>::IndexType SparseMatrix<ValueType>::getRowCount() const {
typename SparseMatrix<ValueType>::index_type SparseMatrix<ValueType>::getRowCount() const {
return rowCount;
}
template<typename ValueType>
typename SparseMatrix<ValueType>::IndexType SparseMatrix<ValueType>::getColumnCount() const {
typename SparseMatrix<ValueType>::index_type SparseMatrix<ValueType>::getColumnCount() const {
return columnCount;
}
template<typename ValueType>
typename SparseMatrix<ValueType>::IndexType SparseMatrix<ValueType>::getEntryCount() const {
typename SparseMatrix<ValueType>::index_type SparseMatrix<ValueType>::getEntryCount() const {
return entryCount;
}
template<typename ValueType>
typename SparseMatrix<ValueType>::IndexType SparseMatrix<ValueType>::getNonzeroEntryCount() const {
typename SparseMatrix<ValueType>::index_type SparseMatrix<ValueType>::getNonzeroEntryCount() const {
return nonzeroEntryCount;
}
template<typename ValueType>
typename SparseMatrix<ValueType>::IndexType SparseMatrix<ValueType>::getRowGroupCount() const {
typename SparseMatrix<ValueType>::index_type SparseMatrix<ValueType>::getRowGroupCount() const {
return rowGroupIndices.size() - 1;
}
template<typename ValueType>
typename SparseMatrix<ValueType>::IndexType SparseMatrix<ValueType>::getRowGroupSize(IndexType group) const {
typename SparseMatrix<ValueType>::index_type SparseMatrix<ValueType>::getRowGroupSize(index_type group) const {
return this->getRowGroupIndices()[group + 1] - this->getRowGroupIndices()[group];
}
template<typename ValueType>
std::vector<typename SparseMatrix<ValueType>::IndexType> const& SparseMatrix<ValueType>::getRowGroupIndices() const {
std::vector<typename SparseMatrix<ValueType>::index_type> const& SparseMatrix<ValueType>::getRowGroupIndices() const {
return rowGroupIndices;
}
@ -415,14 +427,14 @@ namespace storm {
template<typename ValueType>
void SparseMatrix<ValueType>::makeRowGroupsAbsorbing(storm::storage::BitVector const& rowGroupConstraint) {
for (auto rowGroup : rowGroupConstraint) {
for (IndexType row = this->getRowGroupIndices()[rowGroup]; row < this->getRowGroupIndices()[rowGroup + 1]; ++row) {
for (index_type row = this->getRowGroupIndices()[rowGroup]; row < this->getRowGroupIndices()[rowGroup + 1]; ++row) {
makeRowDirac(row, rowGroup);
}
}
}
template<typename ValueType>
void SparseMatrix<ValueType>::makeRowDirac(IndexType row, IndexType column) {
void SparseMatrix<ValueType>::makeRowDirac(index_type row, index_type column) {
iterator columnValuePtr = this->begin(row);
iterator columnValuePtrEnd = this->end(row);
@ -444,7 +456,7 @@ namespace storm {
}
template<typename ValueType>
ValueType SparseMatrix<ValueType>::getConstrainedRowSum(IndexType row, storm::storage::BitVector const& constraint) const {
ValueType SparseMatrix<ValueType>::getConstrainedRowSum(index_type row, storm::storage::BitVector const& constraint) const {
ValueType result = storm::utility::constantZero<ValueType>();
for (const_iterator it = this->begin(row), ite = this->end(row); it != ite; ++it) {
if (constraint.get(it->getColumn())) {
@ -457,7 +469,7 @@ namespace storm {
template<typename ValueType>
std::vector<ValueType> SparseMatrix<ValueType>::getConstrainedRowSumVector(storm::storage::BitVector const& rowConstraint, storm::storage::BitVector const& columnConstraint) const {
std::vector<ValueType> result(rowConstraint.getNumberOfSetBits());
IndexType currentRowCount = 0;
index_type currentRowCount = 0;
for (auto row : rowConstraint) {
result[currentRowCount++] = getConstrainedRowSum(row, columnConstraint);
}
@ -469,7 +481,7 @@ namespace storm {
std::vector<ValueType> result;
result.reserve(rowGroupConstraint.getNumberOfSetBits());
for (auto rowGroup : rowGroupConstraint) {
for (IndexType row = this->getRowGroupIndices()[rowGroup]; row < this->getRowGroupIndices()[rowGroup + 1]; ++row) {
for (index_type row = this->getRowGroupIndices()[rowGroup]; row < this->getRowGroupIndices()[rowGroup + 1]; ++row) {
result.push_back(getConstrainedRowSum(row, columnConstraint));
}
}
@ -482,9 +494,9 @@ namespace storm {
return getSubmatrix(rowConstraint, columnConstraint, this->getRowGroupIndices(), insertDiagonalElements);
} else {
// Create a fake row grouping to reduce this to a call to a more general method.
std::vector<IndexType> fakeRowGroupIndices(rowCount + 1);
IndexType i = 0;
for (std::vector<IndexType>::iterator it = fakeRowGroupIndices.begin(); it != fakeRowGroupIndices.end(); ++it, ++i) {
std::vector<index_type> fakeRowGroupIndices(rowCount + 1);
index_type i = 0;
for (std::vector<index_type>::iterator it = fakeRowGroupIndices.begin(); it != fakeRowGroupIndices.end(); ++it, ++i) {
*it = i;
}
return getSubmatrix(rowConstraint, columnConstraint, fakeRowGroupIndices, insertDiagonalElements);
@ -492,13 +504,13 @@ namespace storm {
}
template<typename ValueType>
SparseMatrix<ValueType> SparseMatrix<ValueType>::getSubmatrix(storm::storage::BitVector const& rowGroupConstraint, storm::storage::BitVector const& columnConstraint, std::vector<IndexType> const& rowGroupIndices, bool insertDiagonalEntries) const {
SparseMatrix<ValueType> SparseMatrix<ValueType>::getSubmatrix(storm::storage::BitVector const& rowGroupConstraint, storm::storage::BitVector const& columnConstraint, std::vector<index_type> const& rowGroupIndices, bool insertDiagonalEntries) const {
// First, we need to determine the number of entries and the number of rows of the submatrix.
IndexType subEntries = 0;
IndexType subRows = 0;
index_type subEntries = 0;
index_type subRows = 0;
for (auto index : rowGroupConstraint) {
subRows += rowGroupIndices[index + 1] - rowGroupIndices[index];
for (IndexType i = rowGroupIndices[index]; i < rowGroupIndices[index + 1]; ++i) {
for (index_type i = rowGroupIndices[index]; i < rowGroupIndices[index + 1]; ++i) {
bool foundDiagonalElement = false;
for (const_iterator it = this->begin(i), ite = this->end(i); it != ite; ++it) {
@ -523,12 +535,12 @@ namespace storm {
// Create a temporary vector that stores for each index whose bit is set to true the number of bits that
// were set before that particular index.
std::vector<IndexType> bitsSetBeforeIndex;
std::vector<index_type> bitsSetBeforeIndex;
bitsSetBeforeIndex.reserve(columnCount);
// Compute the information to fill this vector.
IndexType lastIndex = 0;
IndexType currentNumberOfSetBits = 0;
index_type lastIndex = 0;
index_type currentNumberOfSetBits = 0;
// If we are requested to add missing diagonal entries, we need to make sure the corresponding rows are also
// taken.
@ -545,10 +557,10 @@ namespace storm {
}
// Copy over selected entries.
IndexType rowCount = 0;
index_type rowCount = 0;
for (auto index : rowGroupConstraint) {
matrixBuilder.newRowGroup(rowCount);
for (IndexType i = rowGroupIndices[index]; i < rowGroupIndices[index + 1]; ++i) {
for (index_type i = rowGroupIndices[index]; i < rowGroupIndices[index + 1]; ++i) {
bool insertedDiagonalElement = false;
for (const_iterator it = this->begin(i), ite = this->end(i); it != ite; ++it) {
@ -574,13 +586,13 @@ namespace storm {
}
template<typename ValueType>
SparseMatrix<ValueType> SparseMatrix<ValueType>::selectRowsFromRowGroups(std::vector<IndexType> const& rowGroupToRowIndexMapping, bool insertDiagonalEntries) const {
SparseMatrix<ValueType> SparseMatrix<ValueType>::selectRowsFromRowGroups(std::vector<index_type> const& rowGroupToRowIndexMapping, bool insertDiagonalEntries) const {
// First, we need to count how many non-zero entries the resulting matrix will have and reserve space for
// diagonal entries if requested.
IndexType subEntries = 0;
for (IndexType rowGroupIndex = 0, rowGroupIndexEnd = rowGroupToRowIndexMapping.size(); rowGroupIndex < rowGroupIndexEnd; ++rowGroupIndex) {
index_type subEntries = 0;
for (index_type rowGroupIndex = 0, rowGroupIndexEnd = rowGroupToRowIndexMapping.size(); rowGroupIndex < rowGroupIndexEnd; ++rowGroupIndex) {
// Determine which row we need to select from the current row group.
IndexType rowToCopy = rowGroupIndices[rowGroupIndex] + rowGroupToRowIndexMapping[rowGroupIndex];
index_type rowToCopy = rowGroupIndices[rowGroupIndex] + rowGroupToRowIndexMapping[rowGroupIndex];
// Iterate through that row and count the number of slots we have to reserve for copying.
bool foundDiagonalElement = false;
@ -599,9 +611,9 @@ namespace storm {
SparseMatrixBuilder<ValueType> matrixBuilder(rowGroupIndices.size() - 1, columnCount, subEntries);
// Copy over the selected lines from the source matrix.
for (IndexType rowGroupIndex = 0, rowGroupIndexEnd = rowGroupToRowIndexMapping.size(); rowGroupIndex < rowGroupIndexEnd; ++rowGroupIndex) {
for (index_type rowGroupIndex = 0, rowGroupIndexEnd = rowGroupToRowIndexMapping.size(); rowGroupIndex < rowGroupIndexEnd; ++rowGroupIndex) {
// Determine which row we need to select from the current row group.
IndexType rowToCopy = rowGroupIndices[rowGroupIndex] + rowGroupToRowIndexMapping[rowGroupIndex];
index_type rowToCopy = rowGroupIndices[rowGroupIndex] + rowGroupToRowIndexMapping[rowGroupIndex];
// Iterate through that row and copy the entries. This also inserts a zero element on the diagonal if
// there is no entry yet.
@ -626,15 +638,15 @@ namespace storm {
template <typename ValueType>
SparseMatrix<ValueType> SparseMatrix<ValueType>::transpose(bool joinGroups) const {
IndexType rowCount = this->getColumnCount();
IndexType columnCount = joinGroups ? this->getRowGroupCount() : this->getRowCount();
IndexType entryCount = this->getEntryCount();
index_type rowCount = this->getColumnCount();
index_type columnCount = joinGroups ? this->getRowGroupCount() : this->getRowCount();
index_type entryCount = this->getEntryCount();
std::vector<IndexType> rowIndications(rowCount + 1);
std::vector<MatrixEntry<IndexType, ValueType>> columnsAndValues(entryCount);
std::vector<index_type> rowIndications(rowCount + 1);
std::vector<MatrixEntry<index_type, ValueType>> columnsAndValues(entryCount);
// First, we need to count how many entries each column has.
for (IndexType group = 0; group < columnCount; ++group) {
for (index_type group = 0; group < columnCount; ++group) {
for (auto const& transition : joinGroups ? this->getRowGroup(group) : this->getRow(group)) {
if (transition.getValue() != storm::utility::constantZero<ValueType>()) {
++rowIndications[transition.getColumn() + 1];
@ -643,17 +655,17 @@ namespace storm {
}
// Now compute the accumulated offsets.
for (IndexType i = 1; i < rowCount + 1; ++i) {
for (index_type i = 1; i < rowCount + 1; ++i) {
rowIndications[i] = rowIndications[i - 1] + rowIndications[i];
}
// Create an array that stores the index for the next value to be added for
// each row in the transposed matrix. Initially this corresponds to the previously
// computed accumulated offsets.
std::vector<IndexType> nextIndices = rowIndications;
std::vector<index_type> nextIndices = rowIndications;
// Now we are ready to actually fill in the values of the transposed matrix.
for (IndexType group = 0; group < columnCount; ++group) {
for (index_type group = 0; group < columnCount; ++group) {
for (auto const& transition : joinGroups ? this->getRowGroup(group) : this->getRow(group)) {
if (transition.getValue() != storm::utility::constantZero<ValueType>()) {
columnsAndValues[nextIndices[transition.getColumn()]] = std::make_pair(group, transition.getValue());
@ -662,8 +674,8 @@ namespace storm {
}
}
std::vector<IndexType> rowGroupIndices(rowCount + 1);
for (IndexType i = 0; i <= rowCount; ++i) {
std::vector<index_type> rowGroupIndices(rowCount + 1);
for (index_type i = 0; i <= rowCount; ++i) {
rowGroupIndices[i] = i;
}
@ -684,7 +696,7 @@ namespace storm {
// If there is a row without the diagonal element, an exception is thrown.
ValueType one = storm::utility::constantOne<ValueType>();
bool foundDiagonalElement = false;
for (IndexType group = 0; group < this->getRowGroupCount(); ++group) {
for (index_type group = 0; group < this->getRowGroupCount(); ++group) {
for (auto& entry : this->getRowGroup(group)) {
if (entry.getColumn() == group) {
entry.setValue(one - entry.getValue());
@ -702,7 +714,7 @@ namespace storm {
template<typename ValueType>
void SparseMatrix<ValueType>::negateAllNonDiagonalEntries() {
// Iterate over all row groups and negate all the elements that are not on the diagonal.
for (IndexType group = 0; group < this->getRowGroupCount(); ++group) {
for (index_type group = 0; group < this->getRowGroupCount(); ++group) {
for (auto& entry : this->getRowGroup(group)) {
if (entry.getColumn() != group) {
entry.setValue(-entry.getValue());
@ -714,7 +726,7 @@ namespace storm {
template<typename ValueType>
void SparseMatrix<ValueType>::deleteDiagonalEntries() {
// Iterate over all rows and negate all the elements that are not on the diagonal.
for (IndexType group = 0; group < this->getRowGroupCount(); ++group) {
for (index_type group = 0; group < this->getRowGroupCount(); ++group) {
for (auto& entry : this->getRowGroup(group)) {
if (entry.getColumn() == group) {
entry.setValue(storm::utility::constantZero<ValueType>());
@ -734,7 +746,7 @@ namespace storm {
SparseMatrixBuilder<ValueType> dInvBuilder(rowCount, columnCount, rowCount);
// Copy entries to the appropriate matrices.
for (IndexType rowNumber = 0; rowNumber < rowCount; ++rowNumber) {
for (index_type rowNumber = 0; rowNumber < rowCount; ++rowNumber) {
// Because the matrix may have several entries on the diagonal, we need to sum them before we are able
// to invert the entry.
@ -759,7 +771,7 @@ namespace storm {
// Iterate over all elements of the current matrix and either continue with the next element in case the
// given matrix does not have a non-zero element at this column position, or multiply the two entries and
// add the result to the corresponding position in the vector.
for (IndexType row = 0; row < rowCount && row < otherMatrix.rowCount; ++row) {
for (index_type row = 0; row < rowCount && row < otherMatrix.rowCount; ++row) {
for (const_iterator it1 = this->begin(row), ite1 = this->end(row), it2 = otherMatrix.begin(row), ite2 = otherMatrix.end(row); it1 != ite1 && it2 != ite2; ++it1) {
if (it1->getColumn() < it2->getColumn()) {
continue;
@ -794,7 +806,7 @@ namespace storm {
void SparseMatrix<ValueType>::multiplyWithVectorSequential(std::vector<ValueType> const& vector, std::vector<ValueType>& result) const {
const_iterator it = this->begin();
const_iterator ite;
typename std::vector<IndexType>::const_iterator rowIterator = rowIndications.begin();
typename std::vector<index_type>::const_iterator rowIterator = rowIndications.begin();
typename std::vector<ValueType>::iterator resultIterator = result.begin();
typename std::vector<ValueType>::iterator resultIteratorEnd = result.end();
@ -810,14 +822,14 @@ namespace storm {
#ifdef STORM_HAVE_INTELTBB
template<typename ValueType>
void SparseMatrix<ValueType>::multiplyWithVectorParallel(std::vector<ValueType> const& vector, std::vector<ValueType>& result) const {
tbb::parallel_for(tbb::blocked_range<IndexType>(0, result.size(), 10),
[&] (tbb::blocked_range<IndexType> const& range) {
IndexType startRow = range.begin();
IndexType endRow = range.end();
tbb::parallel_for(tbb::blocked_range<index_type>(0, result.size(), 10),
[&] (tbb::blocked_range<index_type> const& range) {
index_type startRow = range.begin();
index_type endRow = range.end();
const_iterator it = this->begin(startRow);
const_iterator ite;
std::vector<IndexType>::const_iterator rowIterator = this->rowIndications.begin() + startRow;
std::vector<IndexType>::const_iterator rowIteratorEnd = this->rowIndications.begin() + endRow;
std::vector<index_type>::const_iterator rowIterator = this->rowIndications.begin() + startRow;
std::vector<index_type>::const_iterator rowIteratorEnd = this->rowIndications.begin() + endRow;
typename std::vector<ValueType>::iterator resultIterator = result.begin() + startRow;
typename std::vector<ValueType>::iterator resultIteratorEnd = result.begin() + endRow;
@ -837,7 +849,7 @@ namespace storm {
uint_fast64_t size = sizeof(*this);
// Add size of columns and values.
size += sizeof(MatrixEntry<IndexType, ValueType>) * columnsAndValues.capacity();
size += sizeof(MatrixEntry<index_type, ValueType>) * columnsAndValues.capacity();
// Add row_indications size.
size += sizeof(uint_fast64_t) * rowIndications.capacity();
@ -846,52 +858,52 @@ namespace storm {
}
template<typename ValueType>
typename SparseMatrix<ValueType>::const_rows SparseMatrix<ValueType>::getRows(IndexType startRow, IndexType endRow) const {
typename SparseMatrix<ValueType>::const_rows SparseMatrix<ValueType>::getRows(index_type startRow, index_type endRow) const {
return const_rows(this->columnsAndValues.begin() + this->rowIndications[startRow], this->rowIndications[endRow + 1] - this->rowIndications[startRow]);
}
template<typename ValueType>
typename SparseMatrix<ValueType>::rows SparseMatrix<ValueType>::getRows(IndexType startRow, IndexType endRow) {
typename SparseMatrix<ValueType>::rows SparseMatrix<ValueType>::getRows(index_type startRow, index_type endRow) {
return rows(this->columnsAndValues.begin() + this->rowIndications[startRow], this->rowIndications[endRow + 1] - this->rowIndications[startRow]);
}
template<typename ValueType>
typename SparseMatrix<ValueType>::const_rows SparseMatrix<ValueType>::getRow(IndexType row) const {
typename SparseMatrix<ValueType>::const_rows SparseMatrix<ValueType>::getRow(index_type row) const {
return getRows(row, row);
}
template<typename ValueType>
typename SparseMatrix<ValueType>::rows SparseMatrix<ValueType>::getRow(IndexType row) {
typename SparseMatrix<ValueType>::rows SparseMatrix<ValueType>::getRow(index_type row) {
return getRows(row, row);
}
template<typename ValueType>
typename SparseMatrix<ValueType>::const_rows SparseMatrix<ValueType>::getRowGroup(IndexType rowGroup) const {
typename SparseMatrix<ValueType>::const_rows SparseMatrix<ValueType>::getRowGroup(index_type rowGroup) const {
return getRows(rowGroupIndices[rowGroup], rowGroupIndices[rowGroup + 1] - 1);
}
template<typename ValueType>
typename SparseMatrix<ValueType>::rows SparseMatrix<ValueType>::getRowGroup(IndexType rowGroup) {
typename SparseMatrix<ValueType>::rows SparseMatrix<ValueType>::getRowGroup(index_type rowGroup) {
return getRows(rowGroupIndices[rowGroup], rowGroupIndices[rowGroup + 1] - 1);
}
template<typename ValueType>
typename SparseMatrix<ValueType>::const_iterator SparseMatrix<ValueType>::begin(IndexType row) const {
typename SparseMatrix<ValueType>::const_iterator SparseMatrix<ValueType>::begin(index_type row) const {
return this->columnsAndValues.begin() + this->rowIndications[row];
}
template<typename ValueType>
typename SparseMatrix<ValueType>::iterator SparseMatrix<ValueType>::begin(IndexType row) {
typename SparseMatrix<ValueType>::iterator SparseMatrix<ValueType>::begin(index_type row) {
return this->columnsAndValues.begin() + this->rowIndications[row];
}
template<typename ValueType>
typename SparseMatrix<ValueType>::const_iterator SparseMatrix<ValueType>::end(IndexType row) const {
typename SparseMatrix<ValueType>::const_iterator SparseMatrix<ValueType>::end(index_type row) const {
return this->columnsAndValues.begin() + this->rowIndications[row + 1];
}
template<typename ValueType>
typename SparseMatrix<ValueType>::iterator SparseMatrix<ValueType>::end(IndexType row) {
typename SparseMatrix<ValueType>::iterator SparseMatrix<ValueType>::end(index_type row) {
return this->columnsAndValues.begin() + this->rowIndications[row + 1];
}
@ -906,7 +918,7 @@ namespace storm {
}
template<typename ValueType>
ValueType SparseMatrix<ValueType>::getRowSum(IndexType row) const {
ValueType SparseMatrix<ValueType>::getRowSum(index_type row) const {
ValueType sum = storm::utility::constantZero<ValueType>();
for (const_iterator it = this->begin(row), ite = this->end(row); it != ite; ++it) {
sum += it->getValue();
@ -922,7 +934,7 @@ namespace storm {
if (this->getRowGroupIndices() != matrix.getRowGroupIndices()) return false;
// Check the subset property for all rows individually.
for (IndexType row = 0; row < this->getRowCount(); ++row) {
for (index_type row = 0; row < this->getRowCount(); ++row) {
for (const_iterator it1 = this->begin(row), ite1 = this->end(row), it2 = matrix.begin(row), ite2 = matrix.end(row); it1 != ite1; ++it1) {
// Skip over all entries of the other matrix that are before the current entry in the current matrix.
while (it2 != ite2 && it2->getColumn() < it1->getColumn()) {
@ -940,20 +952,20 @@ namespace storm {
std::ostream& operator<<(std::ostream& out, SparseMatrix<ValueType> const& matrix) {
// Print column numbers in header.
out << "\t\t";
for (typename SparseMatrix<ValueType>::IndexType i = 0; i < matrix.getColumnCount(); ++i) {
for (typename SparseMatrix<ValueType>::index_type i = 0; i < matrix.getColumnCount(); ++i) {
out << i << "\t";
}
out << std::endl;
// Iterate over all row groups.
for (typename SparseMatrix<ValueType>::IndexType group = 0; group < matrix.getRowGroupCount(); ++group) {
for (typename SparseMatrix<ValueType>::index_type group = 0; group < matrix.getRowGroupCount(); ++group) {
out << "\t---- group " << group << "/" << (matrix.getRowGroupCount() - 1) << " ---- " << std::endl;
for (typename SparseMatrix<ValueType>::IndexType i = matrix.getRowGroupIndices()[group]; i < matrix.getRowGroupIndices()[group + 1]; ++i) {
typename SparseMatrix<ValueType>::IndexType nextIndex = matrix.rowIndications[i];
for (typename SparseMatrix<ValueType>::index_type i = matrix.getRowGroupIndices()[group]; i < matrix.getRowGroupIndices()[group + 1]; ++i) {
typename SparseMatrix<ValueType>::index_type nextIndex = matrix.rowIndications[i];
// Print the actual row.
out << i << "\t(\t";
typename SparseMatrix<ValueType>::IndexType currentRealIndex = 0;
typename SparseMatrix<ValueType>::index_type currentRealIndex = 0;
while (currentRealIndex < matrix.columnCount) {
if (nextIndex < matrix.rowIndications[i + 1] && currentRealIndex == matrix.columnsAndValues[nextIndex].getColumn()) {
out << matrix.columnsAndValues[nextIndex].getValue() << "\t";
@ -969,7 +981,7 @@ namespace storm {
// Print column numbers in footer.
out << "\t\t";
for (typename SparseMatrix<ValueType>::IndexType i = 0; i < matrix.getColumnCount(); ++i) {
for (typename SparseMatrix<ValueType>::index_type i = 0; i < matrix.getColumnCount(); ++i) {
out << i << "\t";
}
out << std::endl;
@ -992,11 +1004,11 @@ namespace storm {
}
// Explicitly instantiate the entry, builder and the matrix.
template class MatrixEntry<typename SparseMatrix<double>::IndexType, double>;
template class MatrixEntry<typename SparseMatrix<double>::index_type, double>;
template class SparseMatrixBuilder<double>;
template class SparseMatrix<double>;
template std::ostream& operator<<(std::ostream& out, SparseMatrix<double> const& matrix);
template class MatrixEntry<typename SparseMatrix<int>::IndexType, int>;
template class MatrixEntry<typename SparseMatrix<int>::index_type, int>;
template class SparseMatrixBuilder<int>;
template class SparseMatrix<int>;
template std::ostream& operator<<(std::ostream& out, SparseMatrix<int> const& matrix);

162
src/storage/SparseMatrix.h

@ -14,6 +14,7 @@
#include "src/exceptions/OutOfRangeException.h"
#include <boost/functional/hash.hpp>
#include <boost/container/flat_map.hpp>
// Forward declaration for adapter classes.
namespace storm {
@ -33,20 +34,23 @@ namespace storm {
template<typename IndexType, typename ValueType>
class MatrixEntry {
public:
typedef IndexType index_type;
typedef ValueType value_type;
/*!
* Constructs a matrix entry with the given column and value.
*
* @param column The column of the matrix entry.
* @param value The value of the matrix entry.
*/
MatrixEntry(IndexType column, ValueType value);
MatrixEntry(index_type column, value_type value);
/*!
* Move-constructs the matrix entry fro the given column-value pair.
*
* @param pair The column-value pair from which to move-construct the matrix entry.
*/
MatrixEntry(std::pair<IndexType, ValueType>&& pair);
MatrixEntry(std::pair<index_type, value_type>&& pair);
MatrixEntry() = default;
MatrixEntry(MatrixEntry const& other) = default;
@ -61,39 +65,39 @@ namespace storm {
*
* @return The column of the matrix entry.
*/
IndexType const& getColumn() const;
index_type const& getColumn() const;
/*!
* Sets the column of the current entry.
*
* @param column The column to set for this entry.
*/
void setColumn(IndexType const& column);
void setColumn(index_type const& column);
/*!
* Retrieves the value of the matrix entry.
*
* @return The value of the matrix entry.
*/
ValueType const& getValue() const;
value_type const& getValue() const;
/*!
* Sets the value of the entry in the matrix.
*
* @param value The value that is to be set for this entry.
*/
void setValue(ValueType const& value);
void setValue(value_type const& value);
/*!
* Retrieves a pair of column and value that characterizes this entry.
*
* @return A column-value pair that characterizes this entry.
*/
std::pair<IndexType, ValueType> const& getColumnValuePair() const;
std::pair<index_type, value_type> const& getColumnValuePair() const;
private:
// The actual matrix entry.
std::pair<IndexType, ValueType> entry;
std::pair<index_type, value_type> entry;
};
/*!
@ -113,7 +117,8 @@ namespace storm {
template<typename ValueType>
class SparseMatrixBuilder {
public:
typedef uint_fast64_t IndexType;
typedef uint_fast64_t index_type;
typedef ValueType value_type;
/*!
* Constructs a sparse matrix builder producing a matrix with the given number of rows, columns and entries.
@ -126,7 +131,7 @@ namespace storm {
* @param rowGroups The number of row groups of the resulting matrix. This is only relevant if the matrix
* has a custom row grouping.
*/
SparseMatrixBuilder(IndexType rows = 0, IndexType columns = 0, IndexType entries = 0, bool hasCustomRowGrouping = false, IndexType rowGroups = 0);
SparseMatrixBuilder(index_type rows = 0, index_type columns = 0, index_type entries = 0, bool hasCustomRowGrouping = false, index_type rowGroups = 0);
/*!
* Sets the matrix entry at the given row and column to the given value. After all entries have been added,
@ -141,7 +146,7 @@ namespace storm {
* @param column The column in which the matrix entry is to be set.
* @param value The value that is to be set at the specified row and column.
*/
void addNextValue(IndexType row, IndexType column, ValueType const& value);
void addNextValue(index_type row, index_type column, value_type const& value);
/*!
* Starts a new row group in the matrix. Note that this needs to be called before any entries in the new row
@ -149,7 +154,7 @@ namespace storm {
*
* @param startingRow The starting row of the new row group.
*/
void newRowGroup(IndexType startingRow);
void newRowGroup(index_type startingRow);
/*
* Finalizes the sparse matrix to indicate that initialization process has been completed and the matrix
@ -170,7 +175,7 @@ namespace storm {
* effect if the matrix has been created without the number of row groups given. By construction, the row
* groups added this way will be empty.
*/
SparseMatrix<ValueType> build(IndexType overriddenRowCount = 0, IndexType overriddenColumnCount = 0, IndexType overriddenRowGroupCount = 0);
SparseMatrix<value_type> build(index_type overriddenRowCount = 0, index_type overriddenColumnCount = 0, index_type overriddenRowGroupCount = 0);
private:
/*!
@ -184,16 +189,16 @@ namespace storm {
bool rowCountSet;
// The number of rows of the matrix.
IndexType rowCount;
index_type rowCount;
// A flag indicating whether the number of columns was set upon construction.
bool columnCountSet;
// The number of columns of the matrix.
IndexType columnCount;
index_type columnCount;
// The number of entries in the matrix.
IndexType entryCount;
index_type entryCount;
// A flag indicating whether the builder is to construct a custom row grouping for the matrix.
bool hasCustomRowGrouping;
@ -202,37 +207,37 @@ namespace storm {
bool rowGroupCountSet;
// The number of row groups in the matrix.
IndexType rowGroupCount;
index_type rowGroupCount;
std::vector<IndexType> rowGroupIndices;
std::vector<index_type> rowGroupIndices;
// Stores whether the storage of the matrix was preallocated or not.
bool storagePreallocated;
// The storage for the columns and values of all entries in the matrix.
std::vector<MatrixEntry<IndexType, ValueType>> columnsAndValues;
std::vector<MatrixEntry<index_type, value_type>> columnsAndValues;
// A vector containing the indices at which each given row begins. This index is to be interpreted as an
// index in the valueStorage and the columnIndications vectors. Put differently, the values of the entries
// in row i are valueStorage[rowIndications[i]] to valueStorage[rowIndications[i + 1]] where the last
// entry is not included anymore.
std::vector<IndexType> rowIndications;
std::vector<index_type> rowIndications;
// Stores the current number of entries in the matrix. This is used for inserting an entry into a matrix
// with preallocated storage.
IndexType currentEntryCount;
index_type currentEntryCount;
// Stores the row of the last entry in the matrix. This is used for correctly inserting an entry into a
// matrix.
IndexType lastRow;
index_type lastRow;
// Stores the column of the currently last entry in the matrix. This is used for correctly inserting an
// entry into a matrix.
IndexType lastColumn;
index_type lastColumn;
// Stores the currently active row group. This is used for correctly constructing the row grouping of the
// matrix.
IndexType currentRowGroup;
index_type currentRowGroup;
};
/*!
@ -257,9 +262,10 @@ namespace storm {
friend class storm::adapters::EigenAdapter;
friend class storm::adapters::StormAdapter;
typedef uint_fast64_t IndexType;
typedef typename std::vector<MatrixEntry<IndexType, ValueType>>::iterator iterator;
typedef typename std::vector<MatrixEntry<IndexType, ValueType>>::const_iterator const_iterator;
typedef uint_fast64_t index_type;
typedef ValueType value_type;
typedef typename std::vector<MatrixEntry<index_type, value_type>>::iterator iterator;
typedef typename std::vector<MatrixEntry<index_type, value_type>>::const_iterator const_iterator;
/*!
* This class represents a number of consecutive rows of the matrix.
@ -273,7 +279,7 @@ namespace storm {
* @param begin An iterator that points to the beginning of the row.
* @param entryCount The number of entrys in the rows.
*/
rows(iterator begin, IndexType entryCount);
rows(iterator begin, index_type entryCount);
/*!
* Retrieves an iterator that points to the beginning of the rows.
@ -294,14 +300,14 @@ namespace storm {
*
* @return The number of entries in the rows.
*/
IndexType getNumberOfEntries() const;
index_type getNumberOfEntries() const;
private:
// The pointer to the columnd and value of the first entry.
iterator beginIterator;
// The number of non-zero entries in the rows.
IndexType entryCount;
index_type entryCount;
};
/*!
@ -316,7 +322,7 @@ namespace storm {
* @param begin An iterator that points to the beginning of the row.
* @param entryCount The number of entrys in the rows.
*/
const_rows(const_iterator begin, IndexType entryCount);
const_rows(const_iterator begin, index_type entryCount);
/*!
* Retrieves an iterator that points to the beginning of the rows.
@ -337,14 +343,14 @@ namespace storm {
*
* @return The number of entries in the rows.
*/
IndexType getNumberOfEntries() const;
index_type getNumberOfEntries() const;
private:
// The pointer to the columnd and value of the first entry.
const_iterator beginIterator;
// The number of non-zero entries in the rows.
IndexType entryCount;
index_type entryCount;
};
/*!
@ -364,14 +370,14 @@ namespace storm {
*
* @param other The matrix from which to copy the content.
*/
SparseMatrix(SparseMatrix<ValueType> const& other);
SparseMatrix(SparseMatrix<value_type> const& other);
/*!
* Constructs a sparse matrix by moving the contents of the given matrix to the newly created one.
*
* @param other The matrix from which to move the content.
*/
SparseMatrix(SparseMatrix<ValueType>&& other);
SparseMatrix(SparseMatrix<value_type>&& other);
/*!
* Constructs a sparse matrix by copying the given contents.
@ -381,7 +387,7 @@ namespace storm {
* @param columnsAndValues The vector containing the columns and values of the entries in the matrix.
* @param rowGroupIndices The vector representing the row groups in the matrix.
*/
SparseMatrix(IndexType columnCount, std::vector<IndexType> const& rowIndications, std::vector<MatrixEntry<IndexType, ValueType>> const& columnsAndValues, std::vector<IndexType> const& rowGroupIndices);
SparseMatrix(index_type columnCount, std::vector<index_type> const& rowIndications, std::vector<MatrixEntry<index_type, value_type>> const& columnsAndValues, std::vector<index_type> const& rowGroupIndices);
/*!
* Constructs a sparse matrix by moving the given contents.
@ -391,21 +397,21 @@ namespace storm {
* @param columnsAndValues The vector containing the columns and values of the entries in the matrix.
* @param rowGroupIndices The vector representing the row groups in the matrix.
*/
SparseMatrix(IndexType columnCount, std::vector<IndexType>&& rowIndications, std::vector<MatrixEntry<IndexType, ValueType>>&& columnsAndValues, std::vector<IndexType>&& rowGroupIndices);
SparseMatrix(index_type columnCount, std::vector<index_type>&& rowIndications, std::vector<MatrixEntry<index_type, value_type>>&& columnsAndValues, std::vector<index_type>&& rowGroupIndices);
/*!
* Assigns the contents of the given matrix to the current one by deep-copying its contents.
*
* @param other The matrix from which to copy-assign.
*/
SparseMatrix<ValueType>& operator=(SparseMatrix<ValueType> const& other);
SparseMatrix<value_type>& operator=(SparseMatrix<value_type> const& other);
/*!
* Assigns the contents of the given matrix to the current one by moving its contents.
*
* @param other The matrix from which to move to contents.
*/
SparseMatrix<ValueType>& operator=(SparseMatrix<ValueType>&& other);
SparseMatrix<value_type>& operator=(SparseMatrix<value_type>&& other);
/*!
* Determines whether the current and the given matrix are semantically equal.
@ -413,42 +419,42 @@ namespace storm {
* @param other The matrix with which to compare the current matrix.
* @return True iff the given matrix is semantically equal to the current one.
*/
bool operator==(SparseMatrix<ValueType> const& other) const;
bool operator==(SparseMatrix<value_type> const& other) const;
/*!
* Returns the number of rows of the matrix.
*
* @return The number of rows of the matrix.
*/
IndexType getRowCount() const;
index_type getRowCount() const;
/*!
* Returns the number of columns of the matrix.
*
* @return The number of columns of the matrix.
*/
IndexType getColumnCount() const;
index_type getColumnCount() const;
/*!
* Returns the number of entries in the matrix.
*
* @return The number of entries in the matrix.
*/
IndexType getEntryCount() const;
index_type getEntryCount() const;
/*!
* Returns the number of nonzero entries in the matrix.
*
* @return The number of nonzero entries in the matrix.
*/
IndexType getNonzeroEntryCount() const;
index_type getNonzeroEntryCount() const;
/*!
* Returns the number of row groups in the matrix.
*
* @return The number of row groups in the matrix.
*/
IndexType getRowGroupCount() const;
index_type getRowGroupCount() const;
/*!
* Returns the size of the given row group.
@ -456,14 +462,14 @@ namespace storm {
* @param group The group whose size to retrieve.
* @return The number of rows that belong to the given row group.
*/
IndexType getRowGroupSize(IndexType group) const;
index_type getRowGroupSize(index_type group) const;
/*!
* Returns the grouping of rows of this matrix.
*
* @return The grouping of rows of this matrix.
*/
std::vector<IndexType> const& getRowGroupIndices() const;
std::vector<index_type> const& getRowGroupIndices() const;
/*!
* This function makes the given rows absorbing.
@ -486,7 +492,7 @@ namespace storm {
* @param row The row to be made Dirac.
* @param column The index of the column whose value is to be set to 1.
*/
void makeRowDirac(const IndexType row, const IndexType column);
void makeRowDirac(index_type row, index_type column);
/*
* Sums the entries in the given row and columns.
@ -495,7 +501,7 @@ namespace storm {
* @param columns A bit vector that indicates which columns to add.
* @return The sum of the entries in the given row and columns.
*/
ValueType getConstrainedRowSum(IndexType row, storm::storage::BitVector const& columns) const;
value_type getConstrainedRowSum(index_type row, storm::storage::BitVector const& columns) const;
/*!
* Computes a vector whose i-th entry is the sum of the entries in the i-th selected row where only those
@ -506,7 +512,7 @@ namespace storm {
*
* @return A vector whose elements are the sums of the selected columns in each row.
*/
std::vector<ValueType> getConstrainedRowSumVector(storm::storage::BitVector const& rowConstraint, storm::storage::BitVector const& columnConstraint) const;
std::vector<value_type> getConstrainedRowSumVector(storm::storage::BitVector const& rowConstraint, storm::storage::BitVector const& columnConstraint) const;
/*!
* Computes a vector whose entries represent the sums of selected columns for all rows in selected row
@ -517,7 +523,7 @@ namespace storm {
* @return A vector whose entries represent the sums of selected columns for all rows in selected row
* groups.
*/
std::vector<ValueType> getConstrainedRowGroupSumVector(storm::storage::BitVector const& rowGroupConstraint, storm::storage::BitVector const& columnConstraint) const;
std::vector<value_type> getConstrainedRowGroupSumVector(storm::storage::BitVector const& rowGroupConstraint, storm::storage::BitVector const& columnConstraint) const;
/*!
* Creates a submatrix of the current matrix by dropping all rows and columns whose bits are not
@ -541,7 +547,7 @@ namespace storm {
* each row in row group i. This can then be used for inserting other values later.
* @return A submatrix of the current matrix by selecting one row out of each row group.
*/
SparseMatrix selectRowsFromRowGroups(std::vector<IndexType> const& rowGroupToRowIndexMapping, bool insertDiagonalEntries = true) const;
SparseMatrix selectRowsFromRowGroups(std::vector<index_type> const& rowGroupToRowIndexMapping, bool insertDiagonalEntries = true) const;
/*!
* Transposes the matrix.
@ -550,7 +556,7 @@ namespace storm {
*
* @return A sparse matrix that represents the transpose of this matrix.
*/
storm::storage::SparseMatrix<ValueType> transpose(bool joinGroups = false) const;
storm::storage::SparseMatrix<value_type> transpose(bool joinGroups = false) const;
/*!
* Transforms the matrix into an equation system. That is, it transforms the matrix A into a matrix (1-A).
@ -578,7 +584,7 @@ namespace storm {
*
* @return A pair (L+U, D^-1) containing the matrix L+U and the inverted diagonal matrix D^-1.
*/
std::pair<storm::storage::SparseMatrix<ValueType>, storm::storage::SparseMatrix<ValueType>> getJacobiDecomposition() const;
std::pair<storm::storage::SparseMatrix<value_type>, storm::storage::SparseMatrix<value_type>> getJacobiDecomposition() const;
/*!
* Performs a pointwise matrix multiplication of the matrix with the given matrix and returns a vector
@ -590,7 +596,7 @@ namespace storm {
* @return A vector containing the sum of the entries in each row of the matrix resulting from pointwise
* multiplication of the current matrix with the given matrix.
*/
std::vector<ValueType> getPointwiseProductRowSumVector(storm::storage::SparseMatrix<ValueType> const& otherMatrix) const;
std::vector<value_type> getPointwiseProductRowSumVector(storm::storage::SparseMatrix<value_type> const& otherMatrix) const;
/*!
* Multiplies the matrix with the given vector and writes the result to the given result vector. If a
@ -601,7 +607,7 @@ namespace storm {
* @param result The vector that is supposed to hold the result of the multiplication after the operation.
* @return The product of the matrix and the given vector as the content of the given result vector.
*/
void multiplyWithVector(std::vector<ValueType> const& vector, std::vector<ValueType>& result) const;
void multiplyWithVector(std::vector<value_type> const& vector, std::vector<value_type>& result) const;
/*!
* Multiplies the matrix with the given vector in a sequential way and writes the result to the given result
@ -611,7 +617,7 @@ namespace storm {
* @param result The vector that is supposed to hold the result of the multiplication after the operation.
* @return The product of the matrix and the given vector as the content of the given result vector.
*/
void multiplyWithVectorSequential(std::vector<ValueType> const& vector, std::vector<ValueType>& result) const;
void multiplyWithVectorSequential(std::vector<value_type> const& vector, std::vector<value_type>& result) const;
#ifdef STORM_HAVE_INTELTBB
/*!
@ -622,7 +628,7 @@ namespace storm {
* @param result The vector that is supposed to hold the result of the multiplication after the operation.
* @return The product of the matrix and the given vector as the content of the given result vector.
*/
void multiplyWithVectorParallel(std::vector<ValueType> const& vector, std::vector<ValueType>& result) const;
void multiplyWithVectorParallel(std::vector<value_type> const& vector, std::vector<value_type>& result) const;
#endif
/*!
@ -631,7 +637,7 @@ namespace storm {
* @param row The row that is to be summed.
* @return The sum of the selected row.
*/
ValueType getRowSum(IndexType row) const;
value_type getRowSum(index_type row) const;
/*!
* Checks if the current matrix is a submatrix of the given matrix, where a matrix A is called a submatrix
@ -640,7 +646,7 @@ namespace storm {
* @param matrix The matrix that possibly is a supermatrix of the current matrix.
* @return True iff the current matrix is a submatrix of the given matrix.
*/
bool isSubmatrixOf(SparseMatrix<ValueType> const& matrix) const;
bool isSubmatrixOf(SparseMatrix<value_type> const& matrix) const;
template<typename TPrime>
friend std::ostream& operator<<(std::ostream& out, SparseMatrix<TPrime> const& matrix);
@ -666,7 +672,7 @@ namespace storm {
* @param endRow The ending row (which is included in the result).
* @return An object representing the consecutive rows given by the parameters.
*/
const_rows getRows(IndexType startRow, IndexType endRow) const;
const_rows getRows(index_type startRow, index_type endRow) const;
/*!
* Returns an object representing the consecutive rows given by the parameters.
@ -675,7 +681,7 @@ namespace storm {
* @param endRow The ending row (which is included in the result).
* @return An object representing the consecutive rows given by the parameters.
*/
rows getRows(IndexType startRow, IndexType endRow);
rows getRows(index_type startRow, index_type endRow);
/*!
* Returns an object representing the given row.
@ -683,7 +689,7 @@ namespace storm {
* @param row The row to get.
* @return An object representing the given row.
*/
const_rows getRow(IndexType row) const;
const_rows getRow(index_type row) const;
/*!
* Returns an object representing the given row.
@ -691,7 +697,7 @@ namespace storm {
* @param row The row to get.
* @return An object representing the given row.
*/
rows getRow(IndexType row);
rows getRow(index_type row);
/*!
* Returns an object representing the given row group.
@ -699,7 +705,7 @@ namespace storm {
* @param rowGroup The row group to get.
* @return An object representing the given row group.
*/
const_rows getRowGroup(IndexType rowGroup) const;
const_rows getRowGroup(index_type rowGroup) const;
/*!
* Returns an object representing the given row group.
@ -707,7 +713,7 @@ namespace storm {
* @param rowGroup The row group to get.
* @return An object representing the given row group.
*/
rows getRowGroup(IndexType rowGroup);
rows getRowGroup(index_type rowGroup);
/*!
* Retrieves an iterator that points to the beginning of the given row.
@ -715,7 +721,7 @@ namespace storm {
* @param row The row to the beginning of which the iterator has to point.
* @return An iterator that points to the beginning of the given row.
*/
const_iterator begin(IndexType row = 0) const;
const_iterator begin(index_type row = 0) const;
/*!
* Retrieves an iterator that points to the beginning of the given row.
@ -723,7 +729,7 @@ namespace storm {
* @param row The row to the beginning of which the iterator has to point.
* @return An iterator that points to the beginning of the given row.
*/
iterator begin(IndexType row = 0);
iterator begin(index_type row = 0);
/*!
* Retrieves an iterator that points past the end of the given row.
@ -731,7 +737,7 @@ namespace storm {
* @param row The row past the end of which the iterator has to point.
* @return An iterator that points past the end of the given row.
*/
const_iterator end(IndexType row) const;
const_iterator end(index_type row) const;
/*!
* Retrieves an iterator that points past the end of the given row.
@ -739,7 +745,7 @@ namespace storm {
* @param row The row past the end of which the iterator has to point.
* @return An iterator that points past the end of the given row.
*/
iterator end(IndexType row);
iterator end(index_type row);
/*!
* Retrieves an iterator that points past the end of the last row of the matrix.
@ -768,31 +774,31 @@ namespace storm {
* @return A matrix corresponding to a submatrix of the current matrix in which only row groups and columns
* given by the row group constraint are kept and all others are dropped.
*/
SparseMatrix getSubmatrix(storm::storage::BitVector const& rowGroupConstraint, storm::storage::BitVector const& columnConstraint, std::vector<IndexType> const& rowGroupIndices, bool insertDiagonalEntries = false) const;
SparseMatrix getSubmatrix(storm::storage::BitVector const& rowGroupConstraint, storm::storage::BitVector const& columnConstraint, std::vector<index_type> const& rowGroupIndices, bool insertDiagonalEntries = false) const;
// The number of rows of the matrix.
IndexType rowCount;
index_type rowCount;
// The number of columns of the matrix.
IndexType columnCount;
index_type columnCount;
// The number of entries in the matrix.
IndexType entryCount;
index_type entryCount;
// The number of nonzero entries in the matrix.
IndexType nonzeroEntryCount;
index_type nonzeroEntryCount;
// The storage for the columns and values of all entries in the matrix.
std::vector<MatrixEntry<IndexType, ValueType>> columnsAndValues;
std::vector<MatrixEntry<index_type, value_type>> columnsAndValues;
// A vector containing the indices at which each given row begins. This index is to be interpreted as an
// index in the valueStorage and the columnIndications vectors. Put differently, the values of the entries
// in row i are valueStorage[rowIndications[i]] to valueStorage[rowIndications[i + 1]] where the last
// entry is not included anymore.
std::vector<IndexType> rowIndications;
std::vector<index_type> rowIndications;
// A vector indicating the row groups of the matrix.
std::vector<IndexType> rowGroupIndices;
std::vector<index_type> rowGroupIndices;
};
} // namespace storage

8
test/functional/solver/Z3SmtSolverTest.cpp

@ -7,7 +7,7 @@
TEST(Z3SmtSolver, CheckSat) {
storm::solver::Z3SmtSolver s;
storm::solver::Z3SmtSolver::CheckResult result;
storm::solver::Z3SmtSolver::CheckResult result = storm::solver::Z3SmtSolver::CheckResult::UNKNOWN;
storm::expressions::Expression exprDeMorgan = !(storm::expressions::Expression::createBooleanVariable("x") && storm::expressions::Expression::createBooleanVariable("y")).iff((!storm::expressions::Expression::createBooleanVariable("x") || !storm::expressions::Expression::createBooleanVariable("y")));
@ -33,7 +33,7 @@ TEST(Z3SmtSolver, CheckSat) {
TEST(Z3SmtSolver, CheckUnsat) {
storm::solver::Z3SmtSolver s;
storm::solver::Z3SmtSolver::CheckResult result;
storm::solver::Z3SmtSolver::CheckResult result = storm::solver::Z3SmtSolver::CheckResult::UNKNOWN;
storm::expressions::Expression exprDeMorgan = !(storm::expressions::Expression::createBooleanVariable("x") && storm::expressions::Expression::createBooleanVariable("y")).iff( (!storm::expressions::Expression::createBooleanVariable("x") || !storm::expressions::Expression::createBooleanVariable("y")));
@ -60,7 +60,7 @@ TEST(Z3SmtSolver, CheckUnsat) {
TEST(Z3SmtSolver, Backtracking) {
storm::solver::Z3SmtSolver s;
storm::solver::Z3SmtSolver::CheckResult result;
storm::solver::Z3SmtSolver::CheckResult result = storm::solver::Z3SmtSolver::CheckResult::UNKNOWN;
storm::expressions::Expression expr1 = storm::expressions::Expression::createTrue();
storm::expressions::Expression expr2 = storm::expressions::Expression::createFalse();
@ -114,7 +114,7 @@ TEST(Z3SmtSolver, Backtracking) {
TEST(Z3SmtSolver, Assumptions) {
storm::solver::Z3SmtSolver s;
storm::solver::Z3SmtSolver::CheckResult result;
storm::solver::Z3SmtSolver::CheckResult result = storm::solver::Z3SmtSolver::CheckResult::UNKNOWN;
storm::expressions::Expression a = storm::expressions::Expression::createIntegerVariable("a");
storm::expressions::Expression b = storm::expressions::Expression::createIntegerVariable("b");

Loading…
Cancel
Save