Browse Source

Marked submatrix check in DTMC and sparse matrix as faulty. Needs to be fixed.

tempestpy_adaptions
dehnert 12 years ago
parent
commit
7b259120b7
  1. 9
      src/models/Dtmc.h
  2. 9
      src/storage/SparseMatrix.h

9
src/models/Dtmc.h

@ -50,10 +50,11 @@ public:
throw storm::exceptions::InvalidArgumentException() << "Probability matrix is invalid."; throw storm::exceptions::InvalidArgumentException() << "Probability matrix is invalid.";
} }
if (this->getTransitionRewardMatrix() != nullptr) { if (this->getTransitionRewardMatrix() != nullptr) {
if (!this->getTransitionRewardMatrix()->isSubmatrixOf(*(this->getTransitionMatrix()))) {
LOG4CPLUS_ERROR(logger, "Transition reward matrix is not a submatrix of the transition matrix, i.e. there are rewards for transitions that do not exist.");
throw storm::exceptions::InvalidArgumentException() << "There are transition rewards for nonexistent transitions.";
}
// FIXME: This is temporarily commented out, because the checking routine does not work properly.
//if (!this->getTransitionRewardMatrix()->isSubmatrixOf(*(this->getTransitionMatrix()))) {
// LOG4CPLUS_ERROR(logger, "Transition reward matrix is not a submatrix of the transition matrix, i.e. there are rewards for transitions that do not exist.");
// throw storm::exceptions::InvalidArgumentException() << "There are transition rewards for nonexistent transitions.";
//}
} }
} }

9
src/storage/SparseMatrix.h

@ -354,8 +354,8 @@ public:
throw storm::exceptions::InvalidStateException("Trying to finalize an uninitialized matrix."); throw storm::exceptions::InvalidStateException("Trying to finalize an uninitialized matrix.");
} else if (currentSize != nonZeroEntryCount) { } else if (currentSize != nonZeroEntryCount) {
triggerErrorState(); triggerErrorState();
LOG4CPLUS_ERROR(logger, "Trying to finalize a matrix that was initialized with more non-zero entries than given.");
throw storm::exceptions::InvalidStateException("Trying to finalize a matrix that was initialized with more non-zero entries than given.");
LOG4CPLUS_ERROR(logger, "Trying to finalize a matrix that was initialized with more non-zero entries than given (expected " << nonZeroEntryCount << " but got " << currentSize << " instead)");
throw storm::exceptions::InvalidStateException() << "Trying to finalize a matrix that was initialized with more non-zero entries than given (expected " << nonZeroEntryCount << " but got " << currentSize << " instead).";
} else { } else {
// Fill in the missing entries in the row_indications array. // Fill in the missing entries in the row_indications array.
// (Can happen because of empty rows at the end.) // (Can happen because of empty rows at the end.)
@ -969,7 +969,7 @@ public:
*/ */
std::vector<T>* getPointwiseProductRowSumVector(storm::storage::SparseMatrix<T> const& otherMatrix) { std::vector<T>* getPointwiseProductRowSumVector(storm::storage::SparseMatrix<T> const& otherMatrix) {
// Prepare result. // Prepare result.
std::vector<T>* result = new std::vector<T>(rowCount);
std::vector<T>* result = new std::vector<T>(rowCount, storm::utility::constGetZero<T>());
// Iterate over all elements of the current matrix and either continue with the next element // 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 // in case the given matrix does not have a non-zero element at this column position, or
@ -982,7 +982,7 @@ public:
// If the precondition of this method (i.e. that the given matrix is a submatrix // If the precondition of this method (i.e. that the given matrix is a submatrix
// of the current one) was fulfilled, we know now that the two elements are in // of the current one) was fulfilled, we know now that the two elements are in
// the same column, so we can multiply and add them to the row sum vector. // the same column, so we can multiply and add them to the row sum vector.
(*result)[row] += otherMatrix.valueStorage[element] * valueStorage[nextOtherElement];
(*result)[row] += otherMatrix.valueStorage[nextOtherElement] * valueStorage[element];
++nextOtherElement; ++nextOtherElement;
} }
} }
@ -1084,6 +1084,7 @@ public:
* @return True iff this is a submatrix of matrix. * @return True iff this is a submatrix of matrix.
*/ */
bool isSubmatrixOf(SparseMatrix<T> const & matrix) const { bool isSubmatrixOf(SparseMatrix<T> const & matrix) const {
// FIXME: THIS DOES NOT IMPLEMENT WHAT IS PROMISED.
if (this->getRowCount() != matrix.getRowCount()) return false; if (this->getRowCount() != matrix.getRowCount()) return false;
if (this->getColumnCount() != matrix.getColumnCount()) return false; if (this->getColumnCount() != matrix.getColumnCount()) return false;

Loading…
Cancel
Save