Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
FiniteBeliefMdpDetection.h
Go to the documentation of this file.
1#pragma once
2
3#include <optional>
4
8
9namespace storm {
10namespace pomdp {
11
18template<typename ValueType>
19bool detectFiniteBeliefMdp(storm::models::sparse::Pomdp<ValueType> const& pomdp, std::optional<storm::storage::BitVector> const& targetStates) {
20 // All infinite paths of the POMDP (including the ones with prob. 0 ) either
21 // - reach a target state after finitely many steps or
22 // - after finitely many steps enter an SCC and do not leave it
23 // Hence, any path of the belief MDP will at some point either reach a target state or stay in a set of POMDP SCCs.
24 // Only in the latter case we can get infinitely many different belief states.
25 // Below, we check whether all SCCs only consist of Dirac distributions.
26 // If this is the case, no new belief states will be found at some point.
27
28 // Get the SCC decomposition
30 options.dropNaiveSccs();
31 storm::storage::BitVector relevantStates;
32 if (targetStates) {
33 relevantStates = ~targetStates.value();
34 options.subsystem(relevantStates);
35 }
37
38 // Check whether all choices that stay within an SCC have Dirac distributions
39 for (auto const& scc : sccs) {
40 for (auto const& sccState : scc) {
41 for (uint64_t rowIndex = pomdp.getNondeterministicChoiceIndices()[sccState]; rowIndex < pomdp.getNondeterministicChoiceIndices()[sccState + 1];
42 ++rowIndex) {
43 for (auto const& entry : pomdp.getTransitionMatrix().getRow(rowIndex)) {
44 if (!storm::utility::isOne(entry.getValue()) && !storm::utility::isZero(entry.getValue())) {
45 if (scc.containsState(entry.getColumn())) {
46 // There is a non-dirac choice that stays in the SCC.
47 // This could still mean that the belief MDP is finite
48 // e.g., if at some point the branches merge back to the same state
49 return false;
50 }
51 }
52 }
53 }
54 }
55 }
56
57 return true;
58}
59} // namespace pomdp
60} // namespace storm
storm::storage::SparseMatrix< ValueType > const & getTransitionMatrix() const
Retrieves the matrix representing the transitions of the model.
Definition Model.cpp:197
std::vector< uint_fast64_t > const & getNondeterministicChoiceIndices() const
Retrieves the vector indicating which matrix rows represent non-deterministic choices of a certain st...
This class represents a partially observable Markov decision process.
Definition Pomdp.h:15
A bit vector that is internally represented as a vector of 64-bit values.
Definition BitVector.h:18
This class represents the decomposition of a graph-like structure into its strongly connected compone...
bool detectFiniteBeliefMdp(storm::models::sparse::Pomdp< ValueType > const &pomdp, std::optional< storm::storage::BitVector > const &targetStates)
This method tries to detect that the beliefmdp is finite.
bool isOne(ValueType const &a)
Definition constants.cpp:36
bool isZero(ValueType const &a)
Definition constants.cpp:41
LabParser.cpp.
Definition cli.cpp:18
StronglyConnectedComponentDecompositionOptions & dropNaiveSccs(bool value=true)
Sets if trivial SCCs (i.e. SCCs consisting of just one state without a self-loop) are to be kept in t...
StronglyConnectedComponentDecompositionOptions & subsystem(storm::storage::BitVector const &subsystem)
Sets a bit vector indicating which subsystem to consider for the decomposition into SCCs.