Storm
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,
24 if (!formulas.empty()) {
26 }
27 options.setType(type);
28
29 storm::storage::DeterministicModelBisimulationDecomposition<ModelType> bisimulationDecomposition(*model, options);
30 bisimulationDecomposition.computeBisimulationDecomposition();
31 return bisimulationDecomposition.getQuotient();
32}
33
34template<typename ModelType>
35std::shared_ptr<ModelType> performNondeterministicSparseBisimulationMinimization(std::shared_ptr<ModelType> model,
36 std::vector<std::shared_ptr<storm::logic::Formula const>> const& formulas,
39 if (!formulas.empty()) {
41 }
42 options.setType(type);
43
45 bisimulationDecomposition.computeBisimulationDecomposition();
46 return bisimulationDecomposition.getQuotient();
47}
48
49template<typename ValueType>
50std::shared_ptr<storm::models::sparse::Model<ValueType>> performBisimulationMinimization(
51 std::shared_ptr<storm::models::sparse::Model<ValueType>> const& model, std::vector<std::shared_ptr<storm::logic::Formula const>> const& formulas,
54 model->isOfType(storm::models::ModelType::Dtmc) || model->isOfType(storm::models::ModelType::Ctmc) || model->isOfType(storm::models::ModelType::Mdp),
55 storm::exceptions::NotSupportedException, "Bisimulation minimization is currently only available for DTMCs, CTMCs and MDPs.");
56
57 // Try to get rid of non state-rewards to easy bisimulation computation.
58 model->reduceToStateBasedRewards();
59
60 if (model->isOfType(storm::models::ModelType::Dtmc)) {
61 return performDeterministicSparseBisimulationMinimization<storm::models::sparse::Dtmc<ValueType>>(
62 model->template as<storm::models::sparse::Dtmc<ValueType>>(), formulas, type);
63 } else if (model->isOfType(storm::models::ModelType::Ctmc)) {
64 return performDeterministicSparseBisimulationMinimization<storm::models::sparse::Ctmc<ValueType>>(
65 model->template as<storm::models::sparse::Ctmc<ValueType>>(), formulas, type);
66 } else {
67 return performNondeterministicSparseBisimulationMinimization<storm::models::sparse::Mdp<ValueType>>(
68 model->template as<storm::models::sparse::Mdp<ValueType>>(), formulas, type);
69 }
70}
71
72template<storm::dd::DdType DdType, typename ValueType, typename ExportValueType = ValueType>
73typename std::enable_if<DdType == storm::dd::DdType::Sylvan || std::is_same<ValueType, double>::value,
74 std::shared_ptr<storm::models::Model<ExportValueType>>>::type
76 std::vector<std::shared_ptr<storm::logic::Formula const>> const& formulas,
82 storm::exceptions::NotSupportedException, "Symbolic bisimulation minimization is currently only available for DTMCs, CTMCs, MDPs and MAs.");
83 STORM_LOG_THROW(bisimulationType == storm::storage::BisimulationType::Strong, storm::exceptions::NotSupportedException,
84 "Currently only strong bisimulation is supported.");
85
86 std::shared_ptr<storm::models::Model<ExportValueType>> result;
87 model->getManager().execute([&]() {
88 // Try to get rid of non state-rewards to easy bisimulation computation.
89 model->reduceToStateBasedRewards();
90
91 storm::dd::BisimulationDecomposition<DdType, ValueType, ExportValueType> decomposition(*model, formulas, bisimulationType);
92 decomposition.compute(mode);
93 result = decomposition.getQuotient(quotientFormat);
94 });
95 return result;
96}
97
98template<storm::dd::DdType DdType, typename ValueType, typename ExportValueType = ValueType>
99typename std::enable_if<DdType != storm::dd::DdType::Sylvan && !std::is_same<ValueType, double>::value,
100 std::shared_ptr<storm::models::Model<ExportValueType>>>::type
102 std::vector<std::shared_ptr<storm::logic::Formula const>> const&,
106 STORM_LOG_THROW(false, storm::exceptions::NotSupportedException,
107 "Symbolic bisimulation minimization is not supported for this combination of DD library and value type.");
108 return nullptr;
109}
110
111} // namespace api
112} // 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< ModelType > performDeterministicSparseBisimulationMinimization(std::shared_ptr< ModelType > model, std::vector< std::shared_ptr< storm::logic::Formula const > > const &formulas, storm::storage::BisimulationType type)
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)
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)
LabParser.cpp.
Definition cli.cpp:18