Alexander Bork
6 years ago
7 changed files with 149 additions and 67 deletions
-
4src/storm-dft/api/storm-dft.cpp
-
2src/storm-dft/api/storm-dft.h
-
46src/storm-dft/modelchecker/dft/DFTASFChecker.cpp
-
7src/storm-dft/modelchecker/dft/DFTASFChecker.h
-
112src/storm-dft/utility/FDEPConflictFinder.cpp
-
29src/storm-dft/utility/FDEPConflictFinder.h
-
16src/test/storm-dft/api/DftSmtTest.cpp
@ -0,0 +1,112 @@ |
|||||
|
#include "FDEPConflictFinder.h"
|
||||
|
|
||||
|
namespace storm { |
||||
|
namespace dft { |
||||
|
namespace utility { |
||||
|
|
||||
|
std::vector<std::pair<uint64_t, uint64_t>> |
||||
|
FDEPConflictFinder::getDependencyConflicts(storm::storage::DFT<double> const &dft, |
||||
|
bool useSMT, |
||||
|
uint_fast64_t timeout) { |
||||
|
|
||||
|
std::shared_ptr<storm::modelchecker::DFTASFChecker> smtChecker = nullptr; |
||||
|
if (useSMT) { |
||||
|
storm::modelchecker::DFTASFChecker checker(dft); |
||||
|
smtChecker = std::make_shared<storm::modelchecker::DFTASFChecker>(checker); |
||||
|
smtChecker->activateExperimentalMode(); |
||||
|
smtChecker->toSolver(); |
||||
|
} |
||||
|
|
||||
|
std::vector<std::pair<uint64_t, uint64_t>> res; |
||||
|
uint64_t dep1Index; |
||||
|
uint64_t dep2Index; |
||||
|
for (size_t i = 0; i < dft.getDependencies().size(); ++i) { |
||||
|
dep1Index = dft.getDependencies().at(i); |
||||
|
for (size_t j = i + 1; j < dft.getDependencies().size(); ++j) { |
||||
|
dep2Index = dft.getDependencies().at(j); |
||||
|
if (dft.getDynamicBehavior()[dep1Index] && dft.getDynamicBehavior()[dep2Index]) { |
||||
|
if (useSMT) { // if an SMT solver is to be used
|
||||
|
if (dft.getDependency(dep1Index)->triggerEvent() == |
||||
|
dft.getDependency(dep2Index)->triggerEvent()) { |
||||
|
STORM_LOG_DEBUG("Conflict between " << dft.getElement(dep1Index)->name() << " and " |
||||
|
<< dft.getElement(dep2Index)->name() |
||||
|
<< ": Same trigger"); |
||||
|
res.emplace_back(std::pair<uint64_t, uint64_t>(dep1Index, dep2Index)); |
||||
|
} else { |
||||
|
switch (smtChecker->checkDependencyConflict(dep1Index, dep2Index, timeout)) { |
||||
|
case storm::solver::SmtSolver::CheckResult::Sat: |
||||
|
STORM_LOG_DEBUG( |
||||
|
"Conflict between " << dft.getElement(dep1Index)->name() << " and " |
||||
|
<< dft.getElement(dep2Index)->name()); |
||||
|
res.emplace_back(std::pair<uint64_t, uint64_t>(dep1Index, dep2Index)); |
||||
|
break; |
||||
|
case storm::solver::SmtSolver::CheckResult::Unknown: |
||||
|
STORM_LOG_DEBUG( |
||||
|
"Unknown: Conflict between " << dft.getElement(dep1Index)->name() |
||||
|
<< " and " |
||||
|
<< dft.getElement(dep2Index)->name()); |
||||
|
res.emplace_back(std::pair<uint64_t, uint64_t>(dep1Index, dep2Index)); |
||||
|
break; |
||||
|
default: |
||||
|
STORM_LOG_DEBUG( |
||||
|
"No conflict between " << dft.getElement(dep1Index)->name() |
||||
|
<< " and " |
||||
|
<< dft.getElement(dep2Index)->name()); |
||||
|
break; |
||||
|
} |
||||
|
} |
||||
|
} else { |
||||
|
STORM_LOG_DEBUG( |
||||
|
"Conflict between " << dft.getElement(dep1Index)->name() << " and " |
||||
|
<< dft.getElement(dep2Index)->name()); |
||||
|
res.emplace_back(std::pair<uint64_t, uint64_t>(dep1Index, dep2Index)); |
||||
|
} |
||||
|
} else { |
||||
|
STORM_LOG_DEBUG( |
||||
|
"Static behavior: No conflict between " << dft.getElement(dep1Index)->name() |
||||
|
<< " and " |
||||
|
<< dft.getElement(dep2Index)->name()); |
||||
|
break; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
return res; |
||||
|
} |
||||
|
|
||||
|
std::vector<std::pair<uint64_t, uint64_t>> |
||||
|
FDEPConflictFinder::getDependencyConflicts(storm::storage::DFT<storm::RationalFunction> const &dft, |
||||
|
bool useSMT, |
||||
|
uint_fast64_t timeout) { |
||||
|
if (useSMT) { |
||||
|
STORM_LOG_WARN("SMT encoding for rational functions is not supported"); |
||||
|
} |
||||
|
|
||||
|
std::vector<std::pair<uint64_t, uint64_t>> res; |
||||
|
uint64_t dep1Index; |
||||
|
uint64_t dep2Index; |
||||
|
for (size_t i = 0; i < dft.getDependencies().size(); ++i) { |
||||
|
dep1Index = dft.getDependencies().at(i); |
||||
|
for (size_t j = i + 1; j < dft.getDependencies().size(); ++j) { |
||||
|
dep2Index = dft.getDependencies().at(j); |
||||
|
if (dft.getDynamicBehavior()[dep1Index] && dft.getDynamicBehavior()[dep2Index]) { |
||||
|
STORM_LOG_DEBUG( |
||||
|
"Conflict between " << dft.getElement(dep1Index)->name() << " and " |
||||
|
<< dft.getElement(dep2Index)->name()); |
||||
|
res.emplace_back(std::pair<uint64_t, uint64_t>(dep1Index, dep2Index)); |
||||
|
} else { |
||||
|
STORM_LOG_DEBUG( |
||||
|
"Static behavior: No conflict between " << dft.getElement(dep1Index)->name() |
||||
|
<< " and " |
||||
|
<< dft.getElement(dep2Index)->name()); |
||||
|
break; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
return res; |
||||
|
} |
||||
|
|
||||
|
class FDEPConflictFinder; |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,29 @@ |
|||||
|
#include <vector> |
||||
|
#include "storm-dft/storage/dft/DFT.h" |
||||
|
#include "storm-dft/modelchecker/dft/DFTASFChecker.h" |
||||
|
|
||||
|
namespace storm { |
||||
|
namespace dft { |
||||
|
namespace utility { |
||||
|
class FDEPConflictFinder { |
||||
|
public: |
||||
|
/** |
||||
|
* Get a vector of index pairs of FDEPs in the DFT which are conflicting. Two FDEPs are conflicting if |
||||
|
* their simultaneous triggering may cause unresolvable non-deterministic behavior. |
||||
|
* |
||||
|
* @param dft the DFT |
||||
|
* @param useSMT if set, an SMT solver is used to refine the conflict set |
||||
|
* @param timeout timeout for each query in seconds, defaults to 10 seconds |
||||
|
* @return a vector of pairs of indices. The indices in a pair refer to FDEPs which are conflicting |
||||
|
*/ |
||||
|
static std::vector<std::pair<uint64_t, uint64_t>> |
||||
|
getDependencyConflicts(storm::storage::DFT<double> const &dft, |
||||
|
bool useSMT = false, uint_fast64_t timeout = 10); |
||||
|
|
||||
|
static std::vector<std::pair<uint64_t, uint64_t>> |
||||
|
getDependencyConflicts(storm::storage::DFT<storm::RationalFunction> const &dft, |
||||
|
bool useSMT = false, uint_fast64_t timeout = 10); |
||||
|
}; |
||||
|
} |
||||
|
} |
||||
|
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue