Browse Source

fixed a bug in sparse matrix builder, fixed some tests

tempestpy_adaptions
dehnert 8 years ago
parent
commit
52b07a0c2f
  1. 3
      resources/examples/testfiles/dtmc/die.pm
  2. 1
      src/storm/generator/PrismNextStateGenerator.cpp
  3. 2
      src/storm/modelchecker/exploration/Bounds.cpp
  4. 13
      src/storm/modelchecker/exploration/SparseExplorationModelChecker.cpp
  5. 11
      src/storm/storage/SparseMatrix.cpp

3
resources/examples/testfiles/dtmc/die.pm

@ -24,3 +24,6 @@ rewards "coin_flips"
endrewards endrewards
label "one" = s=7&d=1; label "one" = s=7&d=1;
label "two" = s=7&d=2;
label "three" = s=7&d=3;
label "done" = s=7;

1
src/storm/generator/PrismNextStateGenerator.cpp

@ -216,7 +216,6 @@ namespace storm {
for (auto& choice : allLabeledChoices) { for (auto& choice : allLabeledChoices) {
allChoices.push_back(std::move(choice)); allChoices.push_back(std::move(choice));
} }
std::size_t totalNumberOfChoices = allChoices.size(); std::size_t totalNumberOfChoices = allChoices.size();
// If there is not a single choice, we return immediately, because the state has no behavior (other than // If there is not a single choice, we return immediately, because the state has no behavior (other than

2
src/storm/modelchecker/exploration/Bounds.cpp

@ -98,11 +98,13 @@ namespace storm {
template<typename StateType, typename ValueType> template<typename StateType, typename ValueType>
void Bounds<StateType, ValueType>::setUpperBoundForState(StateType const& state, ExplorationInformation<StateType, ValueType> const& explorationInformation, ValueType const& value) { void Bounds<StateType, ValueType>::setUpperBoundForState(StateType const& state, ExplorationInformation<StateType, ValueType> const& explorationInformation, ValueType const& value) {
std::cout << "setting value " << value << " for state " << state << " with row group " << explorationInformation.getRowGroup(state) << std::endl;
setUpperBoundForRowGroup(explorationInformation.getRowGroup(state), value); setUpperBoundForRowGroup(explorationInformation.getRowGroup(state), value);
} }
template<typename StateType, typename ValueType> template<typename StateType, typename ValueType>
void Bounds<StateType, ValueType>::setUpperBoundForRowGroup(StateType const& group, ValueType const& value) { void Bounds<StateType, ValueType>::setUpperBoundForRowGroup(StateType const& group, ValueType const& value) {
std::cout << "setting value " << value << " for state (row group) " << group << " where size is " << boundsPerState.size() << std::endl;
boundsPerState[group].second = value; boundsPerState[group].second = value;
} }

13
src/storm/modelchecker/exploration/SparseExplorationModelChecker.cpp

@ -476,12 +476,25 @@ namespace storm {
} }
// Set the bounds of the identified states. // Set the bounds of the identified states.
std::cout << "prob0: " << statesWithProbability0 << std::endl;
for (auto state : statesWithProbability0) { for (auto state : statesWithProbability0) {
// Skip the sink state as it is not contained in the original system.
if (state == sink) {
continue;
}
std::cout << "setting 0 for state " << state << std::endl;
StateType originalState = relevantStates[state]; StateType originalState = relevantStates[state];
std::cout << "original state is " << originalState << ", size: " << relevantStates.size() << std::endl;
bounds.setUpperBoundForState(originalState, explorationInformation, storm::utility::zero<ValueType>()); bounds.setUpperBoundForState(originalState, explorationInformation, storm::utility::zero<ValueType>());
explorationInformation.addTerminalState(originalState); explorationInformation.addTerminalState(originalState);
} }
for (auto state : statesWithProbability1) { for (auto state : statesWithProbability1) {
// Skip the sink state as it is not contained in the original system.
if (state == sink) {
continue;
}
StateType originalState = relevantStates[state]; StateType originalState = relevantStates[state];
bounds.setLowerBoundForState(originalState, explorationInformation, storm::utility::one<ValueType>()); bounds.setLowerBoundForState(originalState, explorationInformation, storm::utility::one<ValueType>());
explorationInformation.addTerminalState(originalState); explorationInformation.addTerminalState(originalState);

11
src/storm/storage/SparseMatrix.cpp

@ -193,14 +193,16 @@ namespace storm {
++currentRowGroup; ++currentRowGroup;
// Close all rows from the most recent one to the starting row. // Close all rows from the most recent one to the starting row.
for (index_type i = lastRow + 1; i <= startingRow; ++i) {
for (index_type i = lastRow + 1; i < startingRow; ++i) {
rowIndications.push_back(currentEntryCount); rowIndications.push_back(currentEntryCount);
} }
if (lastRow + 1 < startingRow) {
// Reset the most recently seen row/column to allow for proper insertion of the following elements. // Reset the most recently seen row/column to allow for proper insertion of the following elements.
lastRow = startingRow;
lastRow = startingRow - 1;
lastColumn = 0; lastColumn = 0;
} }
}
template<typename ValueType> template<typename ValueType>
SparseMatrix<ValueType> SparseMatrixBuilder<ValueType>::build(index_type overriddenRowCount, index_type overriddenColumnCount, index_type overriddenRowGroupCount) { SparseMatrix<ValueType> SparseMatrixBuilder<ValueType>::build(index_type overriddenRowCount, index_type overriddenColumnCount, index_type overriddenRowGroupCount) {
@ -228,7 +230,7 @@ namespace storm {
// as now the indices of row i are always between rowIndications[i] and rowIndications[i + 1], also for // as now the indices of row i are always between rowIndications[i] and rowIndications[i + 1], also for
// the first and last row. // the first and last row.
rowIndications.push_back(currentEntryCount); rowIndications.push_back(currentEntryCount);
assert(rowCount == rowIndications.size() - 1);
STORM_LOG_ASSERT(rowCount == rowIndications.size() - 1, "Wrong sizes of vectors.");
uint_fast64_t columnCount = hasEntries ? highestColumn + 1 : 0; uint_fast64_t columnCount = hasEntries ? highestColumn + 1 : 0;
if (initialColumnCountSet && forceInitialDimensions) { if (initialColumnCountSet && forceInitialDimensions) {
STORM_LOG_THROW(columnCount <= initialColumnCount, storm::exceptions::InvalidStateException, "Expected not more than " << initialColumnCount << " columns, but got " << columnCount << "."); STORM_LOG_THROW(columnCount <= initialColumnCount, storm::exceptions::InvalidStateException, "Expected not more than " << initialColumnCount << " columns, but got " << columnCount << ".");
@ -1590,7 +1592,8 @@ namespace storm {
bool SparseMatrix<ValueType>::isProbabilistic() const { bool SparseMatrix<ValueType>::isProbabilistic() const {
storm::utility::ConstantsComparator<ValueType> comparator; storm::utility::ConstantsComparator<ValueType> comparator;
for (index_type row = 0; row < this->rowCount; ++row) { for (index_type row = 0; row < this->rowCount; ++row) {
if(!comparator.isOne(getRowSum(row))) {
ValueType sum = getRowSum(row);
if (!comparator.isOne(sum)) {
return false; return false;
} }
} }

Loading…
Cancel
Save