From 311362d99554a9add4733d5340976806601cc4d2 Mon Sep 17 00:00:00 2001 From: Alexander Bork Date: Wed, 18 Mar 2020 19:16:46 +0100 Subject: [PATCH] Removal of some more obsolete code --- .../ApproximatePOMDPModelchecker.cpp | 97 ------------------- .../ApproximatePOMDPModelchecker.h | 27 ------ 2 files changed, 124 deletions(-) diff --git a/src/storm-pomdp/modelchecker/ApproximatePOMDPModelchecker.cpp b/src/storm-pomdp/modelchecker/ApproximatePOMDPModelchecker.cpp index 9b1c24a70..d8b56e74d 100644 --- a/src/storm-pomdp/modelchecker/ApproximatePOMDPModelchecker.cpp +++ b/src/storm-pomdp/modelchecker/ApproximatePOMDPModelchecker.cpp @@ -1051,85 +1051,6 @@ namespace storm { return storm::pomdp::Belief{id, observation, distribution}; } - template - void ApproximatePOMDPModelchecker::constructBeliefGrid( - std::set const &target_observations, uint64_t gridResolution, - std::vector> &beliefList, - std::vector> &grid, std::vector &beliefIsTarget, - uint64_t nextId) { - bool isTarget; - uint64_t newId = nextId; - - for (uint32_t observation = 0; observation < pomdp.getNrObservations(); ++observation) { - std::vector statesWithObservation = pomdp.getStatesWithObservation(observation); - isTarget = target_observations.find(observation) != target_observations.end(); - - // TODO this can probably be condensed - if (statesWithObservation.size() == 1) { - // If there is only one state with the observation, we can directly add the corresponding belief - std::map distribution; - distribution[statesWithObservation.front()] = storm::utility::one(); - storm::pomdp::Belief belief = {newId, observation, distribution}; - STORM_LOG_TRACE( - "Add Belief " << std::to_string(newId) << " [(" << std::to_string(observation) << ")," - << distribution << "]"); - beliefList.push_back(belief); - grid.push_back(belief); - beliefIsTarget.push_back(isTarget); - ++newId; - } else { - // Otherwise we have to enumerate all possible distributions with regards to the grid - // helper is used to derive the distribution of the belief - std::vector helper(statesWithObservation.size(), ValueType(0)); - helper[0] = storm::utility::convertNumber(gridResolution); - bool done = false; - uint64_t index = 0; - - while (!done) { - std::map distribution; - for (size_t i = 0; i < statesWithObservation.size() - 1; ++i) { - if (helper[i] - helper[i + 1] > ValueType(0)) { - distribution[statesWithObservation[i]] = (helper[i] - helper[i + 1]) / - storm::utility::convertNumber( - gridResolution); - } - } - if (helper[statesWithObservation.size() - 1] > ValueType(0)) { - distribution[statesWithObservation.back()] = - helper[statesWithObservation.size() - 1] / - 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 << "]"); - beliefList.push_back(belief); - grid.push_back(belief); - beliefIsTarget.push_back(isTarget); - if (helper[statesWithObservation.size() - 1] == - storm::utility::convertNumber(gridResolution)) { - // If the last entry of helper is the gridResolution, we have enumerated all necessary distributions - done = true; - } else { - // Update helper by finding the index to increment - index = statesWithObservation.size() - 1; - while (helper[index] == helper[index - 1]) { - --index; - } - STORM_LOG_ASSERT(index > 0, "Error in BeliefGrid generation - index wrong"); - // Increment the value at the index - ++helper[index]; - // Reset all indices greater than the changed one to 0 - ++index; - while (index < statesWithObservation.size()) { - helper[index] = 0; - ++index; - } - } - ++newId; - } - } - } - } - template std::pair>, std::vector> ApproximatePOMDPModelchecker::computeSubSimplexAndLambdas( @@ -1226,24 +1147,6 @@ namespace storm { return res; } - template - storm::pomdp::Belief - ApproximatePOMDPModelchecker::getBeliefAfterAction(storm::pomdp::Belief &belief, uint64_t actionIndex, uint64_t id) { - std::map distributionAfter; - uint32_t observation = 0; - for (auto const &probEntry : belief.probabilities) { - uint64_t state = probEntry.first; - auto row = pomdp.getTransitionMatrix().getRow(pomdp.getChoiceIndex(storm::storage::StateActionPair(state, actionIndex))); - for (auto const &entry : row) { - if (entry.getValue() > 0) { - observation = pomdp.getObservation(entry.getColumn()); - distributionAfter[entry.getColumn()] += belief.probabilities[state] * entry.getValue(); - } - } - } - return storm::pomdp::Belief{id, observation, distributionAfter}; - } - template uint64_t ApproximatePOMDPModelchecker::getBeliefAfterActionAndObservation(std::vector> &beliefList, std::vector &beliefIsTarget, std::set const &targetObservations, storm::pomdp::Belief &belief, uint64_t actionIndex, diff --git a/src/storm-pomdp/modelchecker/ApproximatePOMDPModelchecker.h b/src/storm-pomdp/modelchecker/ApproximatePOMDPModelchecker.h index 26877d062..6837151cd 100644 --- a/src/storm-pomdp/modelchecker/ApproximatePOMDPModelchecker.h +++ b/src/storm-pomdp/modelchecker/ApproximatePOMDPModelchecker.h @@ -184,22 +184,6 @@ namespace storm { computeSubSimplexAndLambdas(std::map &probabilities, uint64_t gridResolution, uint64_t nrStates); - /** - * Helper method to construct the static belief grid for the POMDP overapproximation - * - * @param target_observations set of target observations - * @param gridResolution the resolution of the grid to be constructed - * @param beliefList data structure to store all generated beliefs - * @param grid data structure to store references to the grid beliefs specifically - * @param beliefIsTarget vector containing true if the corresponding belief in the beleif list is a target belief - * @param nextId the ID to be used for the next generated belief - */ - void constructBeliefGrid(std::set const &target_observations, uint64_t gridResolution, - std::vector> &beliefList, - std::vector> &grid, - std::vector &beliefIsTarget, uint64_t nextId); - - /** * Helper method to get the probabilities to be in a state with each observation after performing an action * @@ -228,17 +212,6 @@ namespace storm { storm::pomdp::Belief &belief, uint64_t actionIndex, uint32_t observation, uint64_t id); - /** - * Helper method to generate the next belief that results from a belief by performing an action - * - * @param belief the starting belief - * @param actionIndex the index of the action to be performed - * @param id the ID for the generated belief - * @return a belief object representing the belief after performing the action in the starting belief - */ - storm::pomdp::Belief - getBeliefAfterAction(storm::pomdp::Belief &belief, uint64_t actionIndex, uint64_t id); - /** * Helper to get the id of a Belief stored in a given vector structure *