9template<
typename ValueType,
typename RewardModelType>
12 std::unordered_map<std::string, RewardModelType>
const &rewardModels)
17template<
typename ValueType,
typename RewardModelType>
19 std::unordered_map<std::string, RewardModelType> &&rewardModels)
24template<
typename ValueType,
typename RewardModelType>
27 observations(components.observabilityClasses.value()),
28 canonicFlag(canonicFlag),
29 observationValuations(components.observationValuations) {
33template<
typename ValueType,
typename RewardModelType>
36 observations(components.observabilityClasses.value()),
37 canonicFlag(canonicFlag),
38 observationValuations(components.observationValuations) {
42template<
typename ValueType,
typename RewardModelType>
44 this->printModelInformationHeaderToStream(out);
45 out <<
"Choices: \t" << this->getNumberOfChoices() <<
'\n';
46 out <<
"Observations: \t" << this->nrObservations <<
'\n';
47 this->printModelInformationFooterToStream(out);
50template<
typename ValueType,
typename RewardModelType>
52 uint64_t highestEntry = 0;
53 for (uint32_t entry : observations) {
54 if (entry > highestEntry) {
58 nrObservations = highestEntry + 1;
62template<
typename ValueType,
typename RewardModelType>
64 return observations.at(state);
67template<
typename ValueType,
typename RewardModelType>
69 return nrObservations;
72template<
typename ValueType,
typename RewardModelType>
74 std::map<uint32_t, uint64_t> counts;
75 for (
auto const &obs : observations) {
76 auto insertionRes = counts.emplace(obs, 1ull);
77 if (!insertionRes.second) {
78 ++insertionRes.first->second;
82 for (
auto const &count : counts) {
83 result = std::max(result, count.second);
88template<
typename ValueType,
typename RewardModelType>
93template<
typename ValueType,
typename RewardModelType>
95 observations = std::move(newObservations);
96 computeNrObservations();
97 setIsCanonic(isCanonic() && preservesCanonicity);
100template<
typename ValueType,
typename RewardModelType>
102 return "<" + std::to_string(getObservation(state)) +
">";
105template<
typename ValueType,
typename RewardModelType>
107 std::vector<uint64_t> result;
108 for (uint64_t state = 0; state < this->getNumberOfStates(); ++state) {
109 if (this->getObservation(state) == observation) {
110 result.push_back(state);
116template<
typename ValueType,
typename RewardModelType>
118 return static_cast<bool>(observationValuations);
121template<
typename ValueType,
typename RewardModelType>
123 return observationValuations.value();
126template<
typename ValueType,
typename RewardModelType>
128 return observationValuations;
131template<
typename ValueType,
typename RewardModelType>
136template<
typename ValueType,
typename RewardModelType>
138 this->canonicFlag = newValue;
141template<
typename ValueType,
typename RewardModelType>
146template<
typename ValueType,
typename RewardModelType>
148 std::size_t seed = 0;
150 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.