Browse Source

Added a statistics struct to the approximatePOMDP model checker

tempestpy_adaptions
Tim Quatmann 5 years ago
parent
commit
6f3fab8e80
  1. 34
      src/storm-pomdp/modelchecker/ApproximatePOMDPModelchecker.cpp
  2. 13
      src/storm-pomdp/modelchecker/ApproximatePOMDPModelchecker.h
  3. 17
      src/storm/models/sparse/Pomdp.cpp
  4. 8
      src/storm/models/sparse/Pomdp.h

34
src/storm-pomdp/modelchecker/ApproximatePOMDPModelchecker.cpp

@ -73,6 +73,40 @@ namespace storm {
}
}
template<typename ValueType, typename RewardModelType>
void ApproximatePOMDPModelchecker<ValueType, RewardModelType>::printStatisticsToStream(std::ostream& stream) const {
stream << "##### Grid Approximation Statistics ######" << std::endl;
stream << "# Input model: " << std::endl;
pomdp.printModelInformationToStream(stream);
stream << "# Max. Number of states with same observation: " << pomdp.getMaxNrStatesWithSameObservation() << std::endl;
if (statistics.aborted) {
stream << "# Computation aborted early";
}
// Refinement information:
if (statistics.refinementSteps) {
stream << "# Number of refinement steps " << statistics.refinementSteps.get();
}
// The overapproximation MDP:
if (statistics.overApproximationStates) {
stream << "# Number of states in the ";
if (options.doRefinement) {
stream << "final ";
}
stream << "grid MDP for the over-approximation: ";
if (statistics.overApproximationBuildAborted) {
stream << ">=";
}
stream << statistics.overApproximationStates.get() << std::endl;
stream << "# Time spend for building the grid MDP(s): " << statistics.overApproximationBuildTime << std::endl;
stream << "# Time spend for checking the grid MDP(s): " << statistics.overApproximationCheckTime << std::endl;
}
stream << "##########################################" << std::endl;
}
template<typename ValueType, typename RewardModelType>
std::unique_ptr<POMDPCheckResult<ValueType>>

13
src/storm-pomdp/modelchecker/ApproximatePOMDPModelchecker.h

@ -66,6 +66,8 @@ namespace storm {
std::unique_ptr<POMDPCheckResult<ValueType>> check(storm::logic::Formula const& formula);
void printStatisticsToStream(std::ostream& stream) const;
private:
/**
* Compute the reachability probability of given target observations on a POMDP using the automatic refinement loop
@ -240,7 +242,16 @@ namespace storm {
*/
ValueType getRewardAfterAction(uint64_t action, storm::pomdp::Belief<ValueType> &belief);
struct Statistics {
boost::optional<uint64_t> overApproximationStates;
bool overApproximationBuildAborted;
storm::utility::Stopwatch overApproximationBuildTime;
storm::utility::Stopwatch overApproximationCheckTime;
boost::optional<uint64_t> refinementSteps;
bool aborted;
};
Statistics statistics;
storm::models::sparse::Pomdp<ValueType, RewardModelType> const& pomdp;
Options options;
storm::utility::ConstantsComparator<ValueType> cc;

17
src/storm/models/sparse/Pomdp.cpp

@ -54,10 +54,27 @@ namespace storm {
return nrObservations;
}
template<typename ValueType, typename RewardModelType>
uint64_t Pomdp<ValueType, RewardModelType>::getMaxNrStatesWithSameObservation() const {
std::map<uint32_t, uint64_t> counts;
for (auto const& obs : observations) {
auto insertionRes = counts.emplace(obs, 1ull);
if (!insertionRes.second) {
++insertionRes.first->second;
}
}
uint64_t result = 0;
for (auto const& count : counts) {
result = std::max(result, count.second);
}
return result;
}
template<typename ValueType, typename RewardModelType>
std::vector<uint32_t> const& Pomdp<ValueType, RewardModelType>::getObservations() const {
return observations;
}
template<typename ValueType, typename RewardModelType>
std::string Pomdp<ValueType, RewardModelType>::additionalDotStateInfo(uint64_t state) const {

8
src/storm/models/sparse/Pomdp.h

@ -59,13 +59,17 @@ namespace storm {
uint64_t getNrObservations() const;
/*!
* Returns the number of hidden values, i.e. the maximum number of states with the same observation
*/
uint64_t getMaxNrStatesWithSameObservation() const;
std::vector<uint32_t> const& getObservations() const;
std::vector<uint64_t> getStatesWithObservation(uint32_t observation) const;
bool isCanonic() const;
protected:
/*!
* Return a string that is additonally added to the state information in the dot stream.

Loading…
Cancel
Save