21template<
typename PomdpValueType>
22struct BeliefVerificationInput {
23 std::shared_ptr<storm::models::sparse::Pomdp<PomdpValueType>> pomdp;
24 std::shared_ptr<storm::logic::Formula const> formula;
25 analysis::FormulaInformation formulaInformation;
26 beliefs::PropertyInformation propertyInformation;
29template<
typename PomdpValueType,
typename BeliefMdpValueType>
30BeliefVerificationInput<PomdpValueType> prepareBeliefVerification(storm::models::sparse::Pomdp<PomdpValueType>
const& input,
31 storm::logic::Formula
const& formula,
32 beliefs::BeliefBasedModelCheckerOptions<BeliefMdpValueType>& options) {
34 fragment.setRewardOperatorsAllowed(
true).setReachabilityRewardFormulasAllowed(
true).setQualitativeOperatorResultsAllowed(
false);
36 "The one-shot belief API supports only non-nested, unbounded reachability probabilities and expected reachability rewards without "
41 "One-shot belief verification requires exactly one initial state.");
42 if (options.useClipping) {
44 storm::exceptions::IllegalArgumentException,
"Clipping requires one resolution per input POMDP observation.");
45 STORM_LOG_THROW(std::all_of(options.clippingResolutions->begin(), options.clippingResolutions->end(), [](
auto resolution) { return resolution > 0; }),
46 storm::exceptions::IllegalArgumentException,
"Clipping resolutions must be positive.");
49 using PomdpType = storm::models::sparse::Pomdp<PomdpValueType>;
50 auto pomdp = input.
isCanonic() ? std::make_shared<PomdpType>(input) : storm::transformer::MakePOMDPCanonic<PomdpValueType>(input).transform();
51 STORM_LOG_THROW(!options.buildChoiceLabeling || pomdp->hasChoiceLabeling(), storm::exceptions::IllegalArgumentException,
52 "Building belief MDP choice labels requires choice labels in the input POMDP. Otherwise, set options.buildChoiceLabeling to false.");
53 auto [targetClosedPomdp, targetObservations] =
54 storm::transformer::MakeStateSetObservationClosed<PomdpValueType>(pomdp).transform(formulaInformation.getTargetStates().states);
55 pomdp = std::move(targetClosedPomdp);
56 if (options.useClipping) {
58 auto const originalResolutions = *options.clippingResolutions;
59 options.clippingResolutions->resize(pomdp->getNrObservations());
61 options.clippingResolutions->at(pomdp->getObservation(state)) = originalResolutions.at(input.
getObservation(state));
67 if (formulaInformation.isNonNestedReachabilityProbability() && !formulaInformation.getSinkStates().empty()) {
69 pomdp->getTransitionMatrix().makeRowGroupsAbsorbing(formulaInformation.getSinkStates().states,
true);
72 beliefs::PropertyInformation propertyInformation;
73 propertyInformation.dir = formulaInformation.getOptimizationDirection();
74 propertyInformation.targetObservations = std::move(targetObservations);
75 if (formulaInformation.isNonNestedExpectedRewardFormula()) {
77 propertyInformation.rewardModelName = formulaInformation.getRewardModelName();
83 return {std::move(pomdp), formula.
asSharedPointer(), std::move(formulaInformation), std::move(propertyInformation)};
86template<
typename PomdpValueType>
87storage::BeliefExplorationBounds<PomdpValueType> computeBeliefBounds(storm::Environment
const& env, BeliefVerificationInput<PomdpValueType>
const& prepared,
89 modelchecker::PreprocessingPomdpValueBoundsModelChecker<storm::models::sparse::Pomdp<PomdpValueType>> checker(*prepared.pomdp);
90 storage::BeliefExplorationBounds<PomdpValueType> bounds;
91 bounds.preprocessingBounds = checker.getValueBounds(env, *prepared.formula, prepared.formulaInformation);
93 bounds.extremeBounds = checker.getExtremeValueBound(env, *prepared.formula, prepared.formulaInformation);
98template<
typename PomdpValueType,
typename BeliefValueType,
typename BeliefMdpValueType,
typename PolicyValueType>
99beliefs::BeliefBasedModelCheckerResult<BeliefMdpValueType, PolicyValueType> unfoldPrepared(
100 storm::Environment
const& env, BeliefVerificationInput<PomdpValueType>
const& prepared,
101 beliefs::BeliefBasedModelCheckerOptions<BeliefMdpValueType>
const& options) {
102 auto bounds = computeBeliefBounds(env, prepared, options.useClipping);
103 beliefs::BeliefBasedModelChecker<storm::models::sparse::Pomdp<PomdpValueType>, BeliefValueType, BeliefMdpValueType, PolicyValueType> checker(
105 return checker.checkUnfold(env, prepared.propertyInformation, options, bounds);
110template<
typename PomdpValueType,
typename BeliefValueType,
typename BeliefMdpValueType,
typename PolicyValueType>
114 auto effectiveOptions = options;
115 auto prepared = prepareBeliefVerification(
pomdp, formula, effectiveOptions);
116 return unfoldPrepared<PomdpValueType, BeliefValueType, BeliefMdpValueType, PolicyValueType>(env, prepared, effectiveOptions);
119template<
typename PomdpValueType,
typename BeliefValueType,
typename BeliefMdpValueType,
typename PolicyValueType>
123 STORM_LOG_THROW(resolution > 0, storm::exceptions::IllegalArgumentException,
"The discretization resolution must be positive.");
125 "Belief discretization does not support exploration size or time limits.");
126 STORM_LOG_THROW(!options.
useClipping, storm::exceptions::NotSupportedException,
"Belief discretization does not support clipping.");
127 auto effectiveOptions = options;
128 auto prepared = prepareBeliefVerification(
pomdp, formula, effectiveOptions);
129 auto bounds = computeBeliefBounds(env, prepared,
false);
132 return checker.
checkDiscretize(env, prepared.propertyInformation, effectiveOptions, resolution, useDynamic, bounds);
virtual uint_fast64_t getNumberOfStates() const override
Returns the number of states of the model.
storm::storage::BitVector const & getInitialStates() const
Retrieves the initial states of the model.
This class represents a partially observable Markov decision process.
uint64_t getNrObservations() const
uint32_t getObservation(uint64_t state) const
Builds and checks a finite belief MDP approximation of a POMDP.
BeliefBasedModelCheckerResult< BeliefMdpValueType, PolicyValueType > checkDiscretize(storm::Environment const &env, PropertyInformation const &propertyInformation, storm::pomdp::beliefs::BeliefBasedModelCheckerOptions< BeliefMdpValueType > const &options, uint64_t resolution, bool useDynamic, storage::BeliefExplorationBounds< PomdpValueType > const &valueBounds)
Explores the belief space and discretises beliefs using the Freudenthal triangualtion approximation.
uint64_t getNumberOfSetBits() const
Returns the number of bits that are set to true in this bit vector.
#define STORM_LOG_THROW(cond, exception, message)
FragmentSpecification reachability()
FormulaInformation getFormulaInformation(PomdpType const &pomdp, storm::logic::ProbabilityOperatorFormula const &formula)
beliefs::BeliefBasedModelCheckerResult< BeliefMdpValueType, PolicyValueType > verifyWithBeliefUnfolding(storm::Environment const &env, storm::models::sparse::Pomdp< PomdpValueType > const &pomdp, storm::logic::Formula const &formula, beliefs::BeliefBasedModelCheckerOptions< BeliefMdpValueType > const &options)
Approximates an unbounded reachability probability or expected reachability reward by unfolding the b...
template beliefs::BeliefBasedModelCheckerResult< double, storm::RationalNumber > verifyWithBeliefUnfolding< double, double, double, storm::RationalNumber >(storm::Environment const &, storm::models::sparse::Pomdp< double > const &, storm::logic::Formula const &, beliefs::BeliefBasedModelCheckerOptions< double > const &)
template beliefs::BeliefBasedModelCheckerResult< double > verifyWithBeliefUnfolding< double, double, double >(storm::Environment const &, storm::models::sparse::Pomdp< double > const &, storm::logic::Formula const &, beliefs::BeliefBasedModelCheckerOptions< double > const &)
template beliefs::BeliefBasedModelCheckerResult< double > verifyWithBeliefDiscretization< double, storm::RationalNumber, double >(storm::Environment const &, storm::models::sparse::Pomdp< double > const &, storm::logic::Formula const &, uint64_t, bool, beliefs::BeliefBasedModelCheckerOptions< double > const &)
template beliefs::BeliefBasedModelCheckerResult< double > verifyWithBeliefUnfolding< double, storm::RationalNumber, double >(storm::Environment const &, storm::models::sparse::Pomdp< double > const &, storm::logic::Formula const &, beliefs::BeliefBasedModelCheckerOptions< double > const &)
template beliefs::BeliefBasedModelCheckerResult< storm::RationalNumber > verifyWithBeliefUnfolding< storm::RationalNumber, storm::RationalNumber, storm::RationalNumber >(storm::Environment const &, storm::models::sparse::Pomdp< storm::RationalNumber > const &, storm::logic::Formula const &, beliefs::BeliefBasedModelCheckerOptions< storm::RationalNumber > const &)
template beliefs::BeliefBasedModelCheckerResult< double > verifyWithBeliefUnfolding< storm::RationalNumber, storm::RationalNumber, double >(storm::Environment const &, storm::models::sparse::Pomdp< storm::RationalNumber > const &, storm::logic::Formula const &, beliefs::BeliefBasedModelCheckerOptions< double > const &)
template beliefs::BeliefBasedModelCheckerResult< storm::RationalNumber > verifyWithBeliefDiscretization< storm::RationalNumber, storm::RationalNumber, storm::RationalNumber >(storm::Environment const &, storm::models::sparse::Pomdp< storm::RationalNumber > const &, storm::logic::Formula const &, uint64_t, bool, beliefs::BeliefBasedModelCheckerOptions< storm::RationalNumber > const &)
template beliefs::BeliefBasedModelCheckerResult< double, storm::RationalNumber > verifyWithBeliefDiscretization< double, double, double, storm::RationalNumber >(storm::Environment const &, storm::models::sparse::Pomdp< double > const &, storm::logic::Formula const &, uint64_t, bool, beliefs::BeliefBasedModelCheckerOptions< double > const &)
template beliefs::BeliefBasedModelCheckerResult< double > verifyWithBeliefDiscretization< storm::RationalNumber, storm::RationalNumber, double >(storm::Environment const &, storm::models::sparse::Pomdp< storm::RationalNumber > const &, storm::logic::Formula const &, uint64_t, bool, beliefs::BeliefBasedModelCheckerOptions< double > const &)
beliefs::BeliefBasedModelCheckerResult< BeliefMdpValueType, PolicyValueType > verifyWithBeliefDiscretization(storm::Environment const &env, storm::models::sparse::Pomdp< PomdpValueType > const &pomdp, storm::logic::Formula const &formula, uint64_t resolution, bool useDynamic, beliefs::BeliefBasedModelCheckerOptions< BeliefMdpValueType > const &options)
Approximates an unbounded reachability probability or expected reachability reward by Freudenthal dis...
template beliefs::BeliefBasedModelCheckerResult< storm::RationalNumber > verifyWithBeliefDiscretization< double, double, storm::RationalNumber >(storm::Environment const &, storm::models::sparse::Pomdp< double > const &, storm::logic::Formula const &, uint64_t, bool, beliefs::BeliefBasedModelCheckerOptions< storm::RationalNumber > const &)
template beliefs::BeliefBasedModelCheckerResult< storm::RationalNumber > verifyWithBeliefUnfolding< double, double, storm::RationalNumber >(storm::Environment const &, storm::models::sparse::Pomdp< double > const &, storm::logic::Formula const &, beliefs::BeliefBasedModelCheckerOptions< storm::RationalNumber > const &)
template beliefs::BeliefBasedModelCheckerResult< double > verifyWithBeliefDiscretization< double, double, double >(storm::Environment const &, storm::models::sparse::Pomdp< double > const &, storm::logic::Formula const &, uint64_t, bool, beliefs::BeliefBasedModelCheckerOptions< double > const &)
explorationTerminationCriterion getTerminationCriterion() const
Get the termination criterion for the exploration.
Result of a belief-based model-checking run.