Storm 1.10.0.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
bisimulation.h
Go to the documentation of this file.
1#pragma once
2
6
9
12
15
16namespace storm {
17namespace api {
18
19template<typename ModelType>
20std::shared_ptr<ModelType> performDeterministicSparseBisimulationMinimization(std::shared_ptr<ModelType> model,
21 std::vector<std::shared_ptr<storm::logic::Formula const>> const& formulas,
22 storm::storage::BisimulationType type, bool graphPreserving = true) {
24 if (!formulas.empty() && graphPreserving) {
26 }
27 // If we cannot use formula-based decomposition because of
28 // non-graph-preserving regions but there are reward models, we need to
29 // preserve those
30 if (!graphPreserving &&
31 std::any_of(formulas.begin(), formulas.end(), [](auto const& formula) { return formula->getReferencedRewardModels().size() > 0; })) {
32 options.setKeepRewards(true);
33 }
34 options.setType(type);
35
36 storm::storage::DeterministicModelBisimulationDecomposition<ModelType> bisimulationDecomposition(*model, options);
37 bisimulationDecomposition.computeBisimulationDecomposition();
38 return bisimulationDecomposition.getQuotient();
39}
40
41template<typename ModelType>
42std::shared_ptr<ModelType> performNondeterministicSparseBisimulationMinimization(std::shared_ptr<ModelType> model,
43 std::vector<std::shared_ptr<storm::logic::Formula const>> const& formulas,
44 storm::storage::BisimulationType type, bool graphPreserving = true) {
46 if (!formulas.empty() && graphPreserving) {
48 }
49 // If we cannot use formula-based decomposition because of
50 // non-graph-preserving regions but there are reward models, we need to
51 // preserve those
52 if (!graphPreserving &&
53 std::any_of(formulas.begin(), formulas.end(), [](auto const& formula) { return formula->getReferencedRewardModels().size() > 0; })) {
54 options.setKeepRewards(true);
55 }
56 options.setType(type);
57
59 bisimulationDecomposition.computeBisimulationDecomposition();
60 return bisimulationDecomposition.getQuotient();
61}
62
63template<typename ValueType>
64std::shared_ptr<storm::models::sparse::Model<ValueType>> performBisimulationMinimization(
65 std::shared_ptr<storm::models::sparse::Model<ValueType>> const& model, std::vector<std::shared_ptr<storm::logic::Formula const>> const& formulas,
68 model->isOfType(storm::models::ModelType::Dtmc) || model->isOfType(storm::models::ModelType::Ctmc) || model->isOfType(storm::models::ModelType::Mdp),
69 storm::exceptions::NotSupportedException, "Bisimulation minimization is currently only available for DTMCs, CTMCs and MDPs.");
70
71 // Try to get rid of non state-rewards to easy bisimulation computation.
72 model->reduceToStateBasedRewards();
73
74 if (model->isOfType(storm::models::ModelType::Dtmc)) {
75 return performDeterministicSparseBisimulationMinimization<storm::models::sparse::Dtmc<ValueType>>(
76 model->template as<storm::models::sparse::Dtmc<ValueType>>(), formulas, type, graphPreserving);
77 } else if (model->isOfType(storm::models::ModelType::Ctmc)) {
78 return performDeterministicSparseBisimulationMinimization<storm::models::sparse::Ctmc<ValueType>>(
79 model->template as<storm::models::sparse::Ctmc<ValueType>>(), formulas, type, graphPreserving);
80 } else {
81 return performNondeterministicSparseBisimulationMinimization<storm::models::sparse::Mdp<ValueType>>(
82 model->template as<storm::models::sparse::Mdp<ValueType>>(), formulas, type, graphPreserving);
83 }
84}
85
86template<storm::dd::DdType DdType, typename ValueType, typename ExportValueType = ValueType>
87typename std::enable_if<DdType == storm::dd::DdType::Sylvan || std::is_same<ValueType, double>::value,
88 std::shared_ptr<storm::models::Model<ExportValueType>>>::type
90 std::vector<std::shared_ptr<storm::logic::Formula const>> const& formulas,
96 storm::exceptions::NotSupportedException, "Symbolic bisimulation minimization is currently only available for DTMCs, CTMCs, MDPs and MAs.");
97 STORM_LOG_THROW(bisimulationType == storm::storage::BisimulationType::Strong, storm::exceptions::NotSupportedException,
98 "Currently only strong bisimulation is supported.");
99
100 std::shared_ptr<storm::models::Model<ExportValueType>> result;
101 model->getManager().execute([&]() {
102 // Try to get rid of non state-rewards to easy bisimulation computation.
103 model->reduceToStateBasedRewards();
104
105 storm::dd::BisimulationDecomposition<DdType, ValueType, ExportValueType> decomposition(*model, formulas, bisimulationType);
106 decomposition.compute(mode);
107 result = decomposition.getQuotient(quotientFormat);
108 });
109 return result;
110}
111
112template<storm::dd::DdType DdType, typename ValueType, typename ExportValueType = ValueType>
113typename std::enable_if<DdType != storm::dd::DdType::Sylvan && !std::is_same<ValueType, double>::value,
114 std::shared_ptr<storm::models::Model<ExportValueType>>>::type
116 std::vector<std::shared_ptr<storm::logic::Formula const>> const&,
120 STORM_LOG_THROW(false, storm::exceptions::NotSupportedException,
121 "Symbolic bisimulation minimization is not supported for this combination of DD library and value type.");
122 return nullptr;
123}
124
125} // namespace api
126} // namespace storm
void compute(bisimulation::SignatureMode const &mode=bisimulation::SignatureMode::Eager)
Performs partition refinement until a fixpoint has been reached.
std::shared_ptr< storm::models::Model< ExportValueType > > getQuotient(storm::dd::bisimulation::QuotientFormat const &quotientFormat) const
Retrieves the quotient model after the bisimulation decomposition was computed.
Base class for all sparse models.
Definition Model.h:33
Base class for all symbolic models.
Definition Model.h:46
std::shared_ptr< ModelType > getQuotient() const
Retrieves the quotient of the model under the computed bisimulation.
void computeBisimulationDecomposition()
Computes the decomposition of the model into bisimulation equivalence classes.
This class represents the decomposition of a deterministic model into its bisimulation quotient.
This class represents the decomposition of a nondeterministic model into its bisimulation quotient.
#define STORM_LOG_THROW(cond, exception, message)
Definition macros.h:30
std::shared_ptr< storm::models::sparse::Model< ValueType > > performBisimulationMinimization(std::shared_ptr< storm::models::sparse::Model< ValueType > > const &model, std::vector< std::shared_ptr< storm::logic::Formula const > > const &formulas, storm::storage::BisimulationType type=storm::storage::BisimulationType::Strong, bool graphPreserving=true)
std::shared_ptr< ModelType > performDeterministicSparseBisimulationMinimization(std::shared_ptr< ModelType > model, std::vector< std::shared_ptr< storm::logic::Formula const > > const &formulas, storm::storage::BisimulationType type, bool graphPreserving=true)
std::shared_ptr< ModelType > performNondeterministicSparseBisimulationMinimization(std::shared_ptr< ModelType > model, std::vector< std::shared_ptr< storm::logic::Formula const > > const &formulas, storm::storage::BisimulationType type, bool graphPreserving=true)
LabParser.cpp.
Definition cli.cpp:18