Storm 1.11.1.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
SparseDtmcParameterLiftingMonotonicityTest.cpp
Go to the documentation of this file.
1#include "storm-config.h"
2#include "test/storm_gtest.h"
3
9#include "storm/api/storm.h"
14
15namespace {
16class DoubleSVIEnvironment {
17 public:
18 typedef double ValueType;
20 static storm::Environment createEnvironment() {
22 env.solver().minMax().setMethod(storm::solver::MinMaxMethod::SoundValueIteration);
23 env.solver().minMax().setPrecision(storm::utility::convertNumber<storm::RationalNumber>(1e-6));
24 return env;
25 }
26};
27
28class RationalPiEnvironment {
29 public:
30 typedef storm::RationalNumber ValueType;
32 static storm::Environment createEnvironment() {
34 env.solver().minMax().setMethod(storm::solver::MinMaxMethod::PolicyIteration);
35 return env;
36 }
37};
38template<typename TestType>
39class SparseDtmcParameterLiftingMonotonicityTest : public ::testing::Test {
40 public:
41 typedef typename TestType::ValueType ValueType;
42 SparseDtmcParameterLiftingMonotonicityTest() : _environment(TestType::createEnvironment()) {}
43 storm::Environment const& env() const {
44 return _environment;
45 }
46 std::unique_ptr<storm::modelchecker::RegionModelChecker<storm::RationalFunction>> initializeRegionModelChecker(
47 std::shared_ptr<storm::models::sparse::Model<storm::RationalFunction>> model, std::shared_ptr<const storm::logic::Formula> formula,
48 bool useMonotonicity) {
49 return storm::api::initializeRegionModelChecker(env(), model, storm::api::createTask<storm::RationalFunction>(formula, true), TestType::regionEngine,
50 true, true, false, storm::api::MonotonicitySetting(useMonotonicity));
51 }
52
53 virtual void SetUp() {
54#ifndef STORM_HAVE_Z3
55 GTEST_SKIP() << "Z3 not available.";
56#endif
57 carl::VariablePool::getInstance().clear();
58 }
59 virtual void TearDown() {
60 carl::VariablePool::getInstance().clear();
61 }
62
63 private:
64 storm::Environment _environment;
65};
66
67typedef ::testing::Types<DoubleSVIEnvironment, RationalPiEnvironment> TestingTypes;
68
69TYPED_TEST_SUITE(SparseDtmcParameterLiftingMonotonicityTest, TestingTypes, );
70
71TYPED_TEST(SparseDtmcParameterLiftingMonotonicityTest, Brp_Prob_Mon_LEQ) {
72 typedef typename TestFixture::ValueType ValueType;
73
74 std::string programFile = STORM_TEST_RESOURCES_DIR "/pdtmc/brp16_2.pm";
75 std::string formulaAsString = "P<=0.84 [F s=5 ]";
76 std::string constantsAsString = ""; // e.g. pL=0.9,TOACK=0.5
77
78 // Program and formula
80 program = storm::utility::prism::preprocess(program, constantsAsString);
81 std::vector<std::shared_ptr<const storm::logic::Formula>> formulas =
83 std::shared_ptr<storm::models::sparse::Dtmc<storm::RationalFunction>> model =
84 storm::api::buildSparseModel<storm::RationalFunction>(program, formulas)->as<storm::models::sparse::Dtmc<storm::RationalFunction>>();
85
86 // Simplify model
88 ASSERT_TRUE(simplifier.simplify(*(formulas[0])));
89 model = simplifier.getSimplifiedModel()->as<storm::models::sparse::Dtmc<storm::RationalFunction>>();
90 formulas[0] = simplifier.getSimplifiedFormula();
91
92 // Apply bisimulation
94 if (storm::settings::getModule<storm::settings::modules::BisimulationSettings>().isWeakBisimulationSet()) {
96 }
97 model = storm::api::performBisimulationMinimization<storm::RationalFunction>(model, formulas, bisimType)
99
100 // Model parameters
101 auto modelParameters = storm::models::sparse::getProbabilityParameters(*model);
102 auto rewParameters = storm::models::sparse::getRewardParameters(*model);
103 modelParameters.insert(rewParameters.begin(), rewParameters.end());
104
105 // Reachability order, as it is already done building we don't need to recreate the order for each region
106 auto monHelper = new storm::analysis::MonotonicityHelper<storm::RationalFunction, ValueType>(model, formulas, {});
107 auto monRes = monHelper->checkMonotonicityInBuild(std::cout);
108 auto order = monRes.begin()->first;
109 ASSERT_EQ(order->getNumberOfAddedStates(), model->getTransitionMatrix().getColumnCount());
110 ASSERT_TRUE(order->getDoneBuilding());
111 auto localMonRes =
112 std::make_shared<storm::analysis::LocalMonotonicityResult<storm::RationalFunctionVariable>>(monRes.begin()->second.first, order->getNumberOfStates());
113
114 // Modelcheckers
115 auto regionCheckerMon = this->initializeRegionModelChecker(model, formulas[0], true);
116 auto regionChecker = this->initializeRegionModelChecker(model, formulas[0], false);
117
118 // start testing
119 auto allSatRegion = storm::api::parseRegion<storm::RationalFunction>("0.7<=pL<=0.9,0.75<=pK<=0.95", modelParameters);
120 auto expectedResult = regionChecker->analyzeRegion(this->env(), allSatRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true);
121 EXPECT_EQ(expectedResult, regionCheckerMon->analyzeRegion(this->env(), allSatRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true));
122
123 auto exBothRegion = storm::api::parseRegion<storm::RationalFunction>("0.4<=pL<=0.65,0.75<=pK<=0.95", modelParameters);
124 expectedResult = regionChecker->analyzeRegion(this->env(), exBothRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true);
125 EXPECT_EQ(expectedResult, regionCheckerMon->analyzeRegion(this->env(), exBothRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true));
126
127 auto allVioRegion = storm::api::parseRegion<storm::RationalFunction>("0.1<=pL<=0.73,0.2<=pK<=0.715", modelParameters);
128 expectedResult = regionChecker->analyzeRegion(this->env(), allVioRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true);
129 EXPECT_EQ(expectedResult, regionCheckerMon->analyzeRegion(this->env(), allVioRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true));
130}
131
132TYPED_TEST(SparseDtmcParameterLiftingMonotonicityTest, Brp_Prob_Mon_GEQ) {
133 typedef typename TestFixture::ValueType ValueType;
134
135 std::string programFile = STORM_TEST_RESOURCES_DIR "/pdtmc/brp16_2.pm";
136 std::string formulaAsString = "P>=0.84 [F s=5 ]";
137 std::string constantsAsString = ""; // e.g. pL=0.9,TOACK=0.5
138
139 // Program and formula
140 storm::prism::Program program = storm::api::parseProgram(programFile);
141 program = storm::utility::prism::preprocess(program, constantsAsString);
142 std::vector<std::shared_ptr<const storm::logic::Formula>> formulas =
144 std::shared_ptr<storm::models::sparse::Dtmc<storm::RationalFunction>> model =
145 storm::api::buildSparseModel<storm::RationalFunction>(program, formulas)->as<storm::models::sparse::Dtmc<storm::RationalFunction>>();
146
147 // Simplify model
149 ASSERT_TRUE(simplifier.simplify(*(formulas[0])));
150 model = simplifier.getSimplifiedModel()->as<storm::models::sparse::Dtmc<storm::RationalFunction>>();
151 formulas[0] = simplifier.getSimplifiedFormula();
152
153 // Apply bisimulation
155 if (storm::settings::getModule<storm::settings::modules::BisimulationSettings>().isWeakBisimulationSet()) {
157 }
158 model = storm::api::performBisimulationMinimization<storm::RationalFunction>(model, formulas, bisimType)
160
161 // Model parameters
162 auto modelParameters = storm::models::sparse::getProbabilityParameters(*model);
163 auto rewParameters = storm::models::sparse::getRewardParameters(*model);
164 modelParameters.insert(rewParameters.begin(), rewParameters.end());
165
166 // Reachability order, as it is already done building we don't need to recreate the order for each region
167 auto monHelper = new storm::analysis::MonotonicityHelper<storm::RationalFunction, ValueType>(model, formulas, {});
168 auto monRes = monHelper->checkMonotonicityInBuild(std::cout);
169 auto order = monRes.begin()->first;
170 ASSERT_EQ(order->getNumberOfAddedStates(), model->getTransitionMatrix().getColumnCount());
171 ASSERT_TRUE(order->getDoneBuilding());
172 auto localMonRes =
173 std::make_shared<storm::analysis::LocalMonotonicityResult<storm::RationalFunctionVariable>>(monRes.begin()->second.first, order->getNumberOfStates());
174
175 // Modelcheckers
176 auto regionCheckerMon = this->initializeRegionModelChecker(model, formulas[0], true);
177 auto regionChecker = this->initializeRegionModelChecker(model, formulas[0], false);
178
179 // start testing
180 auto allSatRegion = storm::api::parseRegion<storm::RationalFunction>("0.1<=pL<=0.73,0.2<=pK<=0.715", modelParameters);
181 auto expectedResult = regionChecker->analyzeRegion(this->env(), allSatRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true);
182 EXPECT_EQ(expectedResult, regionCheckerMon->analyzeRegion(this->env(), allSatRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true));
183
184 auto exBothRegion = storm::api::parseRegion<storm::RationalFunction>("0.4<=pL<=0.65,0.75<=pK<=0.95", modelParameters);
185 expectedResult = regionChecker->analyzeRegion(this->env(), exBothRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true);
186 EXPECT_EQ(expectedResult, regionCheckerMon->analyzeRegion(this->env(), exBothRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true));
187
188 auto allVioRegion = storm::api::parseRegion<storm::RationalFunction>("0.7<=pL<=0.9,0.75<=pK<=0.95", modelParameters);
189 expectedResult = regionChecker->analyzeRegion(this->env(), allVioRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true);
190 EXPECT_EQ(expectedResult, regionCheckerMon->analyzeRegion(this->env(), allVioRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true));
191}
192
193TYPED_TEST(SparseDtmcParameterLiftingMonotonicityTest, Brp_Prob_Mon_LEQ_Incr) {
194 typedef typename TestFixture::ValueType ValueType;
195
196 std::string programFile = STORM_TEST_RESOURCES_DIR "/pdtmc/brp16_2_mon_incr.pm";
197 std::string formulaAsString = "P<=0.84 [F s=5 ]";
198 std::string constantsAsString = ""; // e.g. pL=0.9,TOACK=0.5
199
200 // Program and formula
201 storm::prism::Program program = storm::api::parseProgram(programFile);
202 program = storm::utility::prism::preprocess(program, constantsAsString);
203 std::vector<std::shared_ptr<const storm::logic::Formula>> formulas =
205 std::shared_ptr<storm::models::sparse::Dtmc<storm::RationalFunction>> model =
206 storm::api::buildSparseModel<storm::RationalFunction>(program, formulas)->as<storm::models::sparse::Dtmc<storm::RationalFunction>>();
207
208 // Simplify model
210 ASSERT_TRUE(simplifier.simplify(*(formulas[0])));
211 model = simplifier.getSimplifiedModel()->as<storm::models::sparse::Dtmc<storm::RationalFunction>>();
212 formulas[0] = simplifier.getSimplifiedFormula();
213
214 // Apply bisimulation
216 if (storm::settings::getModule<storm::settings::modules::BisimulationSettings>().isWeakBisimulationSet()) {
218 }
219 model = storm::api::performBisimulationMinimization<storm::RationalFunction>(model, formulas, bisimType)
221
222 // Model parameters
223 auto modelParameters = storm::models::sparse::getProbabilityParameters(*model);
224 auto rewParameters = storm::models::sparse::getRewardParameters(*model);
225 modelParameters.insert(rewParameters.begin(), rewParameters.end());
226
227 // Reachability order, as it is already done building we don't need to recreate the order for each region
228 auto monHelper = new storm::analysis::MonotonicityHelper<storm::RationalFunction, ValueType>(model, formulas, {});
229 auto monRes = monHelper->checkMonotonicityInBuild(std::cout);
230 auto order = monRes.begin()->first;
231 ASSERT_EQ(order->getNumberOfAddedStates(), model->getTransitionMatrix().getColumnCount());
232 ASSERT_TRUE(order->getDoneBuilding());
233 auto localMonRes =
234 std::make_shared<storm::analysis::LocalMonotonicityResult<storm::RationalFunctionVariable>>(monRes.begin()->second.first, order->getNumberOfStates());
235
236 // Modelcheckers
237 auto regionCheckerMon = this->initializeRegionModelChecker(model, formulas[0], true);
238 auto regionChecker = this->initializeRegionModelChecker(model, formulas[0], false);
239
240 // start testing
241 auto allSatRegion = storm::api::parseRegion<storm::RationalFunction>("0.7<=pL<=0.9,0.75<=pK<=0.95", modelParameters);
242 auto expectedResult = regionChecker->analyzeRegion(this->env(), allSatRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true);
243 EXPECT_EQ(expectedResult, regionCheckerMon->analyzeRegion(this->env(), allSatRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true));
244
245 auto exBothRegion = storm::api::parseRegion<storm::RationalFunction>("0.4<=pL<=0.65,0.75<=pK<=0.95", modelParameters);
246 expectedResult = regionChecker->analyzeRegion(this->env(), exBothRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true);
247 EXPECT_EQ(expectedResult, regionCheckerMon->analyzeRegion(this->env(), exBothRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true));
248
249 auto allVioRegion = storm::api::parseRegion<storm::RationalFunction>("0.1<=pL<=0.73,0.2<=pK<=0.715", modelParameters);
250 expectedResult = regionChecker->analyzeRegion(this->env(), allVioRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true);
251 EXPECT_EQ(expectedResult, regionCheckerMon->analyzeRegion(this->env(), allVioRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true));
252}
253
254TYPED_TEST(SparseDtmcParameterLiftingMonotonicityTest, Brp_Prob_Mon_GEQ_Incr) {
255 typedef typename TestFixture::ValueType ValueType;
256
257 std::string programFile = STORM_TEST_RESOURCES_DIR "/pdtmc/brp16_2_mon_incr.pm";
258 std::string formulaAsString = "P>=0.84 [F s=5 ]";
259 std::string constantsAsString = ""; // e.g. pL=0.9,TOACK=0.5
260
261 // Program and formula
262 storm::prism::Program program = storm::api::parseProgram(programFile);
263 program = storm::utility::prism::preprocess(program, constantsAsString);
264 std::vector<std::shared_ptr<const storm::logic::Formula>> formulas =
266 std::shared_ptr<storm::models::sparse::Dtmc<storm::RationalFunction>> model =
267 storm::api::buildSparseModel<storm::RationalFunction>(program, formulas)->as<storm::models::sparse::Dtmc<storm::RationalFunction>>();
268
269 // Simplify model
271 ASSERT_TRUE(simplifier.simplify(*(formulas[0])));
272 model = simplifier.getSimplifiedModel()->as<storm::models::sparse::Dtmc<storm::RationalFunction>>();
273 formulas[0] = simplifier.getSimplifiedFormula();
274
275 // Apply bisimulation
277 if (storm::settings::getModule<storm::settings::modules::BisimulationSettings>().isWeakBisimulationSet()) {
279 }
280 model = storm::api::performBisimulationMinimization<storm::RationalFunction>(model, formulas, bisimType)
282
283 // Model parameters
284 auto modelParameters = storm::models::sparse::getProbabilityParameters(*model);
285 auto rewParameters = storm::models::sparse::getRewardParameters(*model);
286 modelParameters.insert(rewParameters.begin(), rewParameters.end());
287
288 // Reachability order, as it is already done building we don't need to recreate the order for each region
289 auto monHelper = new storm::analysis::MonotonicityHelper<storm::RationalFunction, ValueType>(model, formulas, {});
290 auto monRes = monHelper->checkMonotonicityInBuild(std::cout);
291 auto order = monRes.begin()->first;
292 ASSERT_EQ(order->getNumberOfAddedStates(), model->getTransitionMatrix().getColumnCount());
293 ASSERT_TRUE(order->getDoneBuilding());
294 auto localMonRes =
295 std::make_shared<storm::analysis::LocalMonotonicityResult<storm::RationalFunctionVariable>>(monRes.begin()->second.first, order->getNumberOfStates());
296
297 // Modelcheckers
298 auto regionCheckerMon = this->initializeRegionModelChecker(model, formulas[0], true);
299 auto regionChecker = this->initializeRegionModelChecker(model, formulas[0], false);
300
301 // start testing
302 auto allSatRegion = storm::api::parseRegion<storm::RationalFunction>("0.1<=pL<=0.73,0.2<=pK<=0.715", modelParameters);
303 auto expectedResult = regionChecker->analyzeRegion(this->env(), allSatRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true);
304 EXPECT_EQ(expectedResult, regionCheckerMon->analyzeRegion(this->env(), allSatRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true));
305
306 auto exBothRegion = storm::api::parseRegion<storm::RationalFunction>("0.4<=pL<=0.65,0.75<=pK<=0.95", modelParameters);
307 expectedResult = regionChecker->analyzeRegion(this->env(), exBothRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true);
308 EXPECT_EQ(expectedResult, regionCheckerMon->analyzeRegion(this->env(), exBothRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true));
309
310 auto allVioRegion = storm::api::parseRegion<storm::RationalFunction>("0.7<=pL<=0.9,0.75<=pK<=0.95", modelParameters);
311 expectedResult = regionChecker->analyzeRegion(this->env(), allVioRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true);
312 EXPECT_EQ(expectedResult, regionCheckerMon->analyzeRegion(this->env(), allVioRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true));
313}
314
315TYPED_TEST(SparseDtmcParameterLiftingMonotonicityTest, Parametric_Die_Mon) {
316 typedef typename TestFixture::ValueType ValueType;
317
318 std::string programFile = STORM_TEST_RESOURCES_DIR "/pdtmc/parametric_die_2.pm";
319 std::string formulaAsString = "P <=0.5 [F s=7 & d=2 ]";
320 std::string constantsAsString = ""; // e.g. pL=0.9,TOACK=0.5
321
322 // Program and formula
323 storm::prism::Program program = storm::api::parseProgram(programFile);
324 program = storm::utility::prism::preprocess(program, constantsAsString);
325 std::vector<std::shared_ptr<const storm::logic::Formula>> formulas =
327 std::shared_ptr<storm::models::sparse::Dtmc<storm::RationalFunction>> model =
328 storm::api::buildSparseModel<storm::RationalFunction>(program, formulas)->as<storm::models::sparse::Dtmc<storm::RationalFunction>>();
329
330 // Model parameters
331 auto modelParameters = storm::models::sparse::getProbabilityParameters(*model);
332 auto rewParameters = storm::models::sparse::getRewardParameters(*model);
333 modelParameters.insert(rewParameters.begin(), rewParameters.end());
334
335 // Simplify model
337 ASSERT_TRUE(simplifier.simplify(*(formulas[0])));
338 model = simplifier.getSimplifiedModel()->as<storm::models::sparse::Dtmc<storm::RationalFunction>>();
339 formulas[0] = simplifier.getSimplifiedFormula();
340
341 // Apply bisimulation
343 if (storm::settings::getModule<storm::settings::modules::BisimulationSettings>().isWeakBisimulationSet()) {
345 }
346 model = storm::api::performBisimulationMinimization<storm::RationalFunction>(model, formulas, bisimType)
348
349 // Modelcheckers
350 auto regionCheckerMon = this->initializeRegionModelChecker(model, formulas[0], true);
351 auto regionChecker = this->initializeRegionModelChecker(model, formulas[0], false);
352
353 // Start testing, localMonRes will remain the same
354 auto allSatRegion = storm::api::parseRegion<storm::RationalFunction>("0.1<=p<=0.2,0.8<=q<=0.9", modelParameters);
355 auto monHelper = new storm::analysis::MonotonicityHelper<storm::RationalFunction, ValueType>(model, formulas, {});
356 auto order = monHelper->checkMonotonicityInBuild(std::cout).begin()->first;
357 auto monRes = monHelper->createLocalMonotonicityResult(order, allSatRegion);
358 EXPECT_EQ(regionChecker->analyzeRegion(this->env(), allSatRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true),
359 regionCheckerMon->analyzeRegion(this->env(), allSatRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true));
360
361 auto exBothRegion = storm::api::parseRegion<storm::RationalFunction>("0.1<=p<=0.9,0.1<=q<=0.9", modelParameters);
362 EXPECT_EQ(regionChecker->analyzeRegion(this->env(), exBothRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true),
363 regionCheckerMon->analyzeRegion(this->env(), exBothRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true));
364
365 auto allVioRegion = storm::api::parseRegion<storm::RationalFunction>("0.8<=p<=0.9,0.1<=q<=0.2", modelParameters);
366 EXPECT_EQ(regionChecker->analyzeRegion(this->env(), allVioRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true),
367 regionCheckerMon->analyzeRegion(this->env(), allVioRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true));
368}
369
370TYPED_TEST(SparseDtmcParameterLiftingMonotonicityTest, Simple1_Mon) {
371 typedef typename TestFixture::ValueType ValueType;
372
373 std::string programFile = STORM_TEST_RESOURCES_DIR "/pdtmc/simple1.pm";
374 std::string formulaAsString = "P<0.75 [F s=3 ]";
375 std::string constantsAsString = "";
376
377 // Program and formula
378 storm::prism::Program program = storm::api::parseProgram(programFile);
379 program = storm::utility::prism::preprocess(program, constantsAsString);
380 std::vector<std::shared_ptr<const storm::logic::Formula>> formulas =
382 std::shared_ptr<storm::models::sparse::Dtmc<storm::RationalFunction>> model =
383 storm::api::buildSparseModel<storm::RationalFunction>(program, formulas)->as<storm::models::sparse::Dtmc<storm::RationalFunction>>();
384
385 // Model parameters
386 auto modelParameters = storm::models::sparse::getProbabilityParameters(*model);
387 auto rewParameters = storm::models::sparse::getRewardParameters(*model);
388 modelParameters.insert(rewParameters.begin(), rewParameters.end());
389
390 // Modelcheckers
391 auto regionCheckerMon = this->initializeRegionModelChecker(model, formulas[0], true);
392 auto regionChecker = this->initializeRegionModelChecker(model, formulas[0], false);
393
394 // Start testing
395 auto allSatRegion = storm::api::parseRegion<storm::RationalFunction>("0.4<=p<=0.6", modelParameters);
396 auto monHelper = new storm::analysis::MonotonicityHelper<storm::RationalFunction, ValueType>(model, formulas, {});
397 auto order = monHelper->checkMonotonicityInBuild(std::cout).begin()->first;
398 auto monRes = monHelper->createLocalMonotonicityResult(order, allSatRegion);
399 EXPECT_EQ(regionChecker->analyzeRegion(this->env(), allSatRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true),
400 regionCheckerMon->analyzeRegion(this->env(), allSatRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true));
401
402 auto exBothRegion = storm::api::parseRegion<storm::RationalFunction>("0.1<=p<=0.9", modelParameters);
403 EXPECT_EQ(regionChecker->analyzeRegion(this->env(), exBothRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true),
404 regionCheckerMon->analyzeRegion(this->env(), exBothRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true));
405
406 auto allVioRegion = storm::api::parseRegion<storm::RationalFunction>("0.05<=p<=0.1", modelParameters);
407 EXPECT_EQ(regionChecker->analyzeRegion(this->env(), allVioRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true),
408 regionCheckerMon->analyzeRegion(this->env(), allVioRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true));
409}
410
411TYPED_TEST(SparseDtmcParameterLiftingMonotonicityTest, Casestudy1_Mon) {
412 typedef typename TestFixture::ValueType ValueType;
413
414 std::string programFile = STORM_TEST_RESOURCES_DIR "/pdtmc/casestudy1.pm";
415 std::string formulaAsString = "P<0.5 [F s=3 ]";
416 std::string constantsAsString = "";
417
418 // Program and formula
419 storm::prism::Program program = storm::api::parseProgram(programFile);
420 program = storm::utility::prism::preprocess(program, constantsAsString);
421 std::vector<std::shared_ptr<const storm::logic::Formula>> formulas =
423 std::shared_ptr<storm::models::sparse::Dtmc<storm::RationalFunction>> model =
424 storm::api::buildSparseModel<storm::RationalFunction>(program, formulas)->as<storm::models::sparse::Dtmc<storm::RationalFunction>>();
425
426 // Model parameters
427 auto modelParameters = storm::models::sparse::getProbabilityParameters(*model);
428 auto rewParameters = storm::models::sparse::getRewardParameters(*model);
429 modelParameters.insert(rewParameters.begin(), rewParameters.end());
430
431 // Modelcheckers
432 auto regionCheckerMon = this->initializeRegionModelChecker(model, formulas[0], true);
433 auto regionChecker = this->initializeRegionModelChecker(model, formulas[0], false);
434
435 // Start testing
436 auto allSatRegion = storm::api::parseRegion<storm::RationalFunction>("0.1<=p<=0.5", modelParameters);
437 auto monHelper = new storm::analysis::MonotonicityHelper<storm::RationalFunction, ValueType>(model, formulas, {});
438 auto order = monHelper->checkMonotonicityInBuild(std::cout).begin()->first;
439 auto monRes = monHelper->createLocalMonotonicityResult(order, allSatRegion);
440 EXPECT_EQ(regionChecker->analyzeRegion(this->env(), allSatRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true),
441 regionCheckerMon->analyzeRegion(this->env(), allSatRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true));
442
443 auto exBothRegion = storm::api::parseRegion<storm::RationalFunction>("0.4<=p<=0.8", modelParameters);
444 EXPECT_EQ(regionChecker->analyzeRegion(this->env(), exBothRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true),
445 regionCheckerMon->analyzeRegion(this->env(), exBothRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true));
446
447 auto allVioRegion = storm::api::parseRegion<storm::RationalFunction>("0.7<=p<=0.9", modelParameters);
448 EXPECT_EQ(regionChecker->analyzeRegion(this->env(), allVioRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true),
449 regionCheckerMon->analyzeRegion(this->env(), allVioRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true));
450}
451
452TYPED_TEST(SparseDtmcParameterLiftingMonotonicityTest, Casestudy2_Mon) {
453 typedef typename TestFixture::ValueType ValueType;
454
455 std::string programFile = STORM_TEST_RESOURCES_DIR "/pdtmc/casestudy2.pm";
456 std::string formulaAsString = "P<0.5 [F s=4 ]";
457 std::string constantsAsString = "";
458
459 // Program and formula
460 storm::prism::Program program = storm::api::parseProgram(programFile);
461 program = storm::utility::prism::preprocess(program, constantsAsString);
462 std::vector<std::shared_ptr<const storm::logic::Formula>> formulas =
464 std::shared_ptr<storm::models::sparse::Dtmc<storm::RationalFunction>> model =
465 storm::api::buildSparseModel<storm::RationalFunction>(program, formulas)->as<storm::models::sparse::Dtmc<storm::RationalFunction>>();
466
467 // Model parameters
468 auto modelParameters = storm::models::sparse::getProbabilityParameters(*model);
469 auto rewParameters = storm::models::sparse::getRewardParameters(*model);
470 modelParameters.insert(rewParameters.begin(), rewParameters.end());
471
472 // Modelcheckers
473 auto regionCheckerMon = this->initializeRegionModelChecker(model, formulas[0], true);
474 auto regionChecker = this->initializeRegionModelChecker(model, formulas[0], false);
475
476 // Start testing
477 auto allSatRegion = storm::api::parseRegion<storm::RationalFunction>("0.1<=p<=0.4", modelParameters);
478 auto monHelper = new storm::analysis::MonotonicityHelper<storm::RationalFunction, ValueType>(model, formulas, {});
479 auto order = monHelper->checkMonotonicityInBuild(std::cout).begin()->first;
480 auto monRes = monHelper->createLocalMonotonicityResult(order, allSatRegion);
481 EXPECT_EQ(regionChecker->analyzeRegion(this->env(), allSatRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true),
482 regionCheckerMon->analyzeRegion(this->env(), allSatRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true));
483
484 auto exBothRegion = storm::api::parseRegion<storm::RationalFunction>("0.4<=p<=0.9", modelParameters);
485 EXPECT_EQ(regionChecker->analyzeRegion(this->env(), exBothRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true),
486 regionCheckerMon->analyzeRegion(this->env(), exBothRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true));
487
488 auto allVioRegion = storm::api::parseRegion<storm::RationalFunction>("0.8<=p<=0.9", modelParameters);
489 EXPECT_EQ(regionChecker->analyzeRegion(this->env(), allVioRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true),
490 regionCheckerMon->analyzeRegion(this->env(), allVioRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true));
491}
492
493TYPED_TEST(SparseDtmcParameterLiftingMonotonicityTest, Casestudy3_Mon) {
494 typedef typename TestFixture::ValueType ValueType;
495
496 std::string programFile = STORM_TEST_RESOURCES_DIR "/pdtmc/casestudy3.pm";
497 std::string formulaAsString = "P<0.5 [F s=3 ]";
498 std::string constantsAsString = "";
499
500 // Program and formula
501 storm::prism::Program program = storm::api::parseProgram(programFile);
502 program = storm::utility::prism::preprocess(program, constantsAsString);
503 std::vector<std::shared_ptr<const storm::logic::Formula>> formulas =
505 std::shared_ptr<storm::models::sparse::Dtmc<storm::RationalFunction>> model =
506 storm::api::buildSparseModel<storm::RationalFunction>(program, formulas)->as<storm::models::sparse::Dtmc<storm::RationalFunction>>();
507
508 // Model parameters
509 auto modelParameters = storm::models::sparse::getProbabilityParameters(*model);
510 auto rewParameters = storm::models::sparse::getRewardParameters(*model);
511 modelParameters.insert(rewParameters.begin(), rewParameters.end());
512
513 // Modelcheckers
514 auto regionCheckerMon = this->initializeRegionModelChecker(model, formulas[0], true);
515 auto regionChecker = this->initializeRegionModelChecker(model, formulas[0], false);
516
517 model->getTransitionMatrix().printAsMatlabMatrix(std::cout);
518
519 auto monHelper = new storm::analysis::MonotonicityHelper<storm::RationalFunction, ValueType>(model, formulas, {});
520 auto order = monHelper->checkMonotonicityInBuild(std::cout).begin()->first;
521 ASSERT_TRUE(order->getDoneBuilding());
522
523 // Start testing
524 auto allSatRegion = storm::api::parseRegion<storm::RationalFunction>("0.6<=p<=0.9", modelParameters);
525 auto monRes = monHelper->createLocalMonotonicityResult(order, allSatRegion);
526 EXPECT_EQ(regionChecker->analyzeRegion(this->env(), allSatRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true),
527 regionCheckerMon->analyzeRegion(this->env(), allSatRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true));
528
529 auto exBothRegion = storm::api::parseRegion<storm::RationalFunction>("0.3<=p<=0.7", modelParameters);
530 monRes = monHelper->createLocalMonotonicityResult(order, exBothRegion);
531 EXPECT_EQ(regionChecker->analyzeRegion(this->env(), exBothRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true),
532 regionCheckerMon->analyzeRegion(this->env(), exBothRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true));
533
534 auto allVioRegion = storm::api::parseRegion<storm::RationalFunction>("0.1<=p<=0.4", modelParameters);
535 monRes = monHelper->createLocalMonotonicityResult(order, allVioRegion);
536 EXPECT_EQ(regionChecker->analyzeRegion(this->env(), allVioRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true),
537 regionCheckerMon->analyzeRegion(this->env(), allVioRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true));
538}
539} // namespace
SolverEnvironment & solver()
void setPrecision(storm::RationalNumber value)
void setMethod(storm::solver::MinMaxMethod value, bool isSetFromDefault=false)
MinMaxSolverEnvironment & minMax()
std::map< std::shared_ptr< Order >, std::pair< std::shared_ptr< MonotonicityResult< VariableType > >, std::vector< std::shared_ptr< expressions::BinaryRelationExpression > > > > checkMonotonicityInBuild(std::ostream &outfile, bool usePLA=false, std::string dotOutfileName="dotOutput")
Builds Reachability Orders for the given model and simultaneously uses them to check for Monotonicity...
std::shared_ptr< LocalMonotonicityResult< VariableType > > createLocalMonotonicityResult(std::shared_ptr< Order > order, storage::ParameterRegion< ValueType > region)
Builds Reachability Orders for the given model and simultaneously uses them to check for Monotonicity...
std::shared_ptr< ModelType > as()
Casts the model into the model type given by the template parameter.
Definition ModelBase.h:37
This class represents a discrete-time Markov chain.
Definition Dtmc.h:13
Base class for all sparse models.
Definition Model.h:32
This class performs different steps to simplify the given (parametric) model.
std::vector< storm::jani::Property > parsePropertiesForPrismProgram(std::string const &inputString, storm::prism::Program const &program, boost::optional< std::set< std::string > > const &propertyFilter)
storm::prism::Program parseProgram(std::string const &filename, bool prismCompatibility, bool simplify)
std::unique_ptr< storm::modelchecker::RegionModelChecker< ValueType > > initializeRegionModelChecker(Environment const &env, std::shared_ptr< storm::models::sparse::Model< ValueType > > const &model, storm::modelchecker::CheckTask< storm::logic::Formula, ValueType > const &task, storm::modelchecker::RegionCheckEngine engine, bool allowModelSimplification=true, bool graphPreserving=true, bool preconditionsValidated=false, MonotonicitySetting monotonicitySetting=MonotonicitySetting(), std::optional< std::pair< std::set< typename storm::storage::ParameterRegion< ValueType >::VariableType >, std::set< typename storm::storage::ParameterRegion< ValueType >::VariableType > > > monotoneParameters=std::nullopt)
Definition region.h:271
std::vector< std::shared_ptr< storm::logic::Formula const > > extractFormulasFromProperties(std::vector< storm::jani::Property > const &properties)
SFTBDDChecker::ValueType ValueType
RegionCheckEngine
The considered engine for region checking.
@ ParameterLifting
Parameter lifting approach.
@ ExactParameterLifting
Parameter lifting approach with exact arithmethics.
std::set< storm::RationalFunctionVariable > getRewardParameters(Model< storm::RationalFunction > const &model)
Get all parameters occurring in rewards.
Definition Model.cpp:697
std::set< storm::RationalFunctionVariable > getProbabilityParameters(Model< storm::RationalFunction > const &model)
Get all probability parameters occurring on transitions.
Definition Model.cpp:693
storm::prism::Program preprocess(storm::prism::Program const &program, std::map< storm::expressions::Variable, storm::expressions::Expression > const &constantDefinitions)
Definition prism.cpp:19
TYPED_TEST(GraphTestAR, SymbolicProb01StochasticGameDieSmall)
Definition GraphTest.cpp:62
TYPED_TEST_SUITE(GraphTestAR, TestingTypes,)
::testing::Types< Cudd, Sylvan > TestingTypes
Definition GraphTest.cpp:59