From 5a86ee36e372fed401dc0523a4744c3516896cb6 Mon Sep 17 00:00:00 2001 From: Roman Andriushchenko Date: Tue, 2 Jan 2024 10:57:10 +0100 Subject: [PATCH] skip missing state-action reward values when unfolding POMDPs --- payntbind/src/synthesis/pomdp/PomdpManager.cpp | 9 ++++++--- .../src/synthesis/pomdp/PomdpManagerAposteriori.cpp | 6 +++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/payntbind/src/synthesis/pomdp/PomdpManager.cpp b/payntbind/src/synthesis/pomdp/PomdpManager.cpp index eaac2756d..63e35be8e 100644 --- a/payntbind/src/synthesis/pomdp/PomdpManager.cpp +++ b/payntbind/src/synthesis/pomdp/PomdpManager.cpp @@ -224,12 +224,11 @@ namespace storm { components.transitionMatrix = this->constructTransitionMatrix(); // TODO remove unreachable states components.stateLabeling = this->constructStateLabeling(); - for (auto const& reward_model : pomdp.getRewardModels()) { + for (auto const& reward_model : this->pomdp.getRewardModels()) { auto constructed = this->constructRewardModel(reward_model.second); components.rewardModels.emplace(reward_model.first, constructed); } this->mdp = std::make_shared>(std::move(components)); - this->buildDesignSpaceSpurious(); return this->mdp; @@ -287,7 +286,11 @@ namespace storm { std::optional> state_rewards, action_rewards; STORM_LOG_THROW(!reward_model.hasStateRewards(), storm::exceptions::NotSupportedException, "state rewards are currently not supported."); STORM_LOG_THROW(!reward_model.hasTransitionRewards(), storm::exceptions::NotSupportedException, "transition rewards are currently not supported."); - + if(not reward_model.hasStateActionRewards()) { + STORM_LOG_WARN("Reward model exists but has no state-action value vector associated with it."); + return storm::models::sparse::StandardRewardModel(std::move(state_rewards), std::move(action_rewards)); + } + action_rewards = std::vector(); for(uint64_t row = 0; row < this->num_rows; row++) { auto prototype = this->row_prototype[row]; diff --git a/payntbind/src/synthesis/pomdp/PomdpManagerAposteriori.cpp b/payntbind/src/synthesis/pomdp/PomdpManagerAposteriori.cpp index ed84da145..2c22d93a6 100644 --- a/payntbind/src/synthesis/pomdp/PomdpManagerAposteriori.cpp +++ b/payntbind/src/synthesis/pomdp/PomdpManagerAposteriori.cpp @@ -219,7 +219,11 @@ namespace storm { std::optional> state_rewards, action_rewards; STORM_LOG_THROW(!reward_model.hasStateRewards(), storm::exceptions::NotSupportedException, "state rewards are currently not supported."); STORM_LOG_THROW(!reward_model.hasTransitionRewards(), storm::exceptions::NotSupportedException, "transition rewards are currently not supported."); - + if(not reward_model.hasStateActionRewards()) { + STORM_LOG_WARN("Reward model exists but has no state-action value vector associated with it."); + return storm::models::sparse::StandardRewardModel(std::move(state_rewards), std::move(action_rewards)); + } + action_rewards = std::vector(); for(uint64_t row = 0; row < this->row_prototype.size(); row++) { auto prototype = this->row_prototype[row];