Browse Source

Set relevant DFT elements earlier in code

tempestpy_adaptions
Matthias Volk 4 years ago
parent
commit
cec37005ae
No known key found for this signature in database GPG Key ID: 83A57678F739FCD3
  1. 7
      src/storm-dft/builder/ExplicitDFTModelBuilder.cpp
  2. 7
      src/storm-dft/builder/ExplicitDFTModelBuilder.h
  3. 17
      src/storm-dft/modelchecker/dft/DFTModelChecker.cpp
  4. 24
      src/test/storm-dft/api/DftModelBuildingTest.cpp

7
src/storm-dft/builder/ExplicitDFTModelBuilder.cpp

@ -34,19 +34,18 @@ namespace storm {
}
template<typename ValueType, typename StateType>
ExplicitDFTModelBuilder<ValueType, StateType>::ExplicitDFTModelBuilder(storm::storage::DFT<ValueType> const& dft, storm::storage::DFTIndependentSymmetries const& symmetries, std::set<size_t> const& relevantEvents, bool allowDCForRelevantEvents) :
ExplicitDFTModelBuilder<ValueType, StateType>::ExplicitDFTModelBuilder(storm::storage::DFT<ValueType> const& dft, storm::storage::DFTIndependentSymmetries const& symmetries) :
dft(dft),
stateGenerationInfo(std::make_shared<storm::storage::DFTStateGenerationInfo>(dft.buildStateGenerationInfo(symmetries))),
relevantEvents(relevantEvents),
generator(dft, *stateGenerationInfo),
matrixBuilder(!generator.isDeterministicModel()),
stateStorage(dft.stateBitVectorSize()),
explorationQueue(1, 0, 0.9, false)
{
// Set relevant events
this->dft.setRelevantEvents(this->relevantEvents, allowDCForRelevantEvents);
STORM_LOG_DEBUG("Relevant events: " << this->dft.getRelevantEventsString());
if (this->relevantEvents.empty()) {
if (dft.getRelevantEvents().size() <= 1) {
STORM_LOG_ASSERT(dft.getRelevantEvents()[0] == dft.getTopLevelIndex(), "TLE is not relevant");
// Only interested in top level event -> introduce unique failed state
this->uniqueFailedState = true;
STORM_LOG_DEBUG("Using unique failed state with id 0.");

7
src/storm-dft/builder/ExplicitDFTModelBuilder.h

@ -155,10 +155,8 @@ namespace storm {
*
* @param dft DFT.
* @param symmetries Symmetries in the dft.
* @param relevantEvents List with ids of relevant events which should be observed.
* @param allowDCForRelevantEvents If true, Don't Care propagation is allowed even for relevant events.
*/
ExplicitDFTModelBuilder(storm::storage::DFT<ValueType> const& dft, storm::storage::DFTIndependentSymmetries const& symmetries, std::set<size_t> const& relevantEvents, bool allowDCForRelevantEvents);
ExplicitDFTModelBuilder(storm::storage::DFT<ValueType> const& dft, storm::storage::DFTIndependentSymmetries const& symmetries);
/*!
* Build model from DFT.
@ -291,9 +289,6 @@ namespace storm {
// TODO: use const reference
std::shared_ptr<storm::storage::DFTStateGenerationInfo> stateGenerationInfo;
// List with ids of relevant events which should be observed.
std::set<size_t> const& relevantEvents;
// Heuristic used for approximation
storm::builder::ApproximationHeuristic usedHeuristic;

17
src/storm-dft/modelchecker/dft/DFTModelChecker.cpp

@ -207,6 +207,7 @@ namespace storm {
STORM_LOG_DEBUG("Building Model via parallel composition...");
explorationTimer.start();
ft.setRelevantEvents(relevantEvents, allowDCForRelevantEvents);
// Find symmetries
std::map<size_t, std::vector<std::vector<size_t>>> emptySymmetry;
storm::storage::DFTIndependentSymmetries symmetries(emptySymmetry);
@ -219,7 +220,7 @@ namespace storm {
// Build a single CTMC
STORM_LOG_DEBUG("Building Model from DFT with top level element " << ft.getElement(ft.getTopLevelIndex())->toString() << " ...");
storm::builder::ExplicitDFTModelBuilder<ValueType> builder(ft, symmetries, relevantEvents, allowDCForRelevantEvents);
storm::builder::ExplicitDFTModelBuilder<ValueType> builder(ft, symmetries);
builder.buildModel(0, 0.0);
std::shared_ptr<storm::models::sparse::Model<ValueType>> model = builder.getModel();
explorationTimer.stop();
@ -267,6 +268,9 @@ namespace storm {
} else {
// No composition was possible
explorationTimer.start();
dft.setRelevantEvents(relevantEvents, allowDCForRelevantEvents);
// Find symmetries
std::map<size_t, std::vector<std::vector<size_t>>> emptySymmetry;
storm::storage::DFTIndependentSymmetries symmetries(emptySymmetry);
@ -279,8 +283,7 @@ namespace storm {
// Build a single CTMC
STORM_LOG_DEBUG("Building Model...");
storm::builder::ExplicitDFTModelBuilder<ValueType> builder(dft, symmetries, relevantEvents,
allowDCForRelevantEvents);
storm::builder::ExplicitDFTModelBuilder<ValueType> builder(dft, symmetries);
builder.buildModel(0, 0.0);
std::shared_ptr<storm::models::sparse::Model<ValueType>> model = builder.getModel();
if (printInfo) {
@ -306,6 +309,8 @@ namespace storm {
auto ioSettings = storm::settings::getModule<storm::settings::modules::IOSettings>();
auto dftIOSettings = storm::settings::getModule<storm::settings::modules::DftIOSettings>();
dft.setRelevantEvents(relevantEvents, allowDCForRelevantEvents);
// Find symmetries
std::map<size_t, std::vector<std::vector<size_t>>> emptySymmetry;
storm::storage::DFTIndependentSymmetries symmetries(emptySymmetry);
@ -324,8 +329,7 @@ namespace storm {
storm::utility::zero<ValueType>());
std::shared_ptr<storm::models::sparse::Model<ValueType>> model;
std::vector<ValueType> newResult;
storm::builder::ExplicitDFTModelBuilder<ValueType> builder(dft, symmetries, relevantEvents,
allowDCForRelevantEvents);
storm::builder::ExplicitDFTModelBuilder<ValueType> builder(dft, symmetries);
// TODO: compute approximation for all properties simultaneously?
std::shared_ptr<const storm::logic::Formula> property = properties[0];
@ -422,8 +426,7 @@ namespace storm {
// Build a single Markov Automaton
auto ioSettings = storm::settings::getModule<storm::settings::modules::IOSettings>();
STORM_LOG_DEBUG("Building Model...");
storm::builder::ExplicitDFTModelBuilder<ValueType> builder(dft, symmetries, relevantEvents,
allowDCForRelevantEvents);
storm::builder::ExplicitDFTModelBuilder<ValueType> builder(dft, symmetries);
builder.buildModel(0, 0.0);
std::shared_ptr<storm::models::sparse::Model<ValueType>> model = builder.getModel();
if (eliminateChains && model->isOfType(storm::models::ModelType::MarkovAutomaton)) {

24
src/test/storm-dft/api/DftModelBuildingTest.cpp

@ -19,17 +19,18 @@ namespace {
// Set relevant events (none)
std::set<size_t> relevantEvents;
dft->setRelevantEvents(relevantEvents, false);
// Build model
storm::builder::ExplicitDFTModelBuilder<double> builder(*dft, symmetries, relevantEvents, false);
storm::builder::ExplicitDFTModelBuilder<double> builder(*dft, symmetries);
builder.buildModel(0, 0.0);
std::shared_ptr<storm::models::sparse::Model<double>> model = builder.getModel();
EXPECT_EQ(8ul, model->getNumberOfStates());
EXPECT_EQ(13ul, model->getNumberOfTransitions());
// Set relevant events (all)
relevantEvents = dft->getAllIds();
dft->setRelevantEvents(dft->getAllIds(), false);
// Build model
storm::builder::ExplicitDFTModelBuilder<double> builder2(*dft, symmetries, relevantEvents, false);
storm::builder::ExplicitDFTModelBuilder<double> builder2(*dft, symmetries);
builder2.buildModel(0, 0.0);
model = builder2.getModel();
EXPECT_EQ(512ul, model->getNumberOfStates());
@ -38,8 +39,9 @@ namespace {
// Set relevant events (H)
relevantEvents.clear();
relevantEvents.insert(dft->getIndex("H"));
dft->setRelevantEvents(relevantEvents, false);
// Build model
storm::builder::ExplicitDFTModelBuilder<double> builder3(*dft, symmetries, relevantEvents, false);
storm::builder::ExplicitDFTModelBuilder<double> builder3(*dft, symmetries);
builder3.buildModel(0, 0.0);
model = builder3.getModel();
EXPECT_EQ(12ul, model->getNumberOfStates());
@ -50,8 +52,9 @@ namespace {
relevantEvents.clear();
relevantEvents.insert(dft->getIndex("H"));
relevantEvents.insert(dft->getIndex("I"));
dft->setRelevantEvents(relevantEvents, false);
// Build model
storm::builder::ExplicitDFTModelBuilder<double> builder4(*dft, symmetries, relevantEvents, false);
storm::builder::ExplicitDFTModelBuilder<double> builder4(*dft, symmetries);
builder4.buildModel(0, 0.0);
model = builder4.getModel();
EXPECT_EQ(16ul, model->getNumberOfStates());
@ -59,17 +62,18 @@ namespace {
// Set relevant events (none)
relevantEvents.clear();
dft->setRelevantEvents(relevantEvents, true);
// Build model
storm::builder::ExplicitDFTModelBuilder<double> builder5(*dft, symmetries, relevantEvents, true);
storm::builder::ExplicitDFTModelBuilder<double> builder5(*dft, symmetries);
builder5.buildModel(0, 0.0);
model = builder5.getModel();
EXPECT_EQ(8ul, model->getNumberOfStates());
EXPECT_EQ(13ul, model->getNumberOfTransitions());
// Set relevant events (all)
relevantEvents = dft->getAllIds();
dft->setRelevantEvents(dft->getAllIds(), true);
// Build model
storm::builder::ExplicitDFTModelBuilder<double> builder6(*dft, symmetries, relevantEvents, true);
storm::builder::ExplicitDFTModelBuilder<double> builder6(*dft, symmetries);
builder6.buildModel(0, 0.0);
model = builder6.getModel();
EXPECT_EQ(8ul, model->getNumberOfStates());
@ -80,13 +84,13 @@ namespace {
relevantEvents.clear();
relevantEvents.insert(dft->getIndex("H"));
relevantEvents.insert(dft->getIndex("I"));
dft->setRelevantEvents(relevantEvents, true);
// Build model
storm::builder::ExplicitDFTModelBuilder<double> builder7(*dft, symmetries, relevantEvents, true);
storm::builder::ExplicitDFTModelBuilder<double> builder7(*dft, symmetries);
builder7.buildModel(0, 0.0);
model = builder7.getModel();
EXPECT_EQ(8ul, model->getNumberOfStates());
EXPECT_EQ(13ul, model->getNumberOfTransitions());
}
}
Loading…
Cancel
Save