diff --git a/src/storm/abstraction/MenuGameRefiner.h b/src/storm/abstraction/MenuGameRefiner.h index b6a9e7482..03b12b710 100644 --- a/src/storm/abstraction/MenuGameRefiner.h +++ b/src/storm/abstraction/MenuGameRefiner.h @@ -3,6 +3,9 @@ #include #include +#include "storm/abstraction/QualitativeResultMinMax.h" +#include "storm/abstraction/QuantitativeResultMinMax.h" + #include "storm/storage/expressions/Expression.h" #include "storm/storage/dd/DdType.h" @@ -13,6 +16,9 @@ namespace storm { template class MenuGameAbstractor; + template + class MenuGame; + template class MenuGameRefiner { public: @@ -26,7 +32,19 @@ namespace storm { */ void refine(std::vector const& predicates) const; + /*! + * Refines the abstractor based on the qualitative result by trying to derive suitable predicates. + * + * @param True if predicates for refinement could be derived, false otherwise. + */ + bool refine(storm::abstraction::MenuGame const& game, storm::dd::Bdd const& transitionMatrixBdd, QualitativeResultMinMax const& qualitativeResult); + /*! + * Refines the abstractor based on the quantitative result by trying to derive suitable predicates. + * + * @param True if predicates for refinement could be derived, false otherwise. + */ + bool refine(storm::abstraction::MenuGame const& game, storm::dd::Bdd const& transitionMatrixBdd, QuantitativeResultMinMax const& quantitativeResult); private: /// The underlying abstractor to refine. diff --git a/src/storm/abstraction/QualitativeResult.h b/src/storm/abstraction/QualitativeResult.h new file mode 100644 index 000000000..66386e72a --- /dev/null +++ b/src/storm/abstraction/QualitativeResult.h @@ -0,0 +1,12 @@ +#pragma once + +#include "storm/utility/graph.h" + +namespace storm { + namespace abstraction { + + template + using QualitativeResult = storm::utility::graph::GameProb01Result; + + } +} diff --git a/src/storm/abstraction/QualitativeResultMinMax.h b/src/storm/abstraction/QualitativeResultMinMax.h new file mode 100644 index 000000000..b013c8acb --- /dev/null +++ b/src/storm/abstraction/QualitativeResultMinMax.h @@ -0,0 +1,22 @@ +#pragma once + +#include "storm/storage/dd/DdType.h" + +#include "storm/utility/graph.h" + +namespace storm { + namespace abstraction { + + template + struct QualitativeResultMinMax { + public: + QualitativeResultMinMax() = default; + + storm::utility::graph::GameProb01Result prob0Min; + storm::utility::graph::GameProb01Result prob1Min; + storm::utility::graph::GameProb01Result prob0Max; + storm::utility::graph::GameProb01Result prob1Max; + }; + + } +} diff --git a/src/storm/abstraction/QuantitativeResult.h b/src/storm/abstraction/QuantitativeResult.h new file mode 100644 index 000000000..d0c949952 --- /dev/null +++ b/src/storm/abstraction/QuantitativeResult.h @@ -0,0 +1,25 @@ +#pragma once + +#include "storm/storage/dd/DdType.h" +#include "storm/storage/dd/Add.h" +#include "storm/storage/dd/Bdd.h" + +namespace storm { + namespace abstraction { + + template + struct QuantitativeResult { + QuantitativeResult() = default; + + QuantitativeResult(ValueType initialStateValue, storm::dd::Add const& values, storm::dd::Bdd const& player1Strategy, storm::dd::Bdd const& player2Strategy) : initialStateValue(initialStateValue), values(values), player1Strategy(player1Strategy), player2Strategy(player2Strategy) { + // Intentionally left empty. + } + + ValueType initialStateValue; + storm::dd::Add values; + storm::dd::Bdd player1Strategy; + storm::dd::Bdd player2Strategy; + }; + + } +} diff --git a/src/storm/abstraction/QuantitativeResultMinMax.h b/src/storm/abstraction/QuantitativeResultMinMax.h new file mode 100644 index 000000000..f0bdab86d --- /dev/null +++ b/src/storm/abstraction/QuantitativeResultMinMax.h @@ -0,0 +1,21 @@ +#pragma once + +#include "storm/abstraction/QuantitativeResult.h" + +namespace storm { + namespace abstraction { + + template + struct QuantitativeResultMinMax { + QuantitativeResultMinMax() = default; + + QuantitativeResultMinMax(QuantitativeResult const& min, QuantitativeResult const& max) : min(min), max(max) { + // Intentionally left empty. + } + + QuantitativeResult min; + QuantitativeResult max; + }; + + } +} diff --git a/src/storm/modelchecker/abstraction/GameBasedMdpModelChecker.cpp b/src/storm/modelchecker/abstraction/GameBasedMdpModelChecker.cpp index fc0313ab5..b03f72340 100644 --- a/src/storm/modelchecker/abstraction/GameBasedMdpModelChecker.cpp +++ b/src/storm/modelchecker/abstraction/GameBasedMdpModelChecker.cpp @@ -34,6 +34,8 @@ namespace storm { namespace modelchecker { + using storm::abstraction::QuantitativeResult; + template GameBasedMdpModelChecker::GameBasedMdpModelChecker(storm::storage::SymbolicModelDescription const& model, std::shared_ptr const& smtSolverFactory) : smtSolverFactory(smtSolverFactory) { STORM_LOG_THROW(model.isPrismProgram(), storm::exceptions::NotSupportedException, "Currently only PRISM models are supported by the game-based model checker."); @@ -104,7 +106,7 @@ namespace storm { } template - std::unique_ptr checkForResultAfterQualitativeCheck(CheckTask const& checkTask, storm::dd::Bdd const& initialStates, detail::GameProb01ResultMinMax const& qualitativeResult) { + std::unique_ptr checkForResultAfterQualitativeCheck(CheckTask const& checkTask, storm::dd::Bdd const& initialStates, QualitativeResultMinMax const& qualitativeResult) { // Check whether we can already give the answer based on the current information. std::unique_ptr result = checkForResultAfterQualitativeCheck(checkTask, initialStates, qualitativeResult.prob0Min.getPlayer1States(), qualitativeResult.prob0Max.getPlayer1States(), true); if (result) { @@ -205,7 +207,7 @@ namespace storm { } template - bool refineAfterQualitativeCheck(storm::abstraction::prism::PrismMenuGameAbstractor& abstractor, storm::abstraction::MenuGame const& game, detail::GameProb01ResultMinMax const& qualitativeResult, storm::dd::Bdd const& transitionMatrixBdd) { + bool refineAfterQualitativeCheck(storm::abstraction::prism::PrismMenuGameAbstractor& abstractor, storm::abstraction::MenuGame const& game, QualitativeResultMinMax const& qualitativeResult, storm::dd::Bdd const& transitionMatrixBdd) { STORM_LOG_TRACE("Trying refinement after qualitative check."); // Get all relevant strategies. storm::dd::Bdd minPlayer1Strategy = qualitativeResult.prob0Min.getPlayer1Strategy(); @@ -287,19 +289,6 @@ namespace storm { return false; } - template - struct QuantitativeResult { - QuantitativeResult() = default; - - QuantitativeResult(ValueType initialStateValue, storm::dd::Add const& values, storm::dd::Bdd const& player1Strategy, storm::dd::Bdd const& player2Strategy) : initialStateValue(initialStateValue), values(values), player1Strategy(player1Strategy), player2Strategy(player2Strategy) { - // Intentionally left empty. - } - - ValueType initialStateValue; - storm::dd::Add values; - storm::dd::Bdd player1Strategy; - storm::dd::Bdd player2Strategy; - }; template void refineAfterQuantitativeCheck(storm::abstraction::prism::PrismMenuGameAbstractor& abstractor, storm::abstraction::MenuGame const& game, storm::dd::Bdd const& transitionMatrixBdd, QuantitativeResult const& minResult, QuantitativeResult const& maxResult) { @@ -404,7 +393,7 @@ namespace storm { } template - QuantitativeResult computeQuantitativeResult(storm::OptimizationDirection player1Direction, storm::OptimizationDirection player2Direction, storm::abstraction::MenuGame const& game, detail::GameProb01ResultMinMax const& qualitativeResult, storm::dd::Add const& initialStatesAdd, storm::dd::Bdd const& maybeStates, boost::optional> const& startInfo = boost::none) { + QuantitativeResult computeQuantitativeResult(storm::OptimizationDirection player1Direction, storm::OptimizationDirection player2Direction, storm::abstraction::MenuGame const& game, QualitativeResultMinMax const& qualitativeResult, storm::dd::Add const& initialStatesAdd, storm::dd::Bdd const& maybeStates, boost::optional> const& startInfo = boost::none) { bool min = player2Direction == storm::OptimizationDirection::Minimize; @@ -499,7 +488,7 @@ namespace storm { // (3) compute all states with probability 0/1 wrt. to the two different player 2 goals (min/max). auto qualitativeStart = std::chrono::high_resolution_clock::now(); - detail::GameProb01ResultMinMax qualitativeResult; + QualitativeResultMinMax qualitativeResult; std::unique_ptr result = computeProb01States(checkTask, qualitativeResult, game, player1Direction, transitionMatrixBdd, initialStates, constraintStates, targetStates); if (result) { return result; @@ -604,7 +593,7 @@ namespace storm { } template - std::unique_ptr GameBasedMdpModelChecker::computeProb01States(CheckTask const& checkTask, detail::GameProb01ResultMinMax& qualitativeResult, storm::abstraction::MenuGame const& game, storm::OptimizationDirection player1Direction, storm::dd::Bdd const& transitionMatrixBdd, storm::dd::Bdd const& initialStates, storm::dd::Bdd const& constraintStates, storm::dd::Bdd const& targetStates) { + std::unique_ptr GameBasedMdpModelChecker::computeProb01States(CheckTask const& checkTask, QualitativeResultMinMax& qualitativeResult, storm::abstraction::MenuGame const& game, storm::OptimizationDirection player1Direction, storm::dd::Bdd const& transitionMatrixBdd, storm::dd::Bdd const& initialStates, storm::dd::Bdd const& constraintStates, storm::dd::Bdd const& targetStates) { qualitativeResult.prob0Min = computeProb01States(true, player1Direction, storm::OptimizationDirection::Minimize, game, transitionMatrixBdd, constraintStates, targetStates); qualitativeResult.prob1Min = computeProb01States(false, player1Direction, storm::OptimizationDirection::Minimize, game, transitionMatrixBdd, constraintStates, targetStates); std::unique_ptr result = checkForResultAfterQualitativeCheck(checkTask, storm::OptimizationDirection::Minimize, initialStates, qualitativeResult.prob0Min.getPlayer1States(), qualitativeResult.prob1Min.getPlayer1States()); diff --git a/src/storm/modelchecker/abstraction/GameBasedMdpModelChecker.h b/src/storm/modelchecker/abstraction/GameBasedMdpModelChecker.h index 68e949b50..be840c45e 100644 --- a/src/storm/modelchecker/abstraction/GameBasedMdpModelChecker.h +++ b/src/storm/modelchecker/abstraction/GameBasedMdpModelChecker.h @@ -9,6 +9,9 @@ #include "storm/storage/SymbolicModelDescription.h" +#include "storm/abstraction/QualitativeResult.h" +#include "storm/abstraction/QualitativeResultMinMax.h" + #include "storm/logic/Bound.h" #include "storm/utility/solver.h" @@ -21,19 +24,10 @@ namespace storm { } namespace modelchecker { - namespace detail { - template - struct GameProb01ResultMinMax { - public: - GameProb01ResultMinMax() = default; - - storm::utility::graph::GameProb01Result prob0Min; - storm::utility::graph::GameProb01Result prob1Min; - storm::utility::graph::GameProb01Result prob0Max; - storm::utility::graph::GameProb01Result prob1Max; - }; - } - + + using storm::abstraction::QualitativeResult; + using storm::abstraction::QualitativeResultMinMax; + template class GameBasedMdpModelChecker : public AbstractModelChecker { public: @@ -73,8 +67,8 @@ namespace storm { * Performs a qualitative check on the the given game to compute the (player 1) states that have probability * 0 or 1, respectively, to reach a target state and only visiting constraint states before. */ - std::unique_ptr computeProb01States(CheckTask const& checkTask, detail::GameProb01ResultMinMax& qualitativeResult, storm::abstraction::MenuGame const& game, storm::OptimizationDirection player1Direction, storm::dd::Bdd const& transitionMatrixBdd, storm::dd::Bdd const& initialStates, storm::dd::Bdd const& constraintStates, storm::dd::Bdd const& targetStates); - storm::utility::graph::GameProb01Result computeProb01States(bool prob0, storm::OptimizationDirection player1Direction, storm::OptimizationDirection player2Direction, storm::abstraction::MenuGame const& game, storm::dd::Bdd const& transitionMatrixBdd, storm::dd::Bdd const& constraintStates, storm::dd::Bdd const& targetStates); + std::unique_ptr computeProb01States(CheckTask const& checkTask, QualitativeResultMinMax& qualitativeResult, storm::abstraction::MenuGame const& game, storm::OptimizationDirection player1Direction, storm::dd::Bdd const& transitionMatrixBdd, storm::dd::Bdd const& initialStates, storm::dd::Bdd const& constraintStates, storm::dd::Bdd const& targetStates); + QualitativeResult computeProb01States(bool prob0, storm::OptimizationDirection player1Direction, storm::OptimizationDirection player2Direction, storm::abstraction::MenuGame const& game, storm::dd::Bdd const& transitionMatrixBdd, storm::dd::Bdd const& constraintStates, storm::dd::Bdd const& targetStates); /* * Retrieves the expression characterized by the formula. The formula needs to be propositional.