No known key found for this signature in database
GPG Key ID: 83A57678F739FCD3
11 changed files with 200 additions and 165 deletions
-
6src/storm-dft-cli/storm-dft.cpp
-
23src/storm-dft/api/storm-dft.h
-
4src/storm-dft/builder/ExplicitDFTModelBuilder.cpp
-
44src/storm-dft/modelchecker/dft/DFTModelChecker.cpp
-
34src/storm-dft/modelchecker/dft/DFTModelChecker.h
-
14src/storm-dft/storage/dft/DFT.cpp
-
11src/storm-dft/storage/dft/DFT.h
-
155src/storm-dft/utility/RelevantEvents.h
-
6src/test/storm-dft/api/DftApproximationTest.cpp
-
31src/test/storm-dft/api/DftModelBuildingTest.cpp
-
37src/test/storm-dft/api/DftModelCheckerTest.cpp
@ -1,69 +1,122 @@ |
|||||
#pragma once |
#pragma once |
||||
|
|
||||
|
#include "storm/exceptions/InvalidArgumentException.h" |
||||
|
#include "storm/logic/AtomicLabelFormula.h" |
||||
|
#include "storm/logic/Formula.h" |
||||
|
#include "storm/settings/SettingsManager.h" |
||||
|
|
||||
#include "storm-dft/storage/dft/DFT.h" |
#include "storm-dft/storage/dft/DFT.h" |
||||
#include "storm-dft/settings/modules/FaultTreeSettings.h" |
#include "storm-dft/settings/modules/FaultTreeSettings.h" |
||||
|
|
||||
namespace storm { |
namespace storm { |
||||
namespace utility { |
namespace utility { |
||||
|
|
||||
/*! |
class RelevantEvents { |
||||
* Get relevant event names from labels in properties. |
public: |
||||
* |
/*! |
||||
* @param dft DFT. |
* Create relevant events from given event names. |
||||
* @param properties List of properties. All events occurring in a property are relevant. |
* If name 'all' occurs, all elements are stored as relevant. |
||||
* @return List of relevant event names. |
* |
||||
*/ |
* @param relevantEvents List of relevant event names. |
||||
template <typename ValueType> |
* @param allowDCForRelevant Whether to allow Don't Care propagation for relevant events. |
||||
std::vector<std::string> getRelevantEventNames(storm::storage::DFT<ValueType> const& dft, std::vector<std::shared_ptr<storm::logic::Formula const>> const& properties) { |
*/ |
||||
// Get necessary labels from properties |
RelevantEvents(std::vector<std::string> const& relevantEvents = {}, bool allowDCForRelevant = false) : names(), allRelevant(false), allowDC(allowDCForRelevant) { |
||||
std::vector<std::shared_ptr<storm::logic::AtomicLabelFormula const>> atomicLabels; |
for (auto const& name: relevantEvents) { |
||||
for (auto property : properties) { |
if (name == "all") { |
||||
property->gatherAtomicLabelFormulas(atomicLabels); |
this->allRelevant = true; |
||||
|
this->names.clear(); |
||||
|
break; |
||||
|
} else { |
||||
|
this->addEvent(name); |
||||
|
} |
||||
|
} |
||||
} |
} |
||||
// Add relevant event names from properties |
/*! |
||||
std::vector<std::string> relevantEventNames; |
* Add relevant event names required by the labels in properties. |
||||
for (auto atomic : atomicLabels) { |
* |
||||
std::string label = atomic->getLabel(); |
* @param properties List of properties. All events occurring in a property are relevant. |
||||
if (label == "failed" or label == "skipped") { |
*/ |
||||
// Ignore as these label will always be added if necessary |
void addNamesFromProperty(std::vector<std::shared_ptr<storm::logic::Formula const>> const& properties) { |
||||
} else { |
if (this->allRelevant) { |
||||
// Get name of event |
return; |
||||
if (boost::ends_with(label, "_failed")) { |
} |
||||
relevantEventNames.push_back(label.substr(0, label.size() - 7)); |
// Get necessary labels from properties |
||||
} else if (boost::ends_with(label, "_dc")) { |
std::vector<std::shared_ptr<storm::logic::AtomicLabelFormula const>> atomicLabels; |
||||
relevantEventNames.push_back(label.substr(0, label.size() - 3)); |
for (auto property : properties) { |
||||
} else if (label.find("_claimed_") != std::string::npos) { |
property->gatherAtomicLabelFormulas(atomicLabels); |
||||
STORM_LOG_THROW(storm::settings::getModule<storm::settings::modules::FaultTreeSettings>().isAddLabelsClaiming(), storm::exceptions::InvalidArgumentException, "Claiming labels will not be exported but are required for label '" << label << "'. Try setting --labels-claiming."); |
} |
||||
|
|
||||
|
// Add relevant event names from properties |
||||
|
for (auto atomic : atomicLabels) { |
||||
|
std::string label = atomic->getLabel(); |
||||
|
if (label == "failed" or label == "skipped") { |
||||
|
// Ignore as these label will always be added if necessary |
||||
} else { |
} else { |
||||
STORM_LOG_THROW(false, storm::exceptions::InvalidArgumentException, "Label '" << label << "' not known."); |
// Get name of event |
||||
|
if (boost::ends_with(label, "_failed")) { |
||||
|
this->addEvent(label.substr(0, label.size() - 7)); |
||||
|
} else if (boost::ends_with(label, "_dc")) { |
||||
|
this->addEvent(label.substr(0, label.size() - 3)); |
||||
|
} else if (label.find("_claimed_") != std::string::npos) { |
||||
|
STORM_LOG_THROW(storm::settings::getModule<storm::settings::modules::FaultTreeSettings>().isAddLabelsClaiming(), storm::exceptions::InvalidArgumentException, "Claiming labels will not be exported but are required for label '" << label << "'. Try setting --labels-claiming."); |
||||
|
} else { |
||||
|
STORM_LOG_THROW(false, storm::exceptions::InvalidArgumentException, "Label '" << label << "' not known."); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/*! |
||||
|
* Check that the relevant names correspond to existing elements in the DFT. |
||||
|
* |
||||
|
* @param dft DFT. |
||||
|
* @return True iff relevant names are consistent with DFT elements. |
||||
|
*/ |
||||
|
template <typename ValueType> |
||||
|
bool checkRelevantNames(storm::storage::DFT<ValueType> const& dft) const { |
||||
|
for (std::string const& relevantName : this->names) { |
||||
|
if (!dft.existsName(relevantName)) { |
||||
|
return false; |
||||
} |
} |
||||
} |
} |
||||
|
return true; |
||||
} |
} |
||||
return relevantEventNames; |
bool isRelevant(std::string const& name) const { |
||||
} |
if (this->allRelevant) { |
||||
|
return true; |
||||
/*! |
|
||||
* Get relevant event id from relevant event name. |
|
||||
* |
|
||||
* @param dft DFT. |
|
||||
* @param relevantEventNames Names of relevant events. |
|
||||
* @return Set of relevant event ids. |
|
||||
*/ |
|
||||
template <typename ValueType> |
|
||||
std::set<size_t> getRelevantEvents(storm::storage::DFT<ValueType> const& dft, std::vector<std::string> const& relevantEventNames) { |
|
||||
// Set relevant elements |
|
||||
std::set<size_t> relevantEvents; // Per default no event (except the toplevel event) is relevant |
|
||||
for (std::string const& relevantName : relevantEventNames) { |
|
||||
if (relevantName == "all") { |
|
||||
// All events are relevant |
|
||||
return dft.getAllIds(); |
|
||||
} else { |
} else { |
||||
// Find and add corresponding event id |
return this->names.find(name) != this->names.end(); |
||||
relevantEvents.insert(dft.getIndex(relevantName)); |
|
||||
} |
} |
||||
} |
} |
||||
return relevantEvents; |
bool isAllowDC() const { |
||||
} |
return this->allowDC; |
||||
|
} |
||||
|
|
||||
|
private: |
||||
|
|
||||
|
/*! |
||||
|
* Add relevant event. |
||||
|
* |
||||
|
* @param name Name of relevant event. |
||||
|
*/ |
||||
|
void addEvent(std::string const& name) { |
||||
|
names.insert(name); |
||||
|
} |
||||
|
|
||||
|
// Names of relevant events. |
||||
|
std::set<std::string> names; |
||||
|
|
||||
|
// Whether all elements are relevant. |
||||
|
bool allRelevant; |
||||
|
|
||||
|
// Whether to allow Don't Care propagation for relevant events. |
||||
|
bool allowDC; |
||||
|
}; |
||||
|
|
||||
} // namespace utility |
} // namespace utility |
||||
} // namespace storm |
} // namespace storm |
Reference in new issue
xxxxxxxxxx