1#include "storm-config.h"
23 return std::make_unique<storm::modelchecker::ExplicitQualitativeCheckResult<double>>(model->getInitialStates());
27 return std::make_unique<storm::modelchecker::ExplicitQualitativeCheckResult<double>>(model->getInitialStates());
32 return std::make_unique<storm::modelchecker::ExplicitQualitativeCheckResult<storm::RationalNumber>>(model->getInitialStates());
36 std::unique_ptr<storm::modelchecker::CheckResult>& result) {
38 result->filter(*filter);
39 return result->asQuantitativeCheckResult<storm::RationalNumber>().getMin();
44 return std::make_unique<storm::modelchecker::ExplicitQualitativeCheckResult<storm::RationalNumber>>(model->getInitialStates());
48 std::unique_ptr<storm::modelchecker::CheckResult>& result) {
50 result->filter(*filter);
51 return result->asQuantitativeCheckResult<
double>().getMin();
55 std::unique_ptr<storm::modelchecker::CheckResult>& result) {
57 result->filter(*filter);
58 return result->asQuantitativeCheckResult<
double>().getMin();
62 std::unique_ptr<storm::modelchecker::CheckResult>& result) {
64 result->filter(*filter);
65 return result->asQuantitativeCheckResult<storm::RationalNumber>().getMin();
68void expectThrow(std::string
const& path, std::string
const& formulaString) {
83void checkModel(std::string
const& path, std::string
const& formulaString,
double maxmin,
double maxmax,
double minmax,
double minmin,
bool produceScheduler) {
92 taskMax.setUncertaintyResolutionMode(storm::UncertaintyResolutionMode::Robust);
93 taskMax.setProduceSchedulers(produceScheduler);
96 auto resultMax = checker.
check(env, taskMax);
98 taskMax.setUncertaintyResolutionMode(storm::UncertaintyResolutionMode::Cooperative);
99 auto resultMaxNonRobust = checker.check(env, taskMax);
103 taskMin.setUncertaintyResolutionMode(storm::UncertaintyResolutionMode::Robust);
104 taskMin.setProduceSchedulers(produceScheduler);
106 auto resultMin = checker.check(env, taskMin);
108 taskMin.setUncertaintyResolutionMode(storm::UncertaintyResolutionMode::Cooperative);
109 auto resultMinNonRobust = checker.check(env, taskMin);
114 std::string constantsString) {
128 taskMinMin.setUncertaintyResolutionMode(storm::UncertaintyResolutionMode::Minimize);
131 auto resultMinMin = checker.
check(env, taskMinMin);
135 taskMinMax.setUncertaintyResolutionMode(storm::UncertaintyResolutionMode::Maximize);
137 auto resultMinMax = checker.check(env, taskMinMax);
141 taskMaxMin.setUncertaintyResolutionMode(storm::UncertaintyResolutionMode::Minimize);
143 auto resultMaxMin = checker.check(env, taskMaxMin);
147 taskMaxMin.setUncertaintyResolutionMode(storm::UncertaintyResolutionMode::Maximize);
149 auto resultMaxMax = checker.check(env, taskMaxMax);
153void checkModelRational(std::string
const& path, std::string
const& formulaString, storm::RationalNumber maxmin, storm::RationalNumber maxmax,
154 storm::RationalNumber minmax, storm::RationalNumber minmin,
bool produceScheduler) {
164 taskMax.setProduceSchedulers(produceScheduler);
167 taskMax.setUncertaintyResolutionMode(storm::UncertaintyResolutionMode::Robust);
168 auto resultMax = checker.
check(env, taskMax);
170 taskMax.setUncertaintyResolutionMode(storm::UncertaintyResolutionMode::Cooperative);
171 auto resultMaxNonRobust = checker.check(env, taskMax);
175 taskMin.setProduceSchedulers(produceScheduler);
177 taskMin.setUncertaintyResolutionMode(storm::UncertaintyResolutionMode::Robust);
178 auto resultMin = checker.check(env, taskMin);
180 taskMin.setUncertaintyResolutionMode(storm::UncertaintyResolutionMode::Cooperative);
181 auto resultMinNonRobust = checker.check(env, taskMin);
185TEST(RobustMdpModelCheckerTest, RobotMinMaxTest) {
187 GTEST_SKIP() <<
"Z3 not available.";
191 "Pmin=? [ F \"goal2\"];Pmin=? [ F \"goal2\"];Pmax=? [ F \"goal2\"];Pmax=? [ F \"goal2\"]", 0.4, 0.6, 1.0, 1.0,
198 std::vector<std::shared_ptr<storm::logic::Formula const>> formulas =
204 ASSERT_TRUE(formulas[0]->isProbabilityOperatorFormula());
206 ASSERT_TRUE(formulas[0]->asProbabilityOperatorFormula().getOptimalityType() == storm::solver::OptimizationDirection::Maximize);
212 auto exresult = checker.
check(env, task);
220 auto iresultMin = checker.
check(env, task);
222 EXPECT_LE(minValue, certainValue);
223 task.setUncertaintyResolutionMode(storm::UncertaintyResolutionMode::Cooperative);
224 auto iresultMax = checker.check(env, task);
226 EXPECT_LE(certainValue, maxValue);
232 std::vector<std::shared_ptr<storm::logic::Formula const>> formulas =
237 ASSERT_TRUE(formulas[0]->isProbabilityOperatorFormula());
238 ASSERT_TRUE(formulas[0]->asProbabilityOperatorFormula().getOptimalityType() == storm::solver::OptimizationDirection::Maximize);
243 auto exresult = checker.
check(env, taskCertain);
253 taskMin.setUncertaintyResolutionMode(storm::UncertaintyResolutionMode::Minimize);
254 auto iresultMin = ichecker.check(envIntervals, taskMin);
256 EXPECT_LE(minValue, certainValue);
259 taskMax.setUncertaintyResolutionMode(storm::UncertaintyResolutionMode::Maximize);
260 auto iresultMax = ichecker.check(envIntervals, taskMax);
262 EXPECT_LE(certainValue, maxValue);
267TEST(RobustMDPModelCheckingTest, Tiny01maxmin) {
268 checkModel(STORM_TEST_RESOURCES_DIR
"/imdp/tiny-01.drn",
"Pmax=? [ F \"target\"];Pmin=? [ F \"target\"]", 0.4, 0.5, 0.5, 0.4,
false);
271TEST(RobustMDPModelCheckingTest, Tiny03maxmin) {
272 checkModel(STORM_TEST_RESOURCES_DIR
"/imdp/tiny-03.drn",
"Pmax=? [ F \"target\"];Pmin=? [ F \"target\"]", 0.4, 0.6, 0.5, 0.3,
true);
275TEST(RobustMDPModelCheckingTest, BoundedTiny03maxmin) {
276 checkModel(STORM_TEST_RESOURCES_DIR
"/imdp/tiny-03.drn",
"Pmax=? [ F<=1 \"target\"];Pmin=? [ F<=1 \"target\"]", 0.4, 0.6, 0.5, 0.3,
true);
277 checkModel(STORM_TEST_RESOURCES_DIR
"/imdp/tiny-03.drn",
"Pmax=? [ F[1,1] \"target\"];Pmin=? [ F[1,1] \"target\"]", 0.4, 0.6, 0.5, 0.3,
true);
280TEST(RobustMDPModelCheckingTest, BoundedMaxmin) {
281 checkModel(STORM_TEST_RESOURCES_DIR
"/imdp/tiny-bounded.drn",
"Pmax=? [ F<=4 \"target\"];Pmin=? [ F<=4 \"target\"]", 0.6528, 0.81, 0.81, 0.6528,
true);
282 checkModel(STORM_TEST_RESOURCES_DIR
"/imdp/tiny-bounded.drn",
"Pmax=? [ F[0,4] \"target\"];Pmin=? [ F[0,4] \"target\"]", 0.6528, 0.81, 0.81, 0.6528,
true);
283 checkModel(STORM_TEST_RESOURCES_DIR
"/imdp/tiny-bounded.drn",
"Pmax=? [ F[4,4] \"target\"];Pmin=? [ F[4,4] \"target\"]", 0.1952, 0.324, 0.324, 0.1952,
285 checkModel(STORM_TEST_RESOURCES_DIR
"/imdp/tiny-bounded.drn",
"Pmax=? [ F[4,5] \"target\"];Pmin=? [ F[4,5] \"target\"]", 0.3236, 0.50292, 0.50292, 0.3236,
287 checkModel(STORM_TEST_RESOURCES_DIR
"/imdp/tiny-bounded.drn",
"Pmax=? [ F[4,6] \"target\"];Pmin=? [ F[4,6] \"target\"]", 0.37928, 0.57888, 0.57888, 0.37928,
289 checkModel(STORM_TEST_RESOURCES_DIR
"/imdp/tiny-bounded.drn",
"Pmax=? [ F[2,2] \"target\"];Pmin=? [ F[2,2] \"target\"]", 0.32, 0.45, 0.45, 0.32,
true);
290 checkModel(STORM_TEST_RESOURCES_DIR
"/imdp/tiny-bounded.drn",
"Pmax=? [ F<=2 \"target\"];Pmin=? [ F<=2 \"target\"]", 0.32, 0.45, 0.45, 0.32,
true);
293TEST(RobustMDPModelCheckingTest, Tiny04maxmin) {
294 checkModel(STORM_TEST_RESOURCES_DIR
"/imdp/tiny-04.drn",
"Pmax=? [ F \"target\"];Pmin=? [ F \"target\"]", 1, 1, 0.42857, 0.42,
false);
297TEST(RobustMDPModelCheckingTest, Tiny05maxmin) {
298 checkModel(STORM_TEST_RESOURCES_DIR
"/imdp/tiny-05.drn",
"Pmax=? [ F \"target\"];Pmin=? [ F \"target\"]", 0.3, 0.4, 0.4, 0.3,
false);
301TEST(RobustMDPModelCheckingTest, Tiny04maxmin_rewards) {
302 expectThrow(STORM_TEST_RESOURCES_DIR
"/imdp/tiny-04.drn",
"Rmin=? [ F \"target\"]");
305TEST(RobustMDPModelCheckingTest, CrowdsQuotientIMDP) {
307 checkModel(STORM_TEST_RESOURCES_DIR
"/imdp/crowds-quotient-3-5.drn",
"Pmax=? [ F \"observe0Greater1\"]; Pmin=? [ F \"observe0Greater1\"]", 0.1383409,
308 0.1383409, 0.1383409, 0.1383409,
false);
313TEST(RobustRationalMDPModelCheckingTest, Tiny01maxmin) {
314 checkModelRational(STORM_TEST_RESOURCES_DIR
"/imdp/tiny-01.drn",
"Pmax=? [ F \"target\"];Pmin=? [ F \"target\"]", storm::RationalNumber(
"2/5"),
315 storm::RationalNumber(
"1/2"), storm::RationalNumber(
"1/2"), storm::RationalNumber(
"2/5"),
false);
318TEST(RobustRationalMDPModelCheckingTest, Tiny03maxmin) {
319 checkModelRational(STORM_TEST_RESOURCES_DIR
"/imdp/tiny-03.drn",
"Pmax=? [ F \"target\"];Pmin=? [ F \"target\"]", storm::RationalNumber(
"2/5"),
320 storm::RationalNumber(
"3/5"), storm::RationalNumber(
"1/2"), storm::RationalNumber(
"3/10"),
true);
323TEST(RobustRationalMDPModelCheckingTest, BoundedTiny03maxmin) {
324 checkModelRational(STORM_TEST_RESOURCES_DIR
"/imdp/tiny-03.drn",
"Pmax=? [ F<=1 \"target\"];Pmin=? [ F<=1 \"target\"]", storm::RationalNumber(
"2/5"),
325 storm::RationalNumber(
"3/5"), storm::RationalNumber(
"1/2"), storm::RationalNumber(
"3/10"),
true);
326 checkModelRational(STORM_TEST_RESOURCES_DIR
"/imdp/tiny-03.drn",
"Pmax=? [ F[1,1] \"target\"];Pmin=? [ F[1,1] \"target\"]", storm::RationalNumber(
"2/5"),
327 storm::RationalNumber(
"3/5"), storm::RationalNumber(
"1/2"), storm::RationalNumber(
"3/10"),
true);
330TEST(RobustRationalMDPModelCheckingTest, BoundedMaxmin) {
331 checkModelRational(STORM_TEST_RESOURCES_DIR
"/imdp/tiny-bounded.drn",
"Pmax=? [ F<=4 \"target\"];Pmin=? [ F<=4 \"target\"]",
332 storm::RationalNumber(
"408/625"), storm::RationalNumber(
"81/100"), storm::RationalNumber(
"81/100"), storm::RationalNumber(
"408/625"),
334 checkModelRational(STORM_TEST_RESOURCES_DIR
"/imdp/tiny-bounded.drn",
"Pmax=? [ F[0,4] \"target\"];Pmin=? [ F[0,4] \"target\"]",
335 storm::RationalNumber(
"408/625"), storm::RationalNumber(
"81/100"), storm::RationalNumber(
"81/100"), storm::RationalNumber(
"408/625"),
337 checkModelRational(STORM_TEST_RESOURCES_DIR
"/imdp/tiny-bounded.drn",
"Pmax=? [ F[4,4] \"target\"];Pmin=? [ F[4,4] \"target\"]",
338 storm::RationalNumber(
"122/625"), storm::RationalNumber(
"81/250"), storm::RationalNumber(
"81/250"), storm::RationalNumber(
"122/625"),
340 checkModelRational(STORM_TEST_RESOURCES_DIR
"/imdp/tiny-bounded.drn",
"Pmax=? [ F[4,5] \"target\"];Pmin=? [ F[4,5] \"target\"]",
341 storm::RationalNumber(
"809/2500"), storm::RationalNumber(
"12573/25000"), storm::RationalNumber(
"12573/25000"),
342 storm::RationalNumber(
"809/2500"),
true);
343 checkModelRational(STORM_TEST_RESOURCES_DIR
"/imdp/tiny-bounded.drn",
"Pmax=? [ F[4,6] \"target\"];Pmin=? [ F[4,6] \"target\"]",
344 storm::RationalNumber(
"4741/12500"), storm::RationalNumber(
"1809/3125"), storm::RationalNumber(
"1809/3125"),
345 storm::RationalNumber(
"4741/12500"),
true);
346 checkModelRational(STORM_TEST_RESOURCES_DIR
"/imdp/tiny-bounded.drn",
"Pmax=? [ F[2,2] \"target\"];Pmin=? [ F[2,2] \"target\"]",
347 storm::RationalNumber(
"8/25"), storm::RationalNumber(
"9/20"), storm::RationalNumber(
"9/20"), storm::RationalNumber(
"8/25"),
true);
348 checkModelRational(STORM_TEST_RESOURCES_DIR
"/imdp/tiny-bounded.drn",
"Pmax=? [ F<=2 \"target\"];Pmin=? [ F<=2 \"target\"]", storm::RationalNumber(
"8/25"),
349 storm::RationalNumber(
"9/20"), storm::RationalNumber(
"9/20"), storm::RationalNumber(
"8/25"),
true);
352TEST(RobustRationalMDPModelCheckingTest, Tiny04maxmin) {
354 checkModelRational(STORM_TEST_RESOURCES_DIR
"/imdp/tiny-04.drn",
"Pmax=? [ F \"target\"];Pmin=? [ F \"target\"]", storm::RationalNumber(1),
355 storm::RationalNumber(1), storm::RationalNumber(
"42857140807299/100000000000000"), storm::RationalNumber(
"21/50"),
false);
358TEST(RobustRationalMDPModelCheckingTest, Tiny05maxmin) {
359 checkModelRational(STORM_TEST_RESOURCES_DIR
"/imdp/tiny-05.drn",
"Pmax=? [ F \"target\"];Pmin=? [ F \"target\"]", storm::RationalNumber(
"3/10"),
360 storm::RationalNumber(
"2/5"), storm::RationalNumber(
"2/5"), storm::RationalNumber(
"3/10"),
false);
363TEST(RobustMDPModelCheckingTest, AddUncertaintyCoin22max) {
365 GTEST_SKIP() <<
"Z3 not available.";
367 makeUncertainAndCheck(STORM_TEST_RESOURCES_DIR
"/mdp/coin2-2.nm",
"Pmax=? [F \"all_coins_equal_1\"]", 0.1);
368 makeUncertainAndCheck(STORM_TEST_RESOURCES_DIR
"/mdp/coin2-2.nm",
"Pmax=? [F \"all_coins_equal_1\"]", 0.2);
371TEST(RobustRationalMDPModelCheckingTest, AddUncertaintyCoin22max) {
373 GTEST_SKIP() <<
"Z3 not available.";
375 makeUncertainAndCheckRational(STORM_TEST_RESOURCES_DIR
"/mdp/coin2-2.nm",
"Pmax=? [F \"all_coins_equal_1\"]", storm::RationalNumber(
"1/10"));
TEST(RobustMdpModelCheckerTest, RobotMinMaxTest)
std::unique_ptr< storm::modelchecker::QualitativeCheckResult > getInitialStateFilter(std::shared_ptr< storm::models::sparse::Model< storm::Interval > > const &model)
void checkPrismModelForQuantitativeResult(std::string const &path, std::string const &formulaString, double minmin, double minmax, double maxmin, double maxmax, std::string constantsString)
void expectThrow(std::string const &path, std::string const &formulaString)
storm::RationalNumber getQuantitativeResultAtInitialState(std::shared_ptr< storm::models::sparse::Model< storm::RationalNumber > > const &model, std::unique_ptr< storm::modelchecker::CheckResult > &result)
void checkModel(std::string const &path, std::string const &formulaString, double maxmin, double maxmax, double minmax, double minmin, bool produceScheduler)
void checkModelRational(std::string const &path, std::string const &formulaString, storm::RationalNumber maxmin, storm::RationalNumber maxmax, storm::RationalNumber minmax, storm::RationalNumber minmin, bool produceScheduler)
void makeUncertainAndCheckRational(std::string const &path, std::string const &formulaString, storm::RationalNumber amountOfUncertainty)
void makeUncertainAndCheck(std::string const &path, std::string const &formulaString, double amountOfUncertainty)
SolverEnvironment & solver()
void setMethod(storm::solver::MinMaxMethod value, bool isSetFromDefault=false)
MinMaxSolverEnvironment & minMax()
virtual std::unique_ptr< CheckResult > check(Environment const &env, CheckTask< storm::logic::Formula, SolutionType > const &checkTask)
Checks the provided formula.
This class represents a (discrete-time) Markov decision process.
Base class for all sparse models.
std::vector< storm::jani::Property > parsePropertiesForPrismProgram(std::string const &inputString, storm::prism::Program const &program, boost::optional< std::set< std::string > > const &propertyFilter)
std::shared_ptr< storm::models::sparse::Model< ValueType > > buildSparseModel(storm::storage::SymbolicModelDescription const &model, storm::builder::BuilderOptions const &options)
storm::prism::Program parseProgram(std::string const &filename, bool prismCompatibility, bool simplify)
std::vector< storm::jani::Property > parseProperties(storm::parser::FormulaParser &formulaParser, std::string const &inputString, boost::optional< std::set< std::string > > const &propertyFilter)
std::vector< std::shared_ptr< storm::logic::Formula const > > extractFormulasFromProperties(std::vector< storm::jani::Property > const &properties)
template std::shared_ptr< storm::models::sparse::Model< storm::RationalInterval > > parseDirectEncodingModel< storm::RationalInterval >(std::filesystem::path const &file, DirectEncodingParserOptions const &options)
template std::shared_ptr< storm::models::sparse::Model< storm::Interval > > parseDirectEncodingModel< storm::Interval >(std::filesystem::path const &file, DirectEncodingParserOptions const &options)
storm::prism::Program preprocess(storm::prism::Program const &program, std::map< storm::expressions::Variable, storm::expressions::Expression > const &constantDefinitions)
#define STORM_SILENT_EXPECT_THROW(statement, expected_exception)