Browse Source

Moved struct functions to cpp-file

tempestpy_adaptions
Alexander Bork 5 years ago
committed by Tim Quatmann
parent
commit
8b7ab24d66
  1. 31
      src/storm-pomdp/storage/BeliefManager.cpp
  2. 42
      src/storm-pomdp/storage/BeliefManager.h

31
src/storm-pomdp/storage/BeliefManager.cpp

@ -3,6 +3,37 @@
namespace storm {
namespace storage {
template<typename PomdpType, typename BeliefValueType, typename StateType>
uint64_t BeliefManager<PomdpType, BeliefValueType, StateType>::Triangulation::size() const {
return weights.size();
}
template<typename PomdpType, typename BeliefValueType, typename StateType>
BeliefManager<PomdpType, BeliefValueType, StateType>::FreudenthalDiff::FreudenthalDiff(StateType const &dimension, BeliefValueType &&diff) : dimension(dimension),
diff(std::move(diff)) {
// Intentionally left empty
}
template<typename PomdpType, typename BeliefValueType, typename StateType>
bool BeliefManager<PomdpType, BeliefValueType, StateType>::FreudenthalDiff::operator>(FreudenthalDiff const &other) const {
if (diff != other.diff) {
return diff > other.diff;
} else {
return dimension < other.dimension;
}
}
template<typename PomdpType, typename BeliefValueType, typename StateType>
std::size_t BeliefManager<PomdpType, BeliefValueType, StateType>::BeliefHash::operator()(const BeliefType &belief) const {
std::size_t seed = 0;
// Assumes that beliefs are ordered
for (auto const &entry : belief) {
boost::hash_combine(seed, entry.first);
boost::hash_combine(seed, entry.second);
}
return seed;
}
template<typename PomdpType, typename BeliefValueType, typename StateType>
BeliefManager<PomdpType, BeliefValueType, StateType>::BeliefManager(PomdpType const &pomdp, BeliefValueType const &precision, TriangulationMode const &triangulationMode)
: pomdp(pomdp), triangulationMode(triangulationMode) {

42
src/storm-pomdp/storage/BeliefManager.h

@ -34,10 +34,7 @@ namespace storm {
struct Triangulation {
std::vector<BeliefId> gridPoints;
std::vector<BeliefValueType> weights;
uint64_t size() const {
return weights.size();
}
uint64_t size() const;
};
BeliefId noId() const;
@ -77,6 +74,18 @@ namespace storm {
private:
struct BeliefHash {
std::size_t operator()(const BeliefType &belief) const;
};
struct FreudenthalDiff {
FreudenthalDiff(StateType const &dimension, BeliefValueType &&diff);
StateType dimension; // i
BeliefValueType diff; // d[i]
bool operator>(FreudenthalDiff const &other) const;
};
BeliefType const &getBelief(BeliefId const &id) const;
BeliefId getId(BeliefType const &belief) const;
@ -91,19 +100,6 @@ namespace storm {
uint32_t getBeliefObservation(BeliefType belief) const;
struct FreudenthalDiff {
FreudenthalDiff(StateType const &dimension, BeliefValueType &&diff) : dimension(dimension), diff(std::move(diff)) {};
StateType dimension; // i
BeliefValueType diff; // d[i]
bool operator>(FreudenthalDiff const &other) const {
if (diff != other.diff) {
return diff > other.diff;
} else {
return dimension < other.dimension;
}
}
};
void triangulateBeliefFreudenthal(BeliefType const &belief, BeliefValueType const &resolution, Triangulation &result);
void triangulateBeliefDynamic(BeliefType const &belief, BeliefValueType const &resolution, Triangulation &result);
@ -117,18 +113,6 @@ namespace storm {
BeliefId getOrAddBeliefId(BeliefType const &belief);
struct BeliefHash {
std::size_t operator()(const BeliefType &belief) const {
std::size_t seed = 0;
// Assumes that beliefs are ordered
for (auto const &entry : belief) {
boost::hash_combine(seed, entry.first);
boost::hash_combine(seed, entry.second);
}
return seed;
}
};
PomdpType const& pomdp;
std::vector<ValueType> pomdpActionRewardVector;

Loading…
Cancel
Save