Browse Source

factored out helper classes into their own files in preparation of refiner interface

tempestpy_adaptions
dehnert 8 years ago
parent
commit
fcfed19c5d
  1. 18
      src/storm/abstraction/MenuGameRefiner.h
  2. 12
      src/storm/abstraction/QualitativeResult.h
  3. 22
      src/storm/abstraction/QualitativeResultMinMax.h
  4. 25
      src/storm/abstraction/QuantitativeResult.h
  5. 21
      src/storm/abstraction/QuantitativeResultMinMax.h
  6. 25
      src/storm/modelchecker/abstraction/GameBasedMdpModelChecker.cpp
  7. 22
      src/storm/modelchecker/abstraction/GameBasedMdpModelChecker.h

18
src/storm/abstraction/MenuGameRefiner.h

@ -3,6 +3,9 @@
#include <functional>
#include <vector>
#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 <storm::dd::DdType DdType, typename ValueType>
class MenuGameAbstractor;
template <storm::dd::DdType DdType, typename ValueType>
class MenuGame;
template<storm::dd::DdType Type, typename ValueType>
class MenuGameRefiner {
public:
@ -26,7 +32,19 @@ namespace storm {
*/
void refine(std::vector<storm::expressions::Expression> 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<Type, ValueType> const& game, storm::dd::Bdd<Type> const& transitionMatrixBdd, QualitativeResultMinMax<Type> 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<Type, ValueType> const& game, storm::dd::Bdd<Type> const& transitionMatrixBdd, QuantitativeResultMinMax<Type, ValueType> const& quantitativeResult);
private:
/// The underlying abstractor to refine.

12
src/storm/abstraction/QualitativeResult.h

@ -0,0 +1,12 @@
#pragma once
#include "storm/utility/graph.h"
namespace storm {
namespace abstraction {
template <storm::dd::DdType Type>
using QualitativeResult = storm::utility::graph::GameProb01Result<Type>;
}
}

22
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<storm::dd::DdType Type>
struct QualitativeResultMinMax {
public:
QualitativeResultMinMax() = default;
storm::utility::graph::GameProb01Result<Type> prob0Min;
storm::utility::graph::GameProb01Result<Type> prob1Min;
storm::utility::graph::GameProb01Result<Type> prob0Max;
storm::utility::graph::GameProb01Result<Type> prob1Max;
};
}
}

25
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<storm::dd::DdType Type, typename ValueType>
struct QuantitativeResult {
QuantitativeResult() = default;
QuantitativeResult(ValueType initialStateValue, storm::dd::Add<Type, ValueType> const& values, storm::dd::Bdd<Type> const& player1Strategy, storm::dd::Bdd<Type> const& player2Strategy) : initialStateValue(initialStateValue), values(values), player1Strategy(player1Strategy), player2Strategy(player2Strategy) {
// Intentionally left empty.
}
ValueType initialStateValue;
storm::dd::Add<Type, ValueType> values;
storm::dd::Bdd<Type> player1Strategy;
storm::dd::Bdd<Type> player2Strategy;
};
}
}

21
src/storm/abstraction/QuantitativeResultMinMax.h

@ -0,0 +1,21 @@
#pragma once
#include "storm/abstraction/QuantitativeResult.h"
namespace storm {
namespace abstraction {
template<storm::dd::DdType Type, typename ValueType>
struct QuantitativeResultMinMax {
QuantitativeResultMinMax() = default;
QuantitativeResultMinMax(QuantitativeResult<Type, ValueType> const& min, QuantitativeResult<Type, ValueType> const& max) : min(min), max(max) {
// Intentionally left empty.
}
QuantitativeResult<Type, ValueType> min;
QuantitativeResult<Type, ValueType> max;
};
}
}

25
src/storm/modelchecker/abstraction/GameBasedMdpModelChecker.cpp

@ -34,6 +34,8 @@
namespace storm {
namespace modelchecker {
using storm::abstraction::QuantitativeResult;
template<storm::dd::DdType Type, typename ModelType>
GameBasedMdpModelChecker<Type, ModelType>::GameBasedMdpModelChecker(storm::storage::SymbolicModelDescription const& model, std::shared_ptr<storm::utility::solver::SmtSolverFactory> 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<storm::dd::DdType Type, typename ValueType>
std::unique_ptr<CheckResult> checkForResultAfterQualitativeCheck(CheckTask<storm::logic::Formula> const& checkTask, storm::dd::Bdd<Type> const& initialStates, detail::GameProb01ResultMinMax<Type> const& qualitativeResult) {
std::unique_ptr<CheckResult> checkForResultAfterQualitativeCheck(CheckTask<storm::logic::Formula> const& checkTask, storm::dd::Bdd<Type> const& initialStates, QualitativeResultMinMax<Type> const& qualitativeResult) {
// Check whether we can already give the answer based on the current information.
std::unique_ptr<CheckResult> result = checkForResultAfterQualitativeCheck<Type, ValueType>(checkTask, initialStates, qualitativeResult.prob0Min.getPlayer1States(), qualitativeResult.prob0Max.getPlayer1States(), true);
if (result) {
@ -205,7 +207,7 @@ namespace storm {
}
template<storm::dd::DdType Type, typename ValueType>
bool refineAfterQualitativeCheck(storm::abstraction::prism::PrismMenuGameAbstractor<Type, ValueType>& abstractor, storm::abstraction::MenuGame<Type, ValueType> const& game, detail::GameProb01ResultMinMax<Type> const& qualitativeResult, storm::dd::Bdd<Type> const& transitionMatrixBdd) {
bool refineAfterQualitativeCheck(storm::abstraction::prism::PrismMenuGameAbstractor<Type, ValueType>& abstractor, storm::abstraction::MenuGame<Type, ValueType> const& game, QualitativeResultMinMax<Type> const& qualitativeResult, storm::dd::Bdd<Type> const& transitionMatrixBdd) {
STORM_LOG_TRACE("Trying refinement after qualitative check.");
// Get all relevant strategies.
storm::dd::Bdd<Type> minPlayer1Strategy = qualitativeResult.prob0Min.getPlayer1Strategy();
@ -287,19 +289,6 @@ namespace storm {
return false;
}
template<storm::dd::DdType Type, typename ValueType>
struct QuantitativeResult {
QuantitativeResult() = default;
QuantitativeResult(ValueType initialStateValue, storm::dd::Add<Type, ValueType> const& values, storm::dd::Bdd<Type> const& player1Strategy, storm::dd::Bdd<Type> const& player2Strategy) : initialStateValue(initialStateValue), values(values), player1Strategy(player1Strategy), player2Strategy(player2Strategy) {
// Intentionally left empty.
}
ValueType initialStateValue;
storm::dd::Add<Type, ValueType> values;
storm::dd::Bdd<Type> player1Strategy;
storm::dd::Bdd<Type> player2Strategy;
};
template<storm::dd::DdType Type, typename ValueType>
void refineAfterQuantitativeCheck(storm::abstraction::prism::PrismMenuGameAbstractor<Type, ValueType>& abstractor, storm::abstraction::MenuGame<Type, ValueType> const& game, storm::dd::Bdd<Type> const& transitionMatrixBdd, QuantitativeResult<Type, ValueType> const& minResult, QuantitativeResult<Type, ValueType> const& maxResult) {
@ -404,7 +393,7 @@ namespace storm {
}
template<storm::dd::DdType Type, typename ValueType>
QuantitativeResult<Type, ValueType> computeQuantitativeResult(storm::OptimizationDirection player1Direction, storm::OptimizationDirection player2Direction, storm::abstraction::MenuGame<Type, ValueType> const& game, detail::GameProb01ResultMinMax<Type> const& qualitativeResult, storm::dd::Add<Type, ValueType> const& initialStatesAdd, storm::dd::Bdd<Type> const& maybeStates, boost::optional<QuantitativeResult<Type, ValueType>> const& startInfo = boost::none) {
QuantitativeResult<Type, ValueType> computeQuantitativeResult(storm::OptimizationDirection player1Direction, storm::OptimizationDirection player2Direction, storm::abstraction::MenuGame<Type, ValueType> const& game, QualitativeResultMinMax<Type> const& qualitativeResult, storm::dd::Add<Type, ValueType> const& initialStatesAdd, storm::dd::Bdd<Type> const& maybeStates, boost::optional<QuantitativeResult<Type, ValueType>> 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<Type> qualitativeResult;
QualitativeResultMinMax<Type> qualitativeResult;
std::unique_ptr<CheckResult> result = computeProb01States(checkTask, qualitativeResult, game, player1Direction, transitionMatrixBdd, initialStates, constraintStates, targetStates);
if (result) {
return result;
@ -604,7 +593,7 @@ namespace storm {
}
template<storm::dd::DdType Type, typename ModelType>
std::unique_ptr<CheckResult> GameBasedMdpModelChecker<Type, ModelType>::computeProb01States(CheckTask<storm::logic::Formula> const& checkTask, detail::GameProb01ResultMinMax<Type>& qualitativeResult, storm::abstraction::MenuGame<Type, ValueType> const& game, storm::OptimizationDirection player1Direction, storm::dd::Bdd<Type> const& transitionMatrixBdd, storm::dd::Bdd<Type> const& initialStates, storm::dd::Bdd<Type> const& constraintStates, storm::dd::Bdd<Type> const& targetStates) {
std::unique_ptr<CheckResult> GameBasedMdpModelChecker<Type, ModelType>::computeProb01States(CheckTask<storm::logic::Formula> const& checkTask, QualitativeResultMinMax<Type>& qualitativeResult, storm::abstraction::MenuGame<Type, ValueType> const& game, storm::OptimizationDirection player1Direction, storm::dd::Bdd<Type> const& transitionMatrixBdd, storm::dd::Bdd<Type> const& initialStates, storm::dd::Bdd<Type> const& constraintStates, storm::dd::Bdd<Type> 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<CheckResult> result = checkForResultAfterQualitativeCheck<Type, ValueType>(checkTask, storm::OptimizationDirection::Minimize, initialStates, qualitativeResult.prob0Min.getPlayer1States(), qualitativeResult.prob1Min.getPlayer1States());

22
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,18 +24,9 @@ namespace storm {
}
namespace modelchecker {
namespace detail {
template<storm::dd::DdType Type>
struct GameProb01ResultMinMax {
public:
GameProb01ResultMinMax() = default;
storm::utility::graph::GameProb01Result<Type> prob0Min;
storm::utility::graph::GameProb01Result<Type> prob1Min;
storm::utility::graph::GameProb01Result<Type> prob0Max;
storm::utility::graph::GameProb01Result<Type> prob1Max;
};
}
using storm::abstraction::QualitativeResult;
using storm::abstraction::QualitativeResultMinMax;
template<storm::dd::DdType Type, typename ModelType>
class GameBasedMdpModelChecker : public AbstractModelChecker<ModelType> {
@ -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<CheckResult> computeProb01States(CheckTask<storm::logic::Formula> const& checkTask, detail::GameProb01ResultMinMax<Type>& qualitativeResult, storm::abstraction::MenuGame<Type, ValueType> const& game, storm::OptimizationDirection player1Direction, storm::dd::Bdd<Type> const& transitionMatrixBdd, storm::dd::Bdd<Type> const& initialStates, storm::dd::Bdd<Type> const& constraintStates, storm::dd::Bdd<Type> const& targetStates);
storm::utility::graph::GameProb01Result<Type> computeProb01States(bool prob0, storm::OptimizationDirection player1Direction, storm::OptimizationDirection player2Direction, storm::abstraction::MenuGame<Type, ValueType> const& game, storm::dd::Bdd<Type> const& transitionMatrixBdd, storm::dd::Bdd<Type> const& constraintStates, storm::dd::Bdd<Type> const& targetStates);
std::unique_ptr<CheckResult> computeProb01States(CheckTask<storm::logic::Formula> const& checkTask, QualitativeResultMinMax<Type>& qualitativeResult, storm::abstraction::MenuGame<Type, ValueType> const& game, storm::OptimizationDirection player1Direction, storm::dd::Bdd<Type> const& transitionMatrixBdd, storm::dd::Bdd<Type> const& initialStates, storm::dd::Bdd<Type> const& constraintStates, storm::dd::Bdd<Type> const& targetStates);
QualitativeResult<Type> computeProb01States(bool prob0, storm::OptimizationDirection player1Direction, storm::OptimizationDirection player2Direction, storm::abstraction::MenuGame<Type, ValueType> const& game, storm::dd::Bdd<Type> const& transitionMatrixBdd, storm::dd::Bdd<Type> const& constraintStates, storm::dd::Bdd<Type> const& targetStates);
/*
* Retrieves the expression characterized by the formula. The formula needs to be propositional.

Loading…
Cancel
Save