Storm 1.14.0.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
PermissiveSchedulers.h
Go to the documentation of this file.
1#pragma once
2
7
8namespace storm {
9
10class Environment;
11
12namespace ps {
13
15 public:
16 virtual ~PermissiveScheduler() = default;
17};
18
19template<typename RM = storm::models::sparse::StandardRewardModel<double>>
22 storm::storage::BitVector enabledChoices;
23
24 public:
25 virtual ~SubMDPPermissiveScheduler() = default;
26
28
30
32 : PermissiveScheduler(), mdp(refmdp), enabledChoices(refmdp.getNumberOfChoices(), allEnabled) {
33 // Intentionally left empty.
34 }
35
36 void disable(uint_fast64_t choiceIndex) {
37 STORM_LOG_ASSERT(choiceIndex < enabledChoices.size(), "Invalid choiceIndex.");
38 enabledChoices.set(choiceIndex, false);
39 }
40
45
46 template<typename T>
47 std::map<uint_fast64_t, T> remapChoiceIndices(std::map<uint_fast64_t, T> const& in) const {
48 std::map<uint_fast64_t, T> res;
49 uint_fast64_t last = 0;
50 uint_fast64_t curr = 0;
51 storm::storage::BitVector::const_iterator it = enabledChoices.begin();
52 for (auto const& entry : in) {
53 curr = entry.first;
54 uint_fast64_t diff = last - curr;
55 it += diff;
56 res[*it] = entry.second;
57 last = curr;
58 }
59 return res;
60 }
61
62 template<typename T>
63 std::map<uint_fast64_t, T> remapChoiceIndices(std::map<storm::storage::StateActionPair, T> const& in) const {
64 std::map<uint_fast64_t, T> res;
65 uint_fast64_t last = 0;
66 uint_fast64_t curr = 0;
67 storm::storage::BitVector::const_iterator it = enabledChoices.begin();
68 for (auto const& entry : in) {
69 curr = mdp.getChoiceIndex(entry.first);
70 uint_fast64_t diff = curr - last;
71 it += diff;
72 res[*it] = entry.second;
73 last = curr;
74 }
75 return res;
76 }
77};
78
79template<typename RM = storm::models::sparse::StandardRewardModel<double>>
80boost::optional<SubMDPPermissiveScheduler<RM>> computePermissiveSchedulerViaMILP(storm::Environment const& env,
83
84template<typename RM>
85boost::optional<SubMDPPermissiveScheduler<RM>> computePermissiveSchedulerViaSMT(storm::models::sparse::Mdp<double, RM> const& mdp,
87} // namespace ps
88} // namespace storm
This class represents a (discrete-time) Markov decision process.
Definition Mdp.h:13
virtual ~PermissiveScheduler()=default
SubMDPPermissiveScheduler(SubMDPPermissiveScheduler &&)=default
SubMDPPermissiveScheduler(SubMDPPermissiveScheduler const &)=delete
storm::models::sparse::Mdp< double, RM > apply() const
void disable(uint_fast64_t choiceIndex)
SubMDPPermissiveScheduler(storm::models::sparse::Mdp< double, RM > const &refmdp, bool allEnabled)
std::map< uint_fast64_t, T > remapChoiceIndices(std::map< uint_fast64_t, T > const &in) const
virtual ~SubMDPPermissiveScheduler()=default
std::map< uint_fast64_t, T > remapChoiceIndices(std::map< storm::storage::StateActionPair, T > const &in) const
A class that enables iterating over the indices of the bit vector whose corresponding bits are set to...
Definition BitVector.h:23
A bit vector that is internally represented as a vector of 64-bit values.
Definition BitVector.h:16
std::shared_ptr< storm::models::sparse::NondeterministicModel< ValueType, RewardModelType > > transform(storm::storage::BitVector const &enabledActions) const
Constructs an MDP by copying the current MDP and restricting the choices of each state to the ones gi...
#define STORM_LOG_ASSERT(cond, message)
Definition macros.h:9
boost::optional< SubMDPPermissiveScheduler< RM > > computePermissiveSchedulerViaSMT(storm::models::sparse::Mdp< double, RM > const &mdp, storm::logic::ProbabilityOperatorFormula const &safeProp)
boost::optional< SubMDPPermissiveScheduler< RM > > computePermissiveSchedulerViaMILP(storm::Environment const &env, storm::models::sparse::Mdp< double, RM > const &mdp, storm::logic::ProbabilityOperatorFormula const &safeProp)