Storm 1.14.0.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
ClippingBeliefAbstraction.h
Go to the documentation of this file.
1#pragma once
2
3#include <memory>
4#include <optional>
5#include <vector>
6
10
11namespace storm {
12class Environment;
13}
14namespace storm::pomdp::beliefs {
15
23template<typename BeliefType>
25 public:
26 using BeliefValueType = typename BeliefType::ValueType;
27
36
38 explicit ClippingBeliefAbstraction(storm::Environment const& env, std::vector<uint64_t>&& observationResolutions);
39
41 ClippingBeliefAbstraction(storm::Environment const& env, std::vector<uint64_t>&& observationResolutions,
42 std::vector<BeliefValueType>&& extremalRewardValues);
43
50 template<typename AbstractCallback>
51 void abstract(BeliefType&& belief, BeliefValueType&& probabilityFactor, AbstractCallback const& callback) {
52 BeliefClipping clipping = clipBeliefToGrid(belief, observationResolutions[belief.observation()]);
53 if (clipping.isClippable) {
54 BeliefValueType a = (storm::utility::one<BeliefValueType>() - clipping.delta) * probabilityFactor;
55 BeliefValueType b = clipping.delta * probabilityFactor;
56 if (extremalRewardValues.has_value()) {
57 // We compute the reward adjustment necessary for clipping (see https://doi.org/10.48550/arXiv.2201.08772)
58 // Because we don't add clipped beliefs into the abstraction MDP, we compute the influence of the clipping transition (based on the expected
59 // reward value in the implicit clipped belief) here such that we can simply add the value to the state-action reward of the transition
60 auto rewardAdjustment = storm::utility::zero<BeliefValueType>();
61 for (auto const& [state, deltaValue] : clipping.deltaValues) {
62 rewardAdjustment += deltaValue * extremalRewardValues->at(state);
63 }
64 rewardAdjustment = probabilityFactor * rewardAdjustment;
65 callback(std::move(clipping.targetBelief), std::move(a), std::move(b), std::move(rewardAdjustment));
66 } else {
67 callback(std::move(clipping.targetBelief), std::move(a), std::move(b), std::nullopt);
68 }
69 } else {
70 // Belief on Grid
71 callback(std::move(belief), std::move(probabilityFactor), std::nullopt, std::nullopt);
72 }
73 }
74
76 BeliefClipping clipBeliefToGrid(BeliefType const& belief, uint64_t resolution);
77
78 private:
79 std::vector<uint64_t> observationResolutions;
80 std::shared_ptr<storm::solver::LpSolver<BeliefValueType>> lpSolver;
81 std::optional<std::vector<BeliefValueType>> extremalRewardValues = std::nullopt;
82};
83
84} // namespace storm::pomdp::beliefs
BeliefClipping clipBeliefToGrid(BeliefType const &belief, uint64_t resolution)
void abstract(BeliefType &&belief, BeliefValueType &&probabilityFactor, AbstractCallback const &callback)
Clips a belief and passes its representation to callback.
ClippingBeliefAbstraction(storm::Environment const &env, std::vector< uint64_t > &&observationResolutions)
Creates clipping grids with one resolution per POMDP observation.
boost::container::flat_map< BeliefStateType, BeliefValueType > BeliefFlatMap
Definition types.h:17
ValueType zero()
Definition constants.cpp:26
ValueType one()
Definition constants.cpp:21