Storm 1.14.0.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
gspn_transformation.cpp
Go to the documentation of this file.
2
3#include <memory>
4
12
13namespace storm::dft {
14namespace api {
15
16template<>
17std::pair<std::shared_ptr<storm::gspn::GSPN>, uint64_t> transformToGSPN(storm::dft::storage::DFT<double> const& dft) {
20
21 // Set Don't Care elements
22 std::set<uint64_t> dontCareElements;
23 if (!ftSettings.isDisableDC()) {
24 // Insert all elements as Don't Care elements
25 for (std::size_t i = 0; i < dft.nrElements(); i++) {
26 dontCareElements.insert(dft.getElement(i)->id());
27 }
28 }
29
30 // Transform to GSPN
32 auto priorities = gspnTransformator.computePriorities(dftGspnSettings.isExtendPriorities());
33 gspnTransformator.transform(priorities, dontCareElements, !dftGspnSettings.isDisableSmartTransformation(), dftGspnSettings.isMergeDCFailed(),
34 dftGspnSettings.isExtendPriorities());
35 std::shared_ptr<storm::gspn::GSPN> gspn(gspnTransformator.obtainGSPN());
36 return std::make_pair(gspn, gspnTransformator.toplevelFailedPlaceId());
37}
38
39template<>
40std::pair<std::shared_ptr<storm::gspn::GSPN>, uint64_t> transformToGSPN(storm::dft::storage::DFT<storm::RationalFunction> const& dft) {
41 STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, "Transformation to GSPN not supported for this data type.");
42}
43
44std::shared_ptr<storm::jani::Model> transformToJani(storm::gspn::GSPN const& gspn, uint64_t toplevelFailedPlace) {
45 // Build Jani model
47 std::shared_ptr<storm::jani::Model> model(builder.build("dft_gspn"));
48
49 // Build properties
50 std::shared_ptr<storm::expressions::ExpressionManager> const& exprManager = gspn.getExpressionManager();
51 storm::jani::Variable const& topfailedVar = builder.getPlaceVariable(toplevelFailedPlace);
52 storm::expressions::Expression targetExpression = exprManager->integer(1) == topfailedVar.getExpressionVariable().getExpression();
53 // Add variable for easier access to 'failed' state
54 builder.addTransientVariable(model.get(), "failed", targetExpression);
55 auto failedFormula = std::make_shared<storm::logic::AtomicExpressionFormula>(targetExpression);
56 auto properties = builder.getStandardProperties(model.get(), failedFormula, "Failed", "a failed state", true);
57
58 // Export Jani to file
60 if (dftGspnSettings.isWriteToJaniSet()) {
62 storm::api::exportJaniToFile(*model, properties, dftGspnSettings.getWriteToJaniFilename(), jani.isCompactJsonSet());
63 }
64
65 return model;
66}
67
68} // namespace api
69} // namespace storm::dft
This class represents the settings for operations concerning the DFT to GSPN transformation.
bool isExtendPriorities() const
Retrieves whether the experimental setting of priorities should be used.
bool isDisableSmartTransformation() const
Retrieves whether the smart transformation should be disabled.
bool isWriteToJaniSet() const
Retrieves whether the GSPN should be exported as a Jani file.
bool isMergeDCFailed() const
Retrieves whether the DC and failed place should be merged.
std::string getWriteToJaniFilename() const
Retrieves the jani filename for export.
This class represents the settings for DFT model checking.
bool isDisableDC() const
Retrieves whether the option to disable Dont Care propagation is set.
Represents a Dynamic Fault Tree.
Definition DFT.h:49
void transform(std::map< uint64_t, uint64_t > const &priorities, std::set< uint64_t > const &dontCareElements, bool smart=true, bool mergeDCFailed=true, bool extendPriorities=false)
Transform the DFT to a GSPN.
uint64_t toplevelFailedPlaceId()
Get failed place id of top level element.
std::map< uint64_t, uint64_t > computePriorities(bool extendedPrio)
Compute priorities used for GSPN transformation.
storm::expressions::Expression getExpression() const
Retrieves an expression that represents the variable.
Definition Variable.cpp:34
storm::expressions::Variable const & getExpressionVariable() const
Retrieves the associated expression variable.
Definition Variable.cpp:26
#define STORM_LOG_THROW(cond, exception, message)
Definition macros.h:28
void exportJaniToFile(storm::jani::Model const &model, std::vector< storm::jani::Property > const &properties, std::string const &filename, bool compact)
std::shared_ptr< storm::jani::Model > transformToJani(storm::gspn::GSPN const &gspn, uint64_t toplevelFailedPlace)
Transform GSPN to Jani model.
std::pair< std::shared_ptr< storm::gspn::GSPN >, uint64_t > transformToGSPN(storm::dft::storage::DFT< double > const &dft)
SettingsType const & getModule()
Get module.