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"
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 IsGraphPreserving {
22 public:
23 typedef double ValueType;
24 static storm::Environment createEnvironment() {
26 env.solver().minMax().setMethod(storm::solver::MinMaxMethod::ValueIteration);
27 env.solver().minMax().setPrecision(storm::utility::convertNumber<storm::RationalNumber>(1e-8));
28 return env;
29 }
30 static bool graphPreserving() {
31 return true;
32 }
33};
34
35class AssumeGraphPreserving {
36 public:
37 typedef double ValueType;
38 static storm::Environment createEnvironment() {
40 env.solver().minMax().setMethod(storm::solver::MinMaxMethod::ValueIteration);
41 env.solver().minMax().setPrecision(storm::utility::convertNumber<storm::RationalNumber>(1e-8));
42 return env;
43 }
44 static bool graphPreserving() {
45 return false;
46 }
47};
48
49template<typename TestType>
50class SparseRobustDtmcParameterLiftingTest : public ::testing::Test {
51 public:
52 typedef typename TestType::ValueType ValueType;
53 SparseRobustDtmcParameterLiftingTest() : _environment(TestType::createEnvironment()), _graphPreserving(TestType::graphPreserving()) {}
54 storm::Environment const& env() const {
55 return _environment;
56 }
57 bool const& graphPreserving() const {
58 return _graphPreserving;
59 }
60 virtual void SetUp() {
61 carl::VariablePool::getInstance().clear();
62#ifndef STORM_HAVE_Z3
63 GTEST_SKIP() << "Z3 not available.";
64#endif
65 }
66 virtual void TearDown() {
67 carl::VariablePool::getInstance().clear();
68 }
69
70 private:
71 storm::Environment _environment;
72 bool _graphPreserving;
73};
74
75typedef ::testing::Types<IsGraphPreserving, AssumeGraphPreserving> TestingTypes;
76
77TYPED_TEST_SUITE(SparseRobustDtmcParameterLiftingTest, TestingTypes, );
78
79TYPED_TEST(SparseRobustDtmcParameterLiftingTest, Brp_Prob) {
80 typedef typename TestFixture::ValueType ValueType;
81
82 std::string programFile = STORM_TEST_RESOURCES_DIR "/pdtmc/brp16_2.pm";
83 std::string formulaAsString = "P<=0.84 [F s=5 ]";
84 std::string constantsAsString = ""; // e.g. pL=0.9,TOACK=0.5
85
86 // Program and formula
88 program = storm::utility::prism::preprocess(program, constantsAsString);
89 std::vector<std::shared_ptr<const storm::logic::Formula>> formulas =
91 std::shared_ptr<storm::models::sparse::Dtmc<storm::RationalFunction>> model =
92 storm::api::buildSparseModel<storm::RationalFunction>(program, formulas)->as<storm::models::sparse::Dtmc<storm::RationalFunction>>();
93
94 auto modelParameters = storm::models::sparse::getProbabilityParameters(*model);
95 auto rewParameters = storm::models::sparse::getRewardParameters(*model);
96 modelParameters.insert(rewParameters.begin(), rewParameters.end());
97
98 auto regionChecker = storm::api::initializeRegionModelChecker<storm::RationalFunction>(
99 this->env(), model, storm::api::createTask<storm::RationalFunction>(formulas[0], true), storm::modelchecker::RegionCheckEngine::RobustParameterLifting,
100 true, this->graphPreserving());
101
102 // start testing
103 auto allSatRegion = storm::api::parseRegion<storm::RationalFunction>("0.7<=pL<=0.9,0.75<=pK<=0.95", modelParameters);
104 auto exBothRegion = storm::api::parseRegion<storm::RationalFunction>("0.4<=pL<=0.65,0.75<=pK<=0.95", modelParameters);
105 auto allVioRegion = storm::api::parseRegion<storm::RationalFunction>("0.1<=pL<=0.73,0.2<=pK<=0.715", modelParameters);
106
108 regionChecker->analyzeRegion(this->env(), allSatRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true));
110 regionChecker->analyzeRegion(this->env(), exBothRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true));
112 regionChecker->analyzeRegion(this->env(), allVioRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true));
113}
114
115TYPED_TEST(SparseRobustDtmcParameterLiftingTest, Brp_Prob_no_simplification) {
116 typedef typename TestFixture::ValueType ValueType;
117
118 std::string programFile = STORM_TEST_RESOURCES_DIR "/pdtmc/brp16_2.pm";
119 std::string formulaAsString = "P<=0.84 [F s=5 ]";
120 std::string constantsAsString = ""; // e.g. pL=0.9,TOACK=0.5
121
122 // Program and formula
123 storm::prism::Program program = storm::api::parseProgram(programFile);
124 program = storm::utility::prism::preprocess(program, constantsAsString);
125 std::vector<std::shared_ptr<const storm::logic::Formula>> formulas =
127 std::shared_ptr<storm::models::sparse::Dtmc<storm::RationalFunction>> model =
128 storm::api::buildSparseModel<storm::RationalFunction>(program, formulas)->as<storm::models::sparse::Dtmc<storm::RationalFunction>>();
129
130 auto modelParameters = storm::models::sparse::getProbabilityParameters(*model);
131 auto rewParameters = storm::models::sparse::getRewardParameters(*model);
132 modelParameters.insert(rewParameters.begin(), rewParameters.end());
133
134 auto regionChecker = storm::api::initializeRegionModelChecker<storm::RationalFunction>(
135 this->env(), model, storm::api::createTask<storm::RationalFunction>(formulas[0], true), storm::modelchecker::RegionCheckEngine::RobustParameterLifting,
136 true, this->graphPreserving());
137
138 // start testing
139 auto allSatRegion = storm::api::parseRegion<storm::RationalFunction>("0.7<=pL<=0.9,0.75<=pK<=0.95", modelParameters);
140 auto exBothRegion = storm::api::parseRegion<storm::RationalFunction>("0.4<=pL<=0.65,0.75<=pK<=0.95", modelParameters);
141 auto allVioRegion = storm::api::parseRegion<storm::RationalFunction>("0.1<=pL<=0.73,0.2<=pK<=0.715", modelParameters);
142
144 regionChecker->analyzeRegion(this->env(), allSatRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true));
146 regionChecker->analyzeRegion(this->env(), exBothRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true));
148 regionChecker->analyzeRegion(this->env(), allVioRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true));
149}
150
151TYPED_TEST(SparseRobustDtmcParameterLiftingTest, Brp_Rew) {
152 typedef typename TestFixture::ValueType ValueType;
153 std::string programFile = STORM_TEST_RESOURCES_DIR "/pdtmc/brp_rewards16_2.pm";
154 std::string formulaAsString = "R>2.5 [F ((s=5) | (s=0&srep=3)) ]";
155 std::string constantsAsString = "pL=0.9,TOAck=0.5";
156
157 storm::prism::Program program = storm::api::parseProgram(programFile);
158 program = storm::utility::prism::preprocess(program, constantsAsString);
159 std::vector<std::shared_ptr<const storm::logic::Formula>> formulas =
161 std::shared_ptr<storm::models::sparse::Dtmc<storm::RationalFunction>> model =
162 storm::api::buildSparseModel<storm::RationalFunction>(program, formulas)->as<storm::models::sparse::Dtmc<storm::RationalFunction>>();
163
164 auto modelParameters = storm::models::sparse::getProbabilityParameters(*model);
165 auto rewParameters = storm::models::sparse::getRewardParameters(*model);
166 modelParameters.insert(rewParameters.begin(), rewParameters.end());
167
168 auto regionChecker = storm::api::initializeRegionModelChecker<storm::RationalFunction>(
169 this->env(), model, storm::api::createTask<storm::RationalFunction>(formulas[0], true), storm::modelchecker::RegionCheckEngine::RobustParameterLifting,
170 true, this->graphPreserving());
171
172 // start testing
173 auto allSatRegion = storm::api::parseRegion<storm::RationalFunction>("0.7<=pK<=0.875,0.75<=TOMsg<=0.95", modelParameters);
174 auto exBothRegion = storm::api::parseRegion<storm::RationalFunction>("0.6<=pK<=0.9,0.5<=TOMsg<=0.95", modelParameters);
175 auto allVioRegion = storm::api::parseRegion<storm::RationalFunction>("0.1<=pK<=0.3,0.2<=TOMsg<=0.3", modelParameters);
176
178 regionChecker->analyzeRegion(this->env(), allSatRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true));
180 regionChecker->analyzeRegion(this->env(), exBothRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true));
182 regionChecker->analyzeRegion(this->env(), allVioRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true));
183}
184
185TYPED_TEST(SparseRobustDtmcParameterLiftingTest, Brp_Rew_4Par) {
186 typedef typename TestFixture::ValueType ValueType;
187
188 std::string programFile = STORM_TEST_RESOURCES_DIR "/pdtmc/brp_rewards16_2.pm";
189 std::string formulaAsString = "R>2.5 [F ((s=5) | (s=0&srep=3)) ]";
190 std::string constantsAsString = "";
191 storm::prism::Program program = storm::api::parseProgram(programFile);
192 program = storm::utility::prism::preprocess(program, constantsAsString);
193 std::vector<std::shared_ptr<const storm::logic::Formula>> formulas =
195 std::shared_ptr<storm::models::sparse::Dtmc<storm::RationalFunction>> model =
196 storm::api::buildSparseModel<storm::RationalFunction>(program, formulas)->as<storm::models::sparse::Dtmc<storm::RationalFunction>>();
197
198 auto modelParameters = storm::models::sparse::getProbabilityParameters(*model);
199 auto rewParameters = storm::models::sparse::getRewardParameters(*model);
200 modelParameters.insert(rewParameters.begin(), rewParameters.end());
201
202 auto regionChecker = storm::api::initializeRegionModelChecker<storm::RationalFunction>(
203 this->env(), model, storm::api::createTask<storm::RationalFunction>(formulas[0], true), storm::modelchecker::RegionCheckEngine::RobustParameterLifting,
204 true, this->graphPreserving());
205
206 // start testing
207 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);
208 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);
209 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);
210
212 regionChecker->analyzeRegion(this->env(), allSatRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true));
214 regionChecker->analyzeRegion(this->env(), exBothRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true));
216 regionChecker->analyzeRegion(this->env(), allVioRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true));
217}
218
219TYPED_TEST(SparseRobustDtmcParameterLiftingTest, Crowds_Prob) {
220 typedef typename TestFixture::ValueType ValueType;
221
222 std::string programFile = STORM_TEST_RESOURCES_DIR "/pdtmc/crowds3_5.pm";
223 std::string formulaAsString = "P<0.5 [F \"observe0Greater1\" ]";
224 std::string constantsAsString = ""; // e.g. pL=0.9,TOACK=0.5
225
226 storm::prism::Program program = storm::api::parseProgram(programFile);
227 program = storm::utility::prism::preprocess(program, constantsAsString);
228 std::vector<std::shared_ptr<const storm::logic::Formula>> formulas =
230 std::shared_ptr<storm::models::sparse::Dtmc<storm::RationalFunction>> model =
231 storm::api::buildSparseModel<storm::RationalFunction>(program, formulas)->as<storm::models::sparse::Dtmc<storm::RationalFunction>>();
232
233 auto modelParameters = storm::models::sparse::getProbabilityParameters(*model);
234 auto rewParameters = storm::models::sparse::getRewardParameters(*model);
235 modelParameters.insert(rewParameters.begin(), rewParameters.end());
236
237 auto regionChecker = storm::api::initializeRegionModelChecker<storm::RationalFunction>(
238 this->env(), model, storm::api::createTask<storm::RationalFunction>(formulas[0], true), storm::modelchecker::RegionCheckEngine::RobustParameterLifting,
239 true, this->graphPreserving());
240
241 // start testing
242 auto allSatRegion = storm::api::parseRegion<storm::RationalFunction>("0.1<=PF<=0.75,0.15<=badC<=0.2", modelParameters);
243 auto exBothRegion = storm::api::parseRegion<storm::RationalFunction>("0.75<=PF<=0.8,0.2<=badC<=0.3", modelParameters);
244 auto allVioRegion = storm::api::parseRegion<storm::RationalFunction>("0.8<=PF<=0.95,0.2<=badC<=0.2", modelParameters);
245 auto allVioHardRegion = storm::api::parseRegion<storm::RationalFunction>("0.8<=PF<=0.95,0.2<=badC<=0.9", modelParameters);
246
248 regionChecker->analyzeRegion(this->env(), allSatRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true));
250 regionChecker->analyzeRegion(this->env(), exBothRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true));
252 regionChecker->analyzeRegion(this->env(), allVioRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true));
254 regionChecker->analyzeRegion(this->env(), allVioHardRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true));
255}
256
257TYPED_TEST(SparseRobustDtmcParameterLiftingTest, Crowds_Prob_1Par) {
258 typedef typename TestFixture::ValueType ValueType;
259
260 std::string programFile = STORM_TEST_RESOURCES_DIR "/pdtmc/crowds3_5.pm";
261 std::string formulaAsString = "P>0.75 [F \"observe0Greater1\" ]";
262 std::string constantsAsString = "badC=0.3"; // e.g. pL=0.9,TOACK=0.5
263
264 storm::prism::Program program = storm::api::parseProgram(programFile);
265 program = storm::utility::prism::preprocess(program, constantsAsString);
266 std::vector<std::shared_ptr<const storm::logic::Formula>> formulas =
268 std::shared_ptr<storm::models::sparse::Dtmc<storm::RationalFunction>> model =
269 storm::api::buildSparseModel<storm::RationalFunction>(program, formulas)->as<storm::models::sparse::Dtmc<storm::RationalFunction>>();
270
271 auto modelParameters = storm::models::sparse::getProbabilityParameters(*model);
272 auto rewParameters = storm::models::sparse::getRewardParameters(*model);
273 modelParameters.insert(rewParameters.begin(), rewParameters.end());
274
275 auto regionChecker = storm::api::initializeRegionModelChecker<storm::RationalFunction>(
276 this->env(), model, storm::api::createTask<storm::RationalFunction>(formulas[0], true), storm::modelchecker::RegionCheckEngine::RobustParameterLifting,
277 true, this->graphPreserving());
278
279 // start testing
280 auto allSatRegion = storm::api::parseRegion<storm::RationalFunction>("0.9<=PF<=0.99", modelParameters);
281 auto exBothRegion = storm::api::parseRegion<storm::RationalFunction>("0.8<=PF<=0.9", modelParameters);
282 auto allVioRegion = storm::api::parseRegion<storm::RationalFunction>("0.01<=PF<=0.8", modelParameters);
283
285 regionChecker->analyzeRegion(this->env(), allSatRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true));
287 regionChecker->analyzeRegion(this->env(), exBothRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true));
289 regionChecker->analyzeRegion(this->env(), allVioRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true));
290}
291
292TYPED_TEST(SparseRobustDtmcParameterLiftingTest, Crowds_Prob_Const) {
293 typedef typename TestFixture::ValueType ValueType;
294
295 std::string programFile = STORM_TEST_RESOURCES_DIR "/pdtmc/crowds3_5.pm";
296 std::string formulaAsString = "P>0.6 [F \"observe0Greater1\" ]";
297 std::string constantsAsString = "PF=0.9,badC=0.2";
298
299 storm::prism::Program program = storm::api::parseProgram(programFile);
300 program = storm::utility::prism::preprocess(program, constantsAsString);
301 std::vector<std::shared_ptr<const storm::logic::Formula>> formulas =
303 std::shared_ptr<storm::models::sparse::Dtmc<storm::RationalFunction>> model =
304 storm::api::buildSparseModel<storm::RationalFunction>(program, formulas)->as<storm::models::sparse::Dtmc<storm::RationalFunction>>();
305
306 auto modelParameters = storm::models::sparse::getProbabilityParameters(*model);
307 auto rewParameters = storm::models::sparse::getRewardParameters(*model);
308 modelParameters.insert(rewParameters.begin(), rewParameters.end());
309
310 auto regionChecker = storm::api::initializeRegionModelChecker<storm::RationalFunction>(
311 this->env(), model, storm::api::createTask<storm::RationalFunction>(formulas[0], true), storm::modelchecker::RegionCheckEngine::RobustParameterLifting,
312 true, this->graphPreserving());
313
314 // start testing
315 auto allSatRegion = storm::api::parseRegion<storm::RationalFunction>("", modelParameters);
316
318 regionChecker->analyzeRegion(this->env(), allSatRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true));
319}
320
321TYPED_TEST(SparseRobustDtmcParameterLiftingTest, ZeroConf) {
322 typedef typename TestFixture::ValueType ValueType;
323
324 std::string programFile = STORM_TEST_RESOURCES_DIR "/pdtmc/zeroconf4.pm";
325 std::string formulaAsString = "P>0.5 [F s=5 ]";
326 std::string constantsAsString = " n = 4"; // e.g. pL=0.9,TOACK=0.5
327
328 // Program and formula
329 storm::prism::Program program = storm::api::parseProgram(programFile);
330 program = storm::utility::prism::preprocess(program, constantsAsString);
331 std::vector<std::shared_ptr<const storm::logic::Formula>> formulas =
333 std::shared_ptr<storm::models::sparse::Dtmc<storm::RationalFunction>> model =
334 storm::api::buildSparseModel<storm::RationalFunction>(program, formulas)->as<storm::models::sparse::Dtmc<storm::RationalFunction>>();
335
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 auto regionChecker = storm::api::initializeRegionModelChecker<storm::RationalFunction>(
341 this->env(), model, storm::api::createTask<storm::RationalFunction>(formulas[0], true), storm::modelchecker::RegionCheckEngine::RobustParameterLifting,
342 true, this->graphPreserving());
343
344 // start testing
345 auto allSatRegion = storm::api::parseRegion<storm::RationalFunction>("0.8<=pL<=0.95,0.8<=pK<=0.95", modelParameters);
346 auto exBothRegion = storm::api::parseRegion<storm::RationalFunction>("0.6<=pL<=0.9,0.6<=pK<=0.9", modelParameters);
347 auto allVioRegion = storm::api::parseRegion<storm::RationalFunction>("0.1<=pL<=0.7,0.1<=pK<=0.7", modelParameters);
348
350 regionChecker->analyzeRegion(this->env(), allSatRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true));
352 regionChecker->analyzeRegion(this->env(), exBothRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true));
354 regionChecker->analyzeRegion(this->env(), allVioRegion, storm::modelchecker::RegionResultHypothesis::Unknown, true));
355}
356} // namespace
357#endif
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:14
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: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