17template<
typename ValueType>
22template<
typename ValueType>
24 return analyseProb0or1(formula,
true);
27template<
typename ValueType>
29 return analyseProb0or1(formula,
false);
32template<
typename ValueType>
35 "The formula " << formula <<
" does not specify whether to minimize or maximize.");
38 STORM_LOG_THROW(!minimizes, storm::exceptions::NotImplementedException,
"This operation is only supported when maximizing");
40 std::shared_ptr<storm::logic::UntilFormula> untilSubformula;
42 if (subformula->isEventuallyFormula()) {
44 subformula->asEventuallyFormula().getSubformula().asSharedPointer());
45 }
else if (subformula->isUntilFormula()) {
46 untilSubformula = std::make_shared<storm::logic::UntilFormula>(subformula->asUntilFormula());
50 checkPropositionalFormula(untilSubformula->getLeftSubformula()),
51 checkPropositionalFormula(untilSubformula->getRightSubformula()));
54template<
typename ValueType>
57 STORM_LOG_THROW(pomdp.isCanonic(), storm::exceptions::IllegalArgumentException,
"POMDP needs to be canonic");
59 "The formula " << formula <<
" does not specify whether to minimize or maximize.");
65 if (subformula->isEventuallyFormula()) {
67 subformula->asEventuallyFormula().getSubformula().asSharedPointer());
70 if (subformula->isUntilFormula()) {
71 if (minimizes && prob0) {
72 return analyseProb0Min(subformula->asUntilFormula());
73 }
else if (minimizes && !prob0) {
74 return analyseProb1Min(subformula->asUntilFormula());
75 }
else if (!minimizes && prob0) {
76 return analyseProb0Max(subformula->asUntilFormula());
77 }
else if (!minimizes && !prob0) {
78 return analyseProb1Max(subformula->asUntilFormula());
81 STORM_LOG_THROW(
false, storm::exceptions::InvalidPropertyException,
"Prob0or1 analysis is not supported for the property " << formula);
84template<
typename ValueType>
90template<
typename ValueType>
92 STORM_LOG_THROW(
false, storm::exceptions::NotImplementedException,
"Prob0 analysis is currently not implemented for minimizing properties.");
95template<
typename ValueType>
99 pomdp.getTransitionMatrix(), pomdp.getTransitionMatrix().getRowGroupIndices(), pomdp.getBackwardTransitions(), okay, good);
103 pomdp.getTransitionMatrix(), pomdp.getTransitionMatrix().getRowGroupIndices(), pomdp.getBackwardTransitions(), okay, newGoalStates);
104 STORM_LOG_TRACE(
"Prob1E states according to MDP: " << potentialGoalStates);
108 for (uint64_t observation = 0; observation < pomdp.getNrObservations(); ++observation) {
109 for (uint64_t state : avoidStates) {
110 potentialGoalObservations.
set(pomdp.getObservation(state),
false);
114 STORM_LOG_TRACE(
"Prob1E observations according to MDP: " << potentialGoalObservations);
116 std::vector<std::vector<uint64_t>> statesPerObservation(pomdp.getNrObservations(), std::vector<uint64_t>());
117 for (uint64_t state : potentialGoalStates) {
118 statesPerObservation[pomdp.getObservation(state)].push_back(state);
121 for (uint64_t state = 0; state < pomdp.getNumberOfStates(); ++state) {
122 if (statesPerObservation[pomdp.getObservation(state)].size() == 1) {
123 singleObservationStates.
set(state);
128 while (goalStates != newGoalStates) {
130 pomdp.getBackwardTransitions(), okay, newGoalStates);
132 pomdp.getBackwardTransitions(), okay & singleObservationStates, goalStates);
133 newGoalStates = goalStates;
135 for (uint64_t observation : potentialGoalObservations) {
137 uint64_t actsForObservation = pomdp.getTransitionMatrix().getRowGroupSize(statesPerObservation[observation][0]);
139 for (uint64_t act = 0; act < actsForObservation; act++) {
141 bool isGoalAction =
true;
142 for (uint64_t state : statesPerObservation[observation]) {
144 if (newGoalStates.
get(state)) {
153 uint64_t row = pomdp.getNondeterministicChoiceIndices()[state] + act;
155 bool hasGoalEntry =
false;
156 for (
auto const& entry : pomdp.getTransitionMatrix().getRow(row)) {
158 if (newGoalStates.
get(entry.getColumn())) {
159 STORM_LOG_TRACE(
"Reaches state " << entry.getColumn() <<
" which is a PROB1e state");
161 }
else if (pomdp.getObservation(entry.getColumn()) != observation) {
162 STORM_LOG_TRACE(
"Reaches state " << entry.getColumn() <<
" which may not be a PROB1e state");
163 isGoalAction =
false;
167 if (!isGoalAction || !hasGoalEntry) {
169 isGoalAction =
false;
174 for (uint64_t state : statesPerObservation[observation]) {
175 newGoalStates.
set(state);
187template<
typename ValueType>
193template<
typename ValueType>
200template<
typename ValueType>
203 STORM_LOG_THROW(mc.canHandle(propositionalFormula), storm::exceptions::InvalidPropertyException,
204 "Propositional model checker can not handle formula " << propositionalFormula);
205 return mc.check(propositionalFormula)->asExplicitQualitativeCheckResult().getTruthValuesVector();
208template class QualitativeAnalysisOnGraphs<storm::RationalNumber>;
210template class QualitativeAnalysisOnGraphs<double>;
storm::storage::BitVector analyseProb0(storm::logic::ProbabilityOperatorFormula const &formula) const
storm::storage::BitVector analyseProbSmaller1(storm::logic::ProbabilityOperatorFormula const &formula) const
storm::storage::BitVector analyseProb1Max(storm::storage::BitVector const &okay, storm::storage::BitVector const &target) const
QualitativeAnalysisOnGraphs(storm::models::sparse::Pomdp< ValueType > const &pomdp)
storm::storage::BitVector analyseProb1(storm::logic::ProbabilityOperatorFormula const &formula) const
This class represents a partially observable Markov decision process.
A bit vector that is internally represented as a vector of 64-bit values.
void set(uint_fast64_t index, bool value=true)
Sets the given truth value at the given index.
bool get(uint_fast64_t index) const
Retrieves the truth value of the bit at the given index and performs a bound check.
#define STORM_LOG_TRACE(message)
#define STORM_LOG_THROW(cond, exception, message)
bool isLowerBound(ComparisonType t)
bool constexpr minimize(OptimizationDirection d)
storm::storage::BitVector performProb1A(storm::models::sparse::NondeterministicModel< T, RM > const &model, storm::storage::SparseMatrix< T > const &backwardTransitions, storm::storage::BitVector const &phiStates, storm::storage::BitVector const &psiStates)
Computes the sets of states that have probability 1 of satisfying phi until psi under all possible re...
storm::storage::BitVector performProb0A(storm::storage::SparseMatrix< T > const &backwardTransitions, storm::storage::BitVector const &phiStates, storm::storage::BitVector const &psiStates)
storm::storage::BitVector performProb1E(storm::storage::SparseMatrix< T > const &transitionMatrix, std::vector< uint_fast64_t > const &nondeterministicChoiceIndices, storm::storage::SparseMatrix< T > const &backwardTransitions, storm::storage::BitVector const &phiStates, storm::storage::BitVector const &psiStates, boost::optional< storm::storage::BitVector > const &choiceConstraint)
Computes the sets of states that have probability 1 of satisfying phi until psi under at least one po...
bool isZero(ValueType const &a)
ComparisonType comparisonType