From fe81e0d7cf6cd536fc4066381a7a76dd1540220c Mon Sep 17 00:00:00 2001 From: Alexander Bork Date: Fri, 29 Nov 2019 13:59:43 +0100 Subject: [PATCH] Smaller touch-ups (Removal of unused code, pass-by-reference) --- .../ApproximatePOMDPModelchecker.cpp | 40 ++++++++----------- .../ApproximatePOMDPModelchecker.h | 36 ++++++++--------- 2 files changed, 35 insertions(+), 41 deletions(-) diff --git a/src/storm-pomdp/modelchecker/ApproximatePOMDPModelchecker.cpp b/src/storm-pomdp/modelchecker/ApproximatePOMDPModelchecker.cpp index 90fe6dc3b..282f4dd68 100644 --- a/src/storm-pomdp/modelchecker/ApproximatePOMDPModelchecker.cpp +++ b/src/storm-pomdp/modelchecker/ApproximatePOMDPModelchecker.cpp @@ -49,14 +49,10 @@ namespace storm { template std::unique_ptr> ApproximatePOMDPModelchecker::computeReachabilityOTF(storm::models::sparse::Pomdp const &pomdp, - std::set targetObservations, bool min, uint64_t gridResolution, + std::set const &targetObservations, bool min, uint64_t gridResolution, bool computeRewards) { STORM_PRINT("Use On-The-Fly Grid Generation" << std::endl) - if (computeRewards) { - RewardModelType const &pomdpRewardModel = pomdp.getUniqueRewardModel(); - } - bool finished = false; uint64_t iteration = 0; std::vector> beliefList; @@ -364,7 +360,7 @@ namespace storm { } } overApproxTimer.stop(); - ValueType underApprox = storm::utility::zero(); + auto underApprox = storm::utility::zero(); /* storm::utility::Stopwatch underApproxTimer(true); ValueType underApprox = computeUnderapproximationWithMDP(pomdp, beliefList, beliefIsTarget, targetObservations, observationProbabilities, nextBelieves, @@ -401,30 +397,28 @@ namespace storm { template std::unique_ptr> ApproximatePOMDPModelchecker::computeReachabilityRewardOTF(storm::models::sparse::Pomdp const &pomdp, - std::set targetObservations, bool min, uint64_t gridResolution) { + std::set const &targetObservations, bool min, + uint64_t gridResolution) { return computeReachabilityOTF(pomdp, targetObservations, min, gridResolution, true); } template std::unique_ptr> ApproximatePOMDPModelchecker::computeReachabilityProbabilityOTF(storm::models::sparse::Pomdp const &pomdp, - std::set targetObservations, bool min, uint64_t gridResolution) { + std::set const &targetObservations, bool min, + uint64_t gridResolution) { return computeReachabilityOTF(pomdp, targetObservations, min, gridResolution, false); } template std::unique_ptr> ApproximatePOMDPModelchecker::computeReachability(storm::models::sparse::Pomdp const &pomdp, - std::set targetObservations, bool min, uint64_t gridResolution, + std::set const &targetObservations, bool min, uint64_t gridResolution, bool computeRewards) { storm::utility::Stopwatch beliefGridTimer(true); bool finished = false; uint64_t iteration = 0; - if (computeRewards) { - RewardModelType pomdpRewardModel = pomdp.getUniqueRewardModel(); - } - std::vector> beliefList; std::vector beliefIsTarget; uint64_t nextId = 0; @@ -616,14 +610,15 @@ namespace storm { template std::unique_ptr> ApproximatePOMDPModelchecker::computeReachabilityProbability(storm::models::sparse::Pomdp const &pomdp, - std::set targetObservations, bool min, uint64_t gridResolution) { + std::set const &targetObservations, bool min, + uint64_t gridResolution) { return computeReachability(pomdp, targetObservations, min, gridResolution, false); } template std::unique_ptr> ApproximatePOMDPModelchecker::computeReachabilityReward(storm::models::sparse::Pomdp const &pomdp, - std::set targetObservations, bool min, uint64_t gridResolution) { + std::set const &targetObservations, bool min, uint64_t gridResolution) { return computeReachability(pomdp, targetObservations, min, gridResolution, true); } @@ -632,7 +627,7 @@ namespace storm { ApproximatePOMDPModelchecker::computeUnderapproximation(storm::models::sparse::Pomdp const &pomdp, std::vector> &beliefList, std::vector &beliefIsTarget, - std::set &targetObservations, + std::set const &targetObservations, std::map>> &observationProbabilities, std::map>> &nextBelieves, std::map &result, @@ -796,7 +791,7 @@ namespace storm { storm::models::sparse::Pomdp const &pomdp, std::vector> &beliefList, std::vector &beliefIsTarget, - std::set &targetObservations, + std::set const &targetObservations, std::map>> &observationProbabilities, std::map>> &nextBelieves, std::map &result, @@ -870,7 +865,7 @@ namespace storm { storm::models::sparse::Pomdp const &pomdp, std::vector> &beliefList, std::vector &beliefIsTarget, - std::set &targetObservations, + std::set const &targetObservations, std::map>> &observationProbabilities, std::map>> &nextBelieves, std::map &result, @@ -925,7 +920,7 @@ namespace storm { template void ApproximatePOMDPModelchecker::constructBeliefGrid( storm::models::sparse::Pomdp const &pomdp, - std::set target_observations, uint64_t gridResolution, + std::set const &target_observations, uint64_t gridResolution, std::vector> &beliefList, std::vector> &grid, std::vector &beliefIsKnown, uint64_t nextId) { @@ -971,9 +966,7 @@ namespace storm { storm::utility::convertNumber(gridResolution); storm::pomdp::Belief belief = {newId, observation, distribution}; - STORM_LOG_TRACE( - "Add Belief " << std::to_string(newId) << " [(" << std::to_string(observation) - << ")," << distribution << "]"); + STORM_LOG_TRACE("Add Belief " << std::to_string(newId) << " [(" << std::to_string(observation) << ")," << distribution << "]"); beliefList.push_back(belief); grid.push_back(belief); beliefIsKnown.push_back(isTarget); @@ -1107,7 +1100,8 @@ namespace storm { template uint64_t ApproximatePOMDPModelchecker::getBeliefAfterActionAndObservation( storm::models::sparse::Pomdp const &pomdp, std::vector> &beliefList, - std::vector &beliefIsTarget, std::set &targetObservations, storm::pomdp::Belief belief, uint64_t actionIndex, uint32_t observation, + std::vector &beliefIsTarget, std::set const &targetObservations, storm::pomdp::Belief belief, uint64_t actionIndex, + uint32_t observation, uint64_t id) { storm::utility::Stopwatch distrWatch(true); std::vector distributionAfter(pomdp.getNumberOfStates()); //, storm::utility::zero()); diff --git a/src/storm-pomdp/modelchecker/ApproximatePOMDPModelchecker.h b/src/storm-pomdp/modelchecker/ApproximatePOMDPModelchecker.h index 89d1be286..f20f4ebc1 100644 --- a/src/storm-pomdp/modelchecker/ApproximatePOMDPModelchecker.h +++ b/src/storm-pomdp/modelchecker/ApproximatePOMDPModelchecker.h @@ -27,21 +27,21 @@ namespace storm { std::unique_ptr> computeReachabilityProbabilityOTF(storm::models::sparse::Pomdp const &pomdp, - std::set targetObservations, bool min, + std::set const &targetObservations, bool min, uint64_t gridResolution); std::unique_ptr> - computeReachabilityRewardOTF(storm::models::sparse::Pomdp const &pomdp, std::set targetObservations, bool min, + computeReachabilityRewardOTF(storm::models::sparse::Pomdp const &pomdp, std::set const &targetObservations, bool min, uint64_t gridResolution); std::unique_ptr> computeReachabilityProbability(storm::models::sparse::Pomdp const &pomdp, - std::set targetObservations, bool min, + std::set const &targetObservations, bool min, uint64_t gridResolution); std::unique_ptr> computeReachabilityReward(storm::models::sparse::Pomdp const &pomdp, - std::set targetObservations, bool min, + std::set const &targetObservations, bool min, uint64_t gridResolution); private: @@ -56,7 +56,7 @@ namespace storm { */ std::unique_ptr> computeReachabilityOTF(storm::models::sparse::Pomdp const &pomdp, - std::set targetObservations, bool min, + std::set const &targetObservations, bool min, uint64_t gridResolution, bool computeRewards); /** @@ -70,7 +70,7 @@ namespace storm { */ std::unique_ptr> computeReachability(storm::models::sparse::Pomdp const &pomdp, - std::set targetObservations, bool min, + std::set const &targetObservations, bool min, uint64_t gridResolution, bool computeRewards); /** @@ -89,7 +89,7 @@ namespace storm { std::vector extractBestActions(storm::models::sparse::Pomdp const &pomdp, std::vector> &beliefList, std::vector &beliefIsTarget, - std::set &target_observations, + std::set const &target_observations, std::map>> &observationProbabilities, std::map>> &nextBelieves, std::map &result, @@ -110,14 +110,14 @@ namespace storm { * @return */ std::vector extractBestAction(storm::models::sparse::Pomdp const &pomdp, - std::vector> &beliefList, - std::vector &beliefIsTarget, - std::set &target_observations, - std::map>> &observationProbabilities, - std::map>> &nextBelieves, - std::map &result, - uint64_t gridResolution, uint64_t currentBeliefId, uint64_t nextId, - bool min); + std::vector> &beliefList, + std::vector &beliefIsTarget, + std::set const &target_observations, + std::map>> &observationProbabilities, + std::map>> &nextBelieves, + std::map &result, + uint64_t gridResolution, uint64_t currentBeliefId, uint64_t nextId, + bool min); /** * TODO @@ -137,7 +137,7 @@ namespace storm { ValueType computeUnderapproximation(storm::models::sparse::Pomdp const &pomdp, std::vector> &beliefList, std::vector &beliefIsTarget, - std::set &targetObservations, + std::set const &targetObservations, std::map>> &observationProbabilities, std::map>> &nextBelieves, std::map &result, @@ -172,7 +172,7 @@ namespace storm { * */ void constructBeliefGrid(storm::models::sparse::Pomdp const &pomdp, - std::set target_observations, uint64_t gridResolution, + std::set const &target_observations, uint64_t gridResolution, std::vector> &beliefList, std::vector> &grid, std::vector &beliefIsKnown, uint64_t nextId); @@ -206,7 +206,7 @@ namespace storm { storm::models::sparse::Pomdp const &pomdp, std::vector> &beliefList, std::vector &beliefIsTarget, - std::set &targetObservations, + std::set const &targetObservations, storm::pomdp::Belief belief, uint64_t actionIndex, uint32_t observation, uint64_t id);