16template<
typename ValueType>
21template<
typename ValueType>
23 return analyseProb0or1(formula,
true);
26template<
typename ValueType>
28 return analyseProb0or1(formula,
false);
31template<
typename ValueType>
34 "The formula " << formula <<
" does not specify whether to minimize or maximize.");
37 STORM_LOG_THROW(!minimizes, storm::exceptions::NotImplementedException,
"This operation is only supported when maximizing");
39 std::shared_ptr<storm::logic::UntilFormula> untilSubformula;
41 if (subformula->isEventuallyFormula()) {
43 subformula->asEventuallyFormula().getSubformula().asSharedPointer());
44 }
else if (subformula->isUntilFormula()) {
45 untilSubformula = std::make_shared<storm::logic::UntilFormula>(subformula->asUntilFormula());
49 checkPropositionalFormula(untilSubformula->getLeftSubformula()),
50 checkPropositionalFormula(untilSubformula->getRightSubformula()));
53template<
typename ValueType>
56 STORM_LOG_THROW(pomdp.isCanonic(), storm::exceptions::IllegalArgumentException,
"POMDP needs to be canonic");
58 "The formula " << formula <<
" does not specify whether to minimize or maximize.");
64 if (subformula->isEventuallyFormula()) {
66 subformula->asEventuallyFormula().getSubformula().asSharedPointer());
69 if (subformula->isUntilFormula()) {
70 if (minimizes && prob0) {
71 return analyseProb0Min(subformula->asUntilFormula());
72 }
else if (minimizes && !prob0) {
73 return analyseProb1Min(subformula->asUntilFormula());
74 }
else if (!minimizes && prob0) {
75 return analyseProb0Max(subformula->asUntilFormula());
76 }
else if (!minimizes && !prob0) {
77 return analyseProb1Max(subformula->asUntilFormula());
80 STORM_LOG_THROW(
false, storm::exceptions::InvalidPropertyException,
"Prob0or1 analysis is not supported for the property " << formula);
83template<
typename ValueType>
89template<
typename ValueType>
91 STORM_LOG_THROW(
false, storm::exceptions::NotImplementedException,
"Prob0 analysis is currently not implemented for minimizing properties.");
94template<
typename ValueType>
98 pomdp.getTransitionMatrix(), pomdp.getTransitionMatrix().getRowGroupIndices(), pomdp.getBackwardTransitions(), okay, good);
102 pomdp.getTransitionMatrix(), pomdp.getTransitionMatrix().getRowGroupIndices(), pomdp.getBackwardTransitions(), okay, newGoalStates);
103 STORM_LOG_TRACE(
"Prob1E states according to MDP: " << potentialGoalStates);
107 for (uint64_t observation = 0; observation < pomdp.getNrObservations(); ++observation) {
108 for (uint64_t state : avoidStates) {
109 potentialGoalObservations.
set(pomdp.getObservation(state),
false);
113 STORM_LOG_TRACE(
"Prob1E observations according to MDP: " << potentialGoalObservations);
115 std::vector<std::vector<uint64_t>> statesPerObservation(pomdp.getNrObservations(), std::vector<uint64_t>());
116 for (uint64_t state : potentialGoalStates) {
117 statesPerObservation[pomdp.getObservation(state)].push_back(state);
120 for (uint64_t state = 0; state < pomdp.getNumberOfStates(); ++state) {
121 if (statesPerObservation[pomdp.getObservation(state)].size() == 1) {
122 singleObservationStates.
set(state);
127 while (goalStates != newGoalStates) {
129 pomdp.getBackwardTransitions(), okay, newGoalStates);
131 pomdp.getBackwardTransitions(), okay & singleObservationStates, goalStates);
132 newGoalStates = goalStates;
134 for (uint64_t observation : potentialGoalObservations) {
136 uint64_t actsForObservation = pomdp.getTransitionMatrix().getRowGroupSize(statesPerObservation[observation][0]);
138 for (uint64_t act = 0; act < actsForObservation; act++) {
140 bool isGoalAction =
true;
141 for (uint64_t state : statesPerObservation[observation]) {
143 if (newGoalStates.
get(state)) {
152 uint64_t row = pomdp.getNondeterministicChoiceIndices()[state] + act;
154 bool hasGoalEntry =
false;
155 for (
auto const& entry : pomdp.getTransitionMatrix().getRow(row)) {
157 if (newGoalStates.
get(entry.getColumn())) {
158 STORM_LOG_TRACE(
"Reaches state " << entry.getColumn() <<
" which is a PROB1e state");
160 }
else if (pomdp.getObservation(entry.getColumn()) != observation) {
161 STORM_LOG_TRACE(
"Reaches state " << entry.getColumn() <<
" which may not be a PROB1e state");
162 isGoalAction =
false;
166 if (!isGoalAction || !hasGoalEntry) {
168 isGoalAction =
false;
173 for (uint64_t state : statesPerObservation[observation]) {
174 newGoalStates.
set(state);
186template<
typename ValueType>
192template<
typename ValueType>
199template<
typename ValueType>
202 STORM_LOG_THROW(mc.canHandle(propositionalFormula), storm::exceptions::InvalidPropertyException,
203 "Propositional model checker can not handle formula " << propositionalFormula);
204 return mc.check(propositionalFormula)->asExplicitQualitativeCheckResult().getTruthValuesVector();
207template class QualitativeAnalysisOnGraphs<double>;
208template class QualitativeAnalysisOnGraphs<storm::RationalNumber>;
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(uint64_t index, bool value=true)
Sets the given truth value at the given index.
bool get(uint64_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