1#include "storm-config.h"
37enum class DtmcEngine { PrismSparse, JaniSparse,
Hybrid, PrismDd, JaniDd };
40class SparseGmmxxGmresIluEnvironment {
43 static const DtmcEngine engine = DtmcEngine::PrismSparse;
44 static const bool isExact =
false;
46 typedef storm::models::sparse::Dtmc<ValueType>
ModelType;
47 static storm::Environment createEnvironment() {
48 storm::Environment env;
57class JaniSparseGmmxxGmresIluEnvironment {
60 static const DtmcEngine engine = DtmcEngine::JaniSparse;
61 static const bool isExact =
false;
63 typedef storm::models::sparse::Dtmc<ValueType>
ModelType;
64 static storm::Environment createEnvironment() {
65 storm::Environment env;
74class SparseGmmxxGmresDiagEnvironment {
77 static const DtmcEngine engine = DtmcEngine::PrismSparse;
78 static const bool isExact =
false;
80 typedef storm::models::sparse::Dtmc<ValueType>
ModelType;
81 static storm::Environment createEnvironment() {
82 storm::Environment env;
91class SparseGmmxxBicgstabIluEnvironment {
94 static const DtmcEngine engine = DtmcEngine::PrismSparse;
95 static const bool isExact =
false;
97 typedef storm::models::sparse::Dtmc<ValueType>
ModelType;
98 static storm::Environment createEnvironment() {
99 storm::Environment env;
109class SparseEigenDGmresEnvironment {
112 static const DtmcEngine engine = DtmcEngine::PrismSparse;
113 static const bool isExact =
false;
114 typedef double ValueType;
115 typedef storm::models::sparse::Dtmc<ValueType> ModelType;
116 static storm::Environment createEnvironment() {
117 storm::Environment env;
126class SparseEigenDoubleLUEnvironment {
129 static const DtmcEngine engine = DtmcEngine::PrismSparse;
130 static const bool isExact =
false;
131 typedef double ValueType;
132 typedef storm::models::sparse::Dtmc<ValueType> ModelType;
133 static storm::Environment createEnvironment() {
134 storm::Environment env;
141class SparseEigenRationalLUEnvironment {
144 static const DtmcEngine engine = DtmcEngine::PrismSparse;
145 static const bool isExact =
true;
146 typedef storm::RationalNumber ValueType;
147 typedef storm::models::sparse::Dtmc<ValueType> ModelType;
148 static storm::Environment createEnvironment() {
149 storm::Environment env;
156class SparseRationalEliminationEnvironment {
159 static const DtmcEngine engine = DtmcEngine::PrismSparse;
160 static const bool isExact =
true;
161 typedef storm::RationalNumber ValueType;
162 typedef storm::models::sparse::Dtmc<ValueType> ModelType;
163 static storm::Environment createEnvironment() {
164 storm::Environment env;
170class SparseNativeJacobiEnvironment {
173 static const DtmcEngine engine = DtmcEngine::PrismSparse;
174 static const bool isExact =
false;
175 typedef double ValueType;
176 typedef storm::models::sparse::Dtmc<ValueType> ModelType;
177 static storm::Environment createEnvironment() {
178 storm::Environment env;
186class SparseNativeWalkerChaeEnvironment {
189 static const DtmcEngine engine = DtmcEngine::PrismSparse;
190 static const bool isExact =
false;
191 typedef double ValueType;
192 typedef storm::models::sparse::Dtmc<ValueType> ModelType;
193 static storm::Environment createEnvironment() {
194 storm::Environment env;
203class SparseNativeSorEnvironment {
206 static const DtmcEngine engine = DtmcEngine::PrismSparse;
207 static const bool isExact =
false;
208 typedef double ValueType;
209 typedef storm::models::sparse::Dtmc<ValueType> ModelType;
210 static storm::Environment createEnvironment() {
211 storm::Environment env;
219class SparseNativePowerEnvironment {
222 static const DtmcEngine engine = DtmcEngine::PrismSparse;
223 static const bool isExact =
false;
224 typedef double ValueType;
225 typedef storm::models::sparse::Dtmc<ValueType> ModelType;
226 static storm::Environment createEnvironment() {
227 storm::Environment env;
235class SparseNativeSoundValueIterationEnvironment {
238 static const DtmcEngine engine = DtmcEngine::PrismSparse;
239 static const bool isExact =
false;
240 typedef double ValueType;
241 typedef storm::models::sparse::Dtmc<ValueType> ModelType;
242 static storm::Environment createEnvironment() {
243 storm::Environment env;
246 env.
solver().
native().
setMethod(storm::solver::NativeLinearEquationSolverMethod::SoundValueIteration);
252class SparseNativeOptimisticValueIterationEnvironment {
255 static const DtmcEngine engine = DtmcEngine::PrismSparse;
256 static const bool isExact =
false;
257 typedef double ValueType;
258 typedef storm::models::sparse::Dtmc<ValueType> ModelType;
259 static storm::Environment createEnvironment() {
260 storm::Environment env;
263 env.
solver().
native().
setMethod(storm::solver::NativeLinearEquationSolverMethod::OptimisticValueIteration);
269class SparseNativeGuessingValueIterationEnvironment {
272 static const DtmcEngine engine = DtmcEngine::PrismSparse;
273 static const bool isExact =
false;
274 typedef double ValueType;
275 typedef storm::models::sparse::Dtmc<ValueType> ModelType;
276 static storm::Environment createEnvironment() {
277 storm::Environment env;
280 env.
solver().
native().
setMethod(storm::solver::NativeLinearEquationSolverMethod::GuessingValueIteration);
287class SparseNativeIntervalIterationEnvironment {
290 static const DtmcEngine engine = DtmcEngine::PrismSparse;
291 static const bool isExact =
false;
292 typedef double ValueType;
293 typedef storm::models::sparse::Dtmc<ValueType> ModelType;
294 static storm::Environment createEnvironment() {
295 storm::Environment env;
305class SparseNativeRationalSearchEnvironment {
308 static const DtmcEngine engine = DtmcEngine::PrismSparse;
309 static const bool isExact =
true;
310 typedef storm::RationalNumber ValueType;
311 typedef storm::models::sparse::Dtmc<ValueType> ModelType;
312 static storm::Environment createEnvironment() {
313 storm::Environment env;
320class SparseTopologicalEigenLUEnvironment {
323 static const DtmcEngine engine = DtmcEngine::PrismSparse;
324 static const bool isExact =
true;
325 typedef storm::RationalNumber ValueType;
326 typedef storm::models::sparse::Dtmc<ValueType> ModelType;
327 static storm::Environment createEnvironment() {
328 storm::Environment env;
337class HybridSylvanGmmxxGmresEnvironment {
340 static const DtmcEngine engine = DtmcEngine::Hybrid;
341 static const bool isExact =
false;
343 typedef storm::models::symbolic::Dtmc<ddType, ValueType>
ModelType;
345 static void checkLibraryAvailable() {
346#ifndef STORM_HAVE_SYLVAN
347 GTEST_SKIP() <<
"Library Sylvan not available.";
351 static storm::Environment createEnvironment() {
352 storm::Environment env;
361class HybridCuddNativeJacobiEnvironment {
364 static const DtmcEngine engine = DtmcEngine::Hybrid;
365 static const bool isExact =
false;
366 typedef double ValueType;
367 typedef storm::models::symbolic::Dtmc<ddType, ValueType> ModelType;
369 static void checkLibraryAvailable() {
370#ifndef STORM_HAVE_CUDD
371 GTEST_SKIP() <<
"Library CUDD not available.";
375 static storm::Environment createEnvironment() {
376 storm::Environment env;
384class HybridCuddNativeSoundValueIterationEnvironment {
387 static const DtmcEngine engine = DtmcEngine::Hybrid;
388 static const bool isExact =
false;
389 typedef double ValueType;
390 typedef storm::models::symbolic::Dtmc<ddType, ValueType> ModelType;
392 static void checkLibraryAvailable() {
393#ifndef STORM_HAVE_CUDD
394 GTEST_SKIP() <<
"Library CUDD not available.";
398 static storm::Environment createEnvironment() {
399 storm::Environment env;
408class HybridSylvanNativeRationalSearchEnvironment {
411 static const DtmcEngine engine = DtmcEngine::Hybrid;
412 static const bool isExact =
true;
413 typedef storm::RationalNumber ValueType;
414 typedef storm::models::symbolic::Dtmc<ddType, ValueType> ModelType;
416 static void checkLibraryAvailable() {
417#ifndef STORM_HAVE_SYLVAN
418 GTEST_SKIP() <<
"Library Sylvan not available.";
422 static storm::Environment createEnvironment() {
423 storm::Environment env;
430class DdSylvanNativePowerEnvironment {
433 static const DtmcEngine engine = DtmcEngine::PrismDd;
434 static const bool isExact =
false;
435 typedef double ValueType;
436 typedef storm::models::symbolic::Dtmc<ddType, ValueType> ModelType;
438 static void checkLibraryAvailable() {
439#ifndef STORM_HAVE_SYLVAN
440 GTEST_SKIP() <<
"Library Sylvan not available.";
444 static storm::Environment createEnvironment() {
445 storm::Environment env;
453class JaniDdSylvanNativePowerEnvironment {
456 static const DtmcEngine engine = DtmcEngine::JaniDd;
457 static const bool isExact =
false;
458 typedef double ValueType;
459 typedef storm::models::symbolic::Dtmc<ddType, ValueType> ModelType;
461 static void checkLibraryAvailable() {
462#ifndef STORM_HAVE_SYLVAN
463 GTEST_SKIP() <<
"Library Sylvan not available.";
467 static storm::Environment createEnvironment() {
468 storm::Environment env;
476class DdCuddNativeJacobiEnvironment {
479 static const DtmcEngine engine = DtmcEngine::PrismDd;
480 static const bool isExact =
false;
481 typedef double ValueType;
482 typedef storm::models::symbolic::Dtmc<ddType, ValueType> ModelType;
484 static void checkLibraryAvailable() {
485#ifndef STORM_HAVE_CUDD
486 GTEST_SKIP() <<
"Library CUDD not available.";
490 static storm::Environment createEnvironment() {
491 storm::Environment env;
499class DdSylvanRationalSearchEnvironment {
502 static const DtmcEngine engine = DtmcEngine::PrismDd;
503 static const bool isExact =
true;
504 typedef storm::RationalNumber ValueType;
505 typedef storm::models::symbolic::Dtmc<ddType, ValueType> ModelType;
507 static void checkLibraryAvailable() {
508#ifndef STORM_HAVE_SYLVAN
509 GTEST_SKIP() <<
"Library Sylvan not available.";
513 static storm::Environment createEnvironment() {
514 storm::Environment env;
521template<
typename TestType>
522class DtmcPrctlModelCheckerTest :
public ::testing::Test {
524 typedef typename TestType::ValueType ValueType;
525 typedef typename storm::models::sparse::Dtmc<ValueType> SparseModelType;
526 typedef typename storm::models::symbolic::Dtmc<TestType::ddType, ValueType> SymbolicModelType;
528 DtmcPrctlModelCheckerTest() : _environment(TestType::createEnvironment()) {}
530 void SetUp()
override {
531#ifndef STORM_HAVE_SMT_SOLVER
532 GTEST_SKIP() <<
"No SMT solver available.";
534 if constexpr (TestType::engine == DtmcEngine::Hybrid || TestType::engine == DtmcEngine::PrismDd || TestType::engine == DtmcEngine::JaniDd) {
535 TestType::checkLibraryAvailable();
539 storm::Environment
const& env()
const {
542 ValueType
parseNumber(std::string
const& input)
const {
545 ValueType precision()
const {
548 bool isSparseModel()
const {
549 return std::is_same<typename TestType::ModelType, SparseModelType>::value;
551 bool isSymbolicModel()
const {
552 return std::is_same<typename TestType::ModelType, SymbolicModelType>::value;
555 template<
typename MT =
typename TestType::ModelType>
556 typename std::enable_if<std::is_same<MT, SparseModelType>::value,
557 std::pair<std::shared_ptr<MT>, std::vector<std::shared_ptr<storm::logic::Formula const>>>>::type
558 buildModelFormulas(std::string
const& pathToPrismFile, std::string
const& formulasAsString, std::string
const& constantDefinitionString =
"")
const {
559 std::pair<std::shared_ptr<MT>, std::vector<std::shared_ptr<storm::logic::Formula const>>> result;
561 program = program.
preprocess(constantDefinitionString);
562 if (TestType::engine == DtmcEngine::PrismSparse) {
565 }
else if (TestType::engine == DtmcEngine::JaniSparse) {
574 template<
typename MT =
typename TestType::ModelType>
575 typename std::enable_if<std::is_same<MT, SymbolicModelType>::value,
576 std::pair<std::shared_ptr<MT>, std::vector<std::shared_ptr<storm::logic::Formula const>>>>::type
577 buildModelFormulas(std::string
const& pathToPrismFile, std::string
const& formulasAsString, std::string
const& constantDefinitionString =
"")
const {
578 std::pair<std::shared_ptr<MT>, std::vector<std::shared_ptr<storm::logic::Formula const>>> result;
580 program = program.
preprocess(constantDefinitionString);
581 if (TestType::engine == DtmcEngine::Hybrid || TestType::engine == DtmcEngine::PrismDd) {
584 }
else if (TestType::engine == DtmcEngine::JaniDd) {
586 janiData.first.substituteFunctions();
594 template<
typename MT =
typename TestType::ModelType>
595 typename std::enable_if<std::is_same<MT, SparseModelType>::value,
596 std::pair<std::shared_ptr<MT>, std::vector<std::shared_ptr<storm::logic::Formula const>>>>::type
597 buildJaniModelFormulas(std::string
const& pathToJaniFile)
const {
598 std::pair<std::shared_ptr<MT>, std::vector<std::shared_ptr<storm::logic::Formula const>>> result;
605 template<
typename MT =
typename TestType::ModelType>
606 typename std::enable_if<std::is_same<MT, SymbolicModelType>::value,
607 std::pair<std::shared_ptr<MT>, std::vector<std::shared_ptr<storm::logic::Formula const>>>>::type
608 buildJaniModelFormulas(std::string
const& pathToJaniFile)
const {
609 std::pair<std::shared_ptr<MT>, std::vector<std::shared_ptr<storm::logic::Formula const>>> result;
611 janiData.first.substituteFunctions();
617 std::vector<storm::modelchecker::CheckTask<storm::logic::Formula, ValueType>> getTasks(
618 std::vector<std::shared_ptr<storm::logic::Formula const>>
const& formulas)
const {
619 std::vector<storm::modelchecker::CheckTask<storm::logic::Formula, ValueType>> result;
620 for (
auto const& f : formulas) {
621 result.emplace_back(*f);
626 template<
typename MT =
typename TestType::ModelType>
627 typename std::enable_if<std::is_same<MT, SparseModelType>::value, std::shared_ptr<storm::modelchecker::AbstractModelChecker<MT>>>::type createModelChecker(
628 std::shared_ptr<MT>
const& model)
const {
629 if (TestType::engine == DtmcEngine::PrismSparse || TestType::engine == DtmcEngine::JaniSparse) {
630 return std::make_shared<storm::modelchecker::SparseDtmcPrctlModelChecker<SparseModelType>>(*model);
634 template<
typename MT =
typename TestType::ModelType>
635 typename std::enable_if<std::is_same<MT, SymbolicModelType>::value, std::shared_ptr<storm::modelchecker::AbstractModelChecker<MT>>>::type
636 createModelChecker(std::shared_ptr<MT>
const& model)
const {
637 if (TestType::engine == DtmcEngine::Hybrid) {
638 return std::make_shared<storm::modelchecker::HybridDtmcPrctlModelChecker<SymbolicModelType>>(*model);
639 }
else if (TestType::engine == DtmcEngine::PrismDd || TestType::engine == DtmcEngine::JaniDd) {
640 return std::make_shared<storm::modelchecker::SymbolicDtmcPrctlModelChecker<SymbolicModelType>>(*model);
644 template<
typename MT =
typename TestType::ModelType>
645 typename std::enable_if<std::is_same<MT, SparseModelType>::value,
void>::type execute(std::shared_ptr<MT>
const& model,
646 std::function<
void()>
const& f)
const {
650 template<
typename MT =
typename TestType::ModelType>
651 typename std::enable_if<std::is_same<MT, SymbolicModelType>::value,
void>::type execute(std::shared_ptr<MT>
const& model,
652 std::function<
void()>
const& f)
const {
653 model->getManager().execute(f);
656 bool getQualitativeResultAtInitialState(std::shared_ptr<storm::models::Model<ValueType>>
const& model,
657 std::unique_ptr<storm::modelchecker::CheckResult>& result) {
659 result->filter(*filter);
660 return result->asQualitativeCheckResult().forallTrue();
664 std::unique_ptr<storm::modelchecker::CheckResult>& result) {
666 result->filter(*filter);
667 return result->asQuantitativeCheckResult<ValueType>().getMin();
674 void expectQuantitativeResultAtInitialState(std::shared_ptr<storm::models::Model<ValueType>>
const& model,
675 std::unique_ptr<storm::modelchecker::CheckResult>& result, ValueType
const& expected) {
677 if (!result->isExplicitQuantitativeCheckResult()) {
681 auto const& explicitResult = result->template asExplicitQuantitativeCheckResult<ValueType>();
683 if (explicitResult.hasLowerBounds()) {
684 EXPECT_LE(explicitResult.getLowerBoundVector().front(), expected + tolerance) <<
"The lower bound exceeds the expected value.";
686 if (explicitResult.hasUpperBounds()) {
687 EXPECT_LE(expected, explicitResult.getUpperBoundVector().front() + tolerance) <<
"The upper bound falls below the expected value.";
694 void expectExactResultAtInitialState(std::shared_ptr<storm::models::Model<ValueType>>
const& model,
695 std::unique_ptr<storm::modelchecker::CheckResult>& result, ValueType
const& expected) {
696 expectQuantitativeResultAtInitialState(model, result, expected);
697 if (!result->isExplicitQuantitativeCheckResult()) {
700 auto const& explicitResult = result->template asExplicitQuantitativeCheckResult<ValueType>();
701 ASSERT_TRUE(explicitResult.hasLowerBounds()) <<
"No lower bound was reported although the values are exact.";
702 ASSERT_TRUE(explicitResult.hasUpperBounds()) <<
"No upper bound was reported although the values are exact.";
703 EXPECT_EQ(explicitResult.getLowerBoundVector(), explicitResult.getUpperBoundVector()) <<
"The bounds do not pin the values down.";
707 storm::Environment _environment;
709 std::unique_ptr<storm::modelchecker::QualitativeCheckResult>
getInitialStateFilter(std::shared_ptr<storm::models::Model<ValueType>>
const& model)
const {
710 if (isSparseModel()) {
711 return std::make_unique<storm::modelchecker::ExplicitQualitativeCheckResult<ValueType>>(model->template as<SparseModelType>()->getInitialStates());
713 return std::make_unique<storm::modelchecker::SymbolicQualitativeCheckResult<TestType::ddType>>(
714 model->template as<SymbolicModelType>()->getReachableStates(), model->template as<SymbolicModelType>()->getInitialStates());
719typedef ::testing::Types<
721 SparseGmmxxGmresIluEnvironment, JaniSparseGmmxxGmresIluEnvironment, SparseGmmxxGmresDiagEnvironment, SparseGmmxxBicgstabIluEnvironment,
722 HybridSylvanGmmxxGmresEnvironment,
724 SparseEigenDGmresEnvironment, SparseEigenDoubleLUEnvironment, SparseEigenRationalLUEnvironment, SparseRationalEliminationEnvironment,
725 SparseNativeJacobiEnvironment, SparseNativeWalkerChaeEnvironment, SparseNativeSorEnvironment, SparseNativePowerEnvironment,
726 SparseNativeSoundValueIterationEnvironment, SparseNativeOptimisticValueIterationEnvironment, SparseNativeGuessingValueIterationEnvironment,
727 SparseNativeIntervalIterationEnvironment, SparseNativeRationalSearchEnvironment, SparseTopologicalEigenLUEnvironment, HybridCuddNativeJacobiEnvironment,
728 HybridCuddNativeSoundValueIterationEnvironment, HybridSylvanNativeRationalSearchEnvironment, DdSylvanNativePowerEnvironment,
729 JaniDdSylvanNativePowerEnvironment, DdCuddNativeJacobiEnvironment, DdSylvanRationalSearchEnvironment>
735 std::string formulasString =
"P=? [F \"one\"]";
736 formulasString +=
"; P=? [F \"two\"]";
737 formulasString +=
"; P=? [F \"three\"]";
738 formulasString +=
"; R=? [F \"done\"]";
740 auto modelFormulas = this->buildModelFormulas(STORM_TEST_RESOURCES_DIR
"/dtmc/die.pm", formulasString);
741 auto model = std::move(modelFormulas.first);
742 auto tasks = this->getTasks(modelFormulas.second);
743 this->execute(model, [&]() {
744 EXPECT_EQ(13ul, model->getNumberOfStates());
745 EXPECT_EQ(20ul, model->getNumberOfTransitions());
747 auto checker = this->createModelChecker(model);
748 std::unique_ptr<storm::modelchecker::CheckResult> result;
750 result = checker->check(this->env(), tasks[0]);
751 this->expectQuantitativeResultAtInitialState(model, result, this->parseNumber(
"1/6"));
753 result = checker->check(this->env(), tasks[1]);
754 this->expectQuantitativeResultAtInitialState(model, result, this->parseNumber(
"1/6"));
756 result = checker->check(this->env(), tasks[2]);
757 this->expectQuantitativeResultAtInitialState(model, result, this->parseNumber(
"1/6"));
759 result = checker->check(this->env(), tasks[3]);
760 this->expectQuantitativeResultAtInitialState(model, result, this->parseNumber(
"11/3"));
765 std::string formulasString =
"P=? [F observe0>1]";
766 formulasString +=
"; P=? [F \"observeIGreater1\"]";
767 formulasString +=
"; P=? [F observe1>1]";
769 auto modelFormulas = this->buildModelFormulas(STORM_TEST_RESOURCES_DIR
"/dtmc/crowds-4-3.pm", formulasString);
770 auto model = std::move(modelFormulas.first);
771 auto tasks = this->getTasks(modelFormulas.second);
772 this->execute(model, [&]() {
773 EXPECT_EQ(726ul, model->getNumberOfStates());
774 EXPECT_EQ(1146ul, model->getNumberOfTransitions());
776 auto checker = this->createModelChecker(model);
777 std::unique_ptr<storm::modelchecker::CheckResult> result;
779 result = checker->check(this->env(), tasks[0]);
780 this->expectQuantitativeResultAtInitialState(model, result, this->parseNumber(
"78686542099694893/1268858272000000000"));
782 result = checker->check(this->env(), tasks[1]);
783 this->expectQuantitativeResultAtInitialState(model, result, this->parseNumber(
"40300855878315123/1268858272000000000"));
785 result = checker->check(this->env(), tasks[2]);
786 this->expectQuantitativeResultAtInitialState(model, result, this->parseNumber(
"13433618626105041/1268858272000000000"));
790TYPED_TEST(DtmcPrctlModelCheckerTest, SynchronousLeader) {
791 std::string formulasString =
"P=? [F \"elected\"]";
792 formulasString +=
"; P=? [F<=5 \"elected\"]";
793 formulasString +=
"; R=? [F \"elected\"]";
795 auto modelFormulas = this->buildModelFormulas(STORM_TEST_RESOURCES_DIR
"/dtmc/leader-3-5.pm", formulasString);
796 auto model = std::move(modelFormulas.first);
797 auto tasks = this->getTasks(modelFormulas.second);
798 this->execute(model, [&]() {
799 EXPECT_EQ(273ul, model->getNumberOfStates());
800 EXPECT_EQ(397ul, model->getNumberOfTransitions());
802 auto checker = this->createModelChecker(model);
803 std::unique_ptr<storm::modelchecker::CheckResult> result;
805 result = checker->check(this->env(), tasks[0]);
806 this->expectQuantitativeResultAtInitialState(model, result, this->parseNumber(
"1"));
808 result = checker->check(this->env(), tasks[1]);
809 this->expectExactResultAtInitialState(model, result, this->parseNumber(
"24/25"));
811 result = checker->check(this->env(), tasks[2]);
812 this->expectQuantitativeResultAtInitialState(model, result, this->parseNumber(
"25/24"));
816TEST(DtmcPrctlModelCheckerTest, BoundedReachability) {
817 std::string formulasString =
"P=? [F<=1 \"a\"]";
818 formulasString +=
"; P=? [F[1,1] \"a\"]";
819 formulasString +=
"; P=? [F[0,2] \"a\"]";
821 std::shared_ptr<storm::models::sparse::Model<double>> modelPtr =
831 auto expectExactValue = [](std::unique_ptr<storm::modelchecker::CheckResult>
const& result,
double expected) {
832 EXPECT_NEAR(expected, result->asQuantitativeCheckResult<
double>().getMin(), 0.0001);
833 auto const& explicitResult = result->asExplicitQuantitativeCheckResult<
double>();
834 ASSERT_TRUE(explicitResult.hasLowerBounds());
835 ASSERT_TRUE(explicitResult.hasUpperBounds());
836 EXPECT_EQ(explicitResult.getLowerBoundVector(), explicitResult.getUpperBoundVector());
840 auto result = checker.
check(env, task);
841 auto filter = std::make_unique<storm::modelchecker::ExplicitQualitativeCheckResult<double>>(dtmc->getInitialStates());
842 result->filter(*filter);
843 expectExactValue(result, 0.2);
847 result = checker.check(env, task);
848 filter = std::make_unique<storm::modelchecker::ExplicitQualitativeCheckResult<double>>(dtmc->getInitialStates());
849 result->filter(*filter);
850 expectExactValue(result, 0.2);
854 result = checker.check(env, task);
855 filter = std::make_unique<storm::modelchecker::ExplicitQualitativeCheckResult<double>>(dtmc->getInitialStates());
856 result->filter(*filter);
857 expectExactValue(result, 0.366);
860TEST(DtmcPrctlModelCheckerTest, AllUntilProbabilities) {
861#ifndef STORM_HAVE_SMT_SOLVER
862 GTEST_SKIP() <<
"No SMT solver available.";
864 std::string formulasString =
"P=? [F \"one\"]";
865 formulasString +=
"; P=? [F \"two\"]";
866 formulasString +=
"; P=? [F \"three\"]";
870 std::vector<storm::modelchecker::CheckTask<storm::logic::Formula, double>> tasks;
871 for (
auto const& f : formulas) {
872 tasks.emplace_back(*f);
875 EXPECT_EQ(13ul, model->getNumberOfStates());
876 EXPECT_EQ(20ul, model->getNumberOfTransitions());
880 initialStates.set(0);
892 initialStates, phiStates, psiStates);
894 EXPECT_NEAR(1.0 / 6, result[7], 1e-6);
895 EXPECT_NEAR(1.0 / 6, result[8], 1e-6);
896 EXPECT_NEAR(1.0 / 6, result[9], 1e-6);
897 EXPECT_NEAR(1.0 / 6, result[10], 1e-6);
898 EXPECT_NEAR(1.0 / 6, result[11], 1e-6);
899 EXPECT_NEAR(1.0 / 6, result[12], 1e-6);
907 EXPECT_NEAR(1, result[0], 1e-6);
908 EXPECT_NEAR(0.5, result[1], 1e-6);
909 EXPECT_NEAR(0.5, result[2], 1e-6);
910 EXPECT_NEAR(0.25, result[5], 1e-6);
911 EXPECT_NEAR(0, result[7], 1e-6);
912 EXPECT_NEAR(0, result[8], 1e-6);
913 EXPECT_NEAR(0, result[9], 1e-6);
914 EXPECT_NEAR(0.125, result[10], 1e-6);
915 EXPECT_NEAR(0.125, result[11], 1e-6);
916 EXPECT_NEAR(0, result[12], 1e-6);
919TYPED_TEST(DtmcPrctlModelCheckerTest, LtlProbabilitiesDie) {
920#ifdef STORM_HAVE_LTL_MODELCHECKING_SUPPORT
921 std::string formulasString =
"P=? [(X s>0) U (s=7 & d=2)]";
922 formulasString +=
"; P=? [ X (((s=1) U (s=3)) U (s=7))]";
923 formulasString +=
"; P=? [ (F (X (s=6 & (XX s=5)))) & (F G (d!=5))]";
924 formulasString +=
"; P=? [ F (s=3 U (\"three\"))]";
925 formulasString +=
"; P=? [ F s=3 U (\"three\")]";
926 formulasString +=
"; P=? [ F (s=6) & X \"done\"]";
927 formulasString +=
"; P=? [ (F s=6) & (X \"done\")]";
929 auto modelFormulas = this->buildModelFormulas(STORM_TEST_RESOURCES_DIR
"/dtmc/die.pm", formulasString);
930 auto model = std::move(modelFormulas.first);
931 auto tasks = this->getTasks(modelFormulas.second);
932 this->execute(model, [&]() {
933 EXPECT_EQ(13ul, model->getNumberOfStates());
934 EXPECT_EQ(20ul, model->getNumberOfTransitions());
936 auto checker = this->createModelChecker(model);
937 std::unique_ptr<storm::modelchecker::CheckResult> result;
940 if (TypeParam::engine == DtmcEngine::PrismSparse || TypeParam::engine == DtmcEngine::JaniSparse) {
941 result = checker->check(tasks[0]);
942 this->expectQuantitativeResultAtInitialState(model, result, this->parseNumber(
"1/6"));
944 result = checker->check(tasks[1]);
945 this->expectQuantitativeResultAtInitialState(model, result, this->parseNumber(
"1/6"));
947 result = checker->check(tasks[2]);
948 this->expectQuantitativeResultAtInitialState(model, result, this->parseNumber(
"1/24"));
950 result = checker->check(tasks[3]);
951 this->expectQuantitativeResultAtInitialState(model, result, this->parseNumber(
"1/6"));
953 result = checker->check(tasks[4]);
954 this->expectQuantitativeResultAtInitialState(model, result, this->parseNumber(
"0"));
956 result = checker->check(tasks[5]);
957 this->expectQuantitativeResultAtInitialState(model, result, this->parseNumber(
"1/6"));
959 result = checker->check(tasks[6]);
960 this->expectQuantitativeResultAtInitialState(model, result, this->parseNumber(
"0"));
962 EXPECT_FALSE(checker->canHandle(tasks[0]));
970TYPED_TEST(DtmcPrctlModelCheckerTest, LtlProbabilitiesSynchronousLeader) {
971#ifdef STORM_HAVE_LTL_MODELCHECKING_SUPPORT
972 std::string formulasString =
"P=? [X (u1=true U \"elected\")]";
973 formulasString +=
"; P=? [X !(u1=true U \"elected\")]";
974 formulasString +=
"; P=? [X v1=2 & X v1=1]";
975 formulasString +=
"; P=? [(X v1=2) & (X v1=1)]";
976 formulasString +=
"; P=? [(!X v1=2) & (X v1=1)]";
978 auto modelFormulas = this->buildModelFormulas(STORM_TEST_RESOURCES_DIR
"/dtmc/leader-3-5.pm", formulasString);
979 auto model = std::move(modelFormulas.first);
980 auto tasks = this->getTasks(modelFormulas.second);
981 this->execute(model, [&]() {
982 EXPECT_EQ(273ul, model->getNumberOfStates());
983 EXPECT_EQ(397ul, model->getNumberOfTransitions());
985 auto checker = this->createModelChecker(model);
986 std::unique_ptr<storm::modelchecker::CheckResult> result;
989 if (TypeParam::engine == DtmcEngine::PrismSparse || TypeParam::engine == DtmcEngine::JaniSparse) {
990 result = checker->check(tasks[0]);
991 this->expectQuantitativeResultAtInitialState(model, result, this->parseNumber(
"16/25"));
993 result = checker->check(tasks[1]);
994 this->expectQuantitativeResultAtInitialState(model, result, this->parseNumber(
"9/25"));
996 result = checker->check(tasks[2]);
997 this->expectQuantitativeResultAtInitialState(model, result, this->parseNumber(
"1/25"));
999 result = checker->check(tasks[3]);
1000 this->expectQuantitativeResultAtInitialState(model, result, this->parseNumber(
"0"));
1002 result = checker->check(tasks[4]);
1003 this->expectQuantitativeResultAtInitialState(model, result, this->parseNumber(
"1/5"));
1006 EXPECT_FALSE(checker->canHandle(tasks[0]));
1014TYPED_TEST(DtmcPrctlModelCheckerTest, HOAProbabilitiesDie) {
1016 std::string formulasString =
"P=?[HOA: {\"" STORM_TEST_RESOURCES_DIR
"/hoa/automaton_UXp0p1.hoa\", \"p0\" -> (s>0), \"p1\" -> (s=7 & d=2) }]";
1018 formulasString +=
"; P=?[HOA: {\"" STORM_TEST_RESOURCES_DIR
"/hoa/automaton_UXp0p1.hoa\", \"p0\" -> (s>0), \"p1\" -> (d=4 | d=2) }]";
1020 formulasString +=
"; P=?[HOA: {\"" STORM_TEST_RESOURCES_DIR
"/hoa/automaton_Fandp0Xp1.hoa\", \"p0\" -> (s=4), \"p1\" -> \"three\" }]";
1022 formulasString +=
"; P=?[HOA: {\"" STORM_TEST_RESOURCES_DIR
"/hoa/automaton_Fandp0Xp1.hoa\", \"p0\" -> (s=6), \"p1\" -> \"done\" }]";
1024 formulasString +=
"; P=?[HOA: {\"" STORM_TEST_RESOURCES_DIR
"/hoa/automaton_Fandp0Xp1.hoa\", \"p0\" -> (s=6), \"p1\" -> !\"done\" }]";
1026 formulasString +=
"; P=?[HOA: {\"" STORM_TEST_RESOURCES_DIR
"/hoa/automaton_Fandp0Xp1.hoa\", \"p0\" -> (s=4 | s=5), \"p1\" -> s=7 & (d=3 | d=5) }]";
1028 formulasString +=
"; P>0.3[HOA: {\"" STORM_TEST_RESOURCES_DIR
"/hoa/automaton_Fandp0Xp1.hoa\", \"p0\" -> (s=4 | s=5), \"p1\" -> s=7 & (d=3 | d=5) }]";
1030 auto modelFormulas = this->buildModelFormulas(STORM_TEST_RESOURCES_DIR
"/dtmc/die.pm", formulasString);
1031 auto model = std::move(modelFormulas.first);
1032 auto tasks = this->getTasks(modelFormulas.second);
1033 this->execute(model, [&]() {
1034 EXPECT_EQ(13ul, model->getNumberOfStates());
1035 EXPECT_EQ(20ul, model->getNumberOfTransitions());
1037 auto checker = this->createModelChecker(model);
1038 std::unique_ptr<storm::modelchecker::CheckResult> result;
1041 if (TypeParam::engine == DtmcEngine::PrismSparse || TypeParam::engine == DtmcEngine::JaniSparse) {
1042 result = checker->check(tasks[0]);
1043 this->expectQuantitativeResultAtInitialState(model, result, this->parseNumber(
"1/6"));
1045 result = checker->check(tasks[1]);
1046 this->expectQuantitativeResultAtInitialState(model, result, this->parseNumber(
"1/3"));
1048 result = checker->check(tasks[2]);
1049 this->expectQuantitativeResultAtInitialState(model, result, this->parseNumber(
"1/6"));
1051 result = checker->check(tasks[3]);
1052 this->expectQuantitativeResultAtInitialState(model, result, this->parseNumber(
"1/6"));
1054 result = checker->check(tasks[4]);
1055 this->expectQuantitativeResultAtInitialState(model, result, this->parseNumber(
"1/8"));
1057 result = checker->check(tasks[5]);
1058 this->expectQuantitativeResultAtInitialState(model, result, this->parseNumber(
"1/3"));
1060 result = checker->check(tasks[6]);
1061 EXPECT_TRUE(this->getQualitativeResultAtInitialState(model, result));
1063 EXPECT_FALSE(checker->canHandle(tasks[0]));
1068TYPED_TEST(DtmcPrctlModelCheckerTest, SmallDiscount) {
1069 if (TypeParam::isExact) {
1070 GTEST_SKIP() <<
"Exact computations for discounted properties are not supported.";
1072 std::string formulasString =
"R=? [ C ]";
1073 formulasString +=
"; R=? [ Cdiscount=9/10 ]";
1074 formulasString +=
"; R=? [ Cdiscount=15/16 ]";
1075 formulasString +=
"; R=? [ C<5discount=9/10 ]";
1076 formulasString +=
"; R=? [ C<5discount=15/16 ]";
1077 auto modelFormulas = this->buildModelFormulas(STORM_TEST_RESOURCES_DIR
"/dtmc/small_discount.nm", formulasString);
1078 auto model = std::move(modelFormulas.first);
1079 auto tasks = this->getTasks(modelFormulas.second);
1080 EXPECT_EQ(3ul, model->getNumberOfStates());
1081 EXPECT_EQ(4ul, model->getNumberOfTransitions());
1083 auto checker = this->createModelChecker(model);
1085 if (TypeParam::engine == DtmcEngine::PrismSparse || TypeParam::engine == DtmcEngine::JaniSparse) {
1086 std::unique_ptr<storm::modelchecker::CheckResult> result = checker->check(this->env(), tasks[0]);
1087 this->expectQuantitativeResultAtInitialState(model, result, this->parseNumber(
"5"));
1089 result = checker->check(this->env(), tasks[1]);
1090 this->expectQuantitativeResultAtInitialState(model, result, this->parseNumber(
"45/14"));
1091 result = checker->check(this->env(), tasks[2]);
1092 this->expectQuantitativeResultAtInitialState(model, result, this->parseNumber(
"15/4"));
1093 result = checker->check(this->env(), tasks[3]);
1094 this->expectQuantitativeResultAtInitialState(model, result, this->parseNumber(
"12591/6250"));
1095 result = checker->check(this->env(), tasks[4]);
1096 this->expectQuantitativeResultAtInitialState(model, result, this->parseNumber(
"555/256"));
1098 EXPECT_FALSE(checker->canHandle(tasks[0]));
1099 EXPECT_FALSE(checker->canHandle(tasks[1]));
1100 EXPECT_FALSE(checker->canHandle(tasks[2]));
1101 EXPECT_FALSE(checker->canHandle(tasks[3]));
1102 EXPECT_FALSE(checker->canHandle(tasks[4]));
1106TYPED_TEST(DtmcPrctlModelCheckerTest, DieJaniProperties) {
1108 auto modelFormulas = this->buildJaniModelFormulas(STORM_TEST_RESOURCES_DIR
"/dtmc/die_janiproperties.jani");
1109 auto model = std::move(modelFormulas.first);
1110 auto tasks = this->getTasks(modelFormulas.second);
1111 this->execute(model, [&]() {
1112 EXPECT_EQ(13ul, model->getNumberOfStates());
1113 EXPECT_EQ(20ul, model->getNumberOfTransitions());
1115 auto checker = this->createModelChecker(model);
1116 std::unique_ptr<storm::modelchecker::CheckResult> result;
1119 result = checker->check(this->env(), tasks[0]);
1123 result = checker->check(this->env(), tasks[1]);
1127 result = checker->check(this->env(), tasks[9]);
1131 result = checker->check(this->env(), tasks[10]);
1133 EXPECT_NEAR(this->parseNumber(
"1/4"), weakUntilDual, this->precision());
1136 result = checker->check(this->env(), tasks[11]);
1138 EXPECT_NEAR(this->parseNumber(
"1/6"), releaseDual, this->precision());
1141#ifdef STORM_HAVE_LTL_MODELCHECKING_SUPPORT
1143 if (checker->canHandle(tasks[2])) {
1144 result = checker->check(this->env(), tasks[2]);
1149 if (checker->canHandle(tasks[3])) {
1150 result = checker->check(this->env(), tasks[3]);
1155 if (checker->canHandle(tasks[4])) {
1156 result = checker->check(this->env(), tasks[4]);
1161 if (checker->canHandle(tasks[5])) {
1162 result = checker->check(this->env(), tasks[5]);
1169 if (checker->canHandle(tasks[7])) {
1170 result = checker->check(this->env(), tasks[7]);
1172 EXPECT_NEAR(this->parseNumber(
"3/4"), weakUntil, this->precision());
1173 EXPECT_NEAR(this->parseNumber(
"1"), weakUntil + weakUntilDual, this->precision());
1177 if (checker->canHandle(tasks[8])) {
1178 result = checker->check(this->env(), tasks[8]);
1180 EXPECT_NEAR(this->parseNumber(
"5/6"), release, this->precision());
1181 EXPECT_NEAR(this->parseNumber(
"1"), release + releaseDual, this->precision());
1187TYPED_TEST(DtmcPrctlModelCheckerTest, SimpleCommProtocol) {
1189 std::string formulasString =
"P=? [ F (s = 3) ]; ";
1190 formulasString +=
"P=? [ (s<=1) U (s=3) ]; ";
1191 formulasString +=
"P=? [ !(s=3) U (!(s<=1) & !(s=3)) ]; ";
1193 auto modelFormulas = this->buildModelFormulas(STORM_TEST_RESOURCES_DIR
"/dtmc/simple_comm_protocol.prism", formulasString);
1194 auto model = std::move(modelFormulas.first);
1195 auto tasks = this->getTasks(modelFormulas.second);
1197 ASSERT_EQ(3ul, tasks.size());
1198 this->execute(model, [&]() {
1199 EXPECT_EQ(4ul, model->getNumberOfStates());
1200 EXPECT_EQ(5ul, model->getNumberOfTransitions());
1202 auto checker = this->createModelChecker(model);
1203 std::unique_ptr<storm::modelchecker::CheckResult> result;
1205 result = checker->check(this->env(), tasks[0]);
1208 result = checker->check(this->env(), tasks[1]);
1211 result = checker->check(this->env(), tasks[2]);
1216TYPED_TEST(DtmcPrctlModelCheckerTest, SimpleCommProtocolLTL) {
1217#ifdef STORM_HAVE_LTL_MODELCHECKING_SUPPORT
1219 std::string formulasString =
"P=? [ (s<=1) W (s=3) ]; ";
1220 formulasString +=
"P=? [ !(s=3) U (!(s<=1) & !(s=3)) ]; ";
1221 formulasString +=
"P=? [ !(s=2) W ((s=3 & !(s=2))) ]; ";
1222 formulasString +=
"P=? [(!(s=2) W ((s=2) W (!(s=2) W ((s=2) W G !(s=2)))))]; ";
1223 formulasString +=
"P=? [ (s=2) R !(s=3) ]; ";
1225 auto modelFormulas = this->buildModelFormulas(STORM_TEST_RESOURCES_DIR
"/dtmc/simple_comm_protocol.prism", formulasString);
1226 auto model = std::move(modelFormulas.first);
1227 auto tasks = this->getTasks(modelFormulas.second);
1229 ASSERT_EQ(5ul, tasks.size());
1230 this->execute(model, [&]() {
1231 EXPECT_EQ(4ul, model->getNumberOfStates());
1232 EXPECT_EQ(5ul, model->getNumberOfTransitions());
1234 auto checker = this->createModelChecker(model);
1235 std::unique_ptr<storm::modelchecker::CheckResult> result;
1238 if (TypeParam::engine == DtmcEngine::PrismSparse || TypeParam::engine == DtmcEngine::JaniSparse) {
1239 result = checker->check(this->env(), tasks[0]);
1241 EXPECT_NEAR(this->parseNumber(
"99/100"), weakUntil, this->precision());
1243 result = checker->check(this->env(), tasks[1]);
1245 EXPECT_NEAR(this->parseNumber(
"1/100"), weakUntilDual, this->precision());
1247 EXPECT_NEAR(this->parseNumber(
"1"), weakUntil + weakUntilDual, this->precision());
1249 result = checker->check(this->env(), tasks[2]);
1252 result = checker->check(this->env(), tasks[3]);
1255 result = checker->check(this->env(), tasks[4]);
1258 EXPECT_FALSE(checker->canHandle(tasks[0]));
1260 EXPECT_FALSE(checker->canHandle(tasks[4]));
1265 GTEST_SKIP() <<
"Spot not available.";
TEST(RegionConstraintCheckerTest, AffineConstraintHoldsThroughout)
std::unique_ptr< storm::modelchecker::QualitativeCheckResult > getInitialStateFilter(std::shared_ptr< storm::models::sparse::Model< storm::Interval > > const &model)
double getQuantitativeResultAtInitialState(std::shared_ptr< storm::models::sparse::Model< storm::Interval > > const &model, std::unique_ptr< storm::modelchecker::CheckResult > &result)
void setPrecision(storm::RationalNumber value)
void setMethod(storm::solver::EigenLinearEquationSolverMethod value, bool isSetFromDefault=false)
void setPreconditioner(storm::solver::EigenLinearEquationSolverPreconditioner value)
SolverEnvironment & solver()
void setMethod(storm::solver::GmmxxLinearEquationSolverMethod value)
void setPrecision(storm::RationalNumber value)
void setPreconditioner(storm::solver::GmmxxLinearEquationSolverPreconditioner value)
void setMaximalNumberOfIterations(uint64_t value)
void setRelativeTerminationCriterion(bool value)
void setPrecision(storm::RationalNumber value)
void setMethod(storm::solver::NativeLinearEquationSolverMethod value, bool isSetFromDefault=false)
TopologicalSolverEnvironment & topological()
void setLinearEquationSolverType(storm::solver::EquationSolverType const &value, bool isSetFromDefault=false)
EigenSolverEnvironment & eigen()
void setForceSoundness(bool value)
NativeSolverEnvironment & native()
GmmxxSolverEnvironment & gmmxx()
void setUnderlyingEquationSolverType(storm::solver::EquationSolverType value, bool isSetFromDefault=false)
virtual std::unique_ptr< CheckResult > check(Environment const &env, CheckTask< storm::logic::Formula, SolutionType > const &checkTask)
Checks the provided formula.
static std::vector< SolutionType > computeAllUntilProbabilities(Environment const &env, storm::solver::SolveGoal< ValueType, SolutionType > &&goal, storm::storage::SparseMatrix< ValueType > const &transitionMatrix, storm::storage::BitVector const &initialStates, storm::storage::BitVector const &phiStates, storm::storage::BitVector const &psiStates)
This class represents a discrete-time Markov chain.
Program preprocess(std::map< storm::expressions::Variable, storm::expressions::Expression > const &constantDefinitions) const
Preprocesses the program by defining the given constant definitions, substituting constants and formu...
A bit vector that is internally represented as a vector of 64-bit values.
A class that holds a possibly non-square matrix in the compressed row storage format.
std::shared_ptr< storm::models::symbolic::Model< LibraryType, ValueType > > buildSymbolicModel(storm::Environment const &env, storm::languages::SymbolicModelDescription const &model, std::vector< std::shared_ptr< storm::logic::Formula const > > const &formulas, bool buildFullModel=false, bool applyMaximumProgress=true, bool fixDeadlocks=true)
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)
std::pair< storm::jani::Model, std::vector< storm::jani::Property > > convertPrismToJani(storm::prism::Program const &program, storm::converter::PrismToJaniConverterOptions options)
std::vector< storm::jani::Property > parseProperties(storm::parser::FormulaParser &formulaParser, std::string const &inputString, boost::optional< std::set< std::string > > const &propertyFilter)
std::pair< storm::jani::Model, std::vector< storm::jani::Property > > parseJaniModel(std::string const &filename, boost::optional< std::vector< std::string > > const &propertyFilter)
std::shared_ptr< storm::models::sparse::Model< ValueType > > buildSparseModel(storm::languages::SymbolicModelDescription const &model, storm::builder::BuilderOptions const &options, typename storm::builder::ExplicitModelBuilder< ValueType >::Options const &explorationOptions=typename storm::builder::ExplicitModelBuilder< ValueType >::Options())
SFTBDDChecker::ValueType ValueType
NumberType parseNumber(std::string const &value)
Parse number from string.
template STORM_PARSERS_API std::shared_ptr< storm::models::sparse::Model< double > > parseDirectEncodingModel< double >(std::filesystem::path const &file, DirectEncodingParserOptions const &options)
storm::storage::BitVector filter(std::vector< T > const &values, std::function< bool(T const &value)> const &function)
Retrieves a bit vector containing all the indices for which the value at this position makes the give...
std::conditional_t< storm::NumberTraits< ValueType >::HasInfinity, ValueType, ExtendedNumber< ValueType > > ExtendedValueType
The type to use for values that may be infinite.
TargetType convertNumber(SourceType const &number)
TYPED_TEST(GraphTestAR, SymbolicProb01StochasticGameDieSmall)
TYPED_TEST_SUITE(GraphTestAR, TestingTypes,)
::testing::Types< Cudd, Sylvan > TestingTypes
#define STORM_EXPENSIVE_TYPED_TEST(test_suite_name, test_name)
#define STORM_SILENT_EXPECT_THROW(statement, expected_exception)