Storm
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 {
9namespace ps {
10
12 public:
13 virtual ~PermissiveScheduler() = default;
14};
15
16template<typename RM = storm::models::sparse::StandardRewardModel<double>>
19 storm::storage::BitVector enabledChoices;
20
21 public:
22 virtual ~SubMDPPermissiveScheduler() = default;
23
25
27
29 : PermissiveScheduler(), mdp(refmdp), enabledChoices(refmdp.getNumberOfChoices(), allEnabled) {
30 // Intentionally left empty.
31 }
32
33 void disable(uint_fast64_t choiceIndex) {
34 STORM_LOG_ASSERT(choiceIndex < enabledChoices.size(), "Invalid choiceIndex.");
35 enabledChoices.set(choiceIndex, false);
36 }
37
40 return *(cs.transform(enabledChoices)->template as<storm::models::sparse::Mdp<double, RM>>());
41 }
42
43 template<typename T>
44 std::map<uint_fast64_t, T> remapChoiceIndices(std::map<uint_fast64_t, T> const& in) const {
45 std::map<uint_fast64_t, T> res;
46 uint_fast64_t last = 0;
47 uint_fast64_t curr = 0;
49 for (auto const& entry : in) {
50 curr = entry.first;
51 uint_fast64_t diff = last - curr;
52 it += diff;
53 res[*it] = entry.second;
54 last = curr;
55 }
56 return res;
57 }
58
59 template<typename T>
60 std::map<uint_fast64_t, T> remapChoiceIndices(std::map<storm::storage::StateActionPair, T> const& in) const {
61 std::map<uint_fast64_t, T> res;
62 uint_fast64_t last = 0;
63 uint_fast64_t curr = 0;
65 for (auto const& entry : in) {
66 curr = mdp.getChoiceIndex(entry.first);
67 uint_fast64_t diff = curr - last;
68 it += diff;
69 res[*it] = entry.second;
70 last = curr;
71 }
72 return res;
73 }
74};
75
76template<typename RM = storm::models::sparse::StandardRewardModel<double>>
77boost::optional<SubMDPPermissiveScheduler<RM>> computePermissiveSchedulerViaMILP(storm::models::sparse::Mdp<double, RM> const& mdp,
79
80template<typename RM>
81boost::optional<SubMDPPermissiveScheduler<RM>> computePermissiveSchedulerViaSMT(storm::models::sparse::Mdp<double, RM> const& mdp,
83} // namespace ps
84} // namespace storm
This class represents a (discrete-time) Markov decision process.
Definition Mdp.h:14
uint_fast64_t getChoiceIndex(storm::storage::StateActionPair const &stateactPair) const
For a state/action pair, get the choice index referring to the state-action pair.
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:25
A bit vector that is internally represented as a vector of 64-bit values.
Definition BitVector.h:18
const_iterator begin() const
Returns an iterator to the indices of the set bits in the bit vector.
void set(uint_fast64_t index, bool value=true)
Sets the given truth value at the given index.
size_t size() const
Retrieves the number of bits this bit vector can store.
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:11
boost::optional< SubMDPPermissiveScheduler< RM > > computePermissiveSchedulerViaSMT(storm::models::sparse::Mdp< double, RM > const &mdp, storm::logic::ProbabilityOperatorFormula const &safeProp)
boost::optional< SubMDPPermissiveScheduler< RM > > computePermissiveSchedulerViaMILP(storm::models::sparse::Mdp< double, RM > const &mdp, storm::logic::ProbabilityOperatorFormula const &safeProp)
LabParser.cpp.
Definition cli.cpp:18