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
7
8namespace storm::dft {
9namespace api {
10
11template<>
12std::pair<std::shared_ptr<storm::gspn::GSPN>, uint64_t> transformToGSPN(storm::dft::storage::DFT<double> const& dft, bool enableDC, bool extendPriorities,
13 bool enableSmartTransformation, bool mergeDCFailed) {
14 // Set Don't Care elements
15 std::set<uint64_t> dontCareElements;
16 if (enableDC) {
17 // Insert all elements as Don't Care elements
18 for (std::size_t i = 0; i < dft.nrElements(); i++) {
19 dontCareElements.insert(dft.getElement(i)->id());
20 }
21 }
22
23 // Transform to GSPN
25 auto priorities = gspnTransformator.computePriorities(extendPriorities);
26 gspnTransformator.transform(priorities, dontCareElements, enableSmartTransformation, mergeDCFailed, extendPriorities);
27 std::shared_ptr<storm::gspn::GSPN> gspn(gspnTransformator.obtainGSPN());
28 return std::make_pair(gspn, gspnTransformator.toplevelFailedPlaceId());
29}
30
31template<>
32std::pair<std::shared_ptr<storm::gspn::GSPN>, uint64_t> transformToGSPN(storm::dft::storage::DFT<storm::RationalFunction> const& dft, bool enableDC,
33 bool extendPriorities, bool enableSmartTransformation, bool mergeDCFailed) {
34 STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, "Transformation to GSPN not supported for this data type.");
35}
36
37std::pair<std::shared_ptr<storm::jani::Model>, std::vector<storm::jani::Property>> transformToJani(storm::gspn::GSPN const& gspn, uint64_t toplevelFailedPlace,
38 bool addDeadlockProperties) {
39 // Build Jani model
41 std::shared_ptr<storm::jani::Model> model(builder.build("dft_gspn"));
42
43 // Build properties
44 std::shared_ptr<storm::expressions::ExpressionManager> const& exprManager = gspn.getExpressionManager();
45 storm::jani::Variable const& topfailedVar = builder.getPlaceVariable(toplevelFailedPlace);
46 storm::expressions::Expression targetExpression = exprManager->integer(1) == topfailedVar.getExpressionVariable().getExpression();
47 // Add variable for easier access to 'failed' state
48 builder.addTransientVariable(model.get(), "failed", targetExpression);
49 auto failedFormula = std::make_shared<storm::logic::AtomicExpressionFormula>(targetExpression);
50 auto properties = builder.getStandardProperties(model.get(), failedFormula, "Failed", "a failed state", true);
51 if (addDeadlockProperties) {
52 auto deadlockProperties = builder.getDeadlockProperties(model.get());
53 properties.insert(properties.end(), deadlockProperties.begin(), deadlockProperties.end());
54 }
55
56 return std::make_pair(model, properties);
57}
58
59} // namespace api
60} // namespace storm::dft
Represents a Dynamic Fault Tree.
Definition DFT.h:50
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:39
std::pair< std::shared_ptr< storm::gspn::GSPN >, uint64_t > transformToGSPN(storm::dft::storage::DFT< double > const &dft, bool enableDC, bool extendPriorities, bool enableSmartTransformation, bool mergeDCFailed)
std::pair< std::shared_ptr< storm::jani::Model >, std::vector< storm::jani::Property > > transformToJani(storm::gspn::GSPN const &gspn, uint64_t toplevelFailedPlace, bool addDeadlockProperties)
Transform GSPN to Jani model.