Browse Source

first version of a generator for belief support MDPs

tempestpy_adaptions
Sebastian Junges 5 years ago
parent
commit
5277139640
  1. 35
      src/storm-pomdp/generator/BeliefSupportTracker.cpp
  2. 26
      src/storm-pomdp/generator/BeliefSupportTracker.h

35
src/storm-pomdp/generator/BeliefSupportTracker.cpp

@ -0,0 +1,35 @@
#include "storm-pomdp/generator/BeliefSupportTracker.h"
namespace storm {
namespace generator {
template<typename ValueType>
BeliefSupportTracker<ValueType>::BeliefSupportTracker(storm::models::sparse::Pomdp<ValueType> const& pomdp) :
pomdp(pomdp), currentBeliefSupport(pomdp.getInitialStates())
{
}
template<typename ValueType>
storm::storage::BitVector const& BeliefSupportTracker<ValueType>::getCurrentBeliefSupport() const {
return currentBeliefSupport;
}
template<typename ValueType>
void BeliefSupportTracker<ValueType>::track(uint64_t action, uint64_t observation) {
storm::storage::BitVector newBeliefSupport(pomdp.getNumberOfStates());
for (uint64_t oldState : currentBeliefSupport) {
uint64_t row = pomdp.getTransitionMatrix().getRowGroupIndices()[oldState] + action;
for (auto const& successor : pomdp.getTransitionMatrix().getRow(row)) {
assert(!storm::utility::isZero(successor.getValue()));
if (pomdp.getObservation(successor.getColumn()) == observation) {
newBeliefSupport.set(successor.getColumn(), true);
}
}
}
currentBeliefSupport = newBeliefSupport;
}
template class BeliefSupportTracker<double>;
}
}

26
src/storm-pomdp/generator/BeliefSupportTracker.h

@ -0,0 +1,26 @@
#include "storm/models/sparse/Pomdp.h"
#include "storm/storage/BitVector.h"
namespace storm {
namespace generator {
template<typename ValueType>
class BeliefSupportTracker {
/**
* Tracks the current belief support.
* TODO refactor into tracker and generator.
* @param pomdp
*/
public:
BeliefSupportTracker(storm::models::sparse::Pomdp<ValueType> const& pomdp);
storm::storage::BitVector const& getCurrentBeliefSupport() const;
void track(uint64_t action, uint64_t observation);
private:
storm::models::sparse::Pomdp<ValueType> const& pomdp;
storm::storage::BitVector currentBeliefSupport;
};
}
}
Loading…
Cancel
Save