From d76bcc4d103294591baeb3acae60661e65a0b3a9 Mon Sep 17 00:00:00 2001 From: Sebastian Junges Date: Thu, 9 Jul 2020 23:00:10 -0700 Subject: [PATCH] pPOMDP support --- .../ApplyFiniteSchedulerToPomdp.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/storm-pomdp/transformer/ApplyFiniteSchedulerToPomdp.cpp b/src/storm-pomdp/transformer/ApplyFiniteSchedulerToPomdp.cpp index 7d290a6da..a125289bf 100644 --- a/src/storm-pomdp/transformer/ApplyFiniteSchedulerToPomdp.cpp +++ b/src/storm-pomdp/transformer/ApplyFiniteSchedulerToPomdp.cpp @@ -19,7 +19,7 @@ namespace storm { } struct RationalFunctionConstructor { - RationalFunctionConstructor() : cache(std::make_shared()) { + RationalFunctionConstructor(std::shared_ptr const& cache) : cache(cache) { } @@ -31,11 +31,25 @@ namespace storm { std::shared_ptr cache; }; + template + std::shared_ptr getCache(storm::models::sparse::Pomdp const& model) { + return std::make_shared(); + } + + template<> + std::shared_ptr getCache(storm::models::sparse::Pomdp const& model) { + for (auto const& entry : model.getTransitionMatrix()) { + if(!entry.getValue().isConstant()) { + return entry.getValue().nominatorAsPolynomial().pCache(); + } + } + return std::make_shared(); + } template std::unordered_map> ApplyFiniteSchedulerToPomdp::getObservationChoiceWeights(PomdpFscApplicationMode applicationMode ) const { std::unordered_map> res; - RationalFunctionConstructor ratFuncConstructor; + RationalFunctionConstructor ratFuncConstructor(getCache(pomdp)); for (uint64_t state = 0; state < pomdp.getNumberOfStates(); ++state) { auto observation = pomdp.getObservation(state);