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