sjunges
7 years ago
5 changed files with 59 additions and 24 deletions
-
16src/storm/models/sparse/Mdp.cpp
-
7src/storm/models/sparse/Mdp.h
-
4src/storm/permissivesched/PermissiveSchedulers.h
-
26src/storm/transformer/ChoiceSelector.cpp
-
30src/storm/transformer/ChoiceSelector.h
@ -0,0 +1,26 @@ |
|||
#include "storm/transformer/ChoiceSelector.h"
|
|||
#include "storm/models/sparse/Mdp.h"
|
|||
|
|||
namespace storm { |
|||
namespace transformer { |
|||
template <typename ValueType, typename RewardModelType> |
|||
std::shared_ptr<storm::models::sparse::NondeterministicModel<ValueType, RewardModelType>> ChoiceSelector<ValueType, RewardModelType>::transform(storm::storage::BitVector const& enabledActions) const |
|||
{ |
|||
storm::storage::sparse::ModelComponents<ValueType, RewardModelType> newComponents(inputModel.getTransitionMatrix().restrictRows(enabledActions)); |
|||
newComponents.stateLabeling = inputModel.getStateLabeling(); |
|||
for (auto const& rewardModel : inputModel.getRewardModels()) { |
|||
newComponents.rewardModels.emplace(rewardModel.first, rewardModel.second.restrictActions(enabledActions)); |
|||
} |
|||
if (inputModel.hasChoiceLabeling()) { |
|||
newComponents.choiceLabeling = inputModel.getChoiceLabeling().getSubLabeling(enabledActions); |
|||
} |
|||
newComponents.stateValuations = inputModel.getOptionalStateValuations(); |
|||
if (inputModel.hasChoiceOrigins()) { |
|||
newComponents.choiceOrigins = inputModel.getChoiceOrigins()->selectChoices(enabledActions); |
|||
} |
|||
return std::make_shared<storm::models::sparse::Mdp<ValueType, RewardModelType>>(std::move(newComponents)); |
|||
} |
|||
|
|||
template class ChoiceSelector<double>; |
|||
} |
|||
} |
@ -0,0 +1,30 @@ |
|||
#pragma once |
|||
|
|||
#include "storm/models/sparse/StandardRewardModel.h" |
|||
#include "storm/models/sparse/NondeterministicModel.h" |
|||
|
|||
|
|||
namespace storm { |
|||
namespace transformer { |
|||
|
|||
template<typename ValueType, typename RewardModelType = storm::models::sparse::StandardRewardModel<ValueType>> |
|||
class ChoiceSelector { |
|||
public: |
|||
ChoiceSelector(storm::models::sparse::NondeterministicModel<ValueType, RewardModelType> const& inputModel) : inputModel(inputModel) { |
|||
|
|||
} |
|||
|
|||
/*! |
|||
* Constructs an MDP by copying the current MDP and restricting the choices of each state to the ones given by the bitvector. |
|||
* |
|||
* @param enabledActions A BitVector of lenght numberOfChoices(), which is one iff the action should be kept. |
|||
* @return A subMDP. |
|||
*/ |
|||
std::shared_ptr<storm::models::sparse::NondeterministicModel<ValueType, RewardModelType>> transform(storm::storage::BitVector const& enabledActions) const; |
|||
private: |
|||
|
|||
storm::models::sparse::NondeterministicModel<ValueType, RewardModelType> const& inputModel; |
|||
}; |
|||
|
|||
} |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue