Storm 1.11.1.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
DeterministicModelBisimulationDecompositionTest.cpp
Go to the documentation of this file.
1#include "storm-config.h"
2#include "test/storm_gtest.h"
3
11
12TEST(DeterministicModelBisimulationDecomposition, Die) {
13 std::shared_ptr<storm::models::sparse::Model<double>> abstractModel =
14 storm::parser::AutoParser<>::parseModel(STORM_TEST_RESOURCES_DIR "/tra/die.tra", STORM_TEST_RESOURCES_DIR "/lab/die.lab", "", "");
15
16 ASSERT_EQ(abstractModel->getType(), storm::models::ModelType::Dtmc);
17 std::shared_ptr<storm::models::sparse::Dtmc<double>> dtmc = abstractModel->as<storm::models::sparse::Dtmc<double>>();
18
20 ASSERT_NO_THROW(bisim.computeBisimulationDecomposition());
21 std::shared_ptr<storm::models::sparse::Model<double>> result;
22 ASSERT_NO_THROW(result = bisim.getQuotient());
23
24 EXPECT_EQ(storm::models::ModelType::Dtmc, result->getType());
25 EXPECT_EQ(13ul, result->getNumberOfStates());
26 EXPECT_EQ(20ul, result->getNumberOfTransitions());
27
29 options.respectedAtomicPropositions = std::set<std::string>({"one"});
30
32 ASSERT_NO_THROW(bisim2.computeBisimulationDecomposition());
33 ASSERT_NO_THROW(result = bisim2.getQuotient());
34
35 EXPECT_EQ(storm::models::ModelType::Dtmc, result->getType());
36 EXPECT_EQ(5ul, result->getNumberOfStates());
37 EXPECT_EQ(8ul, result->getNumberOfTransitions());
38
40
42 ASSERT_NO_THROW(bisim3.computeBisimulationDecomposition());
43 ASSERT_NO_THROW(result = bisim3.getQuotient());
44
45 EXPECT_EQ(storm::models::ModelType::Dtmc, result->getType());
46 EXPECT_EQ(5ul, result->getNumberOfStates());
47 EXPECT_EQ(8ul, result->getNumberOfTransitions());
48
49 storm::parser::FormulaParser formulaParser;
50 std::shared_ptr<storm::logic::Formula const> formula = formulaParser.parseSingleFormulaFromString("P=? [F \"one\"]");
51
53
55 ASSERT_NO_THROW(bisim4.computeBisimulationDecomposition());
56 ASSERT_NO_THROW(result = bisim4.getQuotient());
57 EXPECT_EQ(storm::models::ModelType::Dtmc, result->getType());
58 EXPECT_EQ(5ul, result->getNumberOfStates());
59 EXPECT_EQ(8ul, result->getNumberOfTransitions());
60}
61
62TEST(DeterministicModelBisimulationDecomposition, Crowds) {
63 std::shared_ptr<storm::models::sparse::Model<double>> abstractModel =
64 storm::parser::AutoParser<>::parseModel(STORM_TEST_RESOURCES_DIR "/tra/crowds5_5.tra", STORM_TEST_RESOURCES_DIR "/lab/crowds5_5.lab", "", "");
65
66 ASSERT_EQ(abstractModel->getType(), storm::models::ModelType::Dtmc);
67 std::shared_ptr<storm::models::sparse::Dtmc<double>> dtmc = abstractModel->as<storm::models::sparse::Dtmc<double>>();
68
70 std::shared_ptr<storm::models::sparse::Model<double>> result;
71 ASSERT_NO_THROW(bisim.computeBisimulationDecomposition());
72 ASSERT_NO_THROW(result = bisim.getQuotient());
73
74 EXPECT_EQ(storm::models::ModelType::Dtmc, result->getType());
75 EXPECT_EQ(334ul, result->getNumberOfStates());
76 EXPECT_EQ(546ul, result->getNumberOfTransitions());
77
79 options.respectedAtomicPropositions = std::set<std::string>({"observe0Greater1"});
80
82 ASSERT_NO_THROW(bisim2.computeBisimulationDecomposition());
83 ASSERT_NO_THROW(result = bisim2.getQuotient());
84
85 EXPECT_EQ(storm::models::ModelType::Dtmc, result->getType());
86 EXPECT_EQ(65ul, result->getNumberOfStates());
87 EXPECT_EQ(105ul, result->getNumberOfTransitions());
88
90
92 ASSERT_NO_THROW(bisim3.computeBisimulationDecomposition());
93 ASSERT_NO_THROW(result = bisim3.getQuotient());
94
95 EXPECT_EQ(storm::models::ModelType::Dtmc, result->getType());
96 EXPECT_EQ(43ul, result->getNumberOfStates());
97 EXPECT_EQ(83ul, result->getNumberOfTransitions());
98
99 storm::parser::FormulaParser formulaParser;
100 std::shared_ptr<storm::logic::Formula const> formula = formulaParser.parseSingleFormulaFromString("P=? [F \"observe0Greater1\"]");
101
103
105 ASSERT_NO_THROW(bisim5.computeBisimulationDecomposition());
106 ASSERT_NO_THROW(result = bisim5.getQuotient());
107
108 EXPECT_EQ(storm::models::ModelType::Dtmc, result->getType());
109 EXPECT_EQ(64ul, result->getNumberOfStates());
110 EXPECT_EQ(104ul, result->getNumberOfTransitions());
111
112 formula = formulaParser.parseSingleFormulaFromString("P=? [true U<=50 \"observe0Greater1\"] ");
113
115
117 ASSERT_NO_THROW(bisim6.computeBisimulationDecomposition());
118 ASSERT_NO_THROW(result = bisim6.getQuotient());
119
120 EXPECT_EQ(storm::models::ModelType::Dtmc, result->getType());
121 EXPECT_EQ(65ul, result->getNumberOfStates());
122 EXPECT_EQ(105ul, result->getNumberOfTransitions());
123}
124
125TEST(DeterministicModelBisimulationDecomposition, Cluster) {
126 // TODO FIXME
127 GTEST_SKIP() << "CTMC bisimulation currently yields unstable results.";
128#ifndef STORM_HAVE_Z3
129 GTEST_SKIP() << "Z3 not available.";
130#endif
131 storm::prism::Program program = storm::parser::PrismParser::parse(STORM_TEST_RESOURCES_DIR "/ctmc/embedded2.sm", true);
132 std::shared_ptr<storm::models::sparse::Model<double>> model =
134
135 ASSERT_EQ(model->getType(), storm::models::ModelType::Ctmc);
136 std::shared_ptr<storm::models::sparse::Ctmc<double>> ctmc = model->as<storm::models::sparse::Ctmc<double>>();
137 ASSERT_EQ(3478ul, ctmc->getNumberOfStates());
138 ASSERT_EQ(14639ul, ctmc->getNumberOfTransitions());
139
141 std::shared_ptr<storm::models::sparse::Model<double>> result;
142 ASSERT_NO_THROW(bisim.computeBisimulationDecomposition());
143 ASSERT_NO_THROW(result = bisim.getQuotient());
144
145 EXPECT_EQ(storm::models::ModelType::Ctmc, result->getType());
146 EXPECT_EQ(1731ul, result->getNumberOfStates());
147 EXPECT_EQ(8619ul, result->getNumberOfTransitions());
148
150 options.respectedAtomicPropositions = std::set<std::string>({"down"});
152 ASSERT_NO_THROW(bisim2.computeBisimulationDecomposition());
153 ASSERT_NO_THROW(result = bisim2.getQuotient());
154
155 EXPECT_EQ(storm::models::ModelType::Ctmc, result->getType());
156 EXPECT_EQ(1618ul, result->getNumberOfStates());
157 EXPECT_EQ(8816ul, result->getNumberOfTransitions());
158
161 ASSERT_NO_THROW(bisim3.computeBisimulationDecomposition());
162 ASSERT_NO_THROW(result = bisim3.getQuotient());
163
164 EXPECT_EQ(storm::models::ModelType::Ctmc, result->getType());
165 EXPECT_EQ(41ul, result->getNumberOfStates());
166 EXPECT_EQ(159ul, result->getNumberOfTransitions());
167
168 storm::parser::FormulaParser formulaParser;
169 std::shared_ptr<storm::logic::Formula const> formula = formulaParser.parseSingleFormulaFromString("P=? [ F<=10000 \"down\"]");
172 ASSERT_NO_THROW(bisim5.computeBisimulationDecomposition());
173 ASSERT_NO_THROW(result = bisim5.getQuotient());
174
175 EXPECT_EQ(storm::models::ModelType::Ctmc, result->getType());
176 EXPECT_EQ(1618ul, result->getNumberOfStates());
177 EXPECT_EQ(8816ul, result->getNumberOfTransitions());
178}
TEST(DeterministicModelBisimulationDecomposition, Die)
std::shared_ptr< storm::models::sparse::Model< ValueType, RewardModelType > > build()
Convert the program given at construction time to an abstract model.
This class represents a continuous-time Markov chain.
Definition Ctmc.h:13
This class represents a discrete-time Markov chain.
Definition Dtmc.h:13
static std::shared_ptr< storm::models::sparse::Model< ValueType, storm::models::sparse::StandardRewardModel< RewardValueType > > > parseModel(std::string const &transitionsFilename, std::string const &labelingFilename, std::string const &stateRewardFilename="", std::string const &transitionRewardFilename="", std::string const &choiceLabelingFilename="")
Checks the given files and parses the model within these files.
std::shared_ptr< storm::logic::Formula const > parseSingleFormulaFromString(std::string const &formulaString) const
Parses the formula given by the provided string.
static storm::prism::Program parse(std::string const &filename, bool prismCompatability=false)
Parses the given file into the PRISM storage classes assuming it complies with the PRISM syntax.
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.