Browse Source

started on proper deadlock handling

Former-commit-id: a10c6b86ab [formerly c0b400e239]
Former-commit-id: 549a0e9880
tempestpy_adaptions
dehnert 8 years ago
parent
commit
169293bfe5
  1. 1
      src/builder/jit/ExplicitJitJaniModelBuilder.cpp
  2. 15
      src/builder/jit/ModelComponentsBuilder.cpp
  3. 1
      src/builder/jit/ModelComponentsBuilder.h
  4. 13
      src/builder/jit/StateBehaviour.cpp
  5. 4
      src/builder/jit/StateBehaviour.h

1
src/builder/jit/ExplicitJitJaniModelBuilder.cpp

@ -227,6 +227,7 @@ namespace storm {
std::cout << "Exploring state " << currentState << ", id " << currentIndex << std::endl; std::cout << "Exploring state " << currentState << ", id " << currentIndex << std::endl;
#endif #endif
behaviour.setExpanded();
exploreNonSynchronizingEdges(currentState, currentIndex, behaviour, statesToExplore); exploreNonSynchronizingEdges(currentState, currentIndex, behaviour, statesToExplore);
this->addStateBehaviour(currentIndex, behaviour); this->addStateBehaviour(currentIndex, behaviour);

15
src/builder/jit/ModelComponentsBuilder.cpp

@ -4,6 +4,10 @@
#include "src/models/sparse/Dtmc.h" #include "src/models/sparse/Dtmc.h"
#include "src/models/sparse/StandardRewardModel.h" #include "src/models/sparse/StandardRewardModel.h"
#include "src/settings/SettingsManager.h"
#include "src/settings/modules/CoreSettings.h"
#include "src/exceptions/WrongFormatException.h"
#include "src/utility/macros.h" #include "src/utility/macros.h"
namespace storm { namespace storm {
@ -12,7 +16,8 @@ namespace storm {
template <typename IndexType, typename ValueType> template <typename IndexType, typename ValueType>
ModelComponentsBuilder<IndexType, ValueType>::ModelComponentsBuilder(storm::jani::ModelType const& modelType) : modelType(modelType), isDeterministicModel(storm::jani::isDeterministicModel(modelType)), isDiscreteTimeModel(storm::jani::isDiscreteTimeModel(modelType)), currentRowGroup(0), currentRow(0), transitionMatrixBuilder(std::make_unique<storm::storage::SparseMatrixBuilder<ValueType>>(0, 0, 0, true, !isDeterministicModel)) { ModelComponentsBuilder<IndexType, ValueType>::ModelComponentsBuilder(storm::jani::ModelType const& modelType) : modelType(modelType), isDeterministicModel(storm::jani::isDeterministicModel(modelType)), isDiscreteTimeModel(storm::jani::isDiscreteTimeModel(modelType)), currentRowGroup(0), currentRow(0), transitionMatrixBuilder(std::make_unique<storm::storage::SparseMatrixBuilder<ValueType>>(0, 0, 0, true, !isDeterministicModel)) {
// Intentionally left empty.
dontFixDeadlocks = storm::settings::getModule<storm::settings::modules::CoreSettings>().isDontFixDeadlocksSet();
} }
template <typename IndexType, typename ValueType> template <typename IndexType, typename ValueType>
@ -30,6 +35,7 @@ namespace storm {
if (!isDeterministicModel) { if (!isDeterministicModel) {
transitionMatrixBuilder->newRowGroup(currentRow); transitionMatrixBuilder->newRowGroup(currentRow);
} }
if (!behaviour.empty()) {
for (auto const& choice : behaviour.getChoices()) { for (auto const& choice : behaviour.getChoices()) {
// Add the elements to the transition matrix. // Add the elements to the transition matrix.
for (auto const& element : choice.getDistribution()) { for (auto const& element : choice.getDistribution()) {
@ -39,6 +45,13 @@ namespace storm {
// Proceed to next row. // Proceed to next row.
++currentRow; ++currentRow;
} }
} else {
if (behaviour.isExpanded() && dontFixDeadlocks) {
STORM_LOG_THROW(false, storm::exceptions::WrongFormatException, "Error while creating sparse matrix from JANI model: found deadlock state and fixing deadlocks was explicitly disabled.");
} else {
// FIXME: fix deadlock
}
}
++currentRowGroup; ++currentRowGroup;
} }

1
src/builder/jit/ModelComponentsBuilder.h

@ -46,6 +46,7 @@ namespace storm {
storm::jani::ModelType modelType; storm::jani::ModelType modelType;
bool isDeterministicModel; bool isDeterministicModel;
bool isDiscreteTimeModel; bool isDiscreteTimeModel;
bool dontFixDeadlocks;
IndexType currentRowGroup; IndexType currentRowGroup;
IndexType currentRow; IndexType currentRow;

13
src/builder/jit/StateBehaviour.cpp

@ -7,7 +7,7 @@ namespace storm {
namespace jit { namespace jit {
template <typename IndexType, typename ValueType> template <typename IndexType, typename ValueType>
StateBehaviour<IndexType, ValueType>::StateBehaviour() : compressed(true) {
StateBehaviour<IndexType, ValueType>::StateBehaviour() : compressed(true), expanded(false) {
// Intentionally left empty. // Intentionally left empty.
} }
@ -56,6 +56,16 @@ namespace storm {
} }
} }
template <typename IndexType, typename ValueType>
bool StateBehaviour<IndexType, ValueType>::isExpanded() const {
return expanded;
}
template <typename IndexType, typename ValueType>
void StateBehaviour<IndexType, ValueType>::setExpaned() {
expanded = true;
}
template <typename IndexType, typename ValueType> template <typename IndexType, typename ValueType>
bool StateBehaviour<IndexType, ValueType>::empty() const { bool StateBehaviour<IndexType, ValueType>::empty() const {
return choices.empty(); return choices.empty();
@ -69,6 +79,7 @@ namespace storm {
template <typename IndexType, typename ValueType> template <typename IndexType, typename ValueType>
void StateBehaviour<IndexType, ValueType>::clear() { void StateBehaviour<IndexType, ValueType>::clear() {
choices.clear(); choices.clear();
expanded = false;
compressed = true; compressed = true;
} }

4
src/builder/jit/StateBehaviour.h

@ -22,6 +22,9 @@ namespace storm {
void reduce(storm::jani::ModelType const& modelType); void reduce(storm::jani::ModelType const& modelType);
void compress(); void compress();
bool isExpanded() const;
void setExpaned();
bool empty() const; bool empty() const;
std::size_t size() const; std::size_t size() const;
void clear(); void clear();
@ -29,6 +32,7 @@ namespace storm {
private: private:
ContainerType choices; ContainerType choices;
bool compressed; bool compressed;
bool expanded;
}; };
} }

Loading…
Cancel
Save