11template<
typename ValueType,
typename RewardModelType>
14 std::unordered_map<std::string, RewardModelType>
const &rewardModels)
19template<
typename ValueType,
typename RewardModelType>
21 std::unordered_map<std::string, RewardModelType> &&rewardModels)
26template<
typename ValueType,
typename RewardModelType>
29 observations(components.observabilityClasses.value()),
30 canonicFlag(canonicFlag),
31 observationValuations(components.observationValuations) {
35template<
typename ValueType,
typename RewardModelType>
38 observations(components.observabilityClasses.value()),
39 canonicFlag(canonicFlag),
40 observationValuations(components.observationValuations) {
44template<
typename ValueType,
typename RewardModelType>
46 this->printModelInformationHeaderToStream(out);
47 out <<
"Choices: \t" << this->getNumberOfChoices() <<
'\n';
48 out <<
"Observations: \t" << this->nrObservations <<
'\n';
49 this->printModelInformationFooterToStream(out);
52template<
typename ValueType,
typename RewardModelType>
54 uint64_t highestEntry = 0;
55 for (uint32_t entry : observations) {
56 if (entry > highestEntry) {
60 nrObservations = highestEntry + 1;
64template<
typename ValueType,
typename RewardModelType>
66 return observations.at(state);
69template<
typename ValueType,
typename RewardModelType>
71 return nrObservations;
74template<
typename ValueType,
typename RewardModelType>
76 std::map<uint32_t, uint64_t> counts;
77 for (
auto const &obs : observations) {
78 auto insertionRes = counts.emplace(obs, 1ull);
79 if (!insertionRes.second) {
80 ++insertionRes.first->second;
84 for (
auto const &count : counts) {
85 result = std::max(result, count.second);
90template<
typename ValueType,
typename RewardModelType>
95template<
typename ValueType,
typename RewardModelType>
97 observations = std::move(newObservations);
98 computeNrObservations();
99 setIsCanonic(isCanonic() && preservesCanonicity);
102template<
typename ValueType,
typename RewardModelType>
104 return "<" + std::to_string(getObservation(state)) +
">";
107template<
typename ValueType,
typename RewardModelType>
109 std::vector<uint64_t> result;
110 for (uint64_t state = 0; state < this->getNumberOfStates(); ++state) {
111 if (this->getObservation(state) == observation) {
112 result.push_back(state);
118template<
typename ValueType,
typename RewardModelType>
120 return static_cast<bool>(observationValuations);
123template<
typename ValueType,
typename RewardModelType>
125 return observationValuations.value();
128template<
typename ValueType,
typename RewardModelType>
130 return observationValuations;
133template<
typename ValueType,
typename RewardModelType>
138template<
typename ValueType,
typename RewardModelType>
140 this->canonicFlag = newValue;
143template<
typename ValueType,
typename RewardModelType>
148template<
typename ValueType,
typename RewardModelType>
150 std::size_t seed = 0;
152 boost::hash_combine(seed, boost::hash_range(observations.begin(), observations.end()));
This class represents a (discrete-time) Markov decision process.
Base class for all sparse models.
CRewardModelType RewardModelType
This class represents a partially observable Markov decision process.
virtual bool isPartiallyObservable() const override
uint64_t getNrObservations() const
storm::storage::sparse::StateValuations const & getObservationValuations() const
Pomdp(storm::storage::SparseMatrix< ValueType > const &transitionMatrix, storm::models::sparse::StateLabeling const &stateLabeling, std::unordered_map< std::string, RewardModelType > const &rewardModels=std::unordered_map< std::string, RewardModelType >())
Constructs a model from the given data.
virtual void printModelInformationToStream(std::ostream &out) const override
Prints information about the model to the specified stream.
void updateObservations(std::vector< uint32_t > &&newObservations, bool preservesCanonicity)
Changes the observations to the given ones and updates redundant informations (like the number of obs...
std::vector< uint64_t > getStatesWithObservation(uint32_t observation) const
std::optional< storm::storage::sparse::StateValuations > const & getOptionalObservationValuations() const
virtual std::size_t hash() const override
void computeNrObservations()
uint32_t getObservation(uint64_t state) const
uint64_t getMaxNrStatesWithSameObservation() const
Returns the number of hidden values, i.e.
void setIsCanonic(bool newValue=true)
bool hasObservationValuations() const
std::vector< uint32_t > const & getObservations() const
virtual std::string additionalDotStateInfo(uint64_t state) const override
Return a string that is additonally added to the state information in the dot stream.
This class manages the labeling of the state space with a number of (atomic) labels.
A class that holds a possibly non-square matrix in the compressed row storage format.