Storm 1.11.1.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
SparseRobustDtmcParameterLiftingTest.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 IsGraphPreserving {
17 public:
18 typedef double ValueType;
19 static storm::Environment createEnvironment() {
21 env.solver().minMax().setMethod(storm::solver::MinMaxMethod::ValueIteration);
22 env.solver().minMax().setPrecision(storm::utility::convertNumber<storm::RationalNumber>(1e-8));
23 return env;
24 }
25 static bool graphPreserving() {
26 return true;
27 }
28};
29
30class AssumeGraphPreserving {
31 public:
32 typedef double ValueType;
33 static storm::Environment createEnvironment() {
35 env.solver().minMax().setMethod(storm::solver::MinMaxMethod::ValueIteration);
36 env.solver().minMax().setPrecision(storm::utility::convertNumber<storm::RationalNumber>(1e-8));
37 return env;
38 }
39 static bool graphPreserving() {
40 return false;
41 }
42};
43
44template<typename TestType>
45class SparseRobustDtmcParameterLiftingTest : public ::testing::Test {
46 public:
47 typedef typename TestType::ValueType ValueType;
48 SparseRobustDtmcParameterLiftingTest() : _environment(TestType::createEnvironment()), _graphPreserving(TestType::graphPreserving()) {}
49 storm::Environment const& env() const {
50 return _environment;
51 }
52 bool const& graphPreserving() const {
53 return _graphPreserving;
54 }
55 virtual void SetUp() {
56 carl::VariablePool::getInstance().clear();
57#ifndef STORM_HAVE_Z3
58 GTEST_SKIP() << "Z3 not available.";
59#endif
60 }
61 virtual void TearDown() {
62 carl::VariablePool::getInstance().clear();
63 }
64
65 private:
66 storm::Environment _environment;
67 bool _graphPreserving;
68};
69
70typedef ::testing::Types<IsGraphPreserving, AssumeGraphPreserving> TestingTypes;
71
72TYPED_TEST_SUITE(SparseRobustDtmcParameterLiftingTest, TestingTypes, );
73
74TYPED_TEST(SparseRobustDtmcParameterLiftingTest, Brp_Prob) {
75 typedef typename TestFixture::ValueType ValueType;
76
77 std::string programFile = STORM_TEST_RESOURCES_DIR "/pdtmc/brp16_2.pm";
78 std::string formulaAsString = "P<=0.84 [F s=5 ]";
79 std::string constantsAsString = ""; // e.g. pL=0.9,TOACK=0.5
80
81 // Program and formula
83 program = storm::utility::prism::preprocess(program, constantsAsString);
84 std::vector<std::shared_ptr<const storm::logic::Formula>> formulas =
86 std::shared_ptr<storm::models::sparse::Dtmc<storm::RationalFunction>> model =
87 storm::api::buildSparseModel<storm::RationalFunction>(program, formulas)->as<storm::models::sparse::Dtmc<storm::RationalFunction>>();
88
89 auto modelParameters = storm::models::sparse::getProbabilityParameters(*model);
90 auto rewParameters = storm::models::sparse::getRewardParameters(*model);
91 modelParameters.insert(rewParameters.begin(), rewParameters.end());
92
93 auto regionChecker = storm::api::initializeRegionModelChecker<storm::RationalFunction>(
94 this->env(), model, storm::api::createTask<storm::RationalFunction>(formulas[0], true), storm::modelchecker::RegionCheckEngine::RobustParameterLifting,
95 true, this->graphPreserving());
96
97 // start testing
98 auto allSatRegion = storm::api::parseRegion<storm::RationalFunction>("0.7<=pL<=0.9,0.75<=pK<=0.95", modelParameters);
99 auto exBothRegion = storm::api::parseRegion<storm::RationalFunction>("0.4<=pL<=0.65,0.75<=pK<=0.95", modelParameters);
100 auto allVioRegion = storm::api::parseRegion<storm::RationalFunction>("0.1<=pL<=0.73,0.2<=pK<=0.715", modelParameters);
101
103 regionChecker->analyzeRegion(this->env(), allSatRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true));
105 regionChecker->analyzeRegion(this->env(), exBothRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true));
107 regionChecker->analyzeRegion(this->env(), allVioRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true));
108}
109
110TYPED_TEST(SparseRobustDtmcParameterLiftingTest, Brp_Prob_no_simplification) {
111 typedef typename TestFixture::ValueType ValueType;
112
113 std::string programFile = STORM_TEST_RESOURCES_DIR "/pdtmc/brp16_2.pm";
114 std::string formulaAsString = "P<=0.84 [F s=5 ]";
115 std::string constantsAsString = ""; // e.g. pL=0.9,TOACK=0.5
116
117 // Program and formula
118 storm::prism::Program program = storm::api::parseProgram(programFile);
119 program = storm::utility::prism::preprocess(program, constantsAsString);
120 std::vector<std::shared_ptr<const storm::logic::Formula>> formulas =
122 std::shared_ptr<storm::models::sparse::Dtmc<storm::RationalFunction>> model =
123 storm::api::buildSparseModel<storm::RationalFunction>(program, formulas)->as<storm::models::sparse::Dtmc<storm::RationalFunction>>();
124
125 auto modelParameters = storm::models::sparse::getProbabilityParameters(*model);
126 auto rewParameters = storm::models::sparse::getRewardParameters(*model);
127 modelParameters.insert(rewParameters.begin(), rewParameters.end());
128
129 auto regionChecker = storm::api::initializeRegionModelChecker<storm::RationalFunction>(
130 this->env(), model, storm::api::createTask<storm::RationalFunction>(formulas[0], true), storm::modelchecker::RegionCheckEngine::RobustParameterLifting,
131 true, this->graphPreserving());
132
133 // start testing
134 auto allSatRegion = storm::api::parseRegion<storm::RationalFunction>("0.7<=pL<=0.9,0.75<=pK<=0.95", modelParameters);
135 auto exBothRegion = storm::api::parseRegion<storm::RationalFunction>("0.4<=pL<=0.65,0.75<=pK<=0.95", modelParameters);
136 auto allVioRegion = storm::api::parseRegion<storm::RationalFunction>("0.1<=pL<=0.73,0.2<=pK<=0.715", modelParameters);
137
139 regionChecker->analyzeRegion(this->env(), allSatRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true));
141 regionChecker->analyzeRegion(this->env(), exBothRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true));
143 regionChecker->analyzeRegion(this->env(), allVioRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true));
144}
145
146TYPED_TEST(SparseRobustDtmcParameterLiftingTest, Brp_Rew) {
147 typedef typename TestFixture::ValueType ValueType;
148 std::string programFile = STORM_TEST_RESOURCES_DIR "/pdtmc/brp_rewards16_2.pm";
149 std::string formulaAsString = "R>2.5 [F ((s=5) | (s=0&srep=3)) ]";
150 std::string constantsAsString = "pL=0.9,TOAck=0.5";
151
152 storm::prism::Program program = storm::api::parseProgram(programFile);
153 program = storm::utility::prism::preprocess(program, constantsAsString);
154 std::vector<std::shared_ptr<const storm::logic::Formula>> formulas =
156 std::shared_ptr<storm::models::sparse::Dtmc<storm::RationalFunction>> model =
157 storm::api::buildSparseModel<storm::RationalFunction>(program, formulas)->as<storm::models::sparse::Dtmc<storm::RationalFunction>>();
158
159 auto modelParameters = storm::models::sparse::getProbabilityParameters(*model);
160 auto rewParameters = storm::models::sparse::getRewardParameters(*model);
161 modelParameters.insert(rewParameters.begin(), rewParameters.end());
162
163 auto regionChecker = storm::api::initializeRegionModelChecker<storm::RationalFunction>(
164 this->env(), model, storm::api::createTask<storm::RationalFunction>(formulas[0], true), storm::modelchecker::RegionCheckEngine::RobustParameterLifting,
165 true, this->graphPreserving());
166
167 // start testing
168 auto allSatRegion = storm::api::parseRegion<storm::RationalFunction>("0.7<=pK<=0.875,0.75<=TOMsg<=0.95", modelParameters);
169 auto exBothRegion = storm::api::parseRegion<storm::RationalFunction>("0.6<=pK<=0.9,0.5<=TOMsg<=0.95", modelParameters);
170 auto allVioRegion = storm::api::parseRegion<storm::RationalFunction>("0.1<=pK<=0.3,0.2<=TOMsg<=0.3", modelParameters);
171
173 regionChecker->analyzeRegion(this->env(), allSatRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true));
175 regionChecker->analyzeRegion(this->env(), exBothRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true));
177 regionChecker->analyzeRegion(this->env(), allVioRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true));
178}
179
180TYPED_TEST(SparseRobustDtmcParameterLiftingTest, Brp_Rew_4Par) {
181 typedef typename TestFixture::ValueType ValueType;
182
183 std::string programFile = STORM_TEST_RESOURCES_DIR "/pdtmc/brp_rewards16_2.pm";
184 std::string formulaAsString = "R>2.5 [F ((s=5) | (s=0&srep=3)) ]";
185 std::string constantsAsString = "";
186 storm::prism::Program program = storm::api::parseProgram(programFile);
187 program = storm::utility::prism::preprocess(program, constantsAsString);
188 std::vector<std::shared_ptr<const storm::logic::Formula>> formulas =
190 std::shared_ptr<storm::models::sparse::Dtmc<storm::RationalFunction>> model =
191 storm::api::buildSparseModel<storm::RationalFunction>(program, formulas)->as<storm::models::sparse::Dtmc<storm::RationalFunction>>();
192
193 auto modelParameters = storm::models::sparse::getProbabilityParameters(*model);
194 auto rewParameters = storm::models::sparse::getRewardParameters(*model);
195 modelParameters.insert(rewParameters.begin(), rewParameters.end());
196
197 auto regionChecker = storm::api::initializeRegionModelChecker<storm::RationalFunction>(
198 this->env(), model, storm::api::createTask<storm::RationalFunction>(formulas[0], true), storm::modelchecker::RegionCheckEngine::RobustParameterLifting,
199 true, this->graphPreserving());
200
201 // start testing
202 auto allSatRegion = storm::api::parseRegion<storm::RationalFunction>("0.7<=pK<=0.9,0.6<=pL<=0.85,0.9<=TOMsg<=0.95,0.85<=TOAck<=0.9", modelParameters);
203 auto exBothRegion = storm::api::parseRegion<storm::RationalFunction>("0.1<=pK<=0.7,0.2<=pL<=0.8,0.15<=TOMsg<=0.65,0.3<=TOAck<=0.9", modelParameters);
204 auto allVioRegion = storm::api::parseRegion<storm::RationalFunction>("0.1<=pK<=0.4,0.2<=pL<=0.3,0.15<=TOMsg<=0.3,0.1<=TOAck<=0.2", modelParameters);
205
207 regionChecker->analyzeRegion(this->env(), allSatRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true));
209 regionChecker->analyzeRegion(this->env(), exBothRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true));
211 regionChecker->analyzeRegion(this->env(), allVioRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true));
212}
213
214TYPED_TEST(SparseRobustDtmcParameterLiftingTest, Crowds_Prob) {
215 typedef typename TestFixture::ValueType ValueType;
216
217 std::string programFile = STORM_TEST_RESOURCES_DIR "/pdtmc/crowds3_5.pm";
218 std::string formulaAsString = "P<0.5 [F \"observe0Greater1\" ]";
219 std::string constantsAsString = ""; // e.g. pL=0.9,TOACK=0.5
220
221 storm::prism::Program program = storm::api::parseProgram(programFile);
222 program = storm::utility::prism::preprocess(program, constantsAsString);
223 std::vector<std::shared_ptr<const storm::logic::Formula>> formulas =
225 std::shared_ptr<storm::models::sparse::Dtmc<storm::RationalFunction>> model =
226 storm::api::buildSparseModel<storm::RationalFunction>(program, formulas)->as<storm::models::sparse::Dtmc<storm::RationalFunction>>();
227
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 auto regionChecker = storm::api::initializeRegionModelChecker<storm::RationalFunction>(
233 this->env(), model, storm::api::createTask<storm::RationalFunction>(formulas[0], true), storm::modelchecker::RegionCheckEngine::RobustParameterLifting,
234 true, this->graphPreserving());
235
236 // start testing
237 auto allSatRegion = storm::api::parseRegion<storm::RationalFunction>("0.1<=PF<=0.75,0.15<=badC<=0.2", modelParameters);
238 auto exBothRegion = storm::api::parseRegion<storm::RationalFunction>("0.75<=PF<=0.8,0.2<=badC<=0.3", modelParameters);
239 auto allVioRegion = storm::api::parseRegion<storm::RationalFunction>("0.8<=PF<=0.95,0.2<=badC<=0.2", modelParameters);
240 auto allVioHardRegion = storm::api::parseRegion<storm::RationalFunction>("0.8<=PF<=0.95,0.2<=badC<=0.9", modelParameters);
241
243 regionChecker->analyzeRegion(this->env(), allSatRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true));
245 regionChecker->analyzeRegion(this->env(), exBothRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true));
247 regionChecker->analyzeRegion(this->env(), allVioRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true));
249 regionChecker->analyzeRegion(this->env(), allVioHardRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true));
250}
251
252TYPED_TEST(SparseRobustDtmcParameterLiftingTest, Crowds_Prob_1Par) {
253 typedef typename TestFixture::ValueType ValueType;
254
255 std::string programFile = STORM_TEST_RESOURCES_DIR "/pdtmc/crowds3_5.pm";
256 std::string formulaAsString = "P>0.75 [F \"observe0Greater1\" ]";
257 std::string constantsAsString = "badC=0.3"; // e.g. pL=0.9,TOACK=0.5
258
259 storm::prism::Program program = storm::api::parseProgram(programFile);
260 program = storm::utility::prism::preprocess(program, constantsAsString);
261 std::vector<std::shared_ptr<const storm::logic::Formula>> formulas =
263 std::shared_ptr<storm::models::sparse::Dtmc<storm::RationalFunction>> model =
264 storm::api::buildSparseModel<storm::RationalFunction>(program, formulas)->as<storm::models::sparse::Dtmc<storm::RationalFunction>>();
265
266 auto modelParameters = storm::models::sparse::getProbabilityParameters(*model);
267 auto rewParameters = storm::models::sparse::getRewardParameters(*model);
268 modelParameters.insert(rewParameters.begin(), rewParameters.end());
269
270 auto regionChecker = storm::api::initializeRegionModelChecker<storm::RationalFunction>(
271 this->env(), model, storm::api::createTask<storm::RationalFunction>(formulas[0], true), storm::modelchecker::RegionCheckEngine::RobustParameterLifting,
272 true, this->graphPreserving());
273
274 // start testing
275 auto allSatRegion = storm::api::parseRegion<storm::RationalFunction>("0.9<=PF<=0.99", modelParameters);
276 auto exBothRegion = storm::api::parseRegion<storm::RationalFunction>("0.8<=PF<=0.9", modelParameters);
277 auto allVioRegion = storm::api::parseRegion<storm::RationalFunction>("0.01<=PF<=0.8", modelParameters);
278
280 regionChecker->analyzeRegion(this->env(), allSatRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true));
282 regionChecker->analyzeRegion(this->env(), exBothRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true));
284 regionChecker->analyzeRegion(this->env(), allVioRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true));
285}
286
287TYPED_TEST(SparseRobustDtmcParameterLiftingTest, Crowds_Prob_Const) {
288 typedef typename TestFixture::ValueType ValueType;
289
290 std::string programFile = STORM_TEST_RESOURCES_DIR "/pdtmc/crowds3_5.pm";
291 std::string formulaAsString = "P>0.6 [F \"observe0Greater1\" ]";
292 std::string constantsAsString = "PF=0.9,badC=0.2";
293
294 storm::prism::Program program = storm::api::parseProgram(programFile);
295 program = storm::utility::prism::preprocess(program, constantsAsString);
296 std::vector<std::shared_ptr<const storm::logic::Formula>> formulas =
298 std::shared_ptr<storm::models::sparse::Dtmc<storm::RationalFunction>> model =
299 storm::api::buildSparseModel<storm::RationalFunction>(program, formulas)->as<storm::models::sparse::Dtmc<storm::RationalFunction>>();
300
301 auto modelParameters = storm::models::sparse::getProbabilityParameters(*model);
302 auto rewParameters = storm::models::sparse::getRewardParameters(*model);
303 modelParameters.insert(rewParameters.begin(), rewParameters.end());
304
305 auto regionChecker = storm::api::initializeRegionModelChecker<storm::RationalFunction>(
306 this->env(), model, storm::api::createTask<storm::RationalFunction>(formulas[0], true), storm::modelchecker::RegionCheckEngine::RobustParameterLifting,
307 true, this->graphPreserving());
308
309 // start testing
310 auto allSatRegion = storm::api::parseRegion<storm::RationalFunction>("", modelParameters);
311
313 regionChecker->analyzeRegion(this->env(), allSatRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true));
314}
315
316TYPED_TEST(SparseRobustDtmcParameterLiftingTest, ZeroConf) {
317 typedef typename TestFixture::ValueType ValueType;
318
319 std::string programFile = STORM_TEST_RESOURCES_DIR "/pdtmc/zeroconf4.pm";
320 std::string formulaAsString = "P>0.5 [F s=5 ]";
321 std::string constantsAsString = " n = 4"; // e.g. pL=0.9,TOACK=0.5
322
323 // Program and formula
324 storm::prism::Program program = storm::api::parseProgram(programFile);
325 program = storm::utility::prism::preprocess(program, constantsAsString);
326 std::vector<std::shared_ptr<const storm::logic::Formula>> formulas =
328 std::shared_ptr<storm::models::sparse::Dtmc<storm::RationalFunction>> model =
329 storm::api::buildSparseModel<storm::RationalFunction>(program, formulas)->as<storm::models::sparse::Dtmc<storm::RationalFunction>>();
330
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 auto regionChecker = storm::api::initializeRegionModelChecker<storm::RationalFunction>(
336 this->env(), model, storm::api::createTask<storm::RationalFunction>(formulas[0], true), storm::modelchecker::RegionCheckEngine::RobustParameterLifting,
337 true, this->graphPreserving());
338
339 // start testing
340 auto allSatRegion = storm::api::parseRegion<storm::RationalFunction>("0.8<=pL<=0.95,0.8<=pK<=0.95", modelParameters);
341 auto exBothRegion = storm::api::parseRegion<storm::RationalFunction>("0.6<=pL<=0.9,0.6<=pK<=0.9", modelParameters);
342 auto allVioRegion = storm::api::parseRegion<storm::RationalFunction>("0.1<=pL<=0.7,0.1<=pK<=0.7", modelParameters);
343
345 regionChecker->analyzeRegion(this->env(), allSatRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true));
347 regionChecker->analyzeRegion(this->env(), exBothRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true));
349 regionChecker->analyzeRegion(this->env(), allVioRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true));
350}
351} // namespace
SolverEnvironment & solver()
void setPrecision(storm::RationalNumber value)
void setMethod(storm::solver::MinMaxMethod value, bool isSetFromDefault=false)
MinMaxSolverEnvironment & minMax()
This class represents a discrete-time Markov chain.
Definition Dtmc.h:13
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::vector< std::shared_ptr< storm::logic::Formula const > > extractFormulasFromProperties(std::vector< storm::jani::Property > const &properties)
SFTBDDChecker::ValueType ValueType
@ AllSat
the formula is satisfied for all well-defined parameters in the given region
@ AllViolated
the formula is violated for all well-defined parameters in the given region
@ ExistsBoth
the formula is satisfied for some parameters but also violated for others
@ CenterViolated
the formula is violated for the parameter Valuation that corresponds to the center point of the regio...
@ RobustParameterLifting
Parameter lifting approach based on robust markov models instead of generating nondeterminism.
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