Browse Source
modelchecker: Added support for non-trivial reward accumulations for Sparse/Hybrid/Dd engines.
tempestpy_adaptions
modelchecker: Added support for non-trivial reward accumulations for Sparse/Hybrid/Dd engines.
tempestpy_adaptions
TimQu
6 years ago
10 changed files with 139 additions and 39 deletions
-
13src/storm/modelchecker/csl/HybridCtmcCslModelChecker.cpp
-
16src/storm/modelchecker/csl/SparseCtmcCslModelChecker.cpp
-
14src/storm/modelchecker/csl/SparseMarkovAutomatonCslModelChecker.cpp
-
12src/storm/modelchecker/prctl/HybridDtmcPrctlModelChecker.cpp
-
9src/storm/modelchecker/prctl/HybridMdpPrctlModelChecker.cpp
-
16src/storm/modelchecker/prctl/SparseDtmcPrctlModelChecker.cpp
-
16src/storm/modelchecker/prctl/SparseMdpPrctlModelChecker.cpp
-
9src/storm/modelchecker/prctl/SymbolicDtmcPrctlModelChecker.cpp
-
9src/storm/modelchecker/prctl/SymbolicMdpPrctlModelChecker.cpp
-
64src/storm/utility/FilteredRewardModel.h
@ -0,0 +1,64 @@ |
|||
#pragma once |
|||
|
|||
#include <memory> |
|||
|
|||
#include "storm/utility/macros.h" |
|||
#include "storm/exceptions/NotSupportedException.h" |
|||
|
|||
namespace storm { |
|||
namespace utility { |
|||
|
|||
|
|||
/* |
|||
* This class wraps around a |
|||
*/ |
|||
template <typename RewardModelType> |
|||
class FilteredRewardModel { |
|||
public: |
|||
FilteredRewardModel(RewardModelType const& baseRewardModel, bool enableStateRewards, bool enableStateActionRewards, bool enableTransitionRewards) { |
|||
if ((baseRewardModel.hasStateRewards() && !enableStateRewards) || (baseRewardModel.hasStateActionRewards() && !enableStateActionRewards) || (baseRewardModel.hasTransitionRewards() && !enableTransitionRewards)) { |
|||
// One of the available reward types need to be deleted. |
|||
typename std::remove_const<typename std::remove_reference<decltype(baseRewardModel.getOptionalStateRewardVector())>::type>::type stateRewards; |
|||
if (enableStateRewards) { |
|||
stateRewards = baseRewardModel.getOptionalStateRewardVector(); |
|||
} |
|||
typename std::remove_const<typename std::remove_reference<decltype(baseRewardModel.getOptionalStateActionRewardVector())>::type>::type stateActionRewards; |
|||
if (enableStateActionRewards) { |
|||
stateActionRewards = baseRewardModel.getOptionalStateActionRewardVector(); |
|||
} |
|||
typename std::remove_const<typename std::remove_reference<decltype(baseRewardModel.getOptionalTransitionRewardMatrix())>::type>::type transitionRewards; |
|||
if (enableTransitionRewards) { |
|||
transitionRewards = baseRewardModel.getOptionalTransitionRewardMatrix(); |
|||
} |
|||
localRewardModel = std::unique_ptr<RewardModelType>(new RewardModelType(stateRewards, stateActionRewards, transitionRewards)); |
|||
rewardModel = localRewardModel.get(); |
|||
} else { |
|||
rewardModel = &baseRewardModel; |
|||
} |
|||
} |
|||
|
|||
RewardModelType const& get() const { |
|||
return *rewardModel; |
|||
} |
|||
private: |
|||
std::unique_ptr<RewardModelType> localRewardModel; |
|||
RewardModelType const* rewardModel; |
|||
}; |
|||
|
|||
template <typename ModelType, typename CheckTaskType> |
|||
FilteredRewardModel<typename ModelType::RewardModelType> createFilteredRewardModel(ModelType const& model, CheckTaskType const& checkTask) { |
|||
auto const& baseRewardModel = checkTask.isRewardModelSet() ? model.getRewardModel(checkTask.getRewardModel()) : model.getUniqueRewardModel(); |
|||
if (checkTask.getFormula().hasRewardAccumulation()) { |
|||
auto const& acc = checkTask.getFormula().getRewardAccumulation(); |
|||
STORM_LOG_THROW(model.isDiscreteTimeModel() || !acc.isExitSet() || !baseRewardModel.hasStateRewards(), storm::exceptions::NotSupportedException, "Exit rewards for continuous time models are not supported."); |
|||
// Check which of the available reward types are allowed. |
|||
bool hasStateRewards = model.isDiscreteTimeModel() ? acc.isExitSet() : acc.isTimeSet(); |
|||
bool hasStateActionRewards = acc.isStepsSet(); |
|||
bool hasTransitionRewards = acc.isStepsSet(); |
|||
return FilteredRewardModel<typename ModelType::RewardModelType>(baseRewardModel, hasStateRewards, hasStateActionRewards, hasTransitionRewards); |
|||
} else { |
|||
return FilteredRewardModel<typename ModelType::RewardModelType>(baseRewardModel, true, true, true); |
|||
} |
|||
} |
|||
} |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue